jquery-ui-1.10.0.custom.js 422 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851
  1. /*! jQuery UI - v1.10.0 - 2013-01-22
  2. * http://jqueryui.com
  3. * Includes: jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.position.js, jquery.ui.draggable.js, jquery.ui.droppable.js, jquery.ui.resizable.js, jquery.ui.selectable.js, jquery.ui.sortable.js, jquery.ui.accordion.js, jquery.ui.autocomplete.js, jquery.ui.button.js, jquery.ui.datepicker.js, jquery.ui.dialog.js, jquery.ui.menu.js, jquery.ui.progressbar.js, jquery.ui.slider.js, jquery.ui.spinner.js, jquery.ui.tabs.js, jquery.ui.tooltip.js, jquery.ui.effect.js, jquery.ui.effect-blind.js, jquery.ui.effect-bounce.js, jquery.ui.effect-clip.js, jquery.ui.effect-drop.js, jquery.ui.effect-explode.js, jquery.ui.effect-fade.js, jquery.ui.effect-fold.js, jquery.ui.effect-highlight.js, jquery.ui.effect-pulsate.js, jquery.ui.effect-scale.js, jquery.ui.effect-shake.js, jquery.ui.effect-slide.js, jquery.ui.effect-transfer.js
  4. * Copyright (c) 2013 jQuery Foundation and other contributors Licensed MIT */
  5. (function( $, undefined ) {
  6. var uuid = 0,
  7. runiqueId = /^ui-id-\d+$/;
  8. // prevent duplicate loading
  9. // this is only a problem because we proxy existing functions
  10. // and we don't want to double proxy them
  11. $.ui = $.ui || {};
  12. if ( $.ui.version ) {
  13. return;
  14. }
  15. $.extend( $.ui, {
  16. version: "1.10.0",
  17. keyCode: {
  18. BACKSPACE: 8,
  19. COMMA: 188,
  20. DELETE: 46,
  21. DOWN: 40,
  22. END: 35,
  23. ENTER: 13,
  24. ESCAPE: 27,
  25. HOME: 36,
  26. LEFT: 37,
  27. NUMPAD_ADD: 107,
  28. NUMPAD_DECIMAL: 110,
  29. NUMPAD_DIVIDE: 111,
  30. NUMPAD_ENTER: 108,
  31. NUMPAD_MULTIPLY: 106,
  32. NUMPAD_SUBTRACT: 109,
  33. PAGE_DOWN: 34,
  34. PAGE_UP: 33,
  35. PERIOD: 190,
  36. RIGHT: 39,
  37. SPACE: 32,
  38. TAB: 9,
  39. UP: 38
  40. }
  41. });
  42. // plugins
  43. $.fn.extend({
  44. _focus: $.fn.focus,
  45. focus: function( delay, fn ) {
  46. return typeof delay === "number" ?
  47. this.each(function() {
  48. var elem = this;
  49. setTimeout(function() {
  50. $( elem ).focus();
  51. if ( fn ) {
  52. fn.call( elem );
  53. }
  54. }, delay );
  55. }) :
  56. this._focus.apply( this, arguments );
  57. },
  58. scrollParent: function() {
  59. var scrollParent;
  60. if (($.ui.ie && (/(static|relative)/).test(this.css("position"))) || (/absolute/).test(this.css("position"))) {
  61. scrollParent = this.parents().filter(function() {
  62. return (/(relative|absolute|fixed)/).test($.css(this,"position")) && (/(auto|scroll)/).test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x"));
  63. }).eq(0);
  64. } else {
  65. scrollParent = this.parents().filter(function() {
  66. return (/(auto|scroll)/).test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x"));
  67. }).eq(0);
  68. }
  69. return (/fixed/).test(this.css("position")) || !scrollParent.length ? $(document) : scrollParent;
  70. },
  71. zIndex: function( zIndex ) {
  72. if ( zIndex !== undefined ) {
  73. return this.css( "zIndex", zIndex );
  74. }
  75. if ( this.length ) {
  76. var elem = $( this[ 0 ] ), position, value;
  77. while ( elem.length && elem[ 0 ] !== document ) {
  78. // Ignore z-index if position is set to a value where z-index is ignored by the browser
  79. // This makes behavior of this function consistent across browsers
  80. // WebKit always returns auto if the element is positioned
  81. position = elem.css( "position" );
  82. if ( position === "absolute" || position === "relative" || position === "fixed" ) {
  83. // IE returns 0 when zIndex is not specified
  84. // other browsers return a string
  85. // we ignore the case of nested elements with an explicit value of 0
  86. // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
  87. value = parseInt( elem.css( "zIndex" ), 10 );
  88. if ( !isNaN( value ) && value !== 0 ) {
  89. return value;
  90. }
  91. }
  92. elem = elem.parent();
  93. }
  94. }
  95. return 0;
  96. },
  97. uniqueId: function() {
  98. return this.each(function() {
  99. if ( !this.id ) {
  100. this.id = "ui-id-" + (++uuid);
  101. }
  102. });
  103. },
  104. removeUniqueId: function() {
  105. return this.each(function() {
  106. if ( runiqueId.test( this.id ) ) {
  107. $( this ).removeAttr( "id" );
  108. }
  109. });
  110. }
  111. });
  112. // selectors
  113. function focusable( element, isTabIndexNotNaN ) {
  114. var map, mapName, img,
  115. nodeName = element.nodeName.toLowerCase();
  116. if ( "area" === nodeName ) {
  117. map = element.parentNode;
  118. mapName = map.name;
  119. if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
  120. return false;
  121. }
  122. img = $( "img[usemap=#" + mapName + "]" )[0];
  123. return !!img && visible( img );
  124. }
  125. return ( /input|select|textarea|button|object/.test( nodeName ) ?
  126. !element.disabled :
  127. "a" === nodeName ?
  128. element.href || isTabIndexNotNaN :
  129. isTabIndexNotNaN) &&
  130. // the element and all of its ancestors must be visible
  131. visible( element );
  132. }
  133. function visible( element ) {
  134. return $.expr.filters.visible( element ) &&
  135. !$( element ).parents().addBack().filter(function() {
  136. return $.css( this, "visibility" ) === "hidden";
  137. }).length;
  138. }
  139. $.extend( $.expr[ ":" ], {
  140. data: $.expr.createPseudo ?
  141. $.expr.createPseudo(function( dataName ) {
  142. return function( elem ) {
  143. return !!$.data( elem, dataName );
  144. };
  145. }) :
  146. // support: jQuery <1.8
  147. function( elem, i, match ) {
  148. return !!$.data( elem, match[ 3 ] );
  149. },
  150. focusable: function( element ) {
  151. return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
  152. },
  153. tabbable: function( element ) {
  154. var tabIndex = $.attr( element, "tabindex" ),
  155. isTabIndexNaN = isNaN( tabIndex );
  156. return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
  157. }
  158. });
  159. // support: jQuery <1.8
  160. if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
  161. $.each( [ "Width", "Height" ], function( i, name ) {
  162. var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
  163. type = name.toLowerCase(),
  164. orig = {
  165. innerWidth: $.fn.innerWidth,
  166. innerHeight: $.fn.innerHeight,
  167. outerWidth: $.fn.outerWidth,
  168. outerHeight: $.fn.outerHeight
  169. };
  170. function reduce( elem, size, border, margin ) {
  171. $.each( side, function() {
  172. size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
  173. if ( border ) {
  174. size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
  175. }
  176. if ( margin ) {
  177. size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
  178. }
  179. });
  180. return size;
  181. }
  182. $.fn[ "inner" + name ] = function( size ) {
  183. if ( size === undefined ) {
  184. return orig[ "inner" + name ].call( this );
  185. }
  186. return this.each(function() {
  187. $( this ).css( type, reduce( this, size ) + "px" );
  188. });
  189. };
  190. $.fn[ "outer" + name] = function( size, margin ) {
  191. if ( typeof size !== "number" ) {
  192. return orig[ "outer" + name ].call( this, size );
  193. }
  194. return this.each(function() {
  195. $( this).css( type, reduce( this, size, true, margin ) + "px" );
  196. });
  197. };
  198. });
  199. }
  200. // support: jQuery <1.8
  201. if ( !$.fn.addBack ) {
  202. $.fn.addBack = function( selector ) {
  203. return this.add( selector == null ?
  204. this.prevObject : this.prevObject.filter( selector )
  205. );
  206. };
  207. }
  208. // support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413)
  209. if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
  210. $.fn.removeData = (function( removeData ) {
  211. return function( key ) {
  212. if ( arguments.length ) {
  213. return removeData.call( this, $.camelCase( key ) );
  214. } else {
  215. return removeData.call( this );
  216. }
  217. };
  218. })( $.fn.removeData );
  219. }
  220. // deprecated
  221. $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
  222. $.support.selectstart = "onselectstart" in document.createElement( "div" );
  223. $.fn.extend({
  224. disableSelection: function() {
  225. return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) +
  226. ".ui-disableSelection", function( event ) {
  227. event.preventDefault();
  228. });
  229. },
  230. enableSelection: function() {
  231. return this.unbind( ".ui-disableSelection" );
  232. }
  233. });
  234. $.extend( $.ui, {
  235. // $.ui.plugin is deprecated. Use the proxy pattern instead.
  236. plugin: {
  237. add: function( module, option, set ) {
  238. var i,
  239. proto = $.ui[ module ].prototype;
  240. for ( i in set ) {
  241. proto.plugins[ i ] = proto.plugins[ i ] || [];
  242. proto.plugins[ i ].push( [ option, set[ i ] ] );
  243. }
  244. },
  245. call: function( instance, name, args ) {
  246. var i,
  247. set = instance.plugins[ name ];
  248. if ( !set || !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) {
  249. return;
  250. }
  251. for ( i = 0; i < set.length; i++ ) {
  252. if ( instance.options[ set[ i ][ 0 ] ] ) {
  253. set[ i ][ 1 ].apply( instance.element, args );
  254. }
  255. }
  256. }
  257. },
  258. // only used by resizable
  259. hasScroll: function( el, a ) {
  260. //If overflow is hidden, the element might have extra content, but the user wants to hide it
  261. if ( $( el ).css( "overflow" ) === "hidden") {
  262. return false;
  263. }
  264. var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
  265. has = false;
  266. if ( el[ scroll ] > 0 ) {
  267. return true;
  268. }
  269. // TODO: determine which cases actually cause this to happen
  270. // if the element doesn't have the scroll set, see if it's possible to
  271. // set the scroll
  272. el[ scroll ] = 1;
  273. has = ( el[ scroll ] > 0 );
  274. el[ scroll ] = 0;
  275. return has;
  276. }
  277. });
  278. })( jQuery );
  279. (function( $, undefined ) {
  280. var uuid = 0,
  281. slice = Array.prototype.slice,
  282. _cleanData = $.cleanData;
  283. $.cleanData = function( elems ) {
  284. for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
  285. try {
  286. $( elem ).triggerHandler( "remove" );
  287. // http://bugs.jquery.com/ticket/8235
  288. } catch( e ) {}
  289. }
  290. _cleanData( elems );
  291. };
  292. $.widget = function( name, base, prototype ) {
  293. var fullName, existingConstructor, constructor, basePrototype,
  294. // proxiedPrototype allows the provided prototype to remain unmodified
  295. // so that it can be used as a mixin for multiple widgets (#8876)
  296. proxiedPrototype = {},
  297. namespace = name.split( "." )[ 0 ];
  298. name = name.split( "." )[ 1 ];
  299. fullName = namespace + "-" + name;
  300. if ( !prototype ) {
  301. prototype = base;
  302. base = $.Widget;
  303. }
  304. // create selector for plugin
  305. $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
  306. return !!$.data( elem, fullName );
  307. };
  308. $[ namespace ] = $[ namespace ] || {};
  309. existingConstructor = $[ namespace ][ name ];
  310. constructor = $[ namespace ][ name ] = function( options, element ) {
  311. // allow instantiation without "new" keyword
  312. if ( !this._createWidget ) {
  313. return new constructor( options, element );
  314. }
  315. // allow instantiation without initializing for simple inheritance
  316. // must use "new" keyword (the code above always passes args)
  317. if ( arguments.length ) {
  318. this._createWidget( options, element );
  319. }
  320. };
  321. // extend with the existing constructor to carry over any static properties
  322. $.extend( constructor, existingConstructor, {
  323. version: prototype.version,
  324. // copy the object used to create the prototype in case we need to
  325. // redefine the widget later
  326. _proto: $.extend( {}, prototype ),
  327. // track widgets that inherit from this widget in case this widget is
  328. // redefined after a widget inherits from it
  329. _childConstructors: []
  330. });
  331. basePrototype = new base();
  332. // we need to make the options hash a property directly on the new instance
  333. // otherwise we'll modify the options hash on the prototype that we're
  334. // inheriting from
  335. basePrototype.options = $.widget.extend( {}, basePrototype.options );
  336. $.each( prototype, function( prop, value ) {
  337. if ( !$.isFunction( value ) ) {
  338. proxiedPrototype[ prop ] = value;
  339. return;
  340. }
  341. proxiedPrototype[ prop ] = (function() {
  342. var _super = function() {
  343. return base.prototype[ prop ].apply( this, arguments );
  344. },
  345. _superApply = function( args ) {
  346. return base.prototype[ prop ].apply( this, args );
  347. };
  348. return function() {
  349. var __super = this._super,
  350. __superApply = this._superApply,
  351. returnValue;
  352. this._super = _super;
  353. this._superApply = _superApply;
  354. returnValue = value.apply( this, arguments );
  355. this._super = __super;
  356. this._superApply = __superApply;
  357. return returnValue;
  358. };
  359. })();
  360. });
  361. constructor.prototype = $.widget.extend( basePrototype, {
  362. // TODO: remove support for widgetEventPrefix
  363. // always use the name + a colon as the prefix, e.g., draggable:start
  364. // don't prefix for widgets that aren't DOM-based
  365. widgetEventPrefix: existingConstructor ? basePrototype.widgetEventPrefix : name
  366. }, proxiedPrototype, {
  367. constructor: constructor,
  368. namespace: namespace,
  369. widgetName: name,
  370. widgetFullName: fullName
  371. });
  372. // If this widget is being redefined then we need to find all widgets that
  373. // are inheriting from it and redefine all of them so that they inherit from
  374. // the new version of this widget. We're essentially trying to replace one
  375. // level in the prototype chain.
  376. if ( existingConstructor ) {
  377. $.each( existingConstructor._childConstructors, function( i, child ) {
  378. var childPrototype = child.prototype;
  379. // redefine the child widget using the same prototype that was
  380. // originally used, but inherit from the new version of the base
  381. $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto );
  382. });
  383. // remove the list of existing child constructors from the old constructor
  384. // so the old child constructors can be garbage collected
  385. delete existingConstructor._childConstructors;
  386. } else {
  387. base._childConstructors.push( constructor );
  388. }
  389. $.widget.bridge( name, constructor );
  390. };
  391. $.widget.extend = function( target ) {
  392. var input = slice.call( arguments, 1 ),
  393. inputIndex = 0,
  394. inputLength = input.length,
  395. key,
  396. value;
  397. for ( ; inputIndex < inputLength; inputIndex++ ) {
  398. for ( key in input[ inputIndex ] ) {
  399. value = input[ inputIndex ][ key ];
  400. if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
  401. // Clone objects
  402. if ( $.isPlainObject( value ) ) {
  403. target[ key ] = $.isPlainObject( target[ key ] ) ?
  404. $.widget.extend( {}, target[ key ], value ) :
  405. // Don't extend strings, arrays, etc. with objects
  406. $.widget.extend( {}, value );
  407. // Copy everything else by reference
  408. } else {
  409. target[ key ] = value;
  410. }
  411. }
  412. }
  413. }
  414. return target;
  415. };
  416. $.widget.bridge = function( name, object ) {
  417. var fullName = object.prototype.widgetFullName || name;
  418. $.fn[ name ] = function( options ) {
  419. var isMethodCall = typeof options === "string",
  420. args = slice.call( arguments, 1 ),
  421. returnValue = this;
  422. // allow multiple hashes to be passed on init
  423. options = !isMethodCall && args.length ?
  424. $.widget.extend.apply( null, [ options ].concat(args) ) :
  425. options;
  426. if ( isMethodCall ) {
  427. this.each(function() {
  428. var methodValue,
  429. instance = $.data( this, fullName );
  430. if ( !instance ) {
  431. return $.error( "cannot call methods on " + name + " prior to initialization; " +
  432. "attempted to call method '" + options + "'" );
  433. }
  434. if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) {
  435. return $.error( "no such method '" + options + "' for " + name + " widget instance" );
  436. }
  437. methodValue = instance[ options ].apply( instance, args );
  438. if ( methodValue !== instance && methodValue !== undefined ) {
  439. returnValue = methodValue && methodValue.jquery ?
  440. returnValue.pushStack( methodValue.get() ) :
  441. methodValue;
  442. return false;
  443. }
  444. });
  445. } else {
  446. this.each(function() {
  447. var instance = $.data( this, fullName );
  448. if ( instance ) {
  449. instance.option( options || {} )._init();
  450. } else {
  451. $.data( this, fullName, new object( options, this ) );
  452. }
  453. });
  454. }
  455. return returnValue;
  456. };
  457. };
  458. $.Widget = function( /* options, element */ ) {};
  459. $.Widget._childConstructors = [];
  460. $.Widget.prototype = {
  461. widgetName: "widget",
  462. widgetEventPrefix: "",
  463. defaultElement: "<div>",
  464. options: {
  465. disabled: false,
  466. // callbacks
  467. create: null
  468. },
  469. _createWidget: function( options, element ) {
  470. element = $( element || this.defaultElement || this )[ 0 ];
  471. this.element = $( element );
  472. this.uuid = uuid++;
  473. this.eventNamespace = "." + this.widgetName + this.uuid;
  474. this.options = $.widget.extend( {},
  475. this.options,
  476. this._getCreateOptions(),
  477. options );
  478. this.bindings = $();
  479. this.hoverable = $();
  480. this.focusable = $();
  481. if ( element !== this ) {
  482. $.data( element, this.widgetFullName, this );
  483. this._on( true, this.element, {
  484. remove: function( event ) {
  485. if ( event.target === element ) {
  486. this.destroy();
  487. }
  488. }
  489. });
  490. this.document = $( element.style ?
  491. // element within the document
  492. element.ownerDocument :
  493. // element is window or document
  494. element.document || element );
  495. this.window = $( this.document[0].defaultView || this.document[0].parentWindow );
  496. }
  497. this._create();
  498. this._trigger( "create", null, this._getCreateEventData() );
  499. this._init();
  500. },
  501. _getCreateOptions: $.noop,
  502. _getCreateEventData: $.noop,
  503. _create: $.noop,
  504. _init: $.noop,
  505. destroy: function() {
  506. this._destroy();
  507. // we can probably remove the unbind calls in 2.0
  508. // all event bindings should go through this._on()
  509. this.element
  510. .unbind( this.eventNamespace )
  511. // 1.9 BC for #7810
  512. // TODO remove dual storage
  513. .removeData( this.widgetName )
  514. .removeData( this.widgetFullName )
  515. // support: jquery <1.6.3
  516. // http://bugs.jquery.com/ticket/9413
  517. .removeData( $.camelCase( this.widgetFullName ) );
  518. this.widget()
  519. .unbind( this.eventNamespace )
  520. .removeAttr( "aria-disabled" )
  521. .removeClass(
  522. this.widgetFullName + "-disabled " +
  523. "ui-state-disabled" );
  524. // clean up events and states
  525. this.bindings.unbind( this.eventNamespace );
  526. this.hoverable.removeClass( "ui-state-hover" );
  527. this.focusable.removeClass( "ui-state-focus" );
  528. },
  529. _destroy: $.noop,
  530. widget: function() {
  531. return this.element;
  532. },
  533. option: function( key, value ) {
  534. var options = key,
  535. parts,
  536. curOption,
  537. i;
  538. if ( arguments.length === 0 ) {
  539. // don't return a reference to the internal hash
  540. return $.widget.extend( {}, this.options );
  541. }
  542. if ( typeof key === "string" ) {
  543. // handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
  544. options = {};
  545. parts = key.split( "." );
  546. key = parts.shift();
  547. if ( parts.length ) {
  548. curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
  549. for ( i = 0; i < parts.length - 1; i++ ) {
  550. curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
  551. curOption = curOption[ parts[ i ] ];
  552. }
  553. key = parts.pop();
  554. if ( value === undefined ) {
  555. return curOption[ key ] === undefined ? null : curOption[ key ];
  556. }
  557. curOption[ key ] = value;
  558. } else {
  559. if ( value === undefined ) {
  560. return this.options[ key ] === undefined ? null : this.options[ key ];
  561. }
  562. options[ key ] = value;
  563. }
  564. }
  565. this._setOptions( options );
  566. return this;
  567. },
  568. _setOptions: function( options ) {
  569. var key;
  570. for ( key in options ) {
  571. this._setOption( key, options[ key ] );
  572. }
  573. return this;
  574. },
  575. _setOption: function( key, value ) {
  576. this.options[ key ] = value;
  577. if ( key === "disabled" ) {
  578. this.widget()
  579. .toggleClass( this.widgetFullName + "-disabled ui-state-disabled", !!value )
  580. .attr( "aria-disabled", value );
  581. this.hoverable.removeClass( "ui-state-hover" );
  582. this.focusable.removeClass( "ui-state-focus" );
  583. }
  584. return this;
  585. },
  586. enable: function() {
  587. return this._setOption( "disabled", false );
  588. },
  589. disable: function() {
  590. return this._setOption( "disabled", true );
  591. },
  592. _on: function( suppressDisabledCheck, element, handlers ) {
  593. var delegateElement,
  594. instance = this;
  595. // no suppressDisabledCheck flag, shuffle arguments
  596. if ( typeof suppressDisabledCheck !== "boolean" ) {
  597. handlers = element;
  598. element = suppressDisabledCheck;
  599. suppressDisabledCheck = false;
  600. }
  601. // no element argument, shuffle and use this.element
  602. if ( !handlers ) {
  603. handlers = element;
  604. element = this.element;
  605. delegateElement = this.widget();
  606. } else {
  607. // accept selectors, DOM elements
  608. element = delegateElement = $( element );
  609. this.bindings = this.bindings.add( element );
  610. }
  611. $.each( handlers, function( event, handler ) {
  612. function handlerProxy() {
  613. // allow widgets to customize the disabled handling
  614. // - disabled as an array instead of boolean
  615. // - disabled class as method for disabling individual parts
  616. if ( !suppressDisabledCheck &&
  617. ( instance.options.disabled === true ||
  618. $( this ).hasClass( "ui-state-disabled" ) ) ) {
  619. return;
  620. }
  621. return ( typeof handler === "string" ? instance[ handler ] : handler )
  622. .apply( instance, arguments );
  623. }
  624. // copy the guid so direct unbinding works
  625. if ( typeof handler !== "string" ) {
  626. handlerProxy.guid = handler.guid =
  627. handler.guid || handlerProxy.guid || $.guid++;
  628. }
  629. var match = event.match( /^(\w+)\s*(.*)$/ ),
  630. eventName = match[1] + instance.eventNamespace,
  631. selector = match[2];
  632. if ( selector ) {
  633. delegateElement.delegate( selector, eventName, handlerProxy );
  634. } else {
  635. element.bind( eventName, handlerProxy );
  636. }
  637. });
  638. },
  639. _off: function( element, eventName ) {
  640. eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) + this.eventNamespace;
  641. element.unbind( eventName ).undelegate( eventName );
  642. },
  643. _delay: function( handler, delay ) {
  644. function handlerProxy() {
  645. return ( typeof handler === "string" ? instance[ handler ] : handler )
  646. .apply( instance, arguments );
  647. }
  648. var instance = this;
  649. return setTimeout( handlerProxy, delay || 0 );
  650. },
  651. _hoverable: function( element ) {
  652. this.hoverable = this.hoverable.add( element );
  653. this._on( element, {
  654. mouseenter: function( event ) {
  655. $( event.currentTarget ).addClass( "ui-state-hover" );
  656. },
  657. mouseleave: function( event ) {
  658. $( event.currentTarget ).removeClass( "ui-state-hover" );
  659. }
  660. });
  661. },
  662. _focusable: function( element ) {
  663. this.focusable = this.focusable.add( element );
  664. this._on( element, {
  665. focusin: function( event ) {
  666. $( event.currentTarget ).addClass( "ui-state-focus" );
  667. },
  668. focusout: function( event ) {
  669. $( event.currentTarget ).removeClass( "ui-state-focus" );
  670. }
  671. });
  672. },
  673. _trigger: function( type, event, data ) {
  674. var prop, orig,
  675. callback = this.options[ type ];
  676. data = data || {};
  677. event = $.Event( event );
  678. event.type = ( type === this.widgetEventPrefix ?
  679. type :
  680. this.widgetEventPrefix + type ).toLowerCase();
  681. // the original event may come from any element
  682. // so we need to reset the target on the new event
  683. event.target = this.element[ 0 ];
  684. // copy original event properties over to the new event
  685. orig = event.originalEvent;
  686. if ( orig ) {
  687. for ( prop in orig ) {
  688. if ( !( prop in event ) ) {
  689. event[ prop ] = orig[ prop ];
  690. }
  691. }
  692. }
  693. this.element.trigger( event, data );
  694. return !( $.isFunction( callback ) &&
  695. callback.apply( this.element[0], [ event ].concat( data ) ) === false ||
  696. event.isDefaultPrevented() );
  697. }
  698. };
  699. $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
  700. $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
  701. if ( typeof options === "string" ) {
  702. options = { effect: options };
  703. }
  704. var hasOptions,
  705. effectName = !options ?
  706. method :
  707. options === true || typeof options === "number" ?
  708. defaultEffect :
  709. options.effect || defaultEffect;
  710. options = options || {};
  711. if ( typeof options === "number" ) {
  712. options = { duration: options };
  713. }
  714. hasOptions = !$.isEmptyObject( options );
  715. options.complete = callback;
  716. if ( options.delay ) {
  717. element.delay( options.delay );
  718. }
  719. if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
  720. element[ method ]( options );
  721. } else if ( effectName !== method && element[ effectName ] ) {
  722. element[ effectName ]( options.duration, options.easing, callback );
  723. } else {
  724. element.queue(function( next ) {
  725. $( this )[ method ]();
  726. if ( callback ) {
  727. callback.call( element[ 0 ] );
  728. }
  729. next();
  730. });
  731. }
  732. };
  733. });
  734. })( jQuery );
  735. (function( $, undefined ) {
  736. var mouseHandled = false;
  737. $( document ).mouseup( function() {
  738. mouseHandled = false;
  739. });
  740. $.widget("ui.mouse", {
  741. version: "1.10.0",
  742. options: {
  743. cancel: "input,textarea,button,select,option",
  744. distance: 1,
  745. delay: 0
  746. },
  747. _mouseInit: function() {
  748. var that = this;
  749. this.element
  750. .bind("mousedown."+this.widgetName, function(event) {
  751. return that._mouseDown(event);
  752. })
  753. .bind("click."+this.widgetName, function(event) {
  754. if (true === $.data(event.target, that.widgetName + ".preventClickEvent")) {
  755. $.removeData(event.target, that.widgetName + ".preventClickEvent");
  756. event.stopImmediatePropagation();
  757. return false;
  758. }
  759. });
  760. this.started = false;
  761. },
  762. // TODO: make sure destroying one instance of mouse doesn't mess with
  763. // other instances of mouse
  764. _mouseDestroy: function() {
  765. this.element.unbind("."+this.widgetName);
  766. if ( this._mouseMoveDelegate ) {
  767. $(document)
  768. .unbind("mousemove."+this.widgetName, this._mouseMoveDelegate)
  769. .unbind("mouseup."+this.widgetName, this._mouseUpDelegate);
  770. }
  771. },
  772. _mouseDown: function(event) {
  773. // don't let more than one widget handle mouseStart
  774. if( mouseHandled ) { return; }
  775. // we may have missed mouseup (out of window)
  776. (this._mouseStarted && this._mouseUp(event));
  777. this._mouseDownEvent = event;
  778. var that = this,
  779. btnIsLeft = (event.which === 1),
  780. // event.target.nodeName works around a bug in IE 8 with
  781. // disabled inputs (#7620)
  782. elIsCancel = (typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false);
  783. if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
  784. return true;
  785. }
  786. this.mouseDelayMet = !this.options.delay;
  787. if (!this.mouseDelayMet) {
  788. this._mouseDelayTimer = setTimeout(function() {
  789. that.mouseDelayMet = true;
  790. }, this.options.delay);
  791. }
  792. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  793. this._mouseStarted = (this._mouseStart(event) !== false);
  794. if (!this._mouseStarted) {
  795. event.preventDefault();
  796. return true;
  797. }
  798. }
  799. // Click event may never have fired (Gecko & Opera)
  800. if (true === $.data(event.target, this.widgetName + ".preventClickEvent")) {
  801. $.removeData(event.target, this.widgetName + ".preventClickEvent");
  802. }
  803. // these delegates are required to keep context
  804. this._mouseMoveDelegate = function(event) {
  805. return that._mouseMove(event);
  806. };
  807. this._mouseUpDelegate = function(event) {
  808. return that._mouseUp(event);
  809. };
  810. $(document)
  811. .bind("mousemove."+this.widgetName, this._mouseMoveDelegate)
  812. .bind("mouseup."+this.widgetName, this._mouseUpDelegate);
  813. event.preventDefault();
  814. mouseHandled = true;
  815. return true;
  816. },
  817. _mouseMove: function(event) {
  818. // IE mouseup check - mouseup happened when mouse was out of window
  819. if ($.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && !event.button) {
  820. return this._mouseUp(event);
  821. }
  822. if (this._mouseStarted) {
  823. this._mouseDrag(event);
  824. return event.preventDefault();
  825. }
  826. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  827. this._mouseStarted =
  828. (this._mouseStart(this._mouseDownEvent, event) !== false);
  829. (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
  830. }
  831. return !this._mouseStarted;
  832. },
  833. _mouseUp: function(event) {
  834. $(document)
  835. .unbind("mousemove."+this.widgetName, this._mouseMoveDelegate)
  836. .unbind("mouseup."+this.widgetName, this._mouseUpDelegate);
  837. if (this._mouseStarted) {
  838. this._mouseStarted = false;
  839. if (event.target === this._mouseDownEvent.target) {
  840. $.data(event.target, this.widgetName + ".preventClickEvent", true);
  841. }
  842. this._mouseStop(event);
  843. }
  844. return false;
  845. },
  846. _mouseDistanceMet: function(event) {
  847. return (Math.max(
  848. Math.abs(this._mouseDownEvent.pageX - event.pageX),
  849. Math.abs(this._mouseDownEvent.pageY - event.pageY)
  850. ) >= this.options.distance
  851. );
  852. },
  853. _mouseDelayMet: function(/* event */) {
  854. return this.mouseDelayMet;
  855. },
  856. // These are placeholder methods, to be overriden by extending plugin
  857. _mouseStart: function(/* event */) {},
  858. _mouseDrag: function(/* event */) {},
  859. _mouseStop: function(/* event */) {},
  860. _mouseCapture: function(/* event */) { return true; }
  861. });
  862. })(jQuery);
  863. (function( $, undefined ) {
  864. $.ui = $.ui || {};
  865. var cachedScrollbarWidth,
  866. max = Math.max,
  867. abs = Math.abs,
  868. round = Math.round,
  869. rhorizontal = /left|center|right/,
  870. rvertical = /top|center|bottom/,
  871. roffset = /[\+\-]\d+%?/,
  872. rposition = /^\w+/,
  873. rpercent = /%$/,
  874. _position = $.fn.position;
  875. function getOffsets( offsets, width, height ) {
  876. return [
  877. parseInt( offsets[ 0 ], 10 ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ),
  878. parseInt( offsets[ 1 ], 10 ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
  879. ];
  880. }
  881. function parseCss( element, property ) {
  882. return parseInt( $.css( element, property ), 10 ) || 0;
  883. }
  884. function getDimensions( elem ) {
  885. var raw = elem[0];
  886. if ( raw.nodeType === 9 ) {
  887. return {
  888. width: elem.width(),
  889. height: elem.height(),
  890. offset: { top: 0, left: 0 }
  891. };
  892. }
  893. if ( $.isWindow( raw ) ) {
  894. return {
  895. width: elem.width(),
  896. height: elem.height(),
  897. offset: { top: elem.scrollTop(), left: elem.scrollLeft() }
  898. };
  899. }
  900. if ( raw.preventDefault ) {
  901. return {
  902. width: 0,
  903. height: 0,
  904. offset: { top: raw.pageY, left: raw.pageX }
  905. };
  906. }
  907. return {
  908. width: elem.outerWidth(),
  909. height: elem.outerHeight(),
  910. offset: elem.offset()
  911. };
  912. }
  913. $.position = {
  914. scrollbarWidth: function() {
  915. if ( cachedScrollbarWidth !== undefined ) {
  916. return cachedScrollbarWidth;
  917. }
  918. var w1, w2,
  919. div = $( "<div style='display:block;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ),
  920. innerDiv = div.children()[0];
  921. $( "body" ).append( div );
  922. w1 = innerDiv.offsetWidth;
  923. div.css( "overflow", "scroll" );
  924. w2 = innerDiv.offsetWidth;
  925. if ( w1 === w2 ) {
  926. w2 = div[0].clientWidth;
  927. }
  928. div.remove();
  929. return (cachedScrollbarWidth = w1 - w2);
  930. },
  931. getScrollInfo: function( within ) {
  932. var overflowX = within.isWindow ? "" : within.element.css( "overflow-x" ),
  933. overflowY = within.isWindow ? "" : within.element.css( "overflow-y" ),
  934. hasOverflowX = overflowX === "scroll" ||
  935. ( overflowX === "auto" && within.width < within.element[0].scrollWidth ),
  936. hasOverflowY = overflowY === "scroll" ||
  937. ( overflowY === "auto" && within.height < within.element[0].scrollHeight );
  938. return {
  939. width: hasOverflowX ? $.position.scrollbarWidth() : 0,
  940. height: hasOverflowY ? $.position.scrollbarWidth() : 0
  941. };
  942. },
  943. getWithinInfo: function( element ) {
  944. var withinElement = $( element || window ),
  945. isWindow = $.isWindow( withinElement[0] );
  946. return {
  947. element: withinElement,
  948. isWindow: isWindow,
  949. offset: withinElement.offset() || { left: 0, top: 0 },
  950. scrollLeft: withinElement.scrollLeft(),
  951. scrollTop: withinElement.scrollTop(),
  952. width: isWindow ? withinElement.width() : withinElement.outerWidth(),
  953. height: isWindow ? withinElement.height() : withinElement.outerHeight()
  954. };
  955. }
  956. };
  957. $.fn.position = function( options ) {
  958. if ( !options || !options.of ) {
  959. return _position.apply( this, arguments );
  960. }
  961. // make a copy, we don't want to modify arguments
  962. options = $.extend( {}, options );
  963. var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
  964. target = $( options.of ),
  965. within = $.position.getWithinInfo( options.within ),
  966. scrollInfo = $.position.getScrollInfo( within ),
  967. collision = ( options.collision || "flip" ).split( " " ),
  968. offsets = {};
  969. dimensions = getDimensions( target );
  970. if ( target[0].preventDefault ) {
  971. // force left top to allow flipping
  972. options.at = "left top";
  973. }
  974. targetWidth = dimensions.width;
  975. targetHeight = dimensions.height;
  976. targetOffset = dimensions.offset;
  977. // clone to reuse original targetOffset later
  978. basePosition = $.extend( {}, targetOffset );
  979. // force my and at to have valid horizontal and vertical positions
  980. // if a value is missing or invalid, it will be converted to center
  981. $.each( [ "my", "at" ], function() {
  982. var pos = ( options[ this ] || "" ).split( " " ),
  983. horizontalOffset,
  984. verticalOffset;
  985. if ( pos.length === 1) {
  986. pos = rhorizontal.test( pos[ 0 ] ) ?
  987. pos.concat( [ "center" ] ) :
  988. rvertical.test( pos[ 0 ] ) ?
  989. [ "center" ].concat( pos ) :
  990. [ "center", "center" ];
  991. }
  992. pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center";
  993. pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center";
  994. // calculate offsets
  995. horizontalOffset = roffset.exec( pos[ 0 ] );
  996. verticalOffset = roffset.exec( pos[ 1 ] );
  997. offsets[ this ] = [
  998. horizontalOffset ? horizontalOffset[ 0 ] : 0,
  999. verticalOffset ? verticalOffset[ 0 ] : 0
  1000. ];
  1001. // reduce to just the positions without the offsets
  1002. options[ this ] = [
  1003. rposition.exec( pos[ 0 ] )[ 0 ],
  1004. rposition.exec( pos[ 1 ] )[ 0 ]
  1005. ];
  1006. });
  1007. // normalize collision option
  1008. if ( collision.length === 1 ) {
  1009. collision[ 1 ] = collision[ 0 ];
  1010. }
  1011. if ( options.at[ 0 ] === "right" ) {
  1012. basePosition.left += targetWidth;
  1013. } else if ( options.at[ 0 ] === "center" ) {
  1014. basePosition.left += targetWidth / 2;
  1015. }
  1016. if ( options.at[ 1 ] === "bottom" ) {
  1017. basePosition.top += targetHeight;
  1018. } else if ( options.at[ 1 ] === "center" ) {
  1019. basePosition.top += targetHeight / 2;
  1020. }
  1021. atOffset = getOffsets( offsets.at, targetWidth, targetHeight );
  1022. basePosition.left += atOffset[ 0 ];
  1023. basePosition.top += atOffset[ 1 ];
  1024. return this.each(function() {
  1025. var collisionPosition, using,
  1026. elem = $( this ),
  1027. elemWidth = elem.outerWidth(),
  1028. elemHeight = elem.outerHeight(),
  1029. marginLeft = parseCss( this, "marginLeft" ),
  1030. marginTop = parseCss( this, "marginTop" ),
  1031. collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + scrollInfo.width,
  1032. collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + scrollInfo.height,
  1033. position = $.extend( {}, basePosition ),
  1034. myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() );
  1035. if ( options.my[ 0 ] === "right" ) {
  1036. position.left -= elemWidth;
  1037. } else if ( options.my[ 0 ] === "center" ) {
  1038. position.left -= elemWidth / 2;
  1039. }
  1040. if ( options.my[ 1 ] === "bottom" ) {
  1041. position.top -= elemHeight;
  1042. } else if ( options.my[ 1 ] === "center" ) {
  1043. position.top -= elemHeight / 2;
  1044. }
  1045. position.left += myOffset[ 0 ];
  1046. position.top += myOffset[ 1 ];
  1047. // if the browser doesn't support fractions, then round for consistent results
  1048. if ( !$.support.offsetFractions ) {
  1049. position.left = round( position.left );
  1050. position.top = round( position.top );
  1051. }
  1052. collisionPosition = {
  1053. marginLeft: marginLeft,
  1054. marginTop: marginTop
  1055. };
  1056. $.each( [ "left", "top" ], function( i, dir ) {
  1057. if ( $.ui.position[ collision[ i ] ] ) {
  1058. $.ui.position[ collision[ i ] ][ dir ]( position, {
  1059. targetWidth: targetWidth,
  1060. targetHeight: targetHeight,
  1061. elemWidth: elemWidth,
  1062. elemHeight: elemHeight,
  1063. collisionPosition: collisionPosition,
  1064. collisionWidth: collisionWidth,
  1065. collisionHeight: collisionHeight,
  1066. offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
  1067. my: options.my,
  1068. at: options.at,
  1069. within: within,
  1070. elem : elem
  1071. });
  1072. }
  1073. });
  1074. if ( options.using ) {
  1075. // adds feedback as second argument to using callback, if present
  1076. using = function( props ) {
  1077. var left = targetOffset.left - position.left,
  1078. right = left + targetWidth - elemWidth,
  1079. top = targetOffset.top - position.top,
  1080. bottom = top + targetHeight - elemHeight,
  1081. feedback = {
  1082. target: {
  1083. element: target,
  1084. left: targetOffset.left,
  1085. top: targetOffset.top,
  1086. width: targetWidth,
  1087. height: targetHeight
  1088. },
  1089. element: {
  1090. element: elem,
  1091. left: position.left,
  1092. top: position.top,
  1093. width: elemWidth,
  1094. height: elemHeight
  1095. },
  1096. horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
  1097. vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
  1098. };
  1099. if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
  1100. feedback.horizontal = "center";
  1101. }
  1102. if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
  1103. feedback.vertical = "middle";
  1104. }
  1105. if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
  1106. feedback.important = "horizontal";
  1107. } else {
  1108. feedback.important = "vertical";
  1109. }
  1110. options.using.call( this, props, feedback );
  1111. };
  1112. }
  1113. elem.offset( $.extend( position, { using: using } ) );
  1114. });
  1115. };
  1116. $.ui.position = {
  1117. fit: {
  1118. left: function( position, data ) {
  1119. var within = data.within,
  1120. withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
  1121. outerWidth = within.width,
  1122. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  1123. overLeft = withinOffset - collisionPosLeft,
  1124. overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
  1125. newOverRight;
  1126. // element is wider than within
  1127. if ( data.collisionWidth > outerWidth ) {
  1128. // element is initially over the left side of within
  1129. if ( overLeft > 0 && overRight <= 0 ) {
  1130. newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset;
  1131. position.left += overLeft - newOverRight;
  1132. // element is initially over right side of within
  1133. } else if ( overRight > 0 && overLeft <= 0 ) {
  1134. position.left = withinOffset;
  1135. // element is initially over both left and right sides of within
  1136. } else {
  1137. if ( overLeft > overRight ) {
  1138. position.left = withinOffset + outerWidth - data.collisionWidth;
  1139. } else {
  1140. position.left = withinOffset;
  1141. }
  1142. }
  1143. // too far left -> align with left edge
  1144. } else if ( overLeft > 0 ) {
  1145. position.left += overLeft;
  1146. // too far right -> align with right edge
  1147. } else if ( overRight > 0 ) {
  1148. position.left -= overRight;
  1149. // adjust based on position and margin
  1150. } else {
  1151. position.left = max( position.left - collisionPosLeft, position.left );
  1152. }
  1153. },
  1154. top: function( position, data ) {
  1155. var within = data.within,
  1156. withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
  1157. outerHeight = data.within.height,
  1158. collisionPosTop = position.top - data.collisionPosition.marginTop,
  1159. overTop = withinOffset - collisionPosTop,
  1160. overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
  1161. newOverBottom;
  1162. // element is taller than within
  1163. if ( data.collisionHeight > outerHeight ) {
  1164. // element is initially over the top of within
  1165. if ( overTop > 0 && overBottom <= 0 ) {
  1166. newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset;
  1167. position.top += overTop - newOverBottom;
  1168. // element is initially over bottom of within
  1169. } else if ( overBottom > 0 && overTop <= 0 ) {
  1170. position.top = withinOffset;
  1171. // element is initially over both top and bottom of within
  1172. } else {
  1173. if ( overTop > overBottom ) {
  1174. position.top = withinOffset + outerHeight - data.collisionHeight;
  1175. } else {
  1176. position.top = withinOffset;
  1177. }
  1178. }
  1179. // too far up -> align with top
  1180. } else if ( overTop > 0 ) {
  1181. position.top += overTop;
  1182. // too far down -> align with bottom edge
  1183. } else if ( overBottom > 0 ) {
  1184. position.top -= overBottom;
  1185. // adjust based on position and margin
  1186. } else {
  1187. position.top = max( position.top - collisionPosTop, position.top );
  1188. }
  1189. }
  1190. },
  1191. flip: {
  1192. left: function( position, data ) {
  1193. var within = data.within,
  1194. withinOffset = within.offset.left + within.scrollLeft,
  1195. outerWidth = within.width,
  1196. offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
  1197. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  1198. overLeft = collisionPosLeft - offsetLeft,
  1199. overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
  1200. myOffset = data.my[ 0 ] === "left" ?
  1201. -data.elemWidth :
  1202. data.my[ 0 ] === "right" ?
  1203. data.elemWidth :
  1204. 0,
  1205. atOffset = data.at[ 0 ] === "left" ?
  1206. data.targetWidth :
  1207. data.at[ 0 ] === "right" ?
  1208. -data.targetWidth :
  1209. 0,
  1210. offset = -2 * data.offset[ 0 ],
  1211. newOverRight,
  1212. newOverLeft;
  1213. if ( overLeft < 0 ) {
  1214. newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset;
  1215. if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
  1216. position.left += myOffset + atOffset + offset;
  1217. }
  1218. }
  1219. else if ( overRight > 0 ) {
  1220. newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft;
  1221. if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
  1222. position.left += myOffset + atOffset + offset;
  1223. }
  1224. }
  1225. },
  1226. top: function( position, data ) {
  1227. var within = data.within,
  1228. withinOffset = within.offset.top + within.scrollTop,
  1229. outerHeight = within.height,
  1230. offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
  1231. collisionPosTop = position.top - data.collisionPosition.marginTop,
  1232. overTop = collisionPosTop - offsetTop,
  1233. overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
  1234. top = data.my[ 1 ] === "top",
  1235. myOffset = top ?
  1236. -data.elemHeight :
  1237. data.my[ 1 ] === "bottom" ?
  1238. data.elemHeight :
  1239. 0,
  1240. atOffset = data.at[ 1 ] === "top" ?
  1241. data.targetHeight :
  1242. data.at[ 1 ] === "bottom" ?
  1243. -data.targetHeight :
  1244. 0,
  1245. offset = -2 * data.offset[ 1 ],
  1246. newOverTop,
  1247. newOverBottom;
  1248. if ( overTop < 0 ) {
  1249. newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset;
  1250. if ( ( position.top + myOffset + atOffset + offset) > overTop && ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) ) {
  1251. position.top += myOffset + atOffset + offset;
  1252. }
  1253. }
  1254. else if ( overBottom > 0 ) {
  1255. newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop;
  1256. if ( ( position.top + myOffset + atOffset + offset) > overBottom && ( newOverTop > 0 || abs( newOverTop ) < overBottom ) ) {
  1257. position.top += myOffset + atOffset + offset;
  1258. }
  1259. }
  1260. }
  1261. },
  1262. flipfit: {
  1263. left: function() {
  1264. $.ui.position.flip.left.apply( this, arguments );
  1265. $.ui.position.fit.left.apply( this, arguments );
  1266. },
  1267. top: function() {
  1268. $.ui.position.flip.top.apply( this, arguments );
  1269. $.ui.position.fit.top.apply( this, arguments );
  1270. }
  1271. }
  1272. };
  1273. // fraction support test
  1274. (function () {
  1275. var testElement, testElementParent, testElementStyle, offsetLeft, i,
  1276. body = document.getElementsByTagName( "body" )[ 0 ],
  1277. div = document.createElement( "div" );
  1278. //Create a "fake body" for testing based on method used in jQuery.support
  1279. testElement = document.createElement( body ? "div" : "body" );
  1280. testElementStyle = {
  1281. visibility: "hidden",
  1282. width: 0,
  1283. height: 0,
  1284. border: 0,
  1285. margin: 0,
  1286. background: "none"
  1287. };
  1288. if ( body ) {
  1289. $.extend( testElementStyle, {
  1290. position: "absolute",
  1291. left: "-1000px",
  1292. top: "-1000px"
  1293. });
  1294. }
  1295. for ( i in testElementStyle ) {
  1296. testElement.style[ i ] = testElementStyle[ i ];
  1297. }
  1298. testElement.appendChild( div );
  1299. testElementParent = body || document.documentElement;
  1300. testElementParent.insertBefore( testElement, testElementParent.firstChild );
  1301. div.style.cssText = "position: absolute; left: 10.7432222px;";
  1302. offsetLeft = $( div ).offset().left;
  1303. $.support.offsetFractions = offsetLeft > 10 && offsetLeft < 11;
  1304. testElement.innerHTML = "";
  1305. testElementParent.removeChild( testElement );
  1306. })();
  1307. }( jQuery ) );
  1308. (function( $, undefined ) {
  1309. $.widget("ui.draggable", $.ui.mouse, {
  1310. version: "1.10.0",
  1311. widgetEventPrefix: "drag",
  1312. options: {
  1313. addClasses: true,
  1314. appendTo: "parent",
  1315. axis: false,
  1316. connectToSortable: false,
  1317. containment: false,
  1318. cursor: "auto",
  1319. cursorAt: false,
  1320. grid: false,
  1321. handle: false,
  1322. helper: "original",
  1323. iframeFix: false,
  1324. opacity: false,
  1325. refreshPositions: false,
  1326. revert: false,
  1327. revertDuration: 500,
  1328. scope: "default",
  1329. scroll: true,
  1330. scrollSensitivity: 20,
  1331. scrollSpeed: 20,
  1332. snap: false,
  1333. snapMode: "both",
  1334. snapTolerance: 20,
  1335. stack: false,
  1336. zIndex: false,
  1337. // callbacks
  1338. drag: null,
  1339. start: null,
  1340. stop: null
  1341. },
  1342. _create: function() {
  1343. if (this.options.helper === "original" && !(/^(?:r|a|f)/).test(this.element.css("position"))) {
  1344. this.element[0].style.position = "relative";
  1345. }
  1346. if (this.options.addClasses){
  1347. this.element.addClass("ui-draggable");
  1348. }
  1349. if (this.options.disabled){
  1350. this.element.addClass("ui-draggable-disabled");
  1351. }
  1352. this._mouseInit();
  1353. },
  1354. _destroy: function() {
  1355. this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" );
  1356. this._mouseDestroy();
  1357. },
  1358. _mouseCapture: function(event) {
  1359. var o = this.options;
  1360. // among others, prevent a drag on a resizable-handle
  1361. if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) {
  1362. return false;
  1363. }
  1364. //Quit if we're not on a valid handle
  1365. this.handle = this._getHandle(event);
  1366. if (!this.handle) {
  1367. return false;
  1368. }
  1369. $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() {
  1370. $("<div class='ui-draggable-iframeFix' style='background: #fff;'></div>")
  1371. .css({
  1372. width: this.offsetWidth+"px", height: this.offsetHeight+"px",
  1373. position: "absolute", opacity: "0.001", zIndex: 1000
  1374. })
  1375. .css($(this).offset())
  1376. .appendTo("body");
  1377. });
  1378. return true;
  1379. },
  1380. _mouseStart: function(event) {
  1381. var o = this.options;
  1382. //Create and append the visible helper
  1383. this.helper = this._createHelper(event);
  1384. this.helper.addClass("ui-draggable-dragging");
  1385. //Cache the helper size
  1386. this._cacheHelperProportions();
  1387. //If ddmanager is used for droppables, set the global draggable
  1388. if($.ui.ddmanager) {
  1389. $.ui.ddmanager.current = this;
  1390. }
  1391. /*
  1392. * - Position generation -
  1393. * This block generates everything position related - it's the core of draggables.
  1394. */
  1395. //Cache the margins of the original element
  1396. this._cacheMargins();
  1397. //Store the helper's css position
  1398. this.cssPosition = this.helper.css("position");
  1399. this.scrollParent = this.helper.scrollParent();
  1400. //The element's absolute position on the page minus margins
  1401. this.offset = this.positionAbs = this.element.offset();
  1402. this.offset = {
  1403. top: this.offset.top - this.margins.top,
  1404. left: this.offset.left - this.margins.left
  1405. };
  1406. $.extend(this.offset, {
  1407. click: { //Where the click happened, relative to the element
  1408. left: event.pageX - this.offset.left,
  1409. top: event.pageY - this.offset.top
  1410. },
  1411. parent: this._getParentOffset(),
  1412. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  1413. });
  1414. //Generate the original position
  1415. this.originalPosition = this.position = this._generatePosition(event);
  1416. this.originalPageX = event.pageX;
  1417. this.originalPageY = event.pageY;
  1418. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  1419. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  1420. //Set a containment if given in the options
  1421. if(o.containment) {
  1422. this._setContainment();
  1423. }
  1424. //Trigger event + callbacks
  1425. if(this._trigger("start", event) === false) {
  1426. this._clear();
  1427. return false;
  1428. }
  1429. //Recache the helper size
  1430. this._cacheHelperProportions();
  1431. //Prepare the droppable offsets
  1432. if ($.ui.ddmanager && !o.dropBehaviour) {
  1433. $.ui.ddmanager.prepareOffsets(this, event);
  1434. }
  1435. this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  1436. //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
  1437. if ( $.ui.ddmanager ) {
  1438. $.ui.ddmanager.dragStart(this, event);
  1439. }
  1440. return true;
  1441. },
  1442. _mouseDrag: function(event, noPropagation) {
  1443. //Compute the helpers position
  1444. this.position = this._generatePosition(event);
  1445. this.positionAbs = this._convertPositionTo("absolute");
  1446. //Call plugins and callbacks and use the resulting position if something is returned
  1447. if (!noPropagation) {
  1448. var ui = this._uiHash();
  1449. if(this._trigger("drag", event, ui) === false) {
  1450. this._mouseUp({});
  1451. return false;
  1452. }
  1453. this.position = ui.position;
  1454. }
  1455. if(!this.options.axis || this.options.axis !== "y") {
  1456. this.helper[0].style.left = this.position.left+"px";
  1457. }
  1458. if(!this.options.axis || this.options.axis !== "x") {
  1459. this.helper[0].style.top = this.position.top+"px";
  1460. }
  1461. if($.ui.ddmanager) {
  1462. $.ui.ddmanager.drag(this, event);
  1463. }
  1464. return false;
  1465. },
  1466. _mouseStop: function(event) {
  1467. //If we are using droppables, inform the manager about the drop
  1468. var element,
  1469. that = this,
  1470. elementInDom = false,
  1471. dropped = false;
  1472. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  1473. dropped = $.ui.ddmanager.drop(this, event);
  1474. }
  1475. //if a drop comes from outside (a sortable)
  1476. if(this.dropped) {
  1477. dropped = this.dropped;
  1478. this.dropped = false;
  1479. }
  1480. //if the original element is no longer in the DOM don't bother to continue (see #8269)
  1481. element = this.element[0];
  1482. while ( element && (element = element.parentNode) ) {
  1483. if (element === document ) {
  1484. elementInDom = true;
  1485. }
  1486. }
  1487. if ( !elementInDom && this.options.helper === "original" ) {
  1488. return false;
  1489. }
  1490. 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))) {
  1491. $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
  1492. if(that._trigger("stop", event) !== false) {
  1493. that._clear();
  1494. }
  1495. });
  1496. } else {
  1497. if(this._trigger("stop", event) !== false) {
  1498. this._clear();
  1499. }
  1500. }
  1501. return false;
  1502. },
  1503. _mouseUp: function(event) {
  1504. //Remove frame helpers
  1505. $("div.ui-draggable-iframeFix").each(function() {
  1506. this.parentNode.removeChild(this);
  1507. });
  1508. //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
  1509. if( $.ui.ddmanager ) {
  1510. $.ui.ddmanager.dragStop(this, event);
  1511. }
  1512. return $.ui.mouse.prototype._mouseUp.call(this, event);
  1513. },
  1514. cancel: function() {
  1515. if(this.helper.is(".ui-draggable-dragging")) {
  1516. this._mouseUp({});
  1517. } else {
  1518. this._clear();
  1519. }
  1520. return this;
  1521. },
  1522. _getHandle: function(event) {
  1523. var handle = !this.options.handle || !$(this.options.handle, this.element).length ? true : false;
  1524. $(this.options.handle, this.element)
  1525. .find("*")
  1526. .addBack()
  1527. .each(function() {
  1528. if(this === event.target) {
  1529. handle = true;
  1530. }
  1531. });
  1532. return handle;
  1533. },
  1534. _createHelper: function(event) {
  1535. var o = this.options,
  1536. helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper === "clone" ? this.element.clone().removeAttr("id") : this.element);
  1537. if(!helper.parents("body").length) {
  1538. helper.appendTo((o.appendTo === "parent" ? this.element[0].parentNode : o.appendTo));
  1539. }
  1540. if(helper[0] !== this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) {
  1541. helper.css("position", "absolute");
  1542. }
  1543. return helper;
  1544. },
  1545. _adjustOffsetFromHelper: function(obj) {
  1546. if (typeof obj === "string") {
  1547. obj = obj.split(" ");
  1548. }
  1549. if ($.isArray(obj)) {
  1550. obj = {left: +obj[0], top: +obj[1] || 0};
  1551. }
  1552. if ("left" in obj) {
  1553. this.offset.click.left = obj.left + this.margins.left;
  1554. }
  1555. if ("right" in obj) {
  1556. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  1557. }
  1558. if ("top" in obj) {
  1559. this.offset.click.top = obj.top + this.margins.top;
  1560. }
  1561. if ("bottom" in obj) {
  1562. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  1563. }
  1564. },
  1565. _getParentOffset: function() {
  1566. //Get the offsetParent and cache its position
  1567. this.offsetParent = this.helper.offsetParent();
  1568. var po = this.offsetParent.offset();
  1569. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  1570. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  1571. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  1572. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  1573. if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  1574. po.left += this.scrollParent.scrollLeft();
  1575. po.top += this.scrollParent.scrollTop();
  1576. }
  1577. //This needs to be actually done for all browsers, since pageX/pageY includes this information
  1578. //Ugly IE fix
  1579. if((this.offsetParent[0] === document.body) ||
  1580. (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
  1581. po = { top: 0, left: 0 };
  1582. }
  1583. return {
  1584. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  1585. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  1586. };
  1587. },
  1588. _getRelativeOffset: function() {
  1589. if(this.cssPosition === "relative") {
  1590. var p = this.element.position();
  1591. return {
  1592. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  1593. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  1594. };
  1595. } else {
  1596. return { top: 0, left: 0 };
  1597. }
  1598. },
  1599. _cacheMargins: function() {
  1600. this.margins = {
  1601. left: (parseInt(this.element.css("marginLeft"),10) || 0),
  1602. top: (parseInt(this.element.css("marginTop"),10) || 0),
  1603. right: (parseInt(this.element.css("marginRight"),10) || 0),
  1604. bottom: (parseInt(this.element.css("marginBottom"),10) || 0)
  1605. };
  1606. },
  1607. _cacheHelperProportions: function() {
  1608. this.helperProportions = {
  1609. width: this.helper.outerWidth(),
  1610. height: this.helper.outerHeight()
  1611. };
  1612. },
  1613. _setContainment: function() {
  1614. var over, c, ce,
  1615. o = this.options;
  1616. if(o.containment === "parent") {
  1617. o.containment = this.helper[0].parentNode;
  1618. }
  1619. if(o.containment === "document" || o.containment === "window") {
  1620. this.containment = [
  1621. o.containment === "document" ? 0 : $(window).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
  1622. o.containment === "document" ? 0 : $(window).scrollTop() - this.offset.relative.top - this.offset.parent.top,
  1623. (o.containment === "document" ? 0 : $(window).scrollLeft()) + $(o.containment === "document" ? document : window).width() - this.helperProportions.width - this.margins.left,
  1624. (o.containment === "document" ? 0 : $(window).scrollTop()) + ($(o.containment === "document" ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
  1625. ];
  1626. }
  1627. if(!(/^(document|window|parent)$/).test(o.containment) && o.containment.constructor !== Array) {
  1628. c = $(o.containment);
  1629. ce = c[0];
  1630. if(!ce) {
  1631. return;
  1632. }
  1633. over = ($(ce).css("overflow") !== "hidden");
  1634. this.containment = [
  1635. (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0),
  1636. (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0),
  1637. (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,
  1638. (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
  1639. ];
  1640. this.relative_container = c;
  1641. } else if(o.containment.constructor === Array) {
  1642. this.containment = o.containment;
  1643. }
  1644. },
  1645. _convertPositionTo: function(d, pos) {
  1646. if(!pos) {
  1647. pos = this.position;
  1648. }
  1649. var mod = d === "absolute" ? 1 : -1,
  1650. scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
  1651. return {
  1652. top: (
  1653. pos.top + // The absolute mouse position
  1654. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  1655. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  1656. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
  1657. ),
  1658. left: (
  1659. pos.left + // The absolute mouse position
  1660. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  1661. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  1662. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
  1663. )
  1664. };
  1665. },
  1666. _generatePosition: function(event) {
  1667. var containment, co, top, left,
  1668. o = this.options,
  1669. scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
  1670. scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName),
  1671. pageX = event.pageX,
  1672. pageY = event.pageY;
  1673. /*
  1674. * - Position constraining -
  1675. * Constrain the position to a mix of grid, containment.
  1676. */
  1677. if(this.originalPosition) { //If we are not dragging yet, we won't check for options
  1678. if(this.containment) {
  1679. if (this.relative_container){
  1680. co = this.relative_container.offset();
  1681. containment = [ this.containment[0] + co.left,
  1682. this.containment[1] + co.top,
  1683. this.containment[2] + co.left,
  1684. this.containment[3] + co.top ];
  1685. }
  1686. else {
  1687. containment = this.containment;
  1688. }
  1689. if(event.pageX - this.offset.click.left < containment[0]) {
  1690. pageX = containment[0] + this.offset.click.left;
  1691. }
  1692. if(event.pageY - this.offset.click.top < containment[1]) {
  1693. pageY = containment[1] + this.offset.click.top;
  1694. }
  1695. if(event.pageX - this.offset.click.left > containment[2]) {
  1696. pageX = containment[2] + this.offset.click.left;
  1697. }
  1698. if(event.pageY - this.offset.click.top > containment[3]) {
  1699. pageY = containment[3] + this.offset.click.top;
  1700. }
  1701. }
  1702. if(o.grid) {
  1703. //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
  1704. top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
  1705. 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;
  1706. left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
  1707. 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;
  1708. }
  1709. }
  1710. return {
  1711. top: (
  1712. pageY - // The absolute mouse position
  1713. this.offset.click.top - // Click offset (relative to the element)
  1714. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  1715. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  1716. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
  1717. ),
  1718. left: (
  1719. pageX - // The absolute mouse position
  1720. this.offset.click.left - // Click offset (relative to the element)
  1721. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  1722. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  1723. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
  1724. )
  1725. };
  1726. },
  1727. _clear: function() {
  1728. this.helper.removeClass("ui-draggable-dragging");
  1729. if(this.helper[0] !== this.element[0] && !this.cancelHelperRemoval) {
  1730. this.helper.remove();
  1731. }
  1732. this.helper = null;
  1733. this.cancelHelperRemoval = false;
  1734. },
  1735. // From now on bulk stuff - mainly helpers
  1736. _trigger: function(type, event, ui) {
  1737. ui = ui || this._uiHash();
  1738. $.ui.plugin.call(this, type, [event, ui]);
  1739. //The absolute position has to be recalculated after plugins
  1740. if(type === "drag") {
  1741. this.positionAbs = this._convertPositionTo("absolute");
  1742. }
  1743. return $.Widget.prototype._trigger.call(this, type, event, ui);
  1744. },
  1745. plugins: {},
  1746. _uiHash: function() {
  1747. return {
  1748. helper: this.helper,
  1749. position: this.position,
  1750. originalPosition: this.originalPosition,
  1751. offset: this.positionAbs
  1752. };
  1753. }
  1754. });
  1755. $.ui.plugin.add("draggable", "connectToSortable", {
  1756. start: function(event, ui) {
  1757. var inst = $(this).data("ui-draggable"), o = inst.options,
  1758. uiSortable = $.extend({}, ui, { item: inst.element });
  1759. inst.sortables = [];
  1760. $(o.connectToSortable).each(function() {
  1761. var sortable = $.data(this, "ui-sortable");
  1762. if (sortable && !sortable.options.disabled) {
  1763. inst.sortables.push({
  1764. instance: sortable,
  1765. shouldRevert: sortable.options.revert
  1766. });
  1767. 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).
  1768. sortable._trigger("activate", event, uiSortable);
  1769. }
  1770. });
  1771. },
  1772. stop: function(event, ui) {
  1773. //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
  1774. var inst = $(this).data("ui-draggable"),
  1775. uiSortable = $.extend({}, ui, { item: inst.element });
  1776. $.each(inst.sortables, function() {
  1777. if(this.instance.isOver) {
  1778. this.instance.isOver = 0;
  1779. inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance
  1780. this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
  1781. //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: "valid/invalid"
  1782. if(this.shouldRevert) {
  1783. this.instance.options.revert = true;
  1784. }
  1785. //Trigger the stop of the sortable
  1786. this.instance._mouseStop(event);
  1787. this.instance.options.helper = this.instance.options._helper;
  1788. //If the helper has been the original item, restore properties in the sortable
  1789. if(inst.options.helper === "original") {
  1790. this.instance.currentItem.css({ top: "auto", left: "auto" });
  1791. }
  1792. } else {
  1793. this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance
  1794. this.instance._trigger("deactivate", event, uiSortable);
  1795. }
  1796. });
  1797. },
  1798. drag: function(event, ui) {
  1799. var inst = $(this).data("ui-draggable"), that = this;
  1800. $.each(inst.sortables, function() {
  1801. var innermostIntersecting = false,
  1802. thisSortable = this;
  1803. //Copy over some variables to allow calling the sortable's native _intersectsWith
  1804. this.instance.positionAbs = inst.positionAbs;
  1805. this.instance.helperProportions = inst.helperProportions;
  1806. this.instance.offset.click = inst.offset.click;
  1807. if(this.instance._intersectsWith(this.instance.containerCache)) {
  1808. innermostIntersecting = true;
  1809. $.each(inst.sortables, function () {
  1810. this.instance.positionAbs = inst.positionAbs;
  1811. this.instance.helperProportions = inst.helperProportions;
  1812. this.instance.offset.click = inst.offset.click;
  1813. if (this !== thisSortable &&
  1814. this.instance._intersectsWith(this.instance.containerCache) &&
  1815. $.ui.contains(thisSortable.instance.element[0], this.instance.element[0])
  1816. ) {
  1817. innermostIntersecting = false;
  1818. }
  1819. return innermostIntersecting;
  1820. });
  1821. }
  1822. if(innermostIntersecting) {
  1823. //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once
  1824. if(!this.instance.isOver) {
  1825. this.instance.isOver = 1;
  1826. //Now we fake the start of dragging for the sortable instance,
  1827. //by cloning the list group item, appending it to the sortable and using it as inst.currentItem
  1828. //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)
  1829. this.instance.currentItem = $(that).clone().removeAttr("id").appendTo(this.instance.element).data("ui-sortable-item", true);
  1830. this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it
  1831. this.instance.options.helper = function() { return ui.helper[0]; };
  1832. event.target = this.instance.currentItem[0];
  1833. this.instance._mouseCapture(event, true);
  1834. this.instance._mouseStart(event, true, true);
  1835. //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes
  1836. this.instance.offset.click.top = inst.offset.click.top;
  1837. this.instance.offset.click.left = inst.offset.click.left;
  1838. this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left;
  1839. this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top;
  1840. inst._trigger("toSortable", event);
  1841. inst.dropped = this.instance.element; //draggable revert needs that
  1842. //hack so receive/update callbacks work (mostly)
  1843. inst.currentItem = inst.element;
  1844. this.instance.fromOutside = inst;
  1845. }
  1846. //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
  1847. if(this.instance.currentItem) {
  1848. this.instance._mouseDrag(event);
  1849. }
  1850. } else {
  1851. //If it doesn't intersect with the sortable, and it intersected before,
  1852. //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval
  1853. if(this.instance.isOver) {
  1854. this.instance.isOver = 0;
  1855. this.instance.cancelHelperRemoval = true;
  1856. //Prevent reverting on this forced stop
  1857. this.instance.options.revert = false;
  1858. // The out event needs to be triggered independently
  1859. this.instance._trigger("out", event, this.instance._uiHash(this.instance));
  1860. this.instance._mouseStop(event, true);
  1861. this.instance.options.helper = this.instance.options._helper;
  1862. //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size
  1863. this.instance.currentItem.remove();
  1864. if(this.instance.placeholder) {
  1865. this.instance.placeholder.remove();
  1866. }
  1867. inst._trigger("fromSortable", event);
  1868. inst.dropped = false; //draggable revert needs that
  1869. }
  1870. }
  1871. });
  1872. }
  1873. });
  1874. $.ui.plugin.add("draggable", "cursor", {
  1875. start: function() {
  1876. var t = $("body"), o = $(this).data("ui-draggable").options;
  1877. if (t.css("cursor")) {
  1878. o._cursor = t.css("cursor");
  1879. }
  1880. t.css("cursor", o.cursor);
  1881. },
  1882. stop: function() {
  1883. var o = $(this).data("ui-draggable").options;
  1884. if (o._cursor) {
  1885. $("body").css("cursor", o._cursor);
  1886. }
  1887. }
  1888. });
  1889. $.ui.plugin.add("draggable", "opacity", {
  1890. start: function(event, ui) {
  1891. var t = $(ui.helper), o = $(this).data("ui-draggable").options;
  1892. if(t.css("opacity")) {
  1893. o._opacity = t.css("opacity");
  1894. }
  1895. t.css("opacity", o.opacity);
  1896. },
  1897. stop: function(event, ui) {
  1898. var o = $(this).data("ui-draggable").options;
  1899. if(o._opacity) {
  1900. $(ui.helper).css("opacity", o._opacity);
  1901. }
  1902. }
  1903. });
  1904. $.ui.plugin.add("draggable", "scroll", {
  1905. start: function() {
  1906. var i = $(this).data("ui-draggable");
  1907. if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") {
  1908. i.overflowOffset = i.scrollParent.offset();
  1909. }
  1910. },
  1911. drag: function( event ) {
  1912. var i = $(this).data("ui-draggable"), o = i.options, scrolled = false;
  1913. if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") {
  1914. if(!o.axis || o.axis !== "x") {
  1915. if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
  1916. i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed;
  1917. } else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity) {
  1918. i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed;
  1919. }
  1920. }
  1921. if(!o.axis || o.axis !== "y") {
  1922. if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
  1923. i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed;
  1924. } else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity) {
  1925. i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed;
  1926. }
  1927. }
  1928. } else {
  1929. if(!o.axis || o.axis !== "x") {
  1930. if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
  1931. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  1932. } else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
  1933. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  1934. }
  1935. }
  1936. if(!o.axis || o.axis !== "y") {
  1937. if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
  1938. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  1939. } else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
  1940. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  1941. }
  1942. }
  1943. }
  1944. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  1945. $.ui.ddmanager.prepareOffsets(i, event);
  1946. }
  1947. }
  1948. });
  1949. $.ui.plugin.add("draggable", "snap", {
  1950. start: function() {
  1951. var i = $(this).data("ui-draggable"),
  1952. o = i.options;
  1953. i.snapElements = [];
  1954. $(o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap).each(function() {
  1955. var $t = $(this),
  1956. $o = $t.offset();
  1957. if(this !== i.element[0]) {
  1958. i.snapElements.push({
  1959. item: this,
  1960. width: $t.outerWidth(), height: $t.outerHeight(),
  1961. top: $o.top, left: $o.left
  1962. });
  1963. }
  1964. });
  1965. },
  1966. drag: function(event, ui) {
  1967. var ts, bs, ls, rs, l, r, t, b, i, first,
  1968. inst = $(this).data("ui-draggable"),
  1969. o = inst.options,
  1970. d = o.snapTolerance,
  1971. x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
  1972. y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
  1973. for (i = inst.snapElements.length - 1; i >= 0; i--){
  1974. l = inst.snapElements[i].left;
  1975. r = l + inst.snapElements[i].width;
  1976. t = inst.snapElements[i].top;
  1977. b = t + inst.snapElements[i].height;
  1978. //Yes, I know, this is insane ;)
  1979. 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))) {
  1980. if(inst.snapElements[i].snapping) {
  1981. (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  1982. }
  1983. inst.snapElements[i].snapping = false;
  1984. continue;
  1985. }
  1986. if(o.snapMode !== "inner") {
  1987. ts = Math.abs(t - y2) <= d;
  1988. bs = Math.abs(b - y1) <= d;
  1989. ls = Math.abs(l - x2) <= d;
  1990. rs = Math.abs(r - x1) <= d;
  1991. if(ts) {
  1992. ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
  1993. }
  1994. if(bs) {
  1995. ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top;
  1996. }
  1997. if(ls) {
  1998. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left;
  1999. }
  2000. if(rs) {
  2001. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left;
  2002. }
  2003. }
  2004. first = (ts || bs || ls || rs);
  2005. if(o.snapMode !== "outer") {
  2006. ts = Math.abs(t - y1) <= d;
  2007. bs = Math.abs(b - y2) <= d;
  2008. ls = Math.abs(l - x1) <= d;
  2009. rs = Math.abs(r - x2) <= d;
  2010. if(ts) {
  2011. ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top;
  2012. }
  2013. if(bs) {
  2014. ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
  2015. }
  2016. if(ls) {
  2017. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left;
  2018. }
  2019. if(rs) {
  2020. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left;
  2021. }
  2022. }
  2023. if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) {
  2024. (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  2025. }
  2026. inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
  2027. }
  2028. }
  2029. });
  2030. $.ui.plugin.add("draggable", "stack", {
  2031. start: function() {
  2032. var min,
  2033. o = $(this).data("ui-draggable").options,
  2034. group = $.makeArray($(o.stack)).sort(function(a,b) {
  2035. return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0);
  2036. });
  2037. if (!group.length) { return; }
  2038. min = parseInt(group[0].style.zIndex, 10) || 0;
  2039. $(group).each(function(i) {
  2040. this.style.zIndex = min + i;
  2041. });
  2042. this[0].style.zIndex = min + group.length;
  2043. }
  2044. });
  2045. $.ui.plugin.add("draggable", "zIndex", {
  2046. start: function(event, ui) {
  2047. var t = $(ui.helper), o = $(this).data("ui-draggable").options;
  2048. if(t.css("zIndex")) {
  2049. o._zIndex = t.css("zIndex");
  2050. }
  2051. t.css("zIndex", o.zIndex);
  2052. },
  2053. stop: function(event, ui) {
  2054. var o = $(this).data("ui-draggable").options;
  2055. if(o._zIndex) {
  2056. $(ui.helper).css("zIndex", o._zIndex);
  2057. }
  2058. }
  2059. });
  2060. })(jQuery);
  2061. (function( $, undefined ) {
  2062. function isOverAxis( x, reference, size ) {
  2063. return ( x > reference ) && ( x < ( reference + size ) );
  2064. }
  2065. $.widget("ui.droppable", {
  2066. version: "1.10.0",
  2067. widgetEventPrefix: "drop",
  2068. options: {
  2069. accept: "*",
  2070. activeClass: false,
  2071. addClasses: true,
  2072. greedy: false,
  2073. hoverClass: false,
  2074. scope: "default",
  2075. tolerance: "intersect",
  2076. // callbacks
  2077. activate: null,
  2078. deactivate: null,
  2079. drop: null,
  2080. out: null,
  2081. over: null
  2082. },
  2083. _create: function() {
  2084. var o = this.options,
  2085. accept = o.accept;
  2086. this.isover = false;
  2087. this.isout = true;
  2088. this.accept = $.isFunction(accept) ? accept : function(d) {
  2089. return d.is(accept);
  2090. };
  2091. //Store the droppable's proportions
  2092. this.proportions = { width: this.element[0].offsetWidth, height: this.element[0].offsetHeight };
  2093. // Add the reference and positions to the manager
  2094. $.ui.ddmanager.droppables[o.scope] = $.ui.ddmanager.droppables[o.scope] || [];
  2095. $.ui.ddmanager.droppables[o.scope].push(this);
  2096. (o.addClasses && this.element.addClass("ui-droppable"));
  2097. },
  2098. _destroy: function() {
  2099. var i = 0,
  2100. drop = $.ui.ddmanager.droppables[this.options.scope];
  2101. for ( ; i < drop.length; i++ ) {
  2102. if ( drop[i] === this ) {
  2103. drop.splice(i, 1);
  2104. }
  2105. }
  2106. this.element.removeClass("ui-droppable ui-droppable-disabled");
  2107. },
  2108. _setOption: function(key, value) {
  2109. if(key === "accept") {
  2110. this.accept = $.isFunction(value) ? value : function(d) {
  2111. return d.is(value);
  2112. };
  2113. }
  2114. $.Widget.prototype._setOption.apply(this, arguments);
  2115. },
  2116. _activate: function(event) {
  2117. var draggable = $.ui.ddmanager.current;
  2118. if(this.options.activeClass) {
  2119. this.element.addClass(this.options.activeClass);
  2120. }
  2121. if(draggable){
  2122. this._trigger("activate", event, this.ui(draggable));
  2123. }
  2124. },
  2125. _deactivate: function(event) {
  2126. var draggable = $.ui.ddmanager.current;
  2127. if(this.options.activeClass) {
  2128. this.element.removeClass(this.options.activeClass);
  2129. }
  2130. if(draggable){
  2131. this._trigger("deactivate", event, this.ui(draggable));
  2132. }
  2133. },
  2134. _over: function(event) {
  2135. var draggable = $.ui.ddmanager.current;
  2136. // Bail if draggable and droppable are same element
  2137. if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
  2138. return;
  2139. }
  2140. if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  2141. if(this.options.hoverClass) {
  2142. this.element.addClass(this.options.hoverClass);
  2143. }
  2144. this._trigger("over", event, this.ui(draggable));
  2145. }
  2146. },
  2147. _out: function(event) {
  2148. var draggable = $.ui.ddmanager.current;
  2149. // Bail if draggable and droppable are same element
  2150. if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
  2151. return;
  2152. }
  2153. if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  2154. if(this.options.hoverClass) {
  2155. this.element.removeClass(this.options.hoverClass);
  2156. }
  2157. this._trigger("out", event, this.ui(draggable));
  2158. }
  2159. },
  2160. _drop: function(event,custom) {
  2161. var draggable = custom || $.ui.ddmanager.current,
  2162. childrenIntersection = false;
  2163. // Bail if draggable and droppable are same element
  2164. if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
  2165. return false;
  2166. }
  2167. this.element.find(":data(ui-droppable)").not(".ui-draggable-dragging").each(function() {
  2168. var inst = $.data(this, "ui-droppable");
  2169. if(
  2170. inst.options.greedy &&
  2171. !inst.options.disabled &&
  2172. inst.options.scope === draggable.options.scope &&
  2173. inst.accept.call(inst.element[0], (draggable.currentItem || draggable.element)) &&
  2174. $.ui.intersect(draggable, $.extend(inst, { offset: inst.element.offset() }), inst.options.tolerance)
  2175. ) { childrenIntersection = true; return false; }
  2176. });
  2177. if(childrenIntersection) {
  2178. return false;
  2179. }
  2180. if(this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  2181. if(this.options.activeClass) {
  2182. this.element.removeClass(this.options.activeClass);
  2183. }
  2184. if(this.options.hoverClass) {
  2185. this.element.removeClass(this.options.hoverClass);
  2186. }
  2187. this._trigger("drop", event, this.ui(draggable));
  2188. return this.element;
  2189. }
  2190. return false;
  2191. },
  2192. ui: function(c) {
  2193. return {
  2194. draggable: (c.currentItem || c.element),
  2195. helper: c.helper,
  2196. position: c.position,
  2197. offset: c.positionAbs
  2198. };
  2199. }
  2200. });
  2201. $.ui.intersect = function(draggable, droppable, toleranceMode) {
  2202. if (!droppable.offset) {
  2203. return false;
  2204. }
  2205. var draggableLeft, draggableTop,
  2206. x1 = (draggable.positionAbs || draggable.position.absolute).left, x2 = x1 + draggable.helperProportions.width,
  2207. y1 = (draggable.positionAbs || draggable.position.absolute).top, y2 = y1 + draggable.helperProportions.height,
  2208. l = droppable.offset.left, r = l + droppable.proportions.width,
  2209. t = droppable.offset.top, b = t + droppable.proportions.height;
  2210. switch (toleranceMode) {
  2211. case "fit":
  2212. return (l <= x1 && x2 <= r && t <= y1 && y2 <= b);
  2213. case "intersect":
  2214. return (l < x1 + (draggable.helperProportions.width / 2) && // Right Half
  2215. x2 - (draggable.helperProportions.width / 2) < r && // Left Half
  2216. t < y1 + (draggable.helperProportions.height / 2) && // Bottom Half
  2217. y2 - (draggable.helperProportions.height / 2) < b ); // Top Half
  2218. case "pointer":
  2219. draggableLeft = ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left);
  2220. draggableTop = ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top);
  2221. return isOverAxis( draggableTop, t, droppable.proportions.height ) && isOverAxis( draggableLeft, l, droppable.proportions.width );
  2222. case "touch":
  2223. return (
  2224. (y1 >= t && y1 <= b) || // Top edge touching
  2225. (y2 >= t && y2 <= b) || // Bottom edge touching
  2226. (y1 < t && y2 > b) // Surrounded vertically
  2227. ) && (
  2228. (x1 >= l && x1 <= r) || // Left edge touching
  2229. (x2 >= l && x2 <= r) || // Right edge touching
  2230. (x1 < l && x2 > r) // Surrounded horizontally
  2231. );
  2232. default:
  2233. return false;
  2234. }
  2235. };
  2236. /*
  2237. This manager tracks offsets of draggables and droppables
  2238. */
  2239. $.ui.ddmanager = {
  2240. current: null,
  2241. droppables: { "default": [] },
  2242. prepareOffsets: function(t, event) {
  2243. var i, j,
  2244. m = $.ui.ddmanager.droppables[t.options.scope] || [],
  2245. type = event ? event.type : null, // workaround for #2317
  2246. list = (t.currentItem || t.element).find(":data(ui-droppable)").addBack();
  2247. droppablesLoop: for (i = 0; i < m.length; i++) {
  2248. //No disabled and non-accepted
  2249. if(m[i].options.disabled || (t && !m[i].accept.call(m[i].element[0],(t.currentItem || t.element)))) {
  2250. continue;
  2251. }
  2252. // Filter out elements in the current dragged item
  2253. for (j=0; j < list.length; j++) {
  2254. if(list[j] === m[i].element[0]) {
  2255. m[i].proportions.height = 0;
  2256. continue droppablesLoop;
  2257. }
  2258. }
  2259. m[i].visible = m[i].element.css("display") !== "none";
  2260. if(!m[i].visible) {
  2261. continue;
  2262. }
  2263. //Activate the droppable if used directly from draggables
  2264. if(type === "mousedown") {
  2265. m[i]._activate.call(m[i], event);
  2266. }
  2267. m[i].offset = m[i].element.offset();
  2268. m[i].proportions = { width: m[i].element[0].offsetWidth, height: m[i].element[0].offsetHeight };
  2269. }
  2270. },
  2271. drop: function(draggable, event) {
  2272. var dropped = false;
  2273. $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() {
  2274. if(!this.options) {
  2275. return;
  2276. }
  2277. if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance)) {
  2278. dropped = this._drop.call(this, event) || dropped;
  2279. }
  2280. if (!this.options.disabled && this.visible && this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  2281. this.isout = true;
  2282. this.isover = false;
  2283. this._deactivate.call(this, event);
  2284. }
  2285. });
  2286. return dropped;
  2287. },
  2288. dragStart: function( draggable, event ) {
  2289. //Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003)
  2290. draggable.element.parentsUntil( "body" ).bind( "scroll.droppable", function() {
  2291. if( !draggable.options.refreshPositions ) {
  2292. $.ui.ddmanager.prepareOffsets( draggable, event );
  2293. }
  2294. });
  2295. },
  2296. drag: function(draggable, event) {
  2297. //If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
  2298. if(draggable.options.refreshPositions) {
  2299. $.ui.ddmanager.prepareOffsets(draggable, event);
  2300. }
  2301. //Run through all droppables and check their positions based on specific tolerance options
  2302. $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() {
  2303. if(this.options.disabled || this.greedyChild || !this.visible) {
  2304. return;
  2305. }
  2306. var parentInstance, scope, parent,
  2307. intersects = $.ui.intersect(draggable, this, this.options.tolerance),
  2308. c = !intersects && this.isover ? "isout" : (intersects && !this.isover ? "isover" : null);
  2309. if(!c) {
  2310. return;
  2311. }
  2312. if (this.options.greedy) {
  2313. // find droppable parents with same scope
  2314. scope = this.options.scope;
  2315. parent = this.element.parents(":data(ui-droppable)").filter(function () {
  2316. return $.data(this, "ui-droppable").options.scope === scope;
  2317. });
  2318. if (parent.length) {
  2319. parentInstance = $.data(parent[0], "ui-droppable");
  2320. parentInstance.greedyChild = (c === "isover");
  2321. }
  2322. }
  2323. // we just moved into a greedy child
  2324. if (parentInstance && c === "isover") {
  2325. parentInstance.isover = false;
  2326. parentInstance.isout = true;
  2327. parentInstance._out.call(parentInstance, event);
  2328. }
  2329. this[c] = true;
  2330. this[c === "isout" ? "isover" : "isout"] = false;
  2331. this[c === "isover" ? "_over" : "_out"].call(this, event);
  2332. // we just moved out of a greedy child
  2333. if (parentInstance && c === "isout") {
  2334. parentInstance.isout = false;
  2335. parentInstance.isover = true;
  2336. parentInstance._over.call(parentInstance, event);
  2337. }
  2338. });
  2339. },
  2340. dragStop: function( draggable, event ) {
  2341. draggable.element.parentsUntil( "body" ).unbind( "scroll.droppable" );
  2342. //Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003)
  2343. if( !draggable.options.refreshPositions ) {
  2344. $.ui.ddmanager.prepareOffsets( draggable, event );
  2345. }
  2346. }
  2347. };
  2348. })(jQuery);
  2349. (function( $, undefined ) {
  2350. function num(v) {
  2351. return parseInt(v, 10) || 0;
  2352. }
  2353. function isNumber(value) {
  2354. return !isNaN(parseInt(value, 10));
  2355. }
  2356. $.widget("ui.resizable", $.ui.mouse, {
  2357. version: "1.10.0",
  2358. widgetEventPrefix: "resize",
  2359. options: {
  2360. alsoResize: false,
  2361. animate: false,
  2362. animateDuration: "slow",
  2363. animateEasing: "swing",
  2364. aspectRatio: false,
  2365. autoHide: false,
  2366. containment: false,
  2367. ghost: false,
  2368. grid: false,
  2369. handles: "e,s,se",
  2370. helper: false,
  2371. maxHeight: null,
  2372. maxWidth: null,
  2373. minHeight: 10,
  2374. minWidth: 10,
  2375. // See #7960
  2376. zIndex: 90,
  2377. // callbacks
  2378. resize: null,
  2379. start: null,
  2380. stop: null
  2381. },
  2382. _create: function() {
  2383. var n, i, handle, axis, hname,
  2384. that = this,
  2385. o = this.options;
  2386. this.element.addClass("ui-resizable");
  2387. $.extend(this, {
  2388. _aspectRatio: !!(o.aspectRatio),
  2389. aspectRatio: o.aspectRatio,
  2390. originalElement: this.element,
  2391. _proportionallyResizeElements: [],
  2392. _helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
  2393. });
  2394. //Wrap the element if it cannot hold child nodes
  2395. if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)) {
  2396. //Create a wrapper element and set the wrapper to the new current internal element
  2397. this.element.wrap(
  2398. $("<div class='ui-wrapper' style='overflow: hidden;'></div>").css({
  2399. position: this.element.css("position"),
  2400. width: this.element.outerWidth(),
  2401. height: this.element.outerHeight(),
  2402. top: this.element.css("top"),
  2403. left: this.element.css("left")
  2404. })
  2405. );
  2406. //Overwrite the original this.element
  2407. this.element = this.element.parent().data(
  2408. "ui-resizable", this.element.data("ui-resizable")
  2409. );
  2410. this.elementIsWrapper = true;
  2411. //Move margins to the wrapper
  2412. this.element.css({ marginLeft: this.originalElement.css("marginLeft"), marginTop: this.originalElement.css("marginTop"), marginRight: this.originalElement.css("marginRight"), marginBottom: this.originalElement.css("marginBottom") });
  2413. this.originalElement.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0});
  2414. //Prevent Safari textarea resize
  2415. this.originalResizeStyle = this.originalElement.css("resize");
  2416. this.originalElement.css("resize", "none");
  2417. //Push the actual element to our proportionallyResize internal array
  2418. this._proportionallyResizeElements.push(this.originalElement.css({ position: "static", zoom: 1, display: "block" }));
  2419. // avoid IE jump (hard set the margin)
  2420. this.originalElement.css({ margin: this.originalElement.css("margin") });
  2421. // fix handlers offset
  2422. this._proportionallyResize();
  2423. }
  2424. 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" });
  2425. if(this.handles.constructor === String) {
  2426. if ( this.handles === "all") {
  2427. this.handles = "n,e,s,w,se,sw,ne,nw";
  2428. }
  2429. n = this.handles.split(",");
  2430. this.handles = {};
  2431. for(i = 0; i < n.length; i++) {
  2432. handle = $.trim(n[i]);
  2433. hname = "ui-resizable-"+handle;
  2434. axis = $("<div class='ui-resizable-handle " + hname + "'></div>");
  2435. // Apply zIndex to all handles - see #7960
  2436. axis.css({ zIndex: o.zIndex });
  2437. //TODO : What's going on here?
  2438. if ("se" === handle) {
  2439. axis.addClass("ui-icon ui-icon-gripsmall-diagonal-se");
  2440. }
  2441. //Insert into internal handles object and append to element
  2442. this.handles[handle] = ".ui-resizable-"+handle;
  2443. this.element.append(axis);
  2444. }
  2445. }
  2446. this._renderAxis = function(target) {
  2447. var i, axis, padPos, padWrapper;
  2448. target = target || this.element;
  2449. for(i in this.handles) {
  2450. if(this.handles[i].constructor === String) {
  2451. this.handles[i] = $(this.handles[i], this.element).show();
  2452. }
  2453. //Apply pad to wrapper element, needed to fix axis position (textarea, inputs, scrolls)
  2454. if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/textarea|input|select|button/i)) {
  2455. axis = $(this.handles[i], this.element);
  2456. //Checking the correct pad and border
  2457. padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
  2458. //The padding type i have to apply...
  2459. padPos = [ "padding",
  2460. /ne|nw|n/.test(i) ? "Top" :
  2461. /se|sw|s/.test(i) ? "Bottom" :
  2462. /^e$/.test(i) ? "Right" : "Left" ].join("");
  2463. target.css(padPos, padWrapper);
  2464. this._proportionallyResize();
  2465. }
  2466. //TODO: What's that good for? There's not anything to be executed left
  2467. if(!$(this.handles[i]).length) {
  2468. continue;
  2469. }
  2470. }
  2471. };
  2472. //TODO: make renderAxis a prototype function
  2473. this._renderAxis(this.element);
  2474. this._handles = $(".ui-resizable-handle", this.element)
  2475. .disableSelection();
  2476. //Matching axis name
  2477. this._handles.mouseover(function() {
  2478. if (!that.resizing) {
  2479. if (this.className) {
  2480. axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
  2481. }
  2482. //Axis, default = se
  2483. that.axis = axis && axis[1] ? axis[1] : "se";
  2484. }
  2485. });
  2486. //If we want to auto hide the elements
  2487. if (o.autoHide) {
  2488. this._handles.hide();
  2489. $(this.element)
  2490. .addClass("ui-resizable-autohide")
  2491. .mouseenter(function() {
  2492. if (o.disabled) {
  2493. return;
  2494. }
  2495. $(this).removeClass("ui-resizable-autohide");
  2496. that._handles.show();
  2497. })
  2498. .mouseleave(function(){
  2499. if (o.disabled) {
  2500. return;
  2501. }
  2502. if (!that.resizing) {
  2503. $(this).addClass("ui-resizable-autohide");
  2504. that._handles.hide();
  2505. }
  2506. });
  2507. }
  2508. //Initialize the mouse interaction
  2509. this._mouseInit();
  2510. },
  2511. _destroy: function() {
  2512. this._mouseDestroy();
  2513. var wrapper,
  2514. _destroy = function(exp) {
  2515. $(exp).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing")
  2516. .removeData("resizable").removeData("ui-resizable").unbind(".resizable").find(".ui-resizable-handle").remove();
  2517. };
  2518. //TODO: Unwrap at same DOM position
  2519. if (this.elementIsWrapper) {
  2520. _destroy(this.element);
  2521. wrapper = this.element;
  2522. this.originalElement.css({
  2523. position: wrapper.css("position"),
  2524. width: wrapper.outerWidth(),
  2525. height: wrapper.outerHeight(),
  2526. top: wrapper.css("top"),
  2527. left: wrapper.css("left")
  2528. }).insertAfter( wrapper );
  2529. wrapper.remove();
  2530. }
  2531. this.originalElement.css("resize", this.originalResizeStyle);
  2532. _destroy(this.originalElement);
  2533. return this;
  2534. },
  2535. _mouseCapture: function(event) {
  2536. var i, handle,
  2537. capture = false;
  2538. for (i in this.handles) {
  2539. handle = $(this.handles[i])[0];
  2540. if (handle === event.target || $.contains(handle, event.target)) {
  2541. capture = true;
  2542. }
  2543. }
  2544. return !this.options.disabled && capture;
  2545. },
  2546. _mouseStart: function(event) {
  2547. var curleft, curtop, cursor,
  2548. o = this.options,
  2549. iniPos = this.element.position(),
  2550. el = this.element;
  2551. this.resizing = true;
  2552. // bugfix for http://dev.jquery.com/ticket/1749
  2553. if ( (/absolute/).test( el.css("position") ) ) {
  2554. el.css({ position: "absolute", top: el.css("top"), left: el.css("left") });
  2555. } else if (el.is(".ui-draggable")) {
  2556. el.css({ position: "absolute", top: iniPos.top, left: iniPos.left });
  2557. }
  2558. this._renderProxy();
  2559. curleft = num(this.helper.css("left"));
  2560. curtop = num(this.helper.css("top"));
  2561. if (o.containment) {
  2562. curleft += $(o.containment).scrollLeft() || 0;
  2563. curtop += $(o.containment).scrollTop() || 0;
  2564. }
  2565. //Store needed variables
  2566. this.offset = this.helper.offset();
  2567. this.position = { left: curleft, top: curtop };
  2568. this.size = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
  2569. this.originalSize = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
  2570. this.originalPosition = { left: curleft, top: curtop };
  2571. this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() };
  2572. this.originalMousePosition = { left: event.pageX, top: event.pageY };
  2573. //Aspect Ratio
  2574. this.aspectRatio = (typeof o.aspectRatio === "number") ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height) || 1);
  2575. cursor = $(".ui-resizable-" + this.axis).css("cursor");
  2576. $("body").css("cursor", cursor === "auto" ? this.axis + "-resize" : cursor);
  2577. el.addClass("ui-resizable-resizing");
  2578. this._propagate("start", event);
  2579. return true;
  2580. },
  2581. _mouseDrag: function(event) {
  2582. //Increase performance, avoid regex
  2583. var data,
  2584. el = this.helper, props = {},
  2585. smp = this.originalMousePosition,
  2586. a = this.axis,
  2587. prevTop = this.position.top,
  2588. prevLeft = this.position.left,
  2589. prevWidth = this.size.width,
  2590. prevHeight = this.size.height,
  2591. dx = (event.pageX-smp.left)||0,
  2592. dy = (event.pageY-smp.top)||0,
  2593. trigger = this._change[a];
  2594. if (!trigger) {
  2595. return false;
  2596. }
  2597. // Calculate the attrs that will be change
  2598. data = trigger.apply(this, [event, dx, dy]);
  2599. // Put this in the mouseDrag handler since the user can start pressing shift while resizing
  2600. this._updateVirtualBoundaries(event.shiftKey);
  2601. if (this._aspectRatio || event.shiftKey) {
  2602. data = this._updateRatio(data, event);
  2603. }
  2604. data = this._respectSize(data, event);
  2605. this._updateCache(data);
  2606. // plugins callbacks need to be called first
  2607. this._propagate("resize", event);
  2608. if (this.position.top !== prevTop) {
  2609. props.top = this.position.top + "px";
  2610. }
  2611. if (this.position.left !== prevLeft) {
  2612. props.left = this.position.left + "px";
  2613. }
  2614. if (this.size.width !== prevWidth) {
  2615. props.width = this.size.width + "px";
  2616. }
  2617. if (this.size.height !== prevHeight) {
  2618. props.height = this.size.height + "px";
  2619. }
  2620. el.css(props);
  2621. if (!this._helper && this._proportionallyResizeElements.length) {
  2622. this._proportionallyResize();
  2623. }
  2624. // Call the user callback if the element was resized
  2625. if ( ! $.isEmptyObject(props) ) {
  2626. this._trigger("resize", event, this.ui());
  2627. }
  2628. return false;
  2629. },
  2630. _mouseStop: function(event) {
  2631. this.resizing = false;
  2632. var pr, ista, soffseth, soffsetw, s, left, top,
  2633. o = this.options, that = this;
  2634. if(this._helper) {
  2635. pr = this._proportionallyResizeElements;
  2636. ista = pr.length && (/textarea/i).test(pr[0].nodeName);
  2637. soffseth = ista && $.ui.hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height;
  2638. soffsetw = ista ? 0 : that.sizeDiff.width;
  2639. s = { width: (that.helper.width() - soffsetw), height: (that.helper.height() - soffseth) };
  2640. left = (parseInt(that.element.css("left"), 10) + (that.position.left - that.originalPosition.left)) || null;
  2641. top = (parseInt(that.element.css("top"), 10) + (that.position.top - that.originalPosition.top)) || null;
  2642. if (!o.animate) {
  2643. this.element.css($.extend(s, { top: top, left: left }));
  2644. }
  2645. that.helper.height(that.size.height);
  2646. that.helper.width(that.size.width);
  2647. if (this._helper && !o.animate) {
  2648. this._proportionallyResize();
  2649. }
  2650. }
  2651. $("body").css("cursor", "auto");
  2652. this.element.removeClass("ui-resizable-resizing");
  2653. this._propagate("stop", event);
  2654. if (this._helper) {
  2655. this.helper.remove();
  2656. }
  2657. return false;
  2658. },
  2659. _updateVirtualBoundaries: function(forceAspectRatio) {
  2660. var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b,
  2661. o = this.options;
  2662. b = {
  2663. minWidth: isNumber(o.minWidth) ? o.minWidth : 0,
  2664. maxWidth: isNumber(o.maxWidth) ? o.maxWidth : Infinity,
  2665. minHeight: isNumber(o.minHeight) ? o.minHeight : 0,
  2666. maxHeight: isNumber(o.maxHeight) ? o.maxHeight : Infinity
  2667. };
  2668. if(this._aspectRatio || forceAspectRatio) {
  2669. // We want to create an enclosing box whose aspect ration is the requested one
  2670. // First, compute the "projected" size for each dimension based on the aspect ratio and other dimension
  2671. pMinWidth = b.minHeight * this.aspectRatio;
  2672. pMinHeight = b.minWidth / this.aspectRatio;
  2673. pMaxWidth = b.maxHeight * this.aspectRatio;
  2674. pMaxHeight = b.maxWidth / this.aspectRatio;
  2675. if(pMinWidth > b.minWidth) {
  2676. b.minWidth = pMinWidth;
  2677. }
  2678. if(pMinHeight > b.minHeight) {
  2679. b.minHeight = pMinHeight;
  2680. }
  2681. if(pMaxWidth < b.maxWidth) {
  2682. b.maxWidth = pMaxWidth;
  2683. }
  2684. if(pMaxHeight < b.maxHeight) {
  2685. b.maxHeight = pMaxHeight;
  2686. }
  2687. }
  2688. this._vBoundaries = b;
  2689. },
  2690. _updateCache: function(data) {
  2691. this.offset = this.helper.offset();
  2692. if (isNumber(data.left)) {
  2693. this.position.left = data.left;
  2694. }
  2695. if (isNumber(data.top)) {
  2696. this.position.top = data.top;
  2697. }
  2698. if (isNumber(data.height)) {
  2699. this.size.height = data.height;
  2700. }
  2701. if (isNumber(data.width)) {
  2702. this.size.width = data.width;
  2703. }
  2704. },
  2705. _updateRatio: function( data ) {
  2706. var cpos = this.position,
  2707. csize = this.size,
  2708. a = this.axis;
  2709. if (isNumber(data.height)) {
  2710. data.width = (data.height * this.aspectRatio);
  2711. } else if (isNumber(data.width)) {
  2712. data.height = (data.width / this.aspectRatio);
  2713. }
  2714. if (a === "sw") {
  2715. data.left = cpos.left + (csize.width - data.width);
  2716. data.top = null;
  2717. }
  2718. if (a === "nw") {
  2719. data.top = cpos.top + (csize.height - data.height);
  2720. data.left = cpos.left + (csize.width - data.width);
  2721. }
  2722. return data;
  2723. },
  2724. _respectSize: function( data ) {
  2725. var o = this._vBoundaries,
  2726. a = this.axis,
  2727. ismaxw = isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width), ismaxh = isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height),
  2728. isminw = isNumber(data.width) && o.minWidth && (o.minWidth > data.width), isminh = isNumber(data.height) && o.minHeight && (o.minHeight > data.height),
  2729. dw = this.originalPosition.left + this.originalSize.width,
  2730. dh = this.position.top + this.size.height,
  2731. cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);
  2732. if (isminw) {
  2733. data.width = o.minWidth;
  2734. }
  2735. if (isminh) {
  2736. data.height = o.minHeight;
  2737. }
  2738. if (ismaxw) {
  2739. data.width = o.maxWidth;
  2740. }
  2741. if (ismaxh) {
  2742. data.height = o.maxHeight;
  2743. }
  2744. if (isminw && cw) {
  2745. data.left = dw - o.minWidth;
  2746. }
  2747. if (ismaxw && cw) {
  2748. data.left = dw - o.maxWidth;
  2749. }
  2750. if (isminh && ch) {
  2751. data.top = dh - o.minHeight;
  2752. }
  2753. if (ismaxh && ch) {
  2754. data.top = dh - o.maxHeight;
  2755. }
  2756. // fixing jump error on top/left - bug #2330
  2757. if (!data.width && !data.height && !data.left && data.top) {
  2758. data.top = null;
  2759. } else if (!data.width && !data.height && !data.top && data.left) {
  2760. data.left = null;
  2761. }
  2762. return data;
  2763. },
  2764. _proportionallyResize: function() {
  2765. if (!this._proportionallyResizeElements.length) {
  2766. return;
  2767. }
  2768. var i, j, borders, paddings, prel,
  2769. element = this.helper || this.element;
  2770. for ( i=0; i < this._proportionallyResizeElements.length; i++) {
  2771. prel = this._proportionallyResizeElements[i];
  2772. if (!this.borderDif) {
  2773. this.borderDif = [];
  2774. borders = [prel.css("borderTopWidth"), prel.css("borderRightWidth"), prel.css("borderBottomWidth"), prel.css("borderLeftWidth")];
  2775. paddings = [prel.css("paddingTop"), prel.css("paddingRight"), prel.css("paddingBottom"), prel.css("paddingLeft")];
  2776. for ( j = 0; j < borders.length; j++ ) {
  2777. this.borderDif[ j ] = ( parseInt( borders[ j ], 10 ) || 0 ) + ( parseInt( paddings[ j ], 10 ) || 0 );
  2778. }
  2779. }
  2780. prel.css({
  2781. height: (element.height() - this.borderDif[0] - this.borderDif[2]) || 0,
  2782. width: (element.width() - this.borderDif[1] - this.borderDif[3]) || 0
  2783. });
  2784. }
  2785. },
  2786. _renderProxy: function() {
  2787. var el = this.element, o = this.options;
  2788. this.elementOffset = el.offset();
  2789. if(this._helper) {
  2790. this.helper = this.helper || $("<div style='overflow:hidden;'></div>");
  2791. this.helper.addClass(this._helper).css({
  2792. width: this.element.outerWidth() - 1,
  2793. height: this.element.outerHeight() - 1,
  2794. position: "absolute",
  2795. left: this.elementOffset.left +"px",
  2796. top: this.elementOffset.top +"px",
  2797. zIndex: ++o.zIndex //TODO: Don't modify option
  2798. });
  2799. this.helper
  2800. .appendTo("body")
  2801. .disableSelection();
  2802. } else {
  2803. this.helper = this.element;
  2804. }
  2805. },
  2806. _change: {
  2807. e: function(event, dx) {
  2808. return { width: this.originalSize.width + dx };
  2809. },
  2810. w: function(event, dx) {
  2811. var cs = this.originalSize, sp = this.originalPosition;
  2812. return { left: sp.left + dx, width: cs.width - dx };
  2813. },
  2814. n: function(event, dx, dy) {
  2815. var cs = this.originalSize, sp = this.originalPosition;
  2816. return { top: sp.top + dy, height: cs.height - dy };
  2817. },
  2818. s: function(event, dx, dy) {
  2819. return { height: this.originalSize.height + dy };
  2820. },
  2821. se: function(event, dx, dy) {
  2822. return $.extend(this._change.s.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
  2823. },
  2824. sw: function(event, dx, dy) {
  2825. return $.extend(this._change.s.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
  2826. },
  2827. ne: function(event, dx, dy) {
  2828. return $.extend(this._change.n.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
  2829. },
  2830. nw: function(event, dx, dy) {
  2831. return $.extend(this._change.n.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
  2832. }
  2833. },
  2834. _propagate: function(n, event) {
  2835. $.ui.plugin.call(this, n, [event, this.ui()]);
  2836. (n !== "resize" && this._trigger(n, event, this.ui()));
  2837. },
  2838. plugins: {},
  2839. ui: function() {
  2840. return {
  2841. originalElement: this.originalElement,
  2842. element: this.element,
  2843. helper: this.helper,
  2844. position: this.position,
  2845. size: this.size,
  2846. originalSize: this.originalSize,
  2847. originalPosition: this.originalPosition
  2848. };
  2849. }
  2850. });
  2851. /*
  2852. * Resizable Extensions
  2853. */
  2854. $.ui.plugin.add("resizable", "animate", {
  2855. stop: function( event ) {
  2856. var that = $(this).data("ui-resizable"),
  2857. o = that.options,
  2858. pr = that._proportionallyResizeElements,
  2859. ista = pr.length && (/textarea/i).test(pr[0].nodeName),
  2860. soffseth = ista && $.ui.hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height,
  2861. soffsetw = ista ? 0 : that.sizeDiff.width,
  2862. style = { width: (that.size.width - soffsetw), height: (that.size.height - soffseth) },
  2863. left = (parseInt(that.element.css("left"), 10) + (that.position.left - that.originalPosition.left)) || null,
  2864. top = (parseInt(that.element.css("top"), 10) + (that.position.top - that.originalPosition.top)) || null;
  2865. that.element.animate(
  2866. $.extend(style, top && left ? { top: top, left: left } : {}), {
  2867. duration: o.animateDuration,
  2868. easing: o.animateEasing,
  2869. step: function() {
  2870. var data = {
  2871. width: parseInt(that.element.css("width"), 10),
  2872. height: parseInt(that.element.css("height"), 10),
  2873. top: parseInt(that.element.css("top"), 10),
  2874. left: parseInt(that.element.css("left"), 10)
  2875. };
  2876. if (pr && pr.length) {
  2877. $(pr[0]).css({ width: data.width, height: data.height });
  2878. }
  2879. // propagating resize, and updating values for each animation step
  2880. that._updateCache(data);
  2881. that._propagate("resize", event);
  2882. }
  2883. }
  2884. );
  2885. }
  2886. });
  2887. $.ui.plugin.add("resizable", "containment", {
  2888. start: function() {
  2889. var element, p, co, ch, cw, width, height,
  2890. that = $(this).data("ui-resizable"),
  2891. o = that.options,
  2892. el = that.element,
  2893. oc = o.containment,
  2894. ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc;
  2895. if (!ce) {
  2896. return;
  2897. }
  2898. that.containerElement = $(ce);
  2899. if (/document/.test(oc) || oc === document) {
  2900. that.containerOffset = { left: 0, top: 0 };
  2901. that.containerPosition = { left: 0, top: 0 };
  2902. that.parentData = {
  2903. element: $(document), left: 0, top: 0,
  2904. width: $(document).width(), height: $(document).height() || document.body.parentNode.scrollHeight
  2905. };
  2906. }
  2907. // i'm a node, so compute top, left, right, bottom
  2908. else {
  2909. element = $(ce);
  2910. p = [];
  2911. $([ "Top", "Right", "Left", "Bottom" ]).each(function(i, name) { p[i] = num(element.css("padding" + name)); });
  2912. that.containerOffset = element.offset();
  2913. that.containerPosition = element.position();
  2914. that.containerSize = { height: (element.innerHeight() - p[3]), width: (element.innerWidth() - p[1]) };
  2915. co = that.containerOffset;
  2916. ch = that.containerSize.height;
  2917. cw = that.containerSize.width;
  2918. width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw );
  2919. height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch);
  2920. that.parentData = {
  2921. element: ce, left: co.left, top: co.top, width: width, height: height
  2922. };
  2923. }
  2924. },
  2925. resize: function( event ) {
  2926. var woset, hoset, isParent, isOffsetRelative,
  2927. that = $(this).data("ui-resizable"),
  2928. o = that.options,
  2929. co = that.containerOffset, cp = that.position,
  2930. pRatio = that._aspectRatio || event.shiftKey,
  2931. cop = { top:0, left:0 }, ce = that.containerElement;
  2932. if (ce[0] !== document && (/static/).test(ce.css("position"))) {
  2933. cop = co;
  2934. }
  2935. if (cp.left < (that._helper ? co.left : 0)) {
  2936. that.size.width = that.size.width + (that._helper ? (that.position.left - co.left) : (that.position.left - cop.left));
  2937. if (pRatio) {
  2938. that.size.height = that.size.width / that.aspectRatio;
  2939. }
  2940. that.position.left = o.helper ? co.left : 0;
  2941. }
  2942. if (cp.top < (that._helper ? co.top : 0)) {
  2943. that.size.height = that.size.height + (that._helper ? (that.position.top - co.top) : that.position.top);
  2944. if (pRatio) {
  2945. that.size.width = that.size.height * that.aspectRatio;
  2946. }
  2947. that.position.top = that._helper ? co.top : 0;
  2948. }
  2949. that.offset.left = that.parentData.left+that.position.left;
  2950. that.offset.top = that.parentData.top+that.position.top;
  2951. woset = Math.abs( (that._helper ? that.offset.left - cop.left : (that.offset.left - cop.left)) + that.sizeDiff.width );
  2952. hoset = Math.abs( (that._helper ? that.offset.top - cop.top : (that.offset.top - co.top)) + that.sizeDiff.height );
  2953. isParent = that.containerElement.get(0) === that.element.parent().get(0);
  2954. isOffsetRelative = /relative|absolute/.test(that.containerElement.css("position"));
  2955. if(isParent && isOffsetRelative) {
  2956. woset -= that.parentData.left;
  2957. }
  2958. if (woset + that.size.width >= that.parentData.width) {
  2959. that.size.width = that.parentData.width - woset;
  2960. if (pRatio) {
  2961. that.size.height = that.size.width / that.aspectRatio;
  2962. }
  2963. }
  2964. if (hoset + that.size.height >= that.parentData.height) {
  2965. that.size.height = that.parentData.height - hoset;
  2966. if (pRatio) {
  2967. that.size.width = that.size.height * that.aspectRatio;
  2968. }
  2969. }
  2970. },
  2971. stop: function(){
  2972. var that = $(this).data("ui-resizable"),
  2973. o = that.options,
  2974. co = that.containerOffset,
  2975. cop = that.containerPosition,
  2976. ce = that.containerElement,
  2977. helper = $(that.helper),
  2978. ho = helper.offset(),
  2979. w = helper.outerWidth() - that.sizeDiff.width,
  2980. h = helper.outerHeight() - that.sizeDiff.height;
  2981. if (that._helper && !o.animate && (/relative/).test(ce.css("position"))) {
  2982. $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
  2983. }
  2984. if (that._helper && !o.animate && (/static/).test(ce.css("position"))) {
  2985. $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
  2986. }
  2987. }
  2988. });
  2989. $.ui.plugin.add("resizable", "alsoResize", {
  2990. start: function () {
  2991. var that = $(this).data("ui-resizable"),
  2992. o = that.options,
  2993. _store = function (exp) {
  2994. $(exp).each(function() {
  2995. var el = $(this);
  2996. el.data("ui-resizable-alsoresize", {
  2997. width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
  2998. left: parseInt(el.css("left"), 10), top: parseInt(el.css("top"), 10)
  2999. });
  3000. });
  3001. };
  3002. if (typeof(o.alsoResize) === "object" && !o.alsoResize.parentNode) {
  3003. if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); }
  3004. else { $.each(o.alsoResize, function (exp) { _store(exp); }); }
  3005. }else{
  3006. _store(o.alsoResize);
  3007. }
  3008. },
  3009. resize: function (event, ui) {
  3010. var that = $(this).data("ui-resizable"),
  3011. o = that.options,
  3012. os = that.originalSize,
  3013. op = that.originalPosition,
  3014. delta = {
  3015. height: (that.size.height - os.height) || 0, width: (that.size.width - os.width) || 0,
  3016. top: (that.position.top - op.top) || 0, left: (that.position.left - op.left) || 0
  3017. },
  3018. _alsoResize = function (exp, c) {
  3019. $(exp).each(function() {
  3020. var el = $(this), start = $(this).data("ui-resizable-alsoresize"), style = {},
  3021. css = c && c.length ? c : el.parents(ui.originalElement[0]).length ? ["width", "height"] : ["width", "height", "top", "left"];
  3022. $.each(css, function (i, prop) {
  3023. var sum = (start[prop]||0) + (delta[prop]||0);
  3024. if (sum && sum >= 0) {
  3025. style[prop] = sum || null;
  3026. }
  3027. });
  3028. el.css(style);
  3029. });
  3030. };
  3031. if (typeof(o.alsoResize) === "object" && !o.alsoResize.nodeType) {
  3032. $.each(o.alsoResize, function (exp, c) { _alsoResize(exp, c); });
  3033. }else{
  3034. _alsoResize(o.alsoResize);
  3035. }
  3036. },
  3037. stop: function () {
  3038. $(this).removeData("resizable-alsoresize");
  3039. }
  3040. });
  3041. $.ui.plugin.add("resizable", "ghost", {
  3042. start: function() {
  3043. var that = $(this).data("ui-resizable"), o = that.options, cs = that.size;
  3044. that.ghost = that.originalElement.clone();
  3045. that.ghost
  3046. .css({ opacity: 0.25, display: "block", position: "relative", height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 })
  3047. .addClass("ui-resizable-ghost")
  3048. .addClass(typeof o.ghost === "string" ? o.ghost : "");
  3049. that.ghost.appendTo(that.helper);
  3050. },
  3051. resize: function(){
  3052. var that = $(this).data("ui-resizable");
  3053. if (that.ghost) {
  3054. that.ghost.css({ position: "relative", height: that.size.height, width: that.size.width });
  3055. }
  3056. },
  3057. stop: function() {
  3058. var that = $(this).data("ui-resizable");
  3059. if (that.ghost && that.helper) {
  3060. that.helper.get(0).removeChild(that.ghost.get(0));
  3061. }
  3062. }
  3063. });
  3064. $.ui.plugin.add("resizable", "grid", {
  3065. resize: function() {
  3066. var that = $(this).data("ui-resizable"),
  3067. o = that.options,
  3068. cs = that.size,
  3069. os = that.originalSize,
  3070. op = that.originalPosition,
  3071. a = that.axis,
  3072. grid = typeof o.grid === "number" ? [o.grid, o.grid] : o.grid,
  3073. gridX = (grid[0]||1),
  3074. gridY = (grid[1]||1),
  3075. ox = Math.round((cs.width - os.width) / gridX) * gridX,
  3076. oy = Math.round((cs.height - os.height) / gridY) * gridY,
  3077. newWidth = os.width + ox,
  3078. newHeight = os.height + oy,
  3079. isMaxWidth = o.maxWidth && (o.maxWidth < newWidth),
  3080. isMaxHeight = o.maxHeight && (o.maxHeight < newHeight),
  3081. isMinWidth = o.minWidth && (o.minWidth > newWidth),
  3082. isMinHeight = o.minHeight && (o.minHeight > newHeight);
  3083. o.grid = grid;
  3084. if (isMinWidth) {
  3085. newWidth = newWidth + gridX;
  3086. }
  3087. if (isMinHeight) {
  3088. newHeight = newHeight + gridY;
  3089. }
  3090. if (isMaxWidth) {
  3091. newWidth = newWidth - gridX;
  3092. }
  3093. if (isMaxHeight) {
  3094. newHeight = newHeight - gridY;
  3095. }
  3096. if (/^(se|s|e)$/.test(a)) {
  3097. that.size.width = newWidth;
  3098. that.size.height = newHeight;
  3099. } else if (/^(ne)$/.test(a)) {
  3100. that.size.width = newWidth;
  3101. that.size.height = newHeight;
  3102. that.position.top = op.top - oy;
  3103. } else if (/^(sw)$/.test(a)) {
  3104. that.size.width = newWidth;
  3105. that.size.height = newHeight;
  3106. that.position.left = op.left - ox;
  3107. } else {
  3108. that.size.width = newWidth;
  3109. that.size.height = newHeight;
  3110. that.position.top = op.top - oy;
  3111. that.position.left = op.left - ox;
  3112. }
  3113. }
  3114. });
  3115. })(jQuery);
  3116. (function( $, undefined ) {
  3117. $.widget("ui.selectable", $.ui.mouse, {
  3118. version: "1.10.0",
  3119. options: {
  3120. appendTo: "body",
  3121. autoRefresh: true,
  3122. distance: 0,
  3123. filter: "*",
  3124. tolerance: "touch",
  3125. // callbacks
  3126. selected: null,
  3127. selecting: null,
  3128. start: null,
  3129. stop: null,
  3130. unselected: null,
  3131. unselecting: null
  3132. },
  3133. _create: function() {
  3134. var selectees,
  3135. that = this;
  3136. this.element.addClass("ui-selectable");
  3137. this.dragged = false;
  3138. // cache selectee children based on filter
  3139. this.refresh = function() {
  3140. selectees = $(that.options.filter, that.element[0]);
  3141. selectees.addClass("ui-selectee");
  3142. selectees.each(function() {
  3143. var $this = $(this),
  3144. pos = $this.offset();
  3145. $.data(this, "selectable-item", {
  3146. element: this,
  3147. $element: $this,
  3148. left: pos.left,
  3149. top: pos.top,
  3150. right: pos.left + $this.outerWidth(),
  3151. bottom: pos.top + $this.outerHeight(),
  3152. startselected: false,
  3153. selected: $this.hasClass("ui-selected"),
  3154. selecting: $this.hasClass("ui-selecting"),
  3155. unselecting: $this.hasClass("ui-unselecting")
  3156. });
  3157. });
  3158. };
  3159. this.refresh();
  3160. this.selectees = selectees.addClass("ui-selectee");
  3161. this._mouseInit();
  3162. this.helper = $("<div class='ui-selectable-helper'></div>");
  3163. },
  3164. _destroy: function() {
  3165. this.selectees
  3166. .removeClass("ui-selectee")
  3167. .removeData("selectable-item");
  3168. this.element
  3169. .removeClass("ui-selectable ui-selectable-disabled");
  3170. this._mouseDestroy();
  3171. },
  3172. _mouseStart: function(event) {
  3173. var that = this,
  3174. options = this.options;
  3175. this.opos = [event.pageX, event.pageY];
  3176. if (this.options.disabled) {
  3177. return;
  3178. }
  3179. this.selectees = $(options.filter, this.element[0]);
  3180. this._trigger("start", event);
  3181. $(options.appendTo).append(this.helper);
  3182. // position helper (lasso)
  3183. this.helper.css({
  3184. "left": event.pageX,
  3185. "top": event.pageY,
  3186. "width": 0,
  3187. "height": 0
  3188. });
  3189. if (options.autoRefresh) {
  3190. this.refresh();
  3191. }
  3192. this.selectees.filter(".ui-selected").each(function() {
  3193. var selectee = $.data(this, "selectable-item");
  3194. selectee.startselected = true;
  3195. if (!event.metaKey && !event.ctrlKey) {
  3196. selectee.$element.removeClass("ui-selected");
  3197. selectee.selected = false;
  3198. selectee.$element.addClass("ui-unselecting");
  3199. selectee.unselecting = true;
  3200. // selectable UNSELECTING callback
  3201. that._trigger("unselecting", event, {
  3202. unselecting: selectee.element
  3203. });
  3204. }
  3205. });
  3206. $(event.target).parents().addBack().each(function() {
  3207. var doSelect,
  3208. selectee = $.data(this, "selectable-item");
  3209. if (selectee) {
  3210. doSelect = (!event.metaKey && !event.ctrlKey) || !selectee.$element.hasClass("ui-selected");
  3211. selectee.$element
  3212. .removeClass(doSelect ? "ui-unselecting" : "ui-selected")
  3213. .addClass(doSelect ? "ui-selecting" : "ui-unselecting");
  3214. selectee.unselecting = !doSelect;
  3215. selectee.selecting = doSelect;
  3216. selectee.selected = doSelect;
  3217. // selectable (UN)SELECTING callback
  3218. if (doSelect) {
  3219. that._trigger("selecting", event, {
  3220. selecting: selectee.element
  3221. });
  3222. } else {
  3223. that._trigger("unselecting", event, {
  3224. unselecting: selectee.element
  3225. });
  3226. }
  3227. return false;
  3228. }
  3229. });
  3230. },
  3231. _mouseDrag: function(event) {
  3232. this.dragged = true;
  3233. if (this.options.disabled) {
  3234. return;
  3235. }
  3236. var tmp,
  3237. that = this,
  3238. options = this.options,
  3239. x1 = this.opos[0],
  3240. y1 = this.opos[1],
  3241. x2 = event.pageX,
  3242. y2 = event.pageY;
  3243. if (x1 > x2) { tmp = x2; x2 = x1; x1 = tmp; }
  3244. if (y1 > y2) { tmp = y2; y2 = y1; y1 = tmp; }
  3245. this.helper.css({left: x1, top: y1, width: x2-x1, height: y2-y1});
  3246. this.selectees.each(function() {
  3247. var selectee = $.data(this, "selectable-item"),
  3248. hit = false;
  3249. //prevent helper from being selected if appendTo: selectable
  3250. if (!selectee || selectee.element === that.element[0]) {
  3251. return;
  3252. }
  3253. if (options.tolerance === "touch") {
  3254. hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
  3255. } else if (options.tolerance === "fit") {
  3256. hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
  3257. }
  3258. if (hit) {
  3259. // SELECT
  3260. if (selectee.selected) {
  3261. selectee.$element.removeClass("ui-selected");
  3262. selectee.selected = false;
  3263. }
  3264. if (selectee.unselecting) {
  3265. selectee.$element.removeClass("ui-unselecting");
  3266. selectee.unselecting = false;
  3267. }
  3268. if (!selectee.selecting) {
  3269. selectee.$element.addClass("ui-selecting");
  3270. selectee.selecting = true;
  3271. // selectable SELECTING callback
  3272. that._trigger("selecting", event, {
  3273. selecting: selectee.element
  3274. });
  3275. }
  3276. } else {
  3277. // UNSELECT
  3278. if (selectee.selecting) {
  3279. if ((event.metaKey || event.ctrlKey) && selectee.startselected) {
  3280. selectee.$element.removeClass("ui-selecting");
  3281. selectee.selecting = false;
  3282. selectee.$element.addClass("ui-selected");
  3283. selectee.selected = true;
  3284. } else {
  3285. selectee.$element.removeClass("ui-selecting");
  3286. selectee.selecting = false;
  3287. if (selectee.startselected) {
  3288. selectee.$element.addClass("ui-unselecting");
  3289. selectee.unselecting = true;
  3290. }
  3291. // selectable UNSELECTING callback
  3292. that._trigger("unselecting", event, {
  3293. unselecting: selectee.element
  3294. });
  3295. }
  3296. }
  3297. if (selectee.selected) {
  3298. if (!event.metaKey && !event.ctrlKey && !selectee.startselected) {
  3299. selectee.$element.removeClass("ui-selected");
  3300. selectee.selected = false;
  3301. selectee.$element.addClass("ui-unselecting");
  3302. selectee.unselecting = true;
  3303. // selectable UNSELECTING callback
  3304. that._trigger("unselecting", event, {
  3305. unselecting: selectee.element
  3306. });
  3307. }
  3308. }
  3309. }
  3310. });
  3311. return false;
  3312. },
  3313. _mouseStop: function(event) {
  3314. var that = this;
  3315. this.dragged = false;
  3316. $(".ui-unselecting", this.element[0]).each(function() {
  3317. var selectee = $.data(this, "selectable-item");
  3318. selectee.$element.removeClass("ui-unselecting");
  3319. selectee.unselecting = false;
  3320. selectee.startselected = false;
  3321. that._trigger("unselected", event, {
  3322. unselected: selectee.element
  3323. });
  3324. });
  3325. $(".ui-selecting", this.element[0]).each(function() {
  3326. var selectee = $.data(this, "selectable-item");
  3327. selectee.$element.removeClass("ui-selecting").addClass("ui-selected");
  3328. selectee.selecting = false;
  3329. selectee.selected = true;
  3330. selectee.startselected = true;
  3331. that._trigger("selected", event, {
  3332. selected: selectee.element
  3333. });
  3334. });
  3335. this._trigger("stop", event);
  3336. this.helper.remove();
  3337. return false;
  3338. }
  3339. });
  3340. })(jQuery);
  3341. (function( $, undefined ) {
  3342. /*jshint loopfunc: true */
  3343. function isOverAxis( x, reference, size ) {
  3344. return ( x > reference ) && ( x < ( reference + size ) );
  3345. }
  3346. $.widget("ui.sortable", $.ui.mouse, {
  3347. version: "1.10.0",
  3348. widgetEventPrefix: "sort",
  3349. ready: false,
  3350. options: {
  3351. appendTo: "parent",
  3352. axis: false,
  3353. connectWith: false,
  3354. containment: false,
  3355. cursor: "auto",
  3356. cursorAt: false,
  3357. dropOnEmpty: true,
  3358. forcePlaceholderSize: false,
  3359. forceHelperSize: false,
  3360. grid: false,
  3361. handle: false,
  3362. helper: "original",
  3363. items: "> *",
  3364. opacity: false,
  3365. placeholder: false,
  3366. revert: false,
  3367. scroll: true,
  3368. scrollSensitivity: 20,
  3369. scrollSpeed: 20,
  3370. scope: "default",
  3371. tolerance: "intersect",
  3372. zIndex: 1000,
  3373. // callbacks
  3374. activate: null,
  3375. beforeStop: null,
  3376. change: null,
  3377. deactivate: null,
  3378. out: null,
  3379. over: null,
  3380. receive: null,
  3381. remove: null,
  3382. sort: null,
  3383. start: null,
  3384. stop: null,
  3385. update: null
  3386. },
  3387. _create: function() {
  3388. var o = this.options;
  3389. this.containerCache = {};
  3390. this.element.addClass("ui-sortable");
  3391. //Get the items
  3392. this.refresh();
  3393. //Let's determine if the items are being displayed horizontally
  3394. 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;
  3395. //Let's determine the parent's offset
  3396. this.offset = this.element.offset();
  3397. //Initialize mouse events for interaction
  3398. this._mouseInit();
  3399. //We're ready to go
  3400. this.ready = true;
  3401. },
  3402. _destroy: function() {
  3403. this.element
  3404. .removeClass("ui-sortable ui-sortable-disabled");
  3405. this._mouseDestroy();
  3406. for ( var i = this.items.length - 1; i >= 0; i-- ) {
  3407. this.items[i].item.removeData(this.widgetName + "-item");
  3408. }
  3409. return this;
  3410. },
  3411. _setOption: function(key, value){
  3412. if ( key === "disabled" ) {
  3413. this.options[ key ] = value;
  3414. this.widget().toggleClass( "ui-sortable-disabled", !!value );
  3415. } else {
  3416. // Don't call widget base _setOption for disable as it adds ui-state-disabled class
  3417. $.Widget.prototype._setOption.apply(this, arguments);
  3418. }
  3419. },
  3420. _mouseCapture: function(event, overrideHandle) {
  3421. var currentItem = null,
  3422. validHandle = false,
  3423. that = this;
  3424. if (this.reverting) {
  3425. return false;
  3426. }
  3427. if(this.options.disabled || this.options.type === "static") {
  3428. return false;
  3429. }
  3430. //We have to refresh the items data once first
  3431. this._refreshItems(event);
  3432. //Find out if the clicked node (or one of its parents) is a actual item in this.items
  3433. $(event.target).parents().each(function() {
  3434. if($.data(this, that.widgetName + "-item") === that) {
  3435. currentItem = $(this);
  3436. return false;
  3437. }
  3438. });
  3439. if($.data(event.target, that.widgetName + "-item") === that) {
  3440. currentItem = $(event.target);
  3441. }
  3442. if(!currentItem) {
  3443. return false;
  3444. }
  3445. if(this.options.handle && !overrideHandle) {
  3446. $(this.options.handle, currentItem).find("*").addBack().each(function() {
  3447. if(this === event.target) {
  3448. validHandle = true;
  3449. }
  3450. });
  3451. if(!validHandle) {
  3452. return false;
  3453. }
  3454. }
  3455. this.currentItem = currentItem;
  3456. this._removeCurrentsFromItems();
  3457. return true;
  3458. },
  3459. _mouseStart: function(event, overrideHandle, noActivation) {
  3460. var i,
  3461. o = this.options;
  3462. this.currentContainer = this;
  3463. //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
  3464. this.refreshPositions();
  3465. //Create and append the visible helper
  3466. this.helper = this._createHelper(event);
  3467. //Cache the helper size
  3468. this._cacheHelperProportions();
  3469. /*
  3470. * - Position generation -
  3471. * This block generates everything position related - it's the core of draggables.
  3472. */
  3473. //Cache the margins of the original element
  3474. this._cacheMargins();
  3475. //Get the next scrolling parent
  3476. this.scrollParent = this.helper.scrollParent();
  3477. //The element's absolute position on the page minus margins
  3478. this.offset = this.currentItem.offset();
  3479. this.offset = {
  3480. top: this.offset.top - this.margins.top,
  3481. left: this.offset.left - this.margins.left
  3482. };
  3483. $.extend(this.offset, {
  3484. click: { //Where the click happened, relative to the element
  3485. left: event.pageX - this.offset.left,
  3486. top: event.pageY - this.offset.top
  3487. },
  3488. parent: this._getParentOffset(),
  3489. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  3490. });
  3491. // Only after we got the offset, we can change the helper's position to absolute
  3492. // TODO: Still need to figure out a way to make relative sorting possible
  3493. this.helper.css("position", "absolute");
  3494. this.cssPosition = this.helper.css("position");
  3495. //Generate the original position
  3496. this.originalPosition = this._generatePosition(event);
  3497. this.originalPageX = event.pageX;
  3498. this.originalPageY = event.pageY;
  3499. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  3500. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  3501. //Cache the former DOM position
  3502. this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
  3503. //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
  3504. if(this.helper[0] !== this.currentItem[0]) {
  3505. this.currentItem.hide();
  3506. }
  3507. //Create the placeholder
  3508. this._createPlaceholder();
  3509. //Set a containment if given in the options
  3510. if(o.containment) {
  3511. this._setContainment();
  3512. }
  3513. if(o.cursor) { // cursor option
  3514. if ($("body").css("cursor")) {
  3515. this._storedCursor = $("body").css("cursor");
  3516. }
  3517. $("body").css("cursor", o.cursor);
  3518. }
  3519. if(o.opacity) { // opacity option
  3520. if (this.helper.css("opacity")) {
  3521. this._storedOpacity = this.helper.css("opacity");
  3522. }
  3523. this.helper.css("opacity", o.opacity);
  3524. }
  3525. if(o.zIndex) { // zIndex option
  3526. if (this.helper.css("zIndex")) {
  3527. this._storedZIndex = this.helper.css("zIndex");
  3528. }
  3529. this.helper.css("zIndex", o.zIndex);
  3530. }
  3531. //Prepare scrolling
  3532. if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
  3533. this.overflowOffset = this.scrollParent.offset();
  3534. }
  3535. //Call callbacks
  3536. this._trigger("start", event, this._uiHash());
  3537. //Recache the helper size
  3538. if(!this._preserveHelperProportions) {
  3539. this._cacheHelperProportions();
  3540. }
  3541. //Post "activate" events to possible containers
  3542. if( !noActivation ) {
  3543. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  3544. this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
  3545. }
  3546. }
  3547. //Prepare possible droppables
  3548. if($.ui.ddmanager) {
  3549. $.ui.ddmanager.current = this;
  3550. }
  3551. if ($.ui.ddmanager && !o.dropBehaviour) {
  3552. $.ui.ddmanager.prepareOffsets(this, event);
  3553. }
  3554. this.dragging = true;
  3555. this.helper.addClass("ui-sortable-helper");
  3556. this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  3557. return true;
  3558. },
  3559. _mouseDrag: function(event) {
  3560. var i, item, itemElement, intersection,
  3561. o = this.options,
  3562. scrolled = false;
  3563. //Compute the helpers position
  3564. this.position = this._generatePosition(event);
  3565. this.positionAbs = this._convertPositionTo("absolute");
  3566. if (!this.lastPositionAbs) {
  3567. this.lastPositionAbs = this.positionAbs;
  3568. }
  3569. //Do scrolling
  3570. if(this.options.scroll) {
  3571. if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
  3572. if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
  3573. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
  3574. } else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity) {
  3575. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
  3576. }
  3577. if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
  3578. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
  3579. } else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity) {
  3580. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
  3581. }
  3582. } else {
  3583. if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
  3584. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  3585. } else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
  3586. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  3587. }
  3588. if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
  3589. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  3590. } else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
  3591. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  3592. }
  3593. }
  3594. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  3595. $.ui.ddmanager.prepareOffsets(this, event);
  3596. }
  3597. }
  3598. //Regenerate the absolute position used for position checks
  3599. this.positionAbs = this._convertPositionTo("absolute");
  3600. //Set the helper position
  3601. if(!this.options.axis || this.options.axis !== "y") {
  3602. this.helper[0].style.left = this.position.left+"px";
  3603. }
  3604. if(!this.options.axis || this.options.axis !== "x") {
  3605. this.helper[0].style.top = this.position.top+"px";
  3606. }
  3607. //Rearrange
  3608. for (i = this.items.length - 1; i >= 0; i--) {
  3609. //Cache variables and intersection, continue if no intersection
  3610. item = this.items[i];
  3611. itemElement = item.item[0];
  3612. intersection = this._intersectsWithPointer(item);
  3613. if (!intersection) {
  3614. continue;
  3615. }
  3616. // Only put the placeholder inside the current Container, skip all
  3617. // items form other containers. This works because when moving
  3618. // an item from one container to another the
  3619. // currentContainer is switched before the placeholder is moved.
  3620. //
  3621. // Without this moving items in "sub-sortables" can cause the placeholder to jitter
  3622. // beetween the outer and inner container.
  3623. if (item.instance !== this.currentContainer) {
  3624. continue;
  3625. }
  3626. // cannot intersect with itself
  3627. // no useless actions that have been done before
  3628. // no action if the item moved is the parent of the item checked
  3629. if (itemElement !== this.currentItem[0] &&
  3630. this.placeholder[intersection === 1 ? "next" : "prev"]()[0] !== itemElement &&
  3631. !$.contains(this.placeholder[0], itemElement) &&
  3632. (this.options.type === "semi-dynamic" ? !$.contains(this.element[0], itemElement) : true)
  3633. ) {
  3634. this.direction = intersection === 1 ? "down" : "up";
  3635. if (this.options.tolerance === "pointer" || this._intersectsWithSides(item)) {
  3636. this._rearrange(event, item);
  3637. } else {
  3638. break;
  3639. }
  3640. this._trigger("change", event, this._uiHash());
  3641. break;
  3642. }
  3643. }
  3644. //Post events to containers
  3645. this._contactContainers(event);
  3646. //Interconnect with droppables
  3647. if($.ui.ddmanager) {
  3648. $.ui.ddmanager.drag(this, event);
  3649. }
  3650. //Call callbacks
  3651. this._trigger("sort", event, this._uiHash());
  3652. this.lastPositionAbs = this.positionAbs;
  3653. return false;
  3654. },
  3655. _mouseStop: function(event, noPropagation) {
  3656. if(!event) {
  3657. return;
  3658. }
  3659. //If we are using droppables, inform the manager about the drop
  3660. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  3661. $.ui.ddmanager.drop(this, event);
  3662. }
  3663. if(this.options.revert) {
  3664. var that = this,
  3665. cur = this.placeholder.offset();
  3666. this.reverting = true;
  3667. $(this.helper).animate({
  3668. left: cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollLeft),
  3669. top: cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollTop)
  3670. }, parseInt(this.options.revert, 10) || 500, function() {
  3671. that._clear(event);
  3672. });
  3673. } else {
  3674. this._clear(event, noPropagation);
  3675. }
  3676. return false;
  3677. },
  3678. cancel: function() {
  3679. if(this.dragging) {
  3680. this._mouseUp({ target: null });
  3681. if(this.options.helper === "original") {
  3682. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  3683. } else {
  3684. this.currentItem.show();
  3685. }
  3686. //Post deactivating events to containers
  3687. for (var i = this.containers.length - 1; i >= 0; i--){
  3688. this.containers[i]._trigger("deactivate", null, this._uiHash(this));
  3689. if(this.containers[i].containerCache.over) {
  3690. this.containers[i]._trigger("out", null, this._uiHash(this));
  3691. this.containers[i].containerCache.over = 0;
  3692. }
  3693. }
  3694. }
  3695. if (this.placeholder) {
  3696. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  3697. if(this.placeholder[0].parentNode) {
  3698. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  3699. }
  3700. if(this.options.helper !== "original" && this.helper && this.helper[0].parentNode) {
  3701. this.helper.remove();
  3702. }
  3703. $.extend(this, {
  3704. helper: null,
  3705. dragging: false,
  3706. reverting: false,
  3707. _noFinalSort: null
  3708. });
  3709. if(this.domPosition.prev) {
  3710. $(this.domPosition.prev).after(this.currentItem);
  3711. } else {
  3712. $(this.domPosition.parent).prepend(this.currentItem);
  3713. }
  3714. }
  3715. return this;
  3716. },
  3717. serialize: function(o) {
  3718. var items = this._getItemsAsjQuery(o && o.connected),
  3719. str = [];
  3720. o = o || {};
  3721. $(items).each(function() {
  3722. var res = ($(o.item || this).attr(o.attribute || "id") || "").match(o.expression || (/(.+)[\-=_](.+)/));
  3723. if (res) {
  3724. str.push((o.key || res[1]+"[]")+"="+(o.key && o.expression ? res[1] : res[2]));
  3725. }
  3726. });
  3727. if(!str.length && o.key) {
  3728. str.push(o.key + "=");
  3729. }
  3730. return str.join("&");
  3731. },
  3732. toArray: function(o) {
  3733. var items = this._getItemsAsjQuery(o && o.connected),
  3734. ret = [];
  3735. o = o || {};
  3736. items.each(function() { ret.push($(o.item || this).attr(o.attribute || "id") || ""); });
  3737. return ret;
  3738. },
  3739. /* Be careful with the following core functions */
  3740. _intersectsWith: function(item) {
  3741. var x1 = this.positionAbs.left,
  3742. x2 = x1 + this.helperProportions.width,
  3743. y1 = this.positionAbs.top,
  3744. y2 = y1 + this.helperProportions.height,
  3745. l = item.left,
  3746. r = l + item.width,
  3747. t = item.top,
  3748. b = t + item.height,
  3749. dyClick = this.offset.click.top,
  3750. dxClick = this.offset.click.left,
  3751. isOverElement = (y1 + dyClick) > t && (y1 + dyClick) < b && (x1 + dxClick) > l && (x1 + dxClick) < r;
  3752. if ( this.options.tolerance === "pointer" ||
  3753. this.options.forcePointerForContainers ||
  3754. (this.options.tolerance !== "pointer" && this.helperProportions[this.floating ? "width" : "height"] > item[this.floating ? "width" : "height"])
  3755. ) {
  3756. return isOverElement;
  3757. } else {
  3758. return (l < x1 + (this.helperProportions.width / 2) && // Right Half
  3759. x2 - (this.helperProportions.width / 2) < r && // Left Half
  3760. t < y1 + (this.helperProportions.height / 2) && // Bottom Half
  3761. y2 - (this.helperProportions.height / 2) < b ); // Top Half
  3762. }
  3763. },
  3764. _intersectsWithPointer: function(item) {
  3765. var isOverElementHeight = (this.options.axis === "x") || isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
  3766. isOverElementWidth = (this.options.axis === "y") || isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
  3767. isOverElement = isOverElementHeight && isOverElementWidth,
  3768. verticalDirection = this._getDragVerticalDirection(),
  3769. horizontalDirection = this._getDragHorizontalDirection();
  3770. if (!isOverElement) {
  3771. return false;
  3772. }
  3773. return this.floating ?
  3774. ( ((horizontalDirection && horizontalDirection === "right") || verticalDirection === "down") ? 2 : 1 )
  3775. : ( verticalDirection && (verticalDirection === "down" ? 2 : 1) );
  3776. },
  3777. _intersectsWithSides: function(item) {
  3778. var isOverBottomHalf = isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
  3779. isOverRightHalf = isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
  3780. verticalDirection = this._getDragVerticalDirection(),
  3781. horizontalDirection = this._getDragHorizontalDirection();
  3782. if (this.floating && horizontalDirection) {
  3783. return ((horizontalDirection === "right" && isOverRightHalf) || (horizontalDirection === "left" && !isOverRightHalf));
  3784. } else {
  3785. return verticalDirection && ((verticalDirection === "down" && isOverBottomHalf) || (verticalDirection === "up" && !isOverBottomHalf));
  3786. }
  3787. },
  3788. _getDragVerticalDirection: function() {
  3789. var delta = this.positionAbs.top - this.lastPositionAbs.top;
  3790. return delta !== 0 && (delta > 0 ? "down" : "up");
  3791. },
  3792. _getDragHorizontalDirection: function() {
  3793. var delta = this.positionAbs.left - this.lastPositionAbs.left;
  3794. return delta !== 0 && (delta > 0 ? "right" : "left");
  3795. },
  3796. refresh: function(event) {
  3797. this._refreshItems(event);
  3798. this.refreshPositions();
  3799. return this;
  3800. },
  3801. _connectWith: function() {
  3802. var options = this.options;
  3803. return options.connectWith.constructor === String ? [options.connectWith] : options.connectWith;
  3804. },
  3805. _getItemsAsjQuery: function(connected) {
  3806. var i, j, cur, inst,
  3807. items = [],
  3808. queries = [],
  3809. connectWith = this._connectWith();
  3810. if(connectWith && connected) {
  3811. for (i = connectWith.length - 1; i >= 0; i--){
  3812. cur = $(connectWith[i]);
  3813. for ( j = cur.length - 1; j >= 0; j--){
  3814. inst = $.data(cur[j], this.widgetFullName);
  3815. if(inst && inst !== this && !inst.options.disabled) {
  3816. 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]);
  3817. }
  3818. }
  3819. }
  3820. }
  3821. 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]);
  3822. for (i = queries.length - 1; i >= 0; i--){
  3823. queries[i][0].each(function() {
  3824. items.push(this);
  3825. });
  3826. }
  3827. return $(items);
  3828. },
  3829. _removeCurrentsFromItems: function() {
  3830. var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
  3831. this.items = $.grep(this.items, function (item) {
  3832. for (var j=0; j < list.length; j++) {
  3833. if(list[j] === item.item[0]) {
  3834. return false;
  3835. }
  3836. }
  3837. return true;
  3838. });
  3839. },
  3840. _refreshItems: function(event) {
  3841. this.items = [];
  3842. this.containers = [this];
  3843. var i, j, cur, inst, targetData, _queries, item, queriesLength,
  3844. items = this.items,
  3845. queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]],
  3846. connectWith = this._connectWith();
  3847. if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
  3848. for (i = connectWith.length - 1; i >= 0; i--){
  3849. cur = $(connectWith[i]);
  3850. for (j = cur.length - 1; j >= 0; j--){
  3851. inst = $.data(cur[j], this.widgetFullName);
  3852. if(inst && inst !== this && !inst.options.disabled) {
  3853. queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
  3854. this.containers.push(inst);
  3855. }
  3856. }
  3857. }
  3858. }
  3859. for (i = queries.length - 1; i >= 0; i--) {
  3860. targetData = queries[i][1];
  3861. _queries = queries[i][0];
  3862. for (j=0, queriesLength = _queries.length; j < queriesLength; j++) {
  3863. item = $(_queries[j]);
  3864. item.data(this.widgetName + "-item", targetData); // Data for target checking (mouse manager)
  3865. items.push({
  3866. item: item,
  3867. instance: targetData,
  3868. width: 0, height: 0,
  3869. left: 0, top: 0
  3870. });
  3871. }
  3872. }
  3873. },
  3874. refreshPositions: function(fast) {
  3875. //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
  3876. if(this.offsetParent && this.helper) {
  3877. this.offset.parent = this._getParentOffset();
  3878. }
  3879. var i, item, t, p;
  3880. for (i = this.items.length - 1; i >= 0; i--){
  3881. item = this.items[i];
  3882. //We ignore calculating positions of all connected containers when we're not over them
  3883. if(item.instance !== this.currentContainer && this.currentContainer && item.item[0] !== this.currentItem[0]) {
  3884. continue;
  3885. }
  3886. t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
  3887. if (!fast) {
  3888. item.width = t.outerWidth();
  3889. item.height = t.outerHeight();
  3890. }
  3891. p = t.offset();
  3892. item.left = p.left;
  3893. item.top = p.top;
  3894. }
  3895. if(this.options.custom && this.options.custom.refreshContainers) {
  3896. this.options.custom.refreshContainers.call(this);
  3897. } else {
  3898. for (i = this.containers.length - 1; i >= 0; i--){
  3899. p = this.containers[i].element.offset();
  3900. this.containers[i].containerCache.left = p.left;
  3901. this.containers[i].containerCache.top = p.top;
  3902. this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
  3903. this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
  3904. }
  3905. }
  3906. return this;
  3907. },
  3908. _createPlaceholder: function(that) {
  3909. that = that || this;
  3910. var className,
  3911. o = that.options;
  3912. if(!o.placeholder || o.placeholder.constructor === String) {
  3913. className = o.placeholder;
  3914. o.placeholder = {
  3915. element: function() {
  3916. var el = $(document.createElement(that.currentItem[0].nodeName))
  3917. .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder")
  3918. .removeClass("ui-sortable-helper")[0];
  3919. if(!className) {
  3920. el.style.visibility = "hidden";
  3921. }
  3922. return el;
  3923. },
  3924. update: function(container, p) {
  3925. // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
  3926. // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
  3927. if(className && !o.forcePlaceholderSize) {
  3928. return;
  3929. }
  3930. //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
  3931. if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css("paddingTop")||0, 10) - parseInt(that.currentItem.css("paddingBottom")||0, 10)); }
  3932. if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css("paddingLeft")||0, 10) - parseInt(that.currentItem.css("paddingRight")||0, 10)); }
  3933. }
  3934. };
  3935. }
  3936. //Create the placeholder
  3937. that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem));
  3938. //Append it after the actual current item
  3939. that.currentItem.after(that.placeholder);
  3940. //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
  3941. o.placeholder.update(that, that.placeholder);
  3942. },
  3943. _contactContainers: function(event) {
  3944. var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, base, cur, nearBottom,
  3945. innermostContainer = null,
  3946. innermostIndex = null;
  3947. // get innermost container that intersects with item
  3948. for (i = this.containers.length - 1; i >= 0; i--) {
  3949. // never consider a container that's located within the item itself
  3950. if($.contains(this.currentItem[0], this.containers[i].element[0])) {
  3951. continue;
  3952. }
  3953. if(this._intersectsWith(this.containers[i].containerCache)) {
  3954. // if we've already found a container and it's more "inner" than this, then continue
  3955. if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0])) {
  3956. continue;
  3957. }
  3958. innermostContainer = this.containers[i];
  3959. innermostIndex = i;
  3960. } else {
  3961. // container doesn't intersect. trigger "out" event if necessary
  3962. if(this.containers[i].containerCache.over) {
  3963. this.containers[i]._trigger("out", event, this._uiHash(this));
  3964. this.containers[i].containerCache.over = 0;
  3965. }
  3966. }
  3967. }
  3968. // if no intersecting containers found, return
  3969. if(!innermostContainer) {
  3970. return;
  3971. }
  3972. // move the item into the container if it's not there already
  3973. if(this.containers.length === 1) {
  3974. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  3975. this.containers[innermostIndex].containerCache.over = 1;
  3976. } else {
  3977. //When entering a new container, we will find the item with the least distance and append our item near it
  3978. dist = 10000;
  3979. itemWithLeastDistance = null;
  3980. posProperty = this.containers[innermostIndex].floating ? "left" : "top";
  3981. sizeProperty = this.containers[innermostIndex].floating ? "width" : "height";
  3982. base = this.positionAbs[posProperty] + this.offset.click[posProperty];
  3983. for (j = this.items.length - 1; j >= 0; j--) {
  3984. if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) {
  3985. continue;
  3986. }
  3987. if(this.items[j].item[0] === this.currentItem[0]) {
  3988. continue;
  3989. }
  3990. cur = this.items[j].item.offset()[posProperty];
  3991. nearBottom = false;
  3992. if(Math.abs(cur - base) > Math.abs(cur + this.items[j][sizeProperty] - base)){
  3993. nearBottom = true;
  3994. cur += this.items[j][sizeProperty];
  3995. }
  3996. if(Math.abs(cur - base) < dist) {
  3997. dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
  3998. this.direction = nearBottom ? "up": "down";
  3999. }
  4000. }
  4001. //Check if dropOnEmpty is enabled
  4002. if(!itemWithLeastDistance && !this.options.dropOnEmpty) {
  4003. return;
  4004. }
  4005. this.currentContainer = this.containers[innermostIndex];
  4006. itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
  4007. this._trigger("change", event, this._uiHash());
  4008. this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
  4009. //Update the placeholder
  4010. this.options.placeholder.update(this.currentContainer, this.placeholder);
  4011. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  4012. this.containers[innermostIndex].containerCache.over = 1;
  4013. }
  4014. },
  4015. _createHelper: function(event) {
  4016. var o = this.options,
  4017. helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper === "clone" ? this.currentItem.clone() : this.currentItem);
  4018. //Add the helper to the DOM if that didn't happen already
  4019. if(!helper.parents("body").length) {
  4020. $(o.appendTo !== "parent" ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
  4021. }
  4022. if(helper[0] === this.currentItem[0]) {
  4023. 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") };
  4024. }
  4025. if(!helper[0].style.width || o.forceHelperSize) {
  4026. helper.width(this.currentItem.width());
  4027. }
  4028. if(!helper[0].style.height || o.forceHelperSize) {
  4029. helper.height(this.currentItem.height());
  4030. }
  4031. return helper;
  4032. },
  4033. _adjustOffsetFromHelper: function(obj) {
  4034. if (typeof obj === "string") {
  4035. obj = obj.split(" ");
  4036. }
  4037. if ($.isArray(obj)) {
  4038. obj = {left: +obj[0], top: +obj[1] || 0};
  4039. }
  4040. if ("left" in obj) {
  4041. this.offset.click.left = obj.left + this.margins.left;
  4042. }
  4043. if ("right" in obj) {
  4044. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  4045. }
  4046. if ("top" in obj) {
  4047. this.offset.click.top = obj.top + this.margins.top;
  4048. }
  4049. if ("bottom" in obj) {
  4050. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  4051. }
  4052. },
  4053. _getParentOffset: function() {
  4054. //Get the offsetParent and cache its position
  4055. this.offsetParent = this.helper.offsetParent();
  4056. var po = this.offsetParent.offset();
  4057. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  4058. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  4059. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  4060. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  4061. if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  4062. po.left += this.scrollParent.scrollLeft();
  4063. po.top += this.scrollParent.scrollTop();
  4064. }
  4065. // This needs to be actually done for all browsers, since pageX/pageY includes this information
  4066. // with an ugly IE fix
  4067. if( this.offsetParent[0] === document.body || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
  4068. po = { top: 0, left: 0 };
  4069. }
  4070. return {
  4071. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  4072. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  4073. };
  4074. },
  4075. _getRelativeOffset: function() {
  4076. if(this.cssPosition === "relative") {
  4077. var p = this.currentItem.position();
  4078. return {
  4079. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  4080. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  4081. };
  4082. } else {
  4083. return { top: 0, left: 0 };
  4084. }
  4085. },
  4086. _cacheMargins: function() {
  4087. this.margins = {
  4088. left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
  4089. top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
  4090. };
  4091. },
  4092. _cacheHelperProportions: function() {
  4093. this.helperProportions = {
  4094. width: this.helper.outerWidth(),
  4095. height: this.helper.outerHeight()
  4096. };
  4097. },
  4098. _setContainment: function() {
  4099. var ce, co, over,
  4100. o = this.options;
  4101. if(o.containment === "parent") {
  4102. o.containment = this.helper[0].parentNode;
  4103. }
  4104. if(o.containment === "document" || o.containment === "window") {
  4105. this.containment = [
  4106. 0 - this.offset.relative.left - this.offset.parent.left,
  4107. 0 - this.offset.relative.top - this.offset.parent.top,
  4108. $(o.containment === "document" ? document : window).width() - this.helperProportions.width - this.margins.left,
  4109. ($(o.containment === "document" ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
  4110. ];
  4111. }
  4112. if(!(/^(document|window|parent)$/).test(o.containment)) {
  4113. ce = $(o.containment)[0];
  4114. co = $(o.containment).offset();
  4115. over = ($(ce).css("overflow") !== "hidden");
  4116. this.containment = [
  4117. co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
  4118. co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
  4119. 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,
  4120. 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
  4121. ];
  4122. }
  4123. },
  4124. _convertPositionTo: function(d, pos) {
  4125. if(!pos) {
  4126. pos = this.position;
  4127. }
  4128. var mod = d === "absolute" ? 1 : -1,
  4129. scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
  4130. scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
  4131. return {
  4132. top: (
  4133. pos.top + // The absolute mouse position
  4134. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  4135. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  4136. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
  4137. ),
  4138. left: (
  4139. pos.left + // The absolute mouse position
  4140. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  4141. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  4142. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
  4143. )
  4144. };
  4145. },
  4146. _generatePosition: function(event) {
  4147. var top, left,
  4148. o = this.options,
  4149. pageX = event.pageX,
  4150. pageY = event.pageY,
  4151. scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
  4152. // This is another very weird special case that only happens for relative elements:
  4153. // 1. If the css position is relative
  4154. // 2. and the scroll parent is the document or similar to the offset parent
  4155. // we have to refresh the relative offset during the scroll so there are no jumps
  4156. if(this.cssPosition === "relative" && !(this.scrollParent[0] !== document && this.scrollParent[0] !== this.offsetParent[0])) {
  4157. this.offset.relative = this._getRelativeOffset();
  4158. }
  4159. /*
  4160. * - Position constraining -
  4161. * Constrain the position to a mix of grid, containment.
  4162. */
  4163. if(this.originalPosition) { //If we are not dragging yet, we won't check for options
  4164. if(this.containment) {
  4165. if(event.pageX - this.offset.click.left < this.containment[0]) {
  4166. pageX = this.containment[0] + this.offset.click.left;
  4167. }
  4168. if(event.pageY - this.offset.click.top < this.containment[1]) {
  4169. pageY = this.containment[1] + this.offset.click.top;
  4170. }
  4171. if(event.pageX - this.offset.click.left > this.containment[2]) {
  4172. pageX = this.containment[2] + this.offset.click.left;
  4173. }
  4174. if(event.pageY - this.offset.click.top > this.containment[3]) {
  4175. pageY = this.containment[3] + this.offset.click.top;
  4176. }
  4177. }
  4178. if(o.grid) {
  4179. top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
  4180. 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;
  4181. left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
  4182. 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;
  4183. }
  4184. }
  4185. return {
  4186. top: (
  4187. pageY - // The absolute mouse position
  4188. this.offset.click.top - // Click offset (relative to the element)
  4189. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  4190. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  4191. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
  4192. ),
  4193. left: (
  4194. pageX - // The absolute mouse position
  4195. this.offset.click.left - // Click offset (relative to the element)
  4196. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  4197. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  4198. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
  4199. )
  4200. };
  4201. },
  4202. _rearrange: function(event, i, a, hardRefresh) {
  4203. 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));
  4204. //Various things done here to improve the performance:
  4205. // 1. we create a setTimeout, that calls refreshPositions
  4206. // 2. on the instance, we have a counter variable, that get's higher after every append
  4207. // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
  4208. // 4. this lets only the last addition to the timeout stack through
  4209. this.counter = this.counter ? ++this.counter : 1;
  4210. var counter = this.counter;
  4211. this._delay(function() {
  4212. if(counter === this.counter) {
  4213. this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
  4214. }
  4215. });
  4216. },
  4217. _clear: function(event, noPropagation) {
  4218. this.reverting = false;
  4219. // We delay all events that have to be triggered to after the point where the placeholder has been removed and
  4220. // everything else normalized again
  4221. var i,
  4222. delayedTriggers = [];
  4223. // We first have to update the dom position of the actual currentItem
  4224. // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
  4225. if(!this._noFinalSort && this.currentItem.parent().length) {
  4226. this.placeholder.before(this.currentItem);
  4227. }
  4228. this._noFinalSort = null;
  4229. if(this.helper[0] === this.currentItem[0]) {
  4230. for(i in this._storedCSS) {
  4231. if(this._storedCSS[i] === "auto" || this._storedCSS[i] === "static") {
  4232. this._storedCSS[i] = "";
  4233. }
  4234. }
  4235. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  4236. } else {
  4237. this.currentItem.show();
  4238. }
  4239. if(this.fromOutside && !noPropagation) {
  4240. delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
  4241. }
  4242. if((this.fromOutside || this.domPosition.prev !== this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent !== this.currentItem.parent()[0]) && !noPropagation) {
  4243. delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
  4244. }
  4245. // Check if the items Container has Changed and trigger appropriate
  4246. // events.
  4247. if (this !== this.currentContainer) {
  4248. if(!noPropagation) {
  4249. delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
  4250. delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  4251. delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  4252. }
  4253. }
  4254. //Post events to containers
  4255. for (i = this.containers.length - 1; i >= 0; i--){
  4256. if(!noPropagation) {
  4257. delayedTriggers.push((function(c) { return function(event) { c._trigger("deactivate", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
  4258. }
  4259. if(this.containers[i].containerCache.over) {
  4260. delayedTriggers.push((function(c) { return function(event) { c._trigger("out", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
  4261. this.containers[i].containerCache.over = 0;
  4262. }
  4263. }
  4264. //Do what was originally in plugins
  4265. if(this._storedCursor) {
  4266. $("body").css("cursor", this._storedCursor);
  4267. }
  4268. if(this._storedOpacity) {
  4269. this.helper.css("opacity", this._storedOpacity);
  4270. }
  4271. if(this._storedZIndex) {
  4272. this.helper.css("zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex);
  4273. }
  4274. this.dragging = false;
  4275. if(this.cancelHelperRemoval) {
  4276. if(!noPropagation) {
  4277. this._trigger("beforeStop", event, this._uiHash());
  4278. for (i=0; i < delayedTriggers.length; i++) {
  4279. delayedTriggers[i].call(this, event);
  4280. } //Trigger all delayed events
  4281. this._trigger("stop", event, this._uiHash());
  4282. }
  4283. this.fromOutside = false;
  4284. return false;
  4285. }
  4286. if(!noPropagation) {
  4287. this._trigger("beforeStop", event, this._uiHash());
  4288. }
  4289. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  4290. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  4291. if(this.helper[0] !== this.currentItem[0]) {
  4292. this.helper.remove();
  4293. }
  4294. this.helper = null;
  4295. if(!noPropagation) {
  4296. for (i=0; i < delayedTriggers.length; i++) {
  4297. delayedTriggers[i].call(this, event);
  4298. } //Trigger all delayed events
  4299. this._trigger("stop", event, this._uiHash());
  4300. }
  4301. this.fromOutside = false;
  4302. return true;
  4303. },
  4304. _trigger: function() {
  4305. if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
  4306. this.cancel();
  4307. }
  4308. },
  4309. _uiHash: function(_inst) {
  4310. var inst = _inst || this;
  4311. return {
  4312. helper: inst.helper,
  4313. placeholder: inst.placeholder || $([]),
  4314. position: inst.position,
  4315. originalPosition: inst.originalPosition,
  4316. offset: inst.positionAbs,
  4317. item: inst.currentItem,
  4318. sender: _inst ? _inst.element : null
  4319. };
  4320. }
  4321. });
  4322. })(jQuery);
  4323. (function( $, undefined ) {
  4324. var uid = 0,
  4325. hideProps = {},
  4326. showProps = {};
  4327. hideProps.height = hideProps.paddingTop = hideProps.paddingBottom =
  4328. hideProps.borderTopWidth = hideProps.borderBottomWidth = "hide";
  4329. showProps.height = showProps.paddingTop = showProps.paddingBottom =
  4330. showProps.borderTopWidth = showProps.borderBottomWidth = "show";
  4331. $.widget( "ui.accordion", {
  4332. version: "1.10.0",
  4333. options: {
  4334. active: 0,
  4335. animate: {},
  4336. collapsible: false,
  4337. event: "click",
  4338. header: "> li > :first-child,> :not(li):even",
  4339. heightStyle: "auto",
  4340. icons: {
  4341. activeHeader: "ui-icon-triangle-1-s",
  4342. header: "ui-icon-triangle-1-e"
  4343. },
  4344. // callbacks
  4345. activate: null,
  4346. beforeActivate: null
  4347. },
  4348. _create: function() {
  4349. var options = this.options;
  4350. this.prevShow = this.prevHide = $();
  4351. this.element.addClass( "ui-accordion ui-widget ui-helper-reset" )
  4352. // ARIA
  4353. .attr( "role", "tablist" );
  4354. // don't allow collapsible: false and active: false / null
  4355. if ( !options.collapsible && (options.active === false || options.active == null) ) {
  4356. options.active = 0;
  4357. }
  4358. this._processPanels();
  4359. // handle negative values
  4360. if ( options.active < 0 ) {
  4361. options.active += this.headers.length;
  4362. }
  4363. this._refresh();
  4364. },
  4365. _getCreateEventData: function() {
  4366. return {
  4367. header: this.active,
  4368. content: !this.active.length ? $() : this.active.next()
  4369. };
  4370. },
  4371. _createIcons: function() {
  4372. var icons = this.options.icons;
  4373. if ( icons ) {
  4374. $( "<span>" )
  4375. .addClass( "ui-accordion-header-icon ui-icon " + icons.header )
  4376. .prependTo( this.headers );
  4377. this.active.children( ".ui-accordion-header-icon" )
  4378. .removeClass( icons.header )
  4379. .addClass( icons.activeHeader );
  4380. this.headers.addClass( "ui-accordion-icons" );
  4381. }
  4382. },
  4383. _destroyIcons: function() {
  4384. this.headers
  4385. .removeClass( "ui-accordion-icons" )
  4386. .children( ".ui-accordion-header-icon" )
  4387. .remove();
  4388. },
  4389. _destroy: function() {
  4390. var contents;
  4391. // clean up main element
  4392. this.element
  4393. .removeClass( "ui-accordion ui-widget ui-helper-reset" )
  4394. .removeAttr( "role" );
  4395. // clean up headers
  4396. this.headers
  4397. .removeClass( "ui-accordion-header ui-accordion-header-active ui-helper-reset ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top" )
  4398. .removeAttr( "role" )
  4399. .removeAttr( "aria-selected" )
  4400. .removeAttr( "aria-controls" )
  4401. .removeAttr( "tabIndex" )
  4402. .each(function() {
  4403. if ( /^ui-accordion/.test( this.id ) ) {
  4404. this.removeAttribute( "id" );
  4405. }
  4406. });
  4407. this._destroyIcons();
  4408. // clean up content panels
  4409. contents = this.headers.next()
  4410. .css( "display", "" )
  4411. .removeAttr( "role" )
  4412. .removeAttr( "aria-expanded" )
  4413. .removeAttr( "aria-hidden" )
  4414. .removeAttr( "aria-labelledby" )
  4415. .removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-state-disabled" )
  4416. .each(function() {
  4417. if ( /^ui-accordion/.test( this.id ) ) {
  4418. this.removeAttribute( "id" );
  4419. }
  4420. });
  4421. if ( this.options.heightStyle !== "content" ) {
  4422. contents.css( "height", "" );
  4423. }
  4424. },
  4425. _setOption: function( key, value ) {
  4426. if ( key === "active" ) {
  4427. // _activate() will handle invalid values and update this.options
  4428. this._activate( value );
  4429. return;
  4430. }
  4431. if ( key === "event" ) {
  4432. if ( this.options.event ) {
  4433. this._off( this.headers, this.options.event );
  4434. }
  4435. this._setupEvents( value );
  4436. }
  4437. this._super( key, value );
  4438. // setting collapsible: false while collapsed; open first panel
  4439. if ( key === "collapsible" && !value && this.options.active === false ) {
  4440. this._activate( 0 );
  4441. }
  4442. if ( key === "icons" ) {
  4443. this._destroyIcons();
  4444. if ( value ) {
  4445. this._createIcons();
  4446. }
  4447. }
  4448. // #5332 - opacity doesn't cascade to positioned elements in IE
  4449. // so we need to add the disabled class to the headers and panels
  4450. if ( key === "disabled" ) {
  4451. this.headers.add( this.headers.next() )
  4452. .toggleClass( "ui-state-disabled", !!value );
  4453. }
  4454. },
  4455. _keydown: function( event ) {
  4456. /*jshint maxcomplexity:15*/
  4457. if ( event.altKey || event.ctrlKey ) {
  4458. return;
  4459. }
  4460. var keyCode = $.ui.keyCode,
  4461. length = this.headers.length,
  4462. currentIndex = this.headers.index( event.target ),
  4463. toFocus = false;
  4464. switch ( event.keyCode ) {
  4465. case keyCode.RIGHT:
  4466. case keyCode.DOWN:
  4467. toFocus = this.headers[ ( currentIndex + 1 ) % length ];
  4468. break;
  4469. case keyCode.LEFT:
  4470. case keyCode.UP:
  4471. toFocus = this.headers[ ( currentIndex - 1 + length ) % length ];
  4472. break;
  4473. case keyCode.SPACE:
  4474. case keyCode.ENTER:
  4475. this._eventHandler( event );
  4476. break;
  4477. case keyCode.HOME:
  4478. toFocus = this.headers[ 0 ];
  4479. break;
  4480. case keyCode.END:
  4481. toFocus = this.headers[ length - 1 ];
  4482. break;
  4483. }
  4484. if ( toFocus ) {
  4485. $( event.target ).attr( "tabIndex", -1 );
  4486. $( toFocus ).attr( "tabIndex", 0 );
  4487. toFocus.focus();
  4488. event.preventDefault();
  4489. }
  4490. },
  4491. _panelKeyDown : function( event ) {
  4492. if ( event.keyCode === $.ui.keyCode.UP && event.ctrlKey ) {
  4493. $( event.currentTarget ).prev().focus();
  4494. }
  4495. },
  4496. refresh: function() {
  4497. var options = this.options;
  4498. this._processPanels();
  4499. // was collapsed or no panel
  4500. if ( ( options.active === false && options.collapsible === true ) || !this.headers.length ) {
  4501. options.active = false;
  4502. this.active = $();
  4503. // active false only when collapsible is true
  4504. } if ( options.active === false ) {
  4505. this._activate( 0 );
  4506. // was active, but active panel is gone
  4507. } else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  4508. // all remaining panel are disabled
  4509. if ( this.headers.length === this.headers.find(".ui-state-disabled").length ) {
  4510. options.active = false;
  4511. this.active = $();
  4512. // activate previous panel
  4513. } else {
  4514. this._activate( Math.max( 0, options.active - 1 ) );
  4515. }
  4516. // was active, active panel still exists
  4517. } else {
  4518. // make sure active index is correct
  4519. options.active = this.headers.index( this.active );
  4520. }
  4521. this._destroyIcons();
  4522. this._refresh();
  4523. },
  4524. _processPanels: function() {
  4525. this.headers = this.element.find( this.options.header )
  4526. .addClass( "ui-accordion-header ui-helper-reset ui-state-default ui-corner-all" );
  4527. this.headers.next()
  4528. .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" )
  4529. .filter(":not(.ui-accordion-content-active)")
  4530. .hide();
  4531. },
  4532. _refresh: function() {
  4533. var maxHeight,
  4534. options = this.options,
  4535. heightStyle = options.heightStyle,
  4536. parent = this.element.parent(),
  4537. accordionId = this.accordionId = "ui-accordion-" +
  4538. (this.element.attr( "id" ) || ++uid);
  4539. this.active = this._findActive( options.active )
  4540. .addClass( "ui-accordion-header-active ui-state-active" )
  4541. .toggleClass( "ui-corner-all ui-corner-top" );
  4542. this.active.next()
  4543. .addClass( "ui-accordion-content-active" )
  4544. .show();
  4545. this.headers
  4546. .attr( "role", "tab" )
  4547. .each(function( i ) {
  4548. var header = $( this ),
  4549. headerId = header.attr( "id" ),
  4550. panel = header.next(),
  4551. panelId = panel.attr( "id" );
  4552. if ( !headerId ) {
  4553. headerId = accordionId + "-header-" + i;
  4554. header.attr( "id", headerId );
  4555. }
  4556. if ( !panelId ) {
  4557. panelId = accordionId + "-panel-" + i;
  4558. panel.attr( "id", panelId );
  4559. }
  4560. header.attr( "aria-controls", panelId );
  4561. panel.attr( "aria-labelledby", headerId );
  4562. })
  4563. .next()
  4564. .attr( "role", "tabpanel" );
  4565. this.headers
  4566. .not( this.active )
  4567. .attr({
  4568. "aria-selected": "false",
  4569. tabIndex: -1
  4570. })
  4571. .next()
  4572. .attr({
  4573. "aria-expanded": "false",
  4574. "aria-hidden": "true"
  4575. })
  4576. .hide();
  4577. // make sure at least one header is in the tab order
  4578. if ( !this.active.length ) {
  4579. this.headers.eq( 0 ).attr( "tabIndex", 0 );
  4580. } else {
  4581. this.active.attr({
  4582. "aria-selected": "true",
  4583. tabIndex: 0
  4584. })
  4585. .next()
  4586. .attr({
  4587. "aria-expanded": "true",
  4588. "aria-hidden": "false"
  4589. });
  4590. }
  4591. this._createIcons();
  4592. this._setupEvents( options.event );
  4593. if ( heightStyle === "fill" ) {
  4594. maxHeight = parent.height();
  4595. this.element.siblings( ":visible" ).each(function() {
  4596. var elem = $( this ),
  4597. position = elem.css( "position" );
  4598. if ( position === "absolute" || position === "fixed" ) {
  4599. return;
  4600. }
  4601. maxHeight -= elem.outerHeight( true );
  4602. });
  4603. this.headers.each(function() {
  4604. maxHeight -= $( this ).outerHeight( true );
  4605. });
  4606. this.headers.next()
  4607. .each(function() {
  4608. $( this ).height( Math.max( 0, maxHeight -
  4609. $( this ).innerHeight() + $( this ).height() ) );
  4610. })
  4611. .css( "overflow", "auto" );
  4612. } else if ( heightStyle === "auto" ) {
  4613. maxHeight = 0;
  4614. this.headers.next()
  4615. .each(function() {
  4616. maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() );
  4617. })
  4618. .height( maxHeight );
  4619. }
  4620. },
  4621. _activate: function( index ) {
  4622. var active = this._findActive( index )[ 0 ];
  4623. // trying to activate the already active panel
  4624. if ( active === this.active[ 0 ] ) {
  4625. return;
  4626. }
  4627. // trying to collapse, simulate a click on the currently active header
  4628. active = active || this.active[ 0 ];
  4629. this._eventHandler({
  4630. target: active,
  4631. currentTarget: active,
  4632. preventDefault: $.noop
  4633. });
  4634. },
  4635. _findActive: function( selector ) {
  4636. return typeof selector === "number" ? this.headers.eq( selector ) : $();
  4637. },
  4638. _setupEvents: function( event ) {
  4639. var events = {
  4640. keydown: "_keydown"
  4641. };
  4642. if ( event ) {
  4643. $.each( event.split(" "), function( index, eventName ) {
  4644. events[ eventName ] = "_eventHandler";
  4645. });
  4646. }
  4647. this._off( this.headers.add( this.headers.next() ) );
  4648. this._on( this.headers, events );
  4649. this._on( this.headers.next(), { keydown: "_panelKeyDown" });
  4650. this._hoverable( this.headers );
  4651. this._focusable( this.headers );
  4652. },
  4653. _eventHandler: function( event ) {
  4654. var options = this.options,
  4655. active = this.active,
  4656. clicked = $( event.currentTarget ),
  4657. clickedIsActive = clicked[ 0 ] === active[ 0 ],
  4658. collapsing = clickedIsActive && options.collapsible,
  4659. toShow = collapsing ? $() : clicked.next(),
  4660. toHide = active.next(),
  4661. eventData = {
  4662. oldHeader: active,
  4663. oldPanel: toHide,
  4664. newHeader: collapsing ? $() : clicked,
  4665. newPanel: toShow
  4666. };
  4667. event.preventDefault();
  4668. if (
  4669. // click on active header, but not collapsible
  4670. ( clickedIsActive && !options.collapsible ) ||
  4671. // allow canceling activation
  4672. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  4673. return;
  4674. }
  4675. options.active = collapsing ? false : this.headers.index( clicked );
  4676. // when the call to ._toggle() comes after the class changes
  4677. // it causes a very odd bug in IE 8 (see #6720)
  4678. this.active = clickedIsActive ? $() : clicked;
  4679. this._toggle( eventData );
  4680. // switch classes
  4681. // corner classes on the previously active header stay after the animation
  4682. active.removeClass( "ui-accordion-header-active ui-state-active" );
  4683. if ( options.icons ) {
  4684. active.children( ".ui-accordion-header-icon" )
  4685. .removeClass( options.icons.activeHeader )
  4686. .addClass( options.icons.header );
  4687. }
  4688. if ( !clickedIsActive ) {
  4689. clicked
  4690. .removeClass( "ui-corner-all" )
  4691. .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" );
  4692. if ( options.icons ) {
  4693. clicked.children( ".ui-accordion-header-icon" )
  4694. .removeClass( options.icons.header )
  4695. .addClass( options.icons.activeHeader );
  4696. }
  4697. clicked
  4698. .next()
  4699. .addClass( "ui-accordion-content-active" );
  4700. }
  4701. },
  4702. _toggle: function( data ) {
  4703. var toShow = data.newPanel,
  4704. toHide = this.prevShow.length ? this.prevShow : data.oldPanel;
  4705. // handle activating a panel during the animation for another activation
  4706. this.prevShow.add( this.prevHide ).stop( true, true );
  4707. this.prevShow = toShow;
  4708. this.prevHide = toHide;
  4709. if ( this.options.animate ) {
  4710. this._animate( toShow, toHide, data );
  4711. } else {
  4712. toHide.hide();
  4713. toShow.show();
  4714. this._toggleComplete( data );
  4715. }
  4716. toHide.attr({
  4717. "aria-expanded": "false",
  4718. "aria-hidden": "true"
  4719. });
  4720. toHide.prev().attr( "aria-selected", "false" );
  4721. // if we're switching panels, remove the old header from the tab order
  4722. // if we're opening from collapsed state, remove the previous header from the tab order
  4723. // if we're collapsing, then keep the collapsing header in the tab order
  4724. if ( toShow.length && toHide.length ) {
  4725. toHide.prev().attr( "tabIndex", -1 );
  4726. } else if ( toShow.length ) {
  4727. this.headers.filter(function() {
  4728. return $( this ).attr( "tabIndex" ) === 0;
  4729. })
  4730. .attr( "tabIndex", -1 );
  4731. }
  4732. toShow
  4733. .attr({
  4734. "aria-expanded": "true",
  4735. "aria-hidden": "false"
  4736. })
  4737. .prev()
  4738. .attr({
  4739. "aria-selected": "true",
  4740. tabIndex: 0
  4741. });
  4742. },
  4743. _animate: function( toShow, toHide, data ) {
  4744. var total, easing, duration,
  4745. that = this,
  4746. adjust = 0,
  4747. down = toShow.length &&
  4748. ( !toHide.length || ( toShow.index() < toHide.index() ) ),
  4749. animate = this.options.animate || {},
  4750. options = down && animate.down || animate,
  4751. complete = function() {
  4752. that._toggleComplete( data );
  4753. };
  4754. if ( typeof options === "number" ) {
  4755. duration = options;
  4756. }
  4757. if ( typeof options === "string" ) {
  4758. easing = options;
  4759. }
  4760. // fall back from options to animation in case of partial down settings
  4761. easing = easing || options.easing || animate.easing;
  4762. duration = duration || options.duration || animate.duration;
  4763. if ( !toHide.length ) {
  4764. return toShow.animate( showProps, duration, easing, complete );
  4765. }
  4766. if ( !toShow.length ) {
  4767. return toHide.animate( hideProps, duration, easing, complete );
  4768. }
  4769. total = toShow.show().outerHeight();
  4770. toHide.animate( hideProps, {
  4771. duration: duration,
  4772. easing: easing,
  4773. step: function( now, fx ) {
  4774. fx.now = Math.round( now );
  4775. }
  4776. });
  4777. toShow
  4778. .hide()
  4779. .animate( showProps, {
  4780. duration: duration,
  4781. easing: easing,
  4782. complete: complete,
  4783. step: function( now, fx ) {
  4784. fx.now = Math.round( now );
  4785. if ( fx.prop !== "height" ) {
  4786. adjust += fx.now;
  4787. } else if ( that.options.heightStyle !== "content" ) {
  4788. fx.now = Math.round( total - toHide.outerHeight() - adjust );
  4789. adjust = 0;
  4790. }
  4791. }
  4792. });
  4793. },
  4794. _toggleComplete: function( data ) {
  4795. var toHide = data.oldPanel;
  4796. toHide
  4797. .removeClass( "ui-accordion-content-active" )
  4798. .prev()
  4799. .removeClass( "ui-corner-top" )
  4800. .addClass( "ui-corner-all" );
  4801. // Work around for rendering bug in IE (#5421)
  4802. if ( toHide.length ) {
  4803. toHide.parent()[0].className = toHide.parent()[0].className;
  4804. }
  4805. this._trigger( "activate", null, data );
  4806. }
  4807. });
  4808. })( jQuery );
  4809. (function( $, undefined ) {
  4810. // used to prevent race conditions with remote data sources
  4811. var requestIndex = 0;
  4812. $.widget( "ui.autocomplete", {
  4813. version: "1.10.0",
  4814. defaultElement: "<input>",
  4815. options: {
  4816. appendTo: null,
  4817. autoFocus: false,
  4818. delay: 300,
  4819. minLength: 1,
  4820. position: {
  4821. my: "left top",
  4822. at: "left bottom",
  4823. collision: "none"
  4824. },
  4825. source: null,
  4826. // callbacks
  4827. change: null,
  4828. close: null,
  4829. focus: null,
  4830. open: null,
  4831. response: null,
  4832. search: null,
  4833. select: null
  4834. },
  4835. pending: 0,
  4836. _create: function() {
  4837. // Some browsers only repeat keydown events, not keypress events,
  4838. // so we use the suppressKeyPress flag to determine if we've already
  4839. // handled the keydown event. #7269
  4840. // Unfortunately the code for & in keypress is the same as the up arrow,
  4841. // so we use the suppressKeyPressRepeat flag to avoid handling keypress
  4842. // events when we know the keydown event was used to modify the
  4843. // search term. #7799
  4844. var suppressKeyPress, suppressKeyPressRepeat, suppressInput;
  4845. this.isMultiLine = this._isMultiLine();
  4846. this.valueMethod = this.element[ this.element.is( "input,textarea" ) ? "val" : "text" ];
  4847. this.isNewMenu = true;
  4848. this.element
  4849. .addClass( "ui-autocomplete-input" )
  4850. .attr( "autocomplete", "off" );
  4851. this._on( this.element, {
  4852. keydown: function( event ) {
  4853. /*jshint maxcomplexity:15*/
  4854. if ( this.element.prop( "readOnly" ) ) {
  4855. suppressKeyPress = true;
  4856. suppressInput = true;
  4857. suppressKeyPressRepeat = true;
  4858. return;
  4859. }
  4860. suppressKeyPress = false;
  4861. suppressInput = false;
  4862. suppressKeyPressRepeat = false;
  4863. var keyCode = $.ui.keyCode;
  4864. switch( event.keyCode ) {
  4865. case keyCode.PAGE_UP:
  4866. suppressKeyPress = true;
  4867. this._move( "previousPage", event );
  4868. break;
  4869. case keyCode.PAGE_DOWN:
  4870. suppressKeyPress = true;
  4871. this._move( "nextPage", event );
  4872. break;
  4873. case keyCode.UP:
  4874. suppressKeyPress = true;
  4875. this._keyEvent( "previous", event );
  4876. break;
  4877. case keyCode.DOWN:
  4878. suppressKeyPress = true;
  4879. this._keyEvent( "next", event );
  4880. break;
  4881. case keyCode.ENTER:
  4882. case keyCode.NUMPAD_ENTER:
  4883. // when menu is open and has focus
  4884. if ( this.menu.active ) {
  4885. // #6055 - Opera still allows the keypress to occur
  4886. // which causes forms to submit
  4887. suppressKeyPress = true;
  4888. event.preventDefault();
  4889. this.menu.select( event );
  4890. }
  4891. break;
  4892. case keyCode.TAB:
  4893. if ( this.menu.active ) {
  4894. this.menu.select( event );
  4895. }
  4896. break;
  4897. case keyCode.ESCAPE:
  4898. if ( this.menu.element.is( ":visible" ) ) {
  4899. this._value( this.term );
  4900. this.close( event );
  4901. // Different browsers have different default behavior for escape
  4902. // Single press can mean undo or clear
  4903. // Double press in IE means clear the whole form
  4904. event.preventDefault();
  4905. }
  4906. break;
  4907. default:
  4908. suppressKeyPressRepeat = true;
  4909. // search timeout should be triggered before the input value is changed
  4910. this._searchTimeout( event );
  4911. break;
  4912. }
  4913. },
  4914. keypress: function( event ) {
  4915. if ( suppressKeyPress ) {
  4916. suppressKeyPress = false;
  4917. event.preventDefault();
  4918. return;
  4919. }
  4920. if ( suppressKeyPressRepeat ) {
  4921. return;
  4922. }
  4923. // replicate some key handlers to allow them to repeat in Firefox and Opera
  4924. var keyCode = $.ui.keyCode;
  4925. switch( event.keyCode ) {
  4926. case keyCode.PAGE_UP:
  4927. this._move( "previousPage", event );
  4928. break;
  4929. case keyCode.PAGE_DOWN:
  4930. this._move( "nextPage", event );
  4931. break;
  4932. case keyCode.UP:
  4933. this._keyEvent( "previous", event );
  4934. break;
  4935. case keyCode.DOWN:
  4936. this._keyEvent( "next", event );
  4937. break;
  4938. }
  4939. },
  4940. input: function( event ) {
  4941. if ( suppressInput ) {
  4942. suppressInput = false;
  4943. event.preventDefault();
  4944. return;
  4945. }
  4946. this._searchTimeout( event );
  4947. },
  4948. focus: function() {
  4949. this.selectedItem = null;
  4950. this.previous = this._value();
  4951. },
  4952. blur: function( event ) {
  4953. if ( this.cancelBlur ) {
  4954. delete this.cancelBlur;
  4955. return;
  4956. }
  4957. clearTimeout( this.searching );
  4958. this.close( event );
  4959. this._change( event );
  4960. }
  4961. });
  4962. this._initSource();
  4963. this.menu = $( "<ul>" )
  4964. .addClass( "ui-autocomplete" )
  4965. .appendTo( this._appendTo() )
  4966. .menu({
  4967. // custom key handling for now
  4968. input: $(),
  4969. // disable ARIA support, the live region takes care of that
  4970. role: null
  4971. })
  4972. .zIndex( this.element.zIndex() + 1 )
  4973. .hide()
  4974. .data( "ui-menu" );
  4975. this._on( this.menu.element, {
  4976. mousedown: function( event ) {
  4977. // prevent moving focus out of the text field
  4978. event.preventDefault();
  4979. // IE doesn't prevent moving focus even with event.preventDefault()
  4980. // so we set a flag to know when we should ignore the blur event
  4981. this.cancelBlur = true;
  4982. this._delay(function() {
  4983. delete this.cancelBlur;
  4984. });
  4985. // clicking on the scrollbar causes focus to shift to the body
  4986. // but we can't detect a mouseup or a click immediately afterward
  4987. // so we have to track the next mousedown and close the menu if
  4988. // the user clicks somewhere outside of the autocomplete
  4989. var menuElement = this.menu.element[ 0 ];
  4990. if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
  4991. this._delay(function() {
  4992. var that = this;
  4993. this.document.one( "mousedown", function( event ) {
  4994. if ( event.target !== that.element[ 0 ] &&
  4995. event.target !== menuElement &&
  4996. !$.contains( menuElement, event.target ) ) {
  4997. that.close();
  4998. }
  4999. });
  5000. });
  5001. }
  5002. },
  5003. menufocus: function( event, ui ) {
  5004. // #7024 - Prevent accidental activation of menu items in Firefox
  5005. if ( this.isNewMenu ) {
  5006. this.isNewMenu = false;
  5007. if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
  5008. this.menu.blur();
  5009. this.document.one( "mousemove", function() {
  5010. $( event.target ).trigger( event.originalEvent );
  5011. });
  5012. return;
  5013. }
  5014. }
  5015. var item = ui.item.data( "ui-autocomplete-item" );
  5016. if ( false !== this._trigger( "focus", event, { item: item } ) ) {
  5017. // use value to match what will end up in the input, if it was a key event
  5018. if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
  5019. this._value( item.value );
  5020. }
  5021. } else {
  5022. // Normally the input is populated with the item's value as the
  5023. // menu is navigated, causing screen readers to notice a change and
  5024. // announce the item. Since the focus event was canceled, this doesn't
  5025. // happen, so we update the live region so that screen readers can
  5026. // still notice the change and announce it.
  5027. this.liveRegion.text( item.value );
  5028. }
  5029. },
  5030. menuselect: function( event, ui ) {
  5031. var item = ui.item.data( "ui-autocomplete-item" ),
  5032. previous = this.previous;
  5033. // only trigger when focus was lost (click on menu)
  5034. if ( this.element[0] !== this.document[0].activeElement ) {
  5035. this.element.focus();
  5036. this.previous = previous;
  5037. // #6109 - IE triggers two focus events and the second
  5038. // is asynchronous, so we need to reset the previous
  5039. // term synchronously and asynchronously :-(
  5040. this._delay(function() {
  5041. this.previous = previous;
  5042. this.selectedItem = item;
  5043. });
  5044. }
  5045. if ( false !== this._trigger( "select", event, { item: item } ) ) {
  5046. this._value( item.value );
  5047. }
  5048. // reset the term after the select event
  5049. // this allows custom select handling to work properly
  5050. this.term = this._value();
  5051. this.close( event );
  5052. this.selectedItem = item;
  5053. }
  5054. });
  5055. this.liveRegion = $( "<span>", {
  5056. role: "status",
  5057. "aria-live": "polite"
  5058. })
  5059. .addClass( "ui-helper-hidden-accessible" )
  5060. .insertAfter( this.element );
  5061. // turning off autocomplete prevents the browser from remembering the
  5062. // value when navigating through history, so we re-enable autocomplete
  5063. // if the page is unloaded before the widget is destroyed. #7790
  5064. this._on( this.window, {
  5065. beforeunload: function() {
  5066. this.element.removeAttr( "autocomplete" );
  5067. }
  5068. });
  5069. },
  5070. _destroy: function() {
  5071. clearTimeout( this.searching );
  5072. this.element
  5073. .removeClass( "ui-autocomplete-input" )
  5074. .removeAttr( "autocomplete" );
  5075. this.menu.element.remove();
  5076. this.liveRegion.remove();
  5077. },
  5078. _setOption: function( key, value ) {
  5079. this._super( key, value );
  5080. if ( key === "source" ) {
  5081. this._initSource();
  5082. }
  5083. if ( key === "appendTo" ) {
  5084. this.menu.element.appendTo( this._appendTo() );
  5085. }
  5086. if ( key === "disabled" && value && this.xhr ) {
  5087. this.xhr.abort();
  5088. }
  5089. },
  5090. _appendTo: function() {
  5091. var element = this.options.appendTo;
  5092. if ( element ) {
  5093. element = element.jquery || element.nodeType ?
  5094. $( element ) :
  5095. this.document.find( element ).eq( 0 );
  5096. }
  5097. if ( !element ) {
  5098. element = this.element.closest( ".ui-front" );
  5099. }
  5100. if ( !element.length ) {
  5101. element = this.document[0].body;
  5102. }
  5103. return element;
  5104. },
  5105. _isMultiLine: function() {
  5106. // Textareas are always multi-line
  5107. if ( this.element.is( "textarea" ) ) {
  5108. return true;
  5109. }
  5110. // Inputs are always single-line, even if inside a contentEditable element
  5111. // IE also treats inputs as contentEditable
  5112. if ( this.element.is( "input" ) ) {
  5113. return false;
  5114. }
  5115. // All other element types are determined by whether or not they're contentEditable
  5116. return this.element.prop( "isContentEditable" );
  5117. },
  5118. _initSource: function() {
  5119. var array, url,
  5120. that = this;
  5121. if ( $.isArray(this.options.source) ) {
  5122. array = this.options.source;
  5123. this.source = function( request, response ) {
  5124. response( $.ui.autocomplete.filter( array, request.term ) );
  5125. };
  5126. } else if ( typeof this.options.source === "string" ) {
  5127. url = this.options.source;
  5128. this.source = function( request, response ) {
  5129. if ( that.xhr ) {
  5130. that.xhr.abort();
  5131. }
  5132. that.xhr = $.ajax({
  5133. url: url,
  5134. data: request,
  5135. dataType: "json",
  5136. success: function( data ) {
  5137. response( data );
  5138. },
  5139. error: function() {
  5140. response( [] );
  5141. }
  5142. });
  5143. };
  5144. } else {
  5145. this.source = this.options.source;
  5146. }
  5147. },
  5148. _searchTimeout: function( event ) {
  5149. clearTimeout( this.searching );
  5150. this.searching = this._delay(function() {
  5151. // only search if the value has changed
  5152. if ( this.term !== this._value() ) {
  5153. this.selectedItem = null;
  5154. this.search( null, event );
  5155. }
  5156. }, this.options.delay );
  5157. },
  5158. search: function( value, event ) {
  5159. value = value != null ? value : this._value();
  5160. // always save the actual value, not the one passed as an argument
  5161. this.term = this._value();
  5162. if ( value.length < this.options.minLength ) {
  5163. return this.close( event );
  5164. }
  5165. if ( this._trigger( "search", event ) === false ) {
  5166. return;
  5167. }
  5168. return this._search( value );
  5169. },
  5170. _search: function( value ) {
  5171. this.pending++;
  5172. this.element.addClass( "ui-autocomplete-loading" );
  5173. this.cancelSearch = false;
  5174. this.source( { term: value }, this._response() );
  5175. },
  5176. _response: function() {
  5177. var that = this,
  5178. index = ++requestIndex;
  5179. return function( content ) {
  5180. if ( index === requestIndex ) {
  5181. that.__response( content );
  5182. }
  5183. that.pending--;
  5184. if ( !that.pending ) {
  5185. that.element.removeClass( "ui-autocomplete-loading" );
  5186. }
  5187. };
  5188. },
  5189. __response: function( content ) {
  5190. if ( content ) {
  5191. content = this._normalize( content );
  5192. }
  5193. this._trigger( "response", null, { content: content } );
  5194. if ( !this.options.disabled && content && content.length && !this.cancelSearch ) {
  5195. this._suggest( content );
  5196. this._trigger( "open" );
  5197. } else {
  5198. // use ._close() instead of .close() so we don't cancel future searches
  5199. this._close();
  5200. }
  5201. },
  5202. close: function( event ) {
  5203. this.cancelSearch = true;
  5204. this._close( event );
  5205. },
  5206. _close: function( event ) {
  5207. if ( this.menu.element.is( ":visible" ) ) {
  5208. this.menu.element.hide();
  5209. this.menu.blur();
  5210. this.isNewMenu = true;
  5211. this._trigger( "close", event );
  5212. }
  5213. },
  5214. _change: function( event ) {
  5215. if ( this.previous !== this._value() ) {
  5216. this._trigger( "change", event, { item: this.selectedItem } );
  5217. }
  5218. },
  5219. _normalize: function( items ) {
  5220. // assume all items have the right format when the first item is complete
  5221. if ( items.length && items[0].label && items[0].value ) {
  5222. return items;
  5223. }
  5224. return $.map( items, function( item ) {
  5225. if ( typeof item === "string" ) {
  5226. return {
  5227. label: item,
  5228. value: item
  5229. };
  5230. }
  5231. return $.extend({
  5232. label: item.label || item.value,
  5233. value: item.value || item.label
  5234. }, item );
  5235. });
  5236. },
  5237. _suggest: function( items ) {
  5238. var ul = this.menu.element
  5239. .empty()
  5240. .zIndex( this.element.zIndex() + 1 );
  5241. this._renderMenu( ul, items );
  5242. this.menu.refresh();
  5243. // size and position menu
  5244. ul.show();
  5245. this._resizeMenu();
  5246. ul.position( $.extend({
  5247. of: this.element
  5248. }, this.options.position ));
  5249. if ( this.options.autoFocus ) {
  5250. this.menu.next();
  5251. }
  5252. },
  5253. _resizeMenu: function() {
  5254. var ul = this.menu.element;
  5255. ul.outerWidth( Math.max(
  5256. // Firefox wraps long text (possibly a rounding bug)
  5257. // so we add 1px to avoid the wrapping (#7513)
  5258. ul.width( "" ).outerWidth() + 1,
  5259. this.element.outerWidth()
  5260. ) );
  5261. },
  5262. _renderMenu: function( ul, items ) {
  5263. var that = this;
  5264. $.each( items, function( index, item ) {
  5265. that._renderItemData( ul, item );
  5266. });
  5267. },
  5268. _renderItemData: function( ul, item ) {
  5269. return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
  5270. },
  5271. _renderItem: function( ul, item ) {
  5272. return $( "<li>" )
  5273. .append( $( "<a>" ).text( item.label ) )
  5274. .appendTo( ul );
  5275. },
  5276. _move: function( direction, event ) {
  5277. if ( !this.menu.element.is( ":visible" ) ) {
  5278. this.search( null, event );
  5279. return;
  5280. }
  5281. if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
  5282. this.menu.isLastItem() && /^next/.test( direction ) ) {
  5283. this._value( this.term );
  5284. this.menu.blur();
  5285. return;
  5286. }
  5287. this.menu[ direction ]( event );
  5288. },
  5289. widget: function() {
  5290. return this.menu.element;
  5291. },
  5292. _value: function() {
  5293. return this.valueMethod.apply( this.element, arguments );
  5294. },
  5295. _keyEvent: function( keyEvent, event ) {
  5296. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  5297. this._move( keyEvent, event );
  5298. // prevents moving cursor to beginning/end of the text field in some browsers
  5299. event.preventDefault();
  5300. }
  5301. }
  5302. });
  5303. $.extend( $.ui.autocomplete, {
  5304. escapeRegex: function( value ) {
  5305. return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
  5306. },
  5307. filter: function(array, term) {
  5308. var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
  5309. return $.grep( array, function(value) {
  5310. return matcher.test( value.label || value.value || value );
  5311. });
  5312. }
  5313. });
  5314. // live region extension, adding a `messages` option
  5315. // NOTE: This is an experimental API. We are still investigating
  5316. // a full solution for string manipulation and internationalization.
  5317. $.widget( "ui.autocomplete", $.ui.autocomplete, {
  5318. options: {
  5319. messages: {
  5320. noResults: "No search results.",
  5321. results: function( amount ) {
  5322. return amount + ( amount > 1 ? " results are" : " result is" ) +
  5323. " available, use up and down arrow keys to navigate.";
  5324. }
  5325. }
  5326. },
  5327. __response: function( content ) {
  5328. var message;
  5329. this._superApply( arguments );
  5330. if ( this.options.disabled || this.cancelSearch ) {
  5331. return;
  5332. }
  5333. if ( content && content.length ) {
  5334. message = this.options.messages.results( content.length );
  5335. } else {
  5336. message = this.options.messages.noResults;
  5337. }
  5338. this.liveRegion.text( message );
  5339. }
  5340. });
  5341. }( jQuery ));
  5342. (function( $, undefined ) {
  5343. var lastActive, startXPos, startYPos, clickDragged,
  5344. baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
  5345. stateClasses = "ui-state-hover ui-state-active ",
  5346. 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",
  5347. formResetHandler = function() {
  5348. var buttons = $( this ).find( ":ui-button" );
  5349. setTimeout(function() {
  5350. buttons.button( "refresh" );
  5351. }, 1 );
  5352. },
  5353. radioGroup = function( radio ) {
  5354. var name = radio.name,
  5355. form = radio.form,
  5356. radios = $( [] );
  5357. if ( name ) {
  5358. name = name.replace( /'/g, "\\'" );
  5359. if ( form ) {
  5360. radios = $( form ).find( "[name='" + name + "']" );
  5361. } else {
  5362. radios = $( "[name='" + name + "']", radio.ownerDocument )
  5363. .filter(function() {
  5364. return !this.form;
  5365. });
  5366. }
  5367. }
  5368. return radios;
  5369. };
  5370. $.widget( "ui.button", {
  5371. version: "1.10.0",
  5372. defaultElement: "<button>",
  5373. options: {
  5374. disabled: null,
  5375. text: true,
  5376. label: null,
  5377. icons: {
  5378. primary: null,
  5379. secondary: null
  5380. }
  5381. },
  5382. _create: function() {
  5383. this.element.closest( "form" )
  5384. .unbind( "reset" + this.eventNamespace )
  5385. .bind( "reset" + this.eventNamespace, formResetHandler );
  5386. if ( typeof this.options.disabled !== "boolean" ) {
  5387. this.options.disabled = !!this.element.prop( "disabled" );
  5388. } else {
  5389. this.element.prop( "disabled", this.options.disabled );
  5390. }
  5391. this._determineButtonType();
  5392. this.hasTitle = !!this.buttonElement.attr( "title" );
  5393. var that = this,
  5394. options = this.options,
  5395. toggleButton = this.type === "checkbox" || this.type === "radio",
  5396. activeClass = !toggleButton ? "ui-state-active" : "",
  5397. focusClass = "ui-state-focus";
  5398. if ( options.label === null ) {
  5399. options.label = (this.type === "input" ? this.buttonElement.val() : this.buttonElement.html());
  5400. }
  5401. this._hoverable( this.buttonElement );
  5402. this.buttonElement
  5403. .addClass( baseClasses )
  5404. .attr( "role", "button" )
  5405. .bind( "mouseenter" + this.eventNamespace, function() {
  5406. if ( options.disabled ) {
  5407. return;
  5408. }
  5409. if ( this === lastActive ) {
  5410. $( this ).addClass( "ui-state-active" );
  5411. }
  5412. })
  5413. .bind( "mouseleave" + this.eventNamespace, function() {
  5414. if ( options.disabled ) {
  5415. return;
  5416. }
  5417. $( this ).removeClass( activeClass );
  5418. })
  5419. .bind( "click" + this.eventNamespace, function( event ) {
  5420. if ( options.disabled ) {
  5421. event.preventDefault();
  5422. event.stopImmediatePropagation();
  5423. }
  5424. });
  5425. this.element
  5426. .bind( "focus" + this.eventNamespace, function() {
  5427. // no need to check disabled, focus won't be triggered anyway
  5428. that.buttonElement.addClass( focusClass );
  5429. })
  5430. .bind( "blur" + this.eventNamespace, function() {
  5431. that.buttonElement.removeClass( focusClass );
  5432. });
  5433. if ( toggleButton ) {
  5434. this.element.bind( "change" + this.eventNamespace, function() {
  5435. if ( clickDragged ) {
  5436. return;
  5437. }
  5438. that.refresh();
  5439. });
  5440. // if mouse moves between mousedown and mouseup (drag) set clickDragged flag
  5441. // prevents issue where button state changes but checkbox/radio checked state
  5442. // does not in Firefox (see ticket #6970)
  5443. this.buttonElement
  5444. .bind( "mousedown" + this.eventNamespace, function( event ) {
  5445. if ( options.disabled ) {
  5446. return;
  5447. }
  5448. clickDragged = false;
  5449. startXPos = event.pageX;
  5450. startYPos = event.pageY;
  5451. })
  5452. .bind( "mouseup" + this.eventNamespace, function( event ) {
  5453. if ( options.disabled ) {
  5454. return;
  5455. }
  5456. if ( startXPos !== event.pageX || startYPos !== event.pageY ) {
  5457. clickDragged = true;
  5458. }
  5459. });
  5460. }
  5461. if ( this.type === "checkbox" ) {
  5462. this.buttonElement.bind( "click" + this.eventNamespace, function() {
  5463. if ( options.disabled || clickDragged ) {
  5464. return false;
  5465. }
  5466. });
  5467. } else if ( this.type === "radio" ) {
  5468. this.buttonElement.bind( "click" + this.eventNamespace, function() {
  5469. if ( options.disabled || clickDragged ) {
  5470. return false;
  5471. }
  5472. $( this ).addClass( "ui-state-active" );
  5473. that.buttonElement.attr( "aria-pressed", "true" );
  5474. var radio = that.element[ 0 ];
  5475. radioGroup( radio )
  5476. .not( radio )
  5477. .map(function() {
  5478. return $( this ).button( "widget" )[ 0 ];
  5479. })
  5480. .removeClass( "ui-state-active" )
  5481. .attr( "aria-pressed", "false" );
  5482. });
  5483. } else {
  5484. this.buttonElement
  5485. .bind( "mousedown" + this.eventNamespace, function() {
  5486. if ( options.disabled ) {
  5487. return false;
  5488. }
  5489. $( this ).addClass( "ui-state-active" );
  5490. lastActive = this;
  5491. that.document.one( "mouseup", function() {
  5492. lastActive = null;
  5493. });
  5494. })
  5495. .bind( "mouseup" + this.eventNamespace, function() {
  5496. if ( options.disabled ) {
  5497. return false;
  5498. }
  5499. $( this ).removeClass( "ui-state-active" );
  5500. })
  5501. .bind( "keydown" + this.eventNamespace, function(event) {
  5502. if ( options.disabled ) {
  5503. return false;
  5504. }
  5505. if ( event.keyCode === $.ui.keyCode.SPACE || event.keyCode === $.ui.keyCode.ENTER ) {
  5506. $( this ).addClass( "ui-state-active" );
  5507. }
  5508. })
  5509. // see #8559, we bind to blur here in case the button element loses
  5510. // focus between keydown and keyup, it would be left in an "active" state
  5511. .bind( "keyup" + this.eventNamespace + " blur" + this.eventNamespace, function() {
  5512. $( this ).removeClass( "ui-state-active" );
  5513. });
  5514. if ( this.buttonElement.is("a") ) {
  5515. this.buttonElement.keyup(function(event) {
  5516. if ( event.keyCode === $.ui.keyCode.SPACE ) {
  5517. // TODO pass through original event correctly (just as 2nd argument doesn't work)
  5518. $( this ).click();
  5519. }
  5520. });
  5521. }
  5522. }
  5523. // TODO: pull out $.Widget's handling for the disabled option into
  5524. // $.Widget.prototype._setOptionDisabled so it's easy to proxy and can
  5525. // be overridden by individual plugins
  5526. this._setOption( "disabled", options.disabled );
  5527. this._resetButton();
  5528. },
  5529. _determineButtonType: function() {
  5530. var ancestor, labelSelector, checked;
  5531. if ( this.element.is("[type=checkbox]") ) {
  5532. this.type = "checkbox";
  5533. } else if ( this.element.is("[type=radio]") ) {
  5534. this.type = "radio";
  5535. } else if ( this.element.is("input") ) {
  5536. this.type = "input";
  5537. } else {
  5538. this.type = "button";
  5539. }
  5540. if ( this.type === "checkbox" || this.type === "radio" ) {
  5541. // we don't search against the document in case the element
  5542. // is disconnected from the DOM
  5543. ancestor = this.element.parents().last();
  5544. labelSelector = "label[for='" + this.element.attr("id") + "']";
  5545. this.buttonElement = ancestor.find( labelSelector );
  5546. if ( !this.buttonElement.length ) {
  5547. ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
  5548. this.buttonElement = ancestor.filter( labelSelector );
  5549. if ( !this.buttonElement.length ) {
  5550. this.buttonElement = ancestor.find( labelSelector );
  5551. }
  5552. }
  5553. this.element.addClass( "ui-helper-hidden-accessible" );
  5554. checked = this.element.is( ":checked" );
  5555. if ( checked ) {
  5556. this.buttonElement.addClass( "ui-state-active" );
  5557. }
  5558. this.buttonElement.prop( "aria-pressed", checked );
  5559. } else {
  5560. this.buttonElement = this.element;
  5561. }
  5562. },
  5563. widget: function() {
  5564. return this.buttonElement;
  5565. },
  5566. _destroy: function() {
  5567. this.element
  5568. .removeClass( "ui-helper-hidden-accessible" );
  5569. this.buttonElement
  5570. .removeClass( baseClasses + " " + stateClasses + " " + typeClasses )
  5571. .removeAttr( "role" )
  5572. .removeAttr( "aria-pressed" )
  5573. .html( this.buttonElement.find(".ui-button-text").html() );
  5574. if ( !this.hasTitle ) {
  5575. this.buttonElement.removeAttr( "title" );
  5576. }
  5577. },
  5578. _setOption: function( key, value ) {
  5579. this._super( key, value );
  5580. if ( key === "disabled" ) {
  5581. if ( value ) {
  5582. this.element.prop( "disabled", true );
  5583. } else {
  5584. this.element.prop( "disabled", false );
  5585. }
  5586. return;
  5587. }
  5588. this._resetButton();
  5589. },
  5590. refresh: function() {
  5591. //See #8237 & #8828
  5592. var isDisabled = this.element.is( "input, button" ) ? this.element.is( ":disabled" ) : this.element.hasClass( "ui-button-disabled" );
  5593. if ( isDisabled !== this.options.disabled ) {
  5594. this._setOption( "disabled", isDisabled );
  5595. }
  5596. if ( this.type === "radio" ) {
  5597. radioGroup( this.element[0] ).each(function() {
  5598. if ( $( this ).is( ":checked" ) ) {
  5599. $( this ).button( "widget" )
  5600. .addClass( "ui-state-active" )
  5601. .attr( "aria-pressed", "true" );
  5602. } else {
  5603. $( this ).button( "widget" )
  5604. .removeClass( "ui-state-active" )
  5605. .attr( "aria-pressed", "false" );
  5606. }
  5607. });
  5608. } else if ( this.type === "checkbox" ) {
  5609. if ( this.element.is( ":checked" ) ) {
  5610. this.buttonElement
  5611. .addClass( "ui-state-active" )
  5612. .attr( "aria-pressed", "true" );
  5613. } else {
  5614. this.buttonElement
  5615. .removeClass( "ui-state-active" )
  5616. .attr( "aria-pressed", "false" );
  5617. }
  5618. }
  5619. },
  5620. _resetButton: function() {
  5621. if ( this.type === "input" ) {
  5622. if ( this.options.label ) {
  5623. this.element.val( this.options.label );
  5624. }
  5625. return;
  5626. }
  5627. var buttonElement = this.buttonElement.removeClass( typeClasses ),
  5628. buttonText = $( "<span></span>", this.document[0] )
  5629. .addClass( "ui-button-text" )
  5630. .html( this.options.label )
  5631. .appendTo( buttonElement.empty() )
  5632. .text(),
  5633. icons = this.options.icons,
  5634. multipleIcons = icons.primary && icons.secondary,
  5635. buttonClasses = [];
  5636. if ( icons.primary || icons.secondary ) {
  5637. if ( this.options.text ) {
  5638. buttonClasses.push( "ui-button-text-icon" + ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
  5639. }
  5640. if ( icons.primary ) {
  5641. buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" );
  5642. }
  5643. if ( icons.secondary ) {
  5644. buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" );
  5645. }
  5646. if ( !this.options.text ) {
  5647. buttonClasses.push( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" );
  5648. if ( !this.hasTitle ) {
  5649. buttonElement.attr( "title", $.trim( buttonText ) );
  5650. }
  5651. }
  5652. } else {
  5653. buttonClasses.push( "ui-button-text-only" );
  5654. }
  5655. buttonElement.addClass( buttonClasses.join( " " ) );
  5656. }
  5657. });
  5658. $.widget( "ui.buttonset", {
  5659. version: "1.10.0",
  5660. options: {
  5661. items: "button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(ui-button)"
  5662. },
  5663. _create: function() {
  5664. this.element.addClass( "ui-buttonset" );
  5665. },
  5666. _init: function() {
  5667. this.refresh();
  5668. },
  5669. _setOption: function( key, value ) {
  5670. if ( key === "disabled" ) {
  5671. this.buttons.button( "option", key, value );
  5672. }
  5673. this._super( key, value );
  5674. },
  5675. refresh: function() {
  5676. var rtl = this.element.css( "direction" ) === "rtl";
  5677. this.buttons = this.element.find( this.options.items )
  5678. .filter( ":ui-button" )
  5679. .button( "refresh" )
  5680. .end()
  5681. .not( ":ui-button" )
  5682. .button()
  5683. .end()
  5684. .map(function() {
  5685. return $( this ).button( "widget" )[ 0 ];
  5686. })
  5687. .removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
  5688. .filter( ":first" )
  5689. .addClass( rtl ? "ui-corner-right" : "ui-corner-left" )
  5690. .end()
  5691. .filter( ":last" )
  5692. .addClass( rtl ? "ui-corner-left" : "ui-corner-right" )
  5693. .end()
  5694. .end();
  5695. },
  5696. _destroy: function() {
  5697. this.element.removeClass( "ui-buttonset" );
  5698. this.buttons
  5699. .map(function() {
  5700. return $( this ).button( "widget" )[ 0 ];
  5701. })
  5702. .removeClass( "ui-corner-left ui-corner-right" )
  5703. .end()
  5704. .button( "destroy" );
  5705. }
  5706. });
  5707. }( jQuery ) );
  5708. (function( $, undefined ) {
  5709. $.extend($.ui, { datepicker: { version: "1.10.0" } });
  5710. var PROP_NAME = "datepicker",
  5711. dpuuid = new Date().getTime(),
  5712. instActive;
  5713. /* Date picker manager.
  5714. Use the singleton instance of this class, $.datepicker, to interact with the date picker.
  5715. Settings for (groups of) date pickers are maintained in an instance object,
  5716. allowing multiple different settings on the same page. */
  5717. function Datepicker() {
  5718. this._curInst = null; // The current instance in use
  5719. this._keyEvent = false; // If the last event was a key event
  5720. this._disabledInputs = []; // List of date picker inputs that have been disabled
  5721. this._datepickerShowing = false; // True if the popup picker is showing , false if not
  5722. this._inDialog = false; // True if showing within a "dialog", false if not
  5723. this._mainDivId = "ui-datepicker-div"; // The ID of the main datepicker division
  5724. this._inlineClass = "ui-datepicker-inline"; // The name of the inline marker class
  5725. this._appendClass = "ui-datepicker-append"; // The name of the append marker class
  5726. this._triggerClass = "ui-datepicker-trigger"; // The name of the trigger marker class
  5727. this._dialogClass = "ui-datepicker-dialog"; // The name of the dialog marker class
  5728. this._disableClass = "ui-datepicker-disabled"; // The name of the disabled covering marker class
  5729. this._unselectableClass = "ui-datepicker-unselectable"; // The name of the unselectable cell marker class
  5730. this._currentClass = "ui-datepicker-current-day"; // The name of the current day marker class
  5731. this._dayOverClass = "ui-datepicker-days-cell-over"; // The name of the day hover marker class
  5732. this.regional = []; // Available regional settings, indexed by language code
  5733. this.regional[""] = { // Default regional settings
  5734. closeText: "Done", // Display text for close link
  5735. prevText: "Prev", // Display text for previous month link
  5736. nextText: "Next", // Display text for next month link
  5737. currentText: "Today", // Display text for current month link
  5738. monthNames: ["January","February","March","April","May","June",
  5739. "July","August","September","October","November","December"], // Names of months for drop-down and formatting
  5740. monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], // For formatting
  5741. dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], // For formatting
  5742. dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], // For formatting
  5743. dayNamesMin: ["Su","Mo","Tu","We","Th","Fr","Sa"], // Column headings for days starting at Sunday
  5744. weekHeader: "Wk", // Column header for week of the year
  5745. dateFormat: "mm/dd/yy", // See format options on parseDate
  5746. firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
  5747. isRTL: false, // True if right-to-left language, false if left-to-right
  5748. showMonthAfterYear: false, // True if the year select precedes month, false for month then year
  5749. yearSuffix: "" // Additional text to append to the year in the month headers
  5750. };
  5751. this._defaults = { // Global defaults for all the date picker instances
  5752. showOn: "focus", // "focus" for popup on focus,
  5753. // "button" for trigger button, or "both" for either
  5754. showAnim: "fadeIn", // Name of jQuery animation for popup
  5755. showOptions: {}, // Options for enhanced animations
  5756. defaultDate: null, // Used when field is blank: actual date,
  5757. // +/-number for offset from today, null for today
  5758. appendText: "", // Display text following the input box, e.g. showing the format
  5759. buttonText: "...", // Text for trigger button
  5760. buttonImage: "", // URL for trigger button image
  5761. buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
  5762. hideIfNoPrevNext: false, // True to hide next/previous month links
  5763. // if not applicable, false to just disable them
  5764. navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
  5765. gotoCurrent: false, // True if today link goes back to current selection instead
  5766. changeMonth: false, // True if month can be selected directly, false if only prev/next
  5767. changeYear: false, // True if year can be selected directly, false if only prev/next
  5768. yearRange: "c-10:c+10", // Range of years to display in drop-down,
  5769. // either relative to today's year (-nn:+nn), relative to currently displayed year
  5770. // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
  5771. showOtherMonths: false, // True to show dates in other months, false to leave blank
  5772. selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
  5773. showWeek: false, // True to show week of the year, false to not show it
  5774. calculateWeek: this.iso8601Week, // How to calculate the week of the year,
  5775. // takes a Date and returns the number of the week for it
  5776. shortYearCutoff: "+10", // Short year values < this are in the current century,
  5777. // > this are in the previous century,
  5778. // string value starting with "+" for current year + value
  5779. minDate: null, // The earliest selectable date, or null for no limit
  5780. maxDate: null, // The latest selectable date, or null for no limit
  5781. duration: "fast", // Duration of display/closure
  5782. beforeShowDay: null, // Function that takes a date and returns an array with
  5783. // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "",
  5784. // [2] = cell title (optional), e.g. $.datepicker.noWeekends
  5785. beforeShow: null, // Function that takes an input field and
  5786. // returns a set of custom settings for the date picker
  5787. onSelect: null, // Define a callback function when a date is selected
  5788. onChangeMonthYear: null, // Define a callback function when the month or year is changed
  5789. onClose: null, // Define a callback function when the datepicker is closed
  5790. numberOfMonths: 1, // Number of months to show at a time
  5791. showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
  5792. stepMonths: 1, // Number of months to step back/forward
  5793. stepBigMonths: 12, // Number of months to step back/forward for the big links
  5794. altField: "", // Selector for an alternate field to store selected dates into
  5795. altFormat: "", // The date format to use for the alternate field
  5796. constrainInput: true, // The input is constrained by the current date format
  5797. showButtonPanel: false, // True to show button panel, false to not show it
  5798. autoSize: false, // True to size the input for the date format, false to leave as is
  5799. disabled: false // The initial disabled state
  5800. };
  5801. $.extend(this._defaults, this.regional[""]);
  5802. this.dpDiv = bindHover($("<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>"));
  5803. }
  5804. $.extend(Datepicker.prototype, {
  5805. /* Class name added to elements to indicate already configured with a date picker. */
  5806. markerClassName: "hasDatepicker",
  5807. //Keep track of the maximum number of rows displayed (see #7043)
  5808. maxRows: 4,
  5809. // TODO rename to "widget" when switching to widget factory
  5810. _widgetDatepicker: function() {
  5811. return this.dpDiv;
  5812. },
  5813. /* Override the default settings for all instances of the date picker.
  5814. * @param settings object - the new settings to use as defaults (anonymous object)
  5815. * @return the manager object
  5816. */
  5817. setDefaults: function(settings) {
  5818. extendRemove(this._defaults, settings || {});
  5819. return this;
  5820. },
  5821. /* Attach the date picker to a jQuery selection.
  5822. * @param target element - the target input field or division or span
  5823. * @param settings object - the new settings to use for this date picker instance (anonymous)
  5824. */
  5825. _attachDatepicker: function(target, settings) {
  5826. var nodeName, inline, inst;
  5827. nodeName = target.nodeName.toLowerCase();
  5828. inline = (nodeName === "div" || nodeName === "span");
  5829. if (!target.id) {
  5830. this.uuid += 1;
  5831. target.id = "dp" + this.uuid;
  5832. }
  5833. inst = this._newInst($(target), inline);
  5834. inst.settings = $.extend({}, settings || {});
  5835. if (nodeName === "input") {
  5836. this._connectDatepicker(target, inst);
  5837. } else if (inline) {
  5838. this._inlineDatepicker(target, inst);
  5839. }
  5840. },
  5841. /* Create a new instance object. */
  5842. _newInst: function(target, inline) {
  5843. var id = target[0].id.replace(/([^A-Za-z0-9_\-])/g, "\\\\$1"); // escape jQuery meta chars
  5844. return {id: id, input: target, // associated target
  5845. selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
  5846. drawMonth: 0, drawYear: 0, // month being drawn
  5847. inline: inline, // is datepicker inline or not
  5848. dpDiv: (!inline ? this.dpDiv : // presentation div
  5849. bindHover($("<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>")))};
  5850. },
  5851. /* Attach the date picker to an input field. */
  5852. _connectDatepicker: function(target, inst) {
  5853. var input = $(target);
  5854. inst.append = $([]);
  5855. inst.trigger = $([]);
  5856. if (input.hasClass(this.markerClassName)) {
  5857. return;
  5858. }
  5859. this._attachments(input, inst);
  5860. input.addClass(this.markerClassName).keydown(this._doKeyDown).
  5861. keypress(this._doKeyPress).keyup(this._doKeyUp);
  5862. this._autoSize(inst);
  5863. $.data(target, PROP_NAME, inst);
  5864. //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
  5865. if( inst.settings.disabled ) {
  5866. this._disableDatepicker( target );
  5867. }
  5868. },
  5869. /* Make attachments based on settings. */
  5870. _attachments: function(input, inst) {
  5871. var showOn, buttonText, buttonImage,
  5872. appendText = this._get(inst, "appendText"),
  5873. isRTL = this._get(inst, "isRTL");
  5874. if (inst.append) {
  5875. inst.append.remove();
  5876. }
  5877. if (appendText) {
  5878. inst.append = $("<span class='" + this._appendClass + "'>" + appendText + "</span>");
  5879. input[isRTL ? "before" : "after"](inst.append);
  5880. }
  5881. input.unbind("focus", this._showDatepicker);
  5882. if (inst.trigger) {
  5883. inst.trigger.remove();
  5884. }
  5885. showOn = this._get(inst, "showOn");
  5886. if (showOn === "focus" || showOn === "both") { // pop-up date picker when in the marked field
  5887. input.focus(this._showDatepicker);
  5888. }
  5889. if (showOn === "button" || showOn === "both") { // pop-up date picker when button clicked
  5890. buttonText = this._get(inst, "buttonText");
  5891. buttonImage = this._get(inst, "buttonImage");
  5892. inst.trigger = $(this._get(inst, "buttonImageOnly") ?
  5893. $("<img/>").addClass(this._triggerClass).
  5894. attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
  5895. $("<button type='button'></button>").addClass(this._triggerClass).
  5896. html(!buttonImage ? buttonText : $("<img/>").attr(
  5897. { src:buttonImage, alt:buttonText, title:buttonText })));
  5898. input[isRTL ? "before" : "after"](inst.trigger);
  5899. inst.trigger.click(function() {
  5900. if ($.datepicker._datepickerShowing && $.datepicker._lastInput === input[0]) {
  5901. $.datepicker._hideDatepicker();
  5902. } else if ($.datepicker._datepickerShowing && $.datepicker._lastInput !== input[0]) {
  5903. $.datepicker._hideDatepicker();
  5904. $.datepicker._showDatepicker(input[0]);
  5905. } else {
  5906. $.datepicker._showDatepicker(input[0]);
  5907. }
  5908. return false;
  5909. });
  5910. }
  5911. },
  5912. /* Apply the maximum length for the date format. */
  5913. _autoSize: function(inst) {
  5914. if (this._get(inst, "autoSize") && !inst.inline) {
  5915. var findMax, max, maxI, i,
  5916. date = new Date(2009, 12 - 1, 20), // Ensure double digits
  5917. dateFormat = this._get(inst, "dateFormat");
  5918. if (dateFormat.match(/[DM]/)) {
  5919. findMax = function(names) {
  5920. max = 0;
  5921. maxI = 0;
  5922. for (i = 0; i < names.length; i++) {
  5923. if (names[i].length > max) {
  5924. max = names[i].length;
  5925. maxI = i;
  5926. }
  5927. }
  5928. return maxI;
  5929. };
  5930. date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ?
  5931. "monthNames" : "monthNamesShort"))));
  5932. date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ?
  5933. "dayNames" : "dayNamesShort"))) + 20 - date.getDay());
  5934. }
  5935. inst.input.attr("size", this._formatDate(inst, date).length);
  5936. }
  5937. },
  5938. /* Attach an inline date picker to a div. */
  5939. _inlineDatepicker: function(target, inst) {
  5940. var divSpan = $(target);
  5941. if (divSpan.hasClass(this.markerClassName)) {
  5942. return;
  5943. }
  5944. divSpan.addClass(this.markerClassName).append(inst.dpDiv);
  5945. $.data(target, PROP_NAME, inst);
  5946. this._setDate(inst, this._getDefaultDate(inst), true);
  5947. this._updateDatepicker(inst);
  5948. this._updateAlternate(inst);
  5949. //If disabled option is true, disable the datepicker before showing it (see ticket #5665)
  5950. if( inst.settings.disabled ) {
  5951. this._disableDatepicker( target );
  5952. }
  5953. // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
  5954. // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
  5955. inst.dpDiv.css( "display", "block" );
  5956. },
  5957. /* Pop-up the date picker in a "dialog" box.
  5958. * @param input element - ignored
  5959. * @param date string or Date - the initial date to display
  5960. * @param onSelect function - the function to call when a date is selected
  5961. * @param settings object - update the dialog date picker instance's settings (anonymous object)
  5962. * @param pos int[2] - coordinates for the dialog's position within the screen or
  5963. * event - with x/y coordinates or
  5964. * leave empty for default (screen centre)
  5965. * @return the manager object
  5966. */
  5967. _dialogDatepicker: function(input, date, onSelect, settings, pos) {
  5968. var id, browserWidth, browserHeight, scrollX, scrollY,
  5969. inst = this._dialogInst; // internal instance
  5970. if (!inst) {
  5971. this.uuid += 1;
  5972. id = "dp" + this.uuid;
  5973. this._dialogInput = $("<input type='text' id='" + id +
  5974. "' style='position: absolute; top: -100px; width: 0px;'/>");
  5975. this._dialogInput.keydown(this._doKeyDown);
  5976. $("body").append(this._dialogInput);
  5977. inst = this._dialogInst = this._newInst(this._dialogInput, false);
  5978. inst.settings = {};
  5979. $.data(this._dialogInput[0], PROP_NAME, inst);
  5980. }
  5981. extendRemove(inst.settings, settings || {});
  5982. date = (date && date.constructor === Date ? this._formatDate(inst, date) : date);
  5983. this._dialogInput.val(date);
  5984. this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
  5985. if (!this._pos) {
  5986. browserWidth = document.documentElement.clientWidth;
  5987. browserHeight = document.documentElement.clientHeight;
  5988. scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
  5989. scrollY = document.documentElement.scrollTop || document.body.scrollTop;
  5990. this._pos = // should use actual width/height below
  5991. [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
  5992. }
  5993. // move input on screen for focus, but hidden behind dialog
  5994. this._dialogInput.css("left", (this._pos[0] + 20) + "px").css("top", this._pos[1] + "px");
  5995. inst.settings.onSelect = onSelect;
  5996. this._inDialog = true;
  5997. this.dpDiv.addClass(this._dialogClass);
  5998. this._showDatepicker(this._dialogInput[0]);
  5999. if ($.blockUI) {
  6000. $.blockUI(this.dpDiv);
  6001. }
  6002. $.data(this._dialogInput[0], PROP_NAME, inst);
  6003. return this;
  6004. },
  6005. /* Detach a datepicker from its control.
  6006. * @param target element - the target input field or division or span
  6007. */
  6008. _destroyDatepicker: function(target) {
  6009. var nodeName,
  6010. $target = $(target),
  6011. inst = $.data(target, PROP_NAME);
  6012. if (!$target.hasClass(this.markerClassName)) {
  6013. return;
  6014. }
  6015. nodeName = target.nodeName.toLowerCase();
  6016. $.removeData(target, PROP_NAME);
  6017. if (nodeName === "input") {
  6018. inst.append.remove();
  6019. inst.trigger.remove();
  6020. $target.removeClass(this.markerClassName).
  6021. unbind("focus", this._showDatepicker).
  6022. unbind("keydown", this._doKeyDown).
  6023. unbind("keypress", this._doKeyPress).
  6024. unbind("keyup", this._doKeyUp);
  6025. } else if (nodeName === "div" || nodeName === "span") {
  6026. $target.removeClass(this.markerClassName).empty();
  6027. }
  6028. },
  6029. /* Enable the date picker to a jQuery selection.
  6030. * @param target element - the target input field or division or span
  6031. */
  6032. _enableDatepicker: function(target) {
  6033. var nodeName, inline,
  6034. $target = $(target),
  6035. inst = $.data(target, PROP_NAME);
  6036. if (!$target.hasClass(this.markerClassName)) {
  6037. return;
  6038. }
  6039. nodeName = target.nodeName.toLowerCase();
  6040. if (nodeName === "input") {
  6041. target.disabled = false;
  6042. inst.trigger.filter("button").
  6043. each(function() { this.disabled = false; }).end().
  6044. filter("img").css({opacity: "1.0", cursor: ""});
  6045. } else if (nodeName === "div" || nodeName === "span") {
  6046. inline = $target.children("." + this._inlineClass);
  6047. inline.children().removeClass("ui-state-disabled");
  6048. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  6049. prop("disabled", false);
  6050. }
  6051. this._disabledInputs = $.map(this._disabledInputs,
  6052. function(value) { return (value === target ? null : value); }); // delete entry
  6053. },
  6054. /* Disable the date picker to a jQuery selection.
  6055. * @param target element - the target input field or division or span
  6056. */
  6057. _disableDatepicker: function(target) {
  6058. var nodeName, inline,
  6059. $target = $(target),
  6060. inst = $.data(target, PROP_NAME);
  6061. if (!$target.hasClass(this.markerClassName)) {
  6062. return;
  6063. }
  6064. nodeName = target.nodeName.toLowerCase();
  6065. if (nodeName === "input") {
  6066. target.disabled = true;
  6067. inst.trigger.filter("button").
  6068. each(function() { this.disabled = true; }).end().
  6069. filter("img").css({opacity: "0.5", cursor: "default"});
  6070. } else if (nodeName === "div" || nodeName === "span") {
  6071. inline = $target.children("." + this._inlineClass);
  6072. inline.children().addClass("ui-state-disabled");
  6073. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  6074. prop("disabled", true);
  6075. }
  6076. this._disabledInputs = $.map(this._disabledInputs,
  6077. function(value) { return (value === target ? null : value); }); // delete entry
  6078. this._disabledInputs[this._disabledInputs.length] = target;
  6079. },
  6080. /* Is the first field in a jQuery collection disabled as a datepicker?
  6081. * @param target element - the target input field or division or span
  6082. * @return boolean - true if disabled, false if enabled
  6083. */
  6084. _isDisabledDatepicker: function(target) {
  6085. if (!target) {
  6086. return false;
  6087. }
  6088. for (var i = 0; i < this._disabledInputs.length; i++) {
  6089. if (this._disabledInputs[i] === target) {
  6090. return true;
  6091. }
  6092. }
  6093. return false;
  6094. },
  6095. /* Retrieve the instance data for the target control.
  6096. * @param target element - the target input field or division or span
  6097. * @return object - the associated instance data
  6098. * @throws error if a jQuery problem getting data
  6099. */
  6100. _getInst: function(target) {
  6101. try {
  6102. return $.data(target, PROP_NAME);
  6103. }
  6104. catch (err) {
  6105. throw "Missing instance data for this datepicker";
  6106. }
  6107. },
  6108. /* Update or retrieve the settings for a date picker attached to an input field or division.
  6109. * @param target element - the target input field or division or span
  6110. * @param name object - the new settings to update or
  6111. * string - the name of the setting to change or retrieve,
  6112. * when retrieving also "all" for all instance settings or
  6113. * "defaults" for all global defaults
  6114. * @param value any - the new value for the setting
  6115. * (omit if above is an object or to retrieve a value)
  6116. */
  6117. _optionDatepicker: function(target, name, value) {
  6118. var settings, date, minDate, maxDate,
  6119. inst = this._getInst(target);
  6120. if (arguments.length === 2 && typeof name === "string") {
  6121. return (name === "defaults" ? $.extend({}, $.datepicker._defaults) :
  6122. (inst ? (name === "all" ? $.extend({}, inst.settings) :
  6123. this._get(inst, name)) : null));
  6124. }
  6125. settings = name || {};
  6126. if (typeof name === "string") {
  6127. settings = {};
  6128. settings[name] = value;
  6129. }
  6130. if (inst) {
  6131. if (this._curInst === inst) {
  6132. this._hideDatepicker();
  6133. }
  6134. date = this._getDateDatepicker(target, true);
  6135. minDate = this._getMinMaxDate(inst, "min");
  6136. maxDate = this._getMinMaxDate(inst, "max");
  6137. extendRemove(inst.settings, settings);
  6138. // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
  6139. if (minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined) {
  6140. inst.settings.minDate = this._formatDate(inst, minDate);
  6141. }
  6142. if (maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined) {
  6143. inst.settings.maxDate = this._formatDate(inst, maxDate);
  6144. }
  6145. if ( "disabled" in settings ) {
  6146. if ( settings.disabled ) {
  6147. this._disableDatepicker(target);
  6148. } else {
  6149. this._enableDatepicker(target);
  6150. }
  6151. }
  6152. this._attachments($(target), inst);
  6153. this._autoSize(inst);
  6154. this._setDate(inst, date);
  6155. this._updateAlternate(inst);
  6156. this._updateDatepicker(inst);
  6157. }
  6158. },
  6159. // change method deprecated
  6160. _changeDatepicker: function(target, name, value) {
  6161. this._optionDatepicker(target, name, value);
  6162. },
  6163. /* Redraw the date picker attached to an input field or division.
  6164. * @param target element - the target input field or division or span
  6165. */
  6166. _refreshDatepicker: function(target) {
  6167. var inst = this._getInst(target);
  6168. if (inst) {
  6169. this._updateDatepicker(inst);
  6170. }
  6171. },
  6172. /* Set the dates for a jQuery selection.
  6173. * @param target element - the target input field or division or span
  6174. * @param date Date - the new date
  6175. */
  6176. _setDateDatepicker: function(target, date) {
  6177. var inst = this._getInst(target);
  6178. if (inst) {
  6179. this._setDate(inst, date);
  6180. this._updateDatepicker(inst);
  6181. this._updateAlternate(inst);
  6182. }
  6183. },
  6184. /* Get the date(s) for the first entry in a jQuery selection.
  6185. * @param target element - the target input field or division or span
  6186. * @param noDefault boolean - true if no default date is to be used
  6187. * @return Date - the current date
  6188. */
  6189. _getDateDatepicker: function(target, noDefault) {
  6190. var inst = this._getInst(target);
  6191. if (inst && !inst.inline) {
  6192. this._setDateFromField(inst, noDefault);
  6193. }
  6194. return (inst ? this._getDate(inst) : null);
  6195. },
  6196. /* Handle keystrokes. */
  6197. _doKeyDown: function(event) {
  6198. var onSelect, dateStr, sel,
  6199. inst = $.datepicker._getInst(event.target),
  6200. handled = true,
  6201. isRTL = inst.dpDiv.is(".ui-datepicker-rtl");
  6202. inst._keyEvent = true;
  6203. if ($.datepicker._datepickerShowing) {
  6204. switch (event.keyCode) {
  6205. case 9: $.datepicker._hideDatepicker();
  6206. handled = false;
  6207. break; // hide on tab out
  6208. case 13: sel = $("td." + $.datepicker._dayOverClass + ":not(." +
  6209. $.datepicker._currentClass + ")", inst.dpDiv);
  6210. if (sel[0]) {
  6211. $.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
  6212. }
  6213. onSelect = $.datepicker._get(inst, "onSelect");
  6214. if (onSelect) {
  6215. dateStr = $.datepicker._formatDate(inst);
  6216. // trigger custom callback
  6217. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);
  6218. } else {
  6219. $.datepicker._hideDatepicker();
  6220. }
  6221. return false; // don't submit the form
  6222. case 27: $.datepicker._hideDatepicker();
  6223. break; // hide on escape
  6224. case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6225. -$.datepicker._get(inst, "stepBigMonths") :
  6226. -$.datepicker._get(inst, "stepMonths")), "M");
  6227. break; // previous month/year on page up/+ ctrl
  6228. case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6229. +$.datepicker._get(inst, "stepBigMonths") :
  6230. +$.datepicker._get(inst, "stepMonths")), "M");
  6231. break; // next month/year on page down/+ ctrl
  6232. case 35: if (event.ctrlKey || event.metaKey) {
  6233. $.datepicker._clearDate(event.target);
  6234. }
  6235. handled = event.ctrlKey || event.metaKey;
  6236. break; // clear on ctrl or command +end
  6237. case 36: if (event.ctrlKey || event.metaKey) {
  6238. $.datepicker._gotoToday(event.target);
  6239. }
  6240. handled = event.ctrlKey || event.metaKey;
  6241. break; // current on ctrl or command +home
  6242. case 37: if (event.ctrlKey || event.metaKey) {
  6243. $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), "D");
  6244. }
  6245. handled = event.ctrlKey || event.metaKey;
  6246. // -1 day on ctrl or command +left
  6247. if (event.originalEvent.altKey) {
  6248. $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6249. -$.datepicker._get(inst, "stepBigMonths") :
  6250. -$.datepicker._get(inst, "stepMonths")), "M");
  6251. }
  6252. // next month/year on alt +left on Mac
  6253. break;
  6254. case 38: if (event.ctrlKey || event.metaKey) {
  6255. $.datepicker._adjustDate(event.target, -7, "D");
  6256. }
  6257. handled = event.ctrlKey || event.metaKey;
  6258. break; // -1 week on ctrl or command +up
  6259. case 39: if (event.ctrlKey || event.metaKey) {
  6260. $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), "D");
  6261. }
  6262. handled = event.ctrlKey || event.metaKey;
  6263. // +1 day on ctrl or command +right
  6264. if (event.originalEvent.altKey) {
  6265. $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6266. +$.datepicker._get(inst, "stepBigMonths") :
  6267. +$.datepicker._get(inst, "stepMonths")), "M");
  6268. }
  6269. // next month/year on alt +right
  6270. break;
  6271. case 40: if (event.ctrlKey || event.metaKey) {
  6272. $.datepicker._adjustDate(event.target, +7, "D");
  6273. }
  6274. handled = event.ctrlKey || event.metaKey;
  6275. break; // +1 week on ctrl or command +down
  6276. default: handled = false;
  6277. }
  6278. } else if (event.keyCode === 36 && event.ctrlKey) { // display the date picker on ctrl+home
  6279. $.datepicker._showDatepicker(this);
  6280. } else {
  6281. handled = false;
  6282. }
  6283. if (handled) {
  6284. event.preventDefault();
  6285. event.stopPropagation();
  6286. }
  6287. },
  6288. /* Filter entered characters - based on date format. */
  6289. _doKeyPress: function(event) {
  6290. var chars, chr,
  6291. inst = $.datepicker._getInst(event.target);
  6292. if ($.datepicker._get(inst, "constrainInput")) {
  6293. chars = $.datepicker._possibleChars($.datepicker._get(inst, "dateFormat"));
  6294. chr = String.fromCharCode(event.charCode == null ? event.keyCode : event.charCode);
  6295. return event.ctrlKey || event.metaKey || (chr < " " || !chars || chars.indexOf(chr) > -1);
  6296. }
  6297. },
  6298. /* Synchronise manual entry and field/alternate field. */
  6299. _doKeyUp: function(event) {
  6300. var date,
  6301. inst = $.datepicker._getInst(event.target);
  6302. if (inst.input.val() !== inst.lastVal) {
  6303. try {
  6304. date = $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
  6305. (inst.input ? inst.input.val() : null),
  6306. $.datepicker._getFormatConfig(inst));
  6307. if (date) { // only if valid
  6308. $.datepicker._setDateFromField(inst);
  6309. $.datepicker._updateAlternate(inst);
  6310. $.datepicker._updateDatepicker(inst);
  6311. }
  6312. }
  6313. catch (err) {
  6314. }
  6315. }
  6316. return true;
  6317. },
  6318. /* Pop-up the date picker for a given input field.
  6319. * If false returned from beforeShow event handler do not show.
  6320. * @param input element - the input field attached to the date picker or
  6321. * event - if triggered by focus
  6322. */
  6323. _showDatepicker: function(input) {
  6324. input = input.target || input;
  6325. if (input.nodeName.toLowerCase() !== "input") { // find from button/image trigger
  6326. input = $("input", input.parentNode)[0];
  6327. }
  6328. if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput === input) { // already here
  6329. return;
  6330. }
  6331. var inst, beforeShow, beforeShowSettings, isFixed,
  6332. offset, showAnim, duration;
  6333. inst = $.datepicker._getInst(input);
  6334. if ($.datepicker._curInst && $.datepicker._curInst !== inst) {
  6335. $.datepicker._curInst.dpDiv.stop(true, true);
  6336. if ( inst && $.datepicker._datepickerShowing ) {
  6337. $.datepicker._hideDatepicker( $.datepicker._curInst.input[0] );
  6338. }
  6339. }
  6340. beforeShow = $.datepicker._get(inst, "beforeShow");
  6341. beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {};
  6342. if(beforeShowSettings === false){
  6343. return;
  6344. }
  6345. extendRemove(inst.settings, beforeShowSettings);
  6346. inst.lastVal = null;
  6347. $.datepicker._lastInput = input;
  6348. $.datepicker._setDateFromField(inst);
  6349. if ($.datepicker._inDialog) { // hide cursor
  6350. input.value = "";
  6351. }
  6352. if (!$.datepicker._pos) { // position below input
  6353. $.datepicker._pos = $.datepicker._findPos(input);
  6354. $.datepicker._pos[1] += input.offsetHeight; // add the height
  6355. }
  6356. isFixed = false;
  6357. $(input).parents().each(function() {
  6358. isFixed |= $(this).css("position") === "fixed";
  6359. return !isFixed;
  6360. });
  6361. offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
  6362. $.datepicker._pos = null;
  6363. //to avoid flashes on Firefox
  6364. inst.dpDiv.empty();
  6365. // determine sizing offscreen
  6366. inst.dpDiv.css({position: "absolute", display: "block", top: "-1000px"});
  6367. $.datepicker._updateDatepicker(inst);
  6368. // fix width for dynamic number of date pickers
  6369. // and adjust position before showing
  6370. offset = $.datepicker._checkOffset(inst, offset, isFixed);
  6371. inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ?
  6372. "static" : (isFixed ? "fixed" : "absolute")), display: "none",
  6373. left: offset.left + "px", top: offset.top + "px"});
  6374. if (!inst.inline) {
  6375. showAnim = $.datepicker._get(inst, "showAnim");
  6376. duration = $.datepicker._get(inst, "duration");
  6377. inst.dpDiv.zIndex($(input).zIndex()+1);
  6378. $.datepicker._datepickerShowing = true;
  6379. if ( $.effects && $.effects.effect[ showAnim ] ) {
  6380. inst.dpDiv.show(showAnim, $.datepicker._get(inst, "showOptions"), duration);
  6381. } else {
  6382. inst.dpDiv[showAnim || "show"](showAnim ? duration : null);
  6383. }
  6384. if (inst.input.is(":visible") && !inst.input.is(":disabled")) {
  6385. inst.input.focus();
  6386. }
  6387. $.datepicker._curInst = inst;
  6388. }
  6389. },
  6390. /* Generate the date picker content. */
  6391. _updateDatepicker: function(inst) {
  6392. this.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
  6393. instActive = inst; // for delegate hover events
  6394. inst.dpDiv.empty().append(this._generateHTML(inst));
  6395. this._attachHandlers(inst);
  6396. inst.dpDiv.find("." + this._dayOverClass + " a").mouseover();
  6397. var origyearshtml,
  6398. numMonths = this._getNumberOfMonths(inst),
  6399. cols = numMonths[1],
  6400. width = 17;
  6401. inst.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width("");
  6402. if (cols > 1) {
  6403. inst.dpDiv.addClass("ui-datepicker-multi-" + cols).css("width", (width * cols) + "em");
  6404. }
  6405. inst.dpDiv[(numMonths[0] !== 1 || numMonths[1] !== 1 ? "add" : "remove") +
  6406. "Class"]("ui-datepicker-multi");
  6407. inst.dpDiv[(this._get(inst, "isRTL") ? "add" : "remove") +
  6408. "Class"]("ui-datepicker-rtl");
  6409. // #6694 - don't focus the input if it's already focused
  6410. // this breaks the change event in IE
  6411. if (inst === $.datepicker._curInst && $.datepicker._datepickerShowing && inst.input &&
  6412. inst.input.is(":visible") && !inst.input.is(":disabled") && inst.input[0] !== document.activeElement) {
  6413. inst.input.focus();
  6414. }
  6415. // deffered render of the years select (to avoid flashes on Firefox)
  6416. if( inst.yearshtml ){
  6417. origyearshtml = inst.yearshtml;
  6418. setTimeout(function(){
  6419. //assure that inst.yearshtml didn't change.
  6420. if( origyearshtml === inst.yearshtml && inst.yearshtml ){
  6421. inst.dpDiv.find("select.ui-datepicker-year:first").replaceWith(inst.yearshtml);
  6422. }
  6423. origyearshtml = inst.yearshtml = null;
  6424. }, 0);
  6425. }
  6426. },
  6427. /* Retrieve the size of left and top borders for an element.
  6428. * @param elem (jQuery object) the element of interest
  6429. * @return (number[2]) the left and top borders
  6430. */
  6431. _getBorders: function(elem) {
  6432. var convert = function(value) {
  6433. return {thin: 1, medium: 2, thick: 3}[value] || value;
  6434. };
  6435. return [parseFloat(convert(elem.css("border-left-width"))),
  6436. parseFloat(convert(elem.css("border-top-width")))];
  6437. },
  6438. /* Check positioning to remain on screen. */
  6439. _checkOffset: function(inst, offset, isFixed) {
  6440. var dpWidth = inst.dpDiv.outerWidth(),
  6441. dpHeight = inst.dpDiv.outerHeight(),
  6442. inputWidth = inst.input ? inst.input.outerWidth() : 0,
  6443. inputHeight = inst.input ? inst.input.outerHeight() : 0,
  6444. viewWidth = document.documentElement.clientWidth + (isFixed ? 0 : $(document).scrollLeft()),
  6445. viewHeight = document.documentElement.clientHeight + (isFixed ? 0 : $(document).scrollTop());
  6446. offset.left -= (this._get(inst, "isRTL") ? (dpWidth - inputWidth) : 0);
  6447. offset.left -= (isFixed && offset.left === inst.input.offset().left) ? $(document).scrollLeft() : 0;
  6448. offset.top -= (isFixed && offset.top === (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
  6449. // now check if datepicker is showing outside window viewport - move to a better place if so.
  6450. offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
  6451. Math.abs(offset.left + dpWidth - viewWidth) : 0);
  6452. offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
  6453. Math.abs(dpHeight + inputHeight) : 0);
  6454. return offset;
  6455. },
  6456. /* Find an object's position on the screen. */
  6457. _findPos: function(obj) {
  6458. var position,
  6459. inst = this._getInst(obj),
  6460. isRTL = this._get(inst, "isRTL");
  6461. while (obj && (obj.type === "hidden" || obj.nodeType !== 1 || $.expr.filters.hidden(obj))) {
  6462. obj = obj[isRTL ? "previousSibling" : "nextSibling"];
  6463. }
  6464. position = $(obj).offset();
  6465. return [position.left, position.top];
  6466. },
  6467. /* Hide the date picker from view.
  6468. * @param input element - the input field attached to the date picker
  6469. */
  6470. _hideDatepicker: function(input) {
  6471. var showAnim, duration, postProcess, onClose,
  6472. inst = this._curInst;
  6473. if (!inst || (input && inst !== $.data(input, PROP_NAME))) {
  6474. return;
  6475. }
  6476. if (this._datepickerShowing) {
  6477. showAnim = this._get(inst, "showAnim");
  6478. duration = this._get(inst, "duration");
  6479. postProcess = function() {
  6480. $.datepicker._tidyDialog(inst);
  6481. };
  6482. // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
  6483. if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) {
  6484. inst.dpDiv.hide(showAnim, $.datepicker._get(inst, "showOptions"), duration, postProcess);
  6485. } else {
  6486. inst.dpDiv[(showAnim === "slideDown" ? "slideUp" :
  6487. (showAnim === "fadeIn" ? "fadeOut" : "hide"))]((showAnim ? duration : null), postProcess);
  6488. }
  6489. if (!showAnim) {
  6490. postProcess();
  6491. }
  6492. this._datepickerShowing = false;
  6493. onClose = this._get(inst, "onClose");
  6494. if (onClose) {
  6495. onClose.apply((inst.input ? inst.input[0] : null), [(inst.input ? inst.input.val() : ""), inst]);
  6496. }
  6497. this._lastInput = null;
  6498. if (this._inDialog) {
  6499. this._dialogInput.css({ position: "absolute", left: "0", top: "-100px" });
  6500. if ($.blockUI) {
  6501. $.unblockUI();
  6502. $("body").append(this.dpDiv);
  6503. }
  6504. }
  6505. this._inDialog = false;
  6506. }
  6507. },
  6508. /* Tidy up after a dialog display. */
  6509. _tidyDialog: function(inst) {
  6510. inst.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar");
  6511. },
  6512. /* Close date picker if clicked elsewhere. */
  6513. _checkExternalClick: function(event) {
  6514. if (!$.datepicker._curInst) {
  6515. return;
  6516. }
  6517. var $target = $(event.target),
  6518. inst = $.datepicker._getInst($target[0]);
  6519. if ( ( ( $target[0].id !== $.datepicker._mainDivId &&
  6520. $target.parents("#" + $.datepicker._mainDivId).length === 0 &&
  6521. !$target.hasClass($.datepicker.markerClassName) &&
  6522. !$target.closest("." + $.datepicker._triggerClass).length &&
  6523. $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) ||
  6524. ( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst !== inst ) ) {
  6525. $.datepicker._hideDatepicker();
  6526. }
  6527. },
  6528. /* Adjust one of the date sub-fields. */
  6529. _adjustDate: function(id, offset, period) {
  6530. var target = $(id),
  6531. inst = this._getInst(target[0]);
  6532. if (this._isDisabledDatepicker(target[0])) {
  6533. return;
  6534. }
  6535. this._adjustInstDate(inst, offset +
  6536. (period === "M" ? this._get(inst, "showCurrentAtPos") : 0), // undo positioning
  6537. period);
  6538. this._updateDatepicker(inst);
  6539. },
  6540. /* Action for current link. */
  6541. _gotoToday: function(id) {
  6542. var date,
  6543. target = $(id),
  6544. inst = this._getInst(target[0]);
  6545. if (this._get(inst, "gotoCurrent") && inst.currentDay) {
  6546. inst.selectedDay = inst.currentDay;
  6547. inst.drawMonth = inst.selectedMonth = inst.currentMonth;
  6548. inst.drawYear = inst.selectedYear = inst.currentYear;
  6549. } else {
  6550. date = new Date();
  6551. inst.selectedDay = date.getDate();
  6552. inst.drawMonth = inst.selectedMonth = date.getMonth();
  6553. inst.drawYear = inst.selectedYear = date.getFullYear();
  6554. }
  6555. this._notifyChange(inst);
  6556. this._adjustDate(target);
  6557. },
  6558. /* Action for selecting a new month/year. */
  6559. _selectMonthYear: function(id, select, period) {
  6560. var target = $(id),
  6561. inst = this._getInst(target[0]);
  6562. inst["selected" + (period === "M" ? "Month" : "Year")] =
  6563. inst["draw" + (period === "M" ? "Month" : "Year")] =
  6564. parseInt(select.options[select.selectedIndex].value,10);
  6565. this._notifyChange(inst);
  6566. this._adjustDate(target);
  6567. },
  6568. /* Action for selecting a day. */
  6569. _selectDay: function(id, month, year, td) {
  6570. var inst,
  6571. target = $(id);
  6572. if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) {
  6573. return;
  6574. }
  6575. inst = this._getInst(target[0]);
  6576. inst.selectedDay = inst.currentDay = $("a", td).html();
  6577. inst.selectedMonth = inst.currentMonth = month;
  6578. inst.selectedYear = inst.currentYear = year;
  6579. this._selectDate(id, this._formatDate(inst,
  6580. inst.currentDay, inst.currentMonth, inst.currentYear));
  6581. },
  6582. /* Erase the input field and hide the date picker. */
  6583. _clearDate: function(id) {
  6584. var target = $(id);
  6585. this._selectDate(target, "");
  6586. },
  6587. /* Update the input field with the selected date. */
  6588. _selectDate: function(id, dateStr) {
  6589. var onSelect,
  6590. target = $(id),
  6591. inst = this._getInst(target[0]);
  6592. dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
  6593. if (inst.input) {
  6594. inst.input.val(dateStr);
  6595. }
  6596. this._updateAlternate(inst);
  6597. onSelect = this._get(inst, "onSelect");
  6598. if (onSelect) {
  6599. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback
  6600. } else if (inst.input) {
  6601. inst.input.trigger("change"); // fire the change event
  6602. }
  6603. if (inst.inline){
  6604. this._updateDatepicker(inst);
  6605. } else {
  6606. this._hideDatepicker();
  6607. this._lastInput = inst.input[0];
  6608. if (typeof(inst.input[0]) !== "object") {
  6609. inst.input.focus(); // restore focus
  6610. }
  6611. this._lastInput = null;
  6612. }
  6613. },
  6614. /* Update any alternate field to synchronise with the main field. */
  6615. _updateAlternate: function(inst) {
  6616. var altFormat, date, dateStr,
  6617. altField = this._get(inst, "altField");
  6618. if (altField) { // update alternate field too
  6619. altFormat = this._get(inst, "altFormat") || this._get(inst, "dateFormat");
  6620. date = this._getDate(inst);
  6621. dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
  6622. $(altField).each(function() { $(this).val(dateStr); });
  6623. }
  6624. },
  6625. /* Set as beforeShowDay function to prevent selection of weekends.
  6626. * @param date Date - the date to customise
  6627. * @return [boolean, string] - is this date selectable?, what is its CSS class?
  6628. */
  6629. noWeekends: function(date) {
  6630. var day = date.getDay();
  6631. return [(day > 0 && day < 6), ""];
  6632. },
  6633. /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
  6634. * @param date Date - the date to get the week for
  6635. * @return number - the number of the week within the year that contains this date
  6636. */
  6637. iso8601Week: function(date) {
  6638. var time,
  6639. checkDate = new Date(date.getTime());
  6640. // Find Thursday of this week starting on Monday
  6641. checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
  6642. time = checkDate.getTime();
  6643. checkDate.setMonth(0); // Compare with Jan 1
  6644. checkDate.setDate(1);
  6645. return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
  6646. },
  6647. /* Parse a string value into a date object.
  6648. * See formatDate below for the possible formats.
  6649. *
  6650. * @param format string - the expected format of the date
  6651. * @param value string - the date in the above format
  6652. * @param settings Object - attributes include:
  6653. * shortYearCutoff number - the cutoff year for determining the century (optional)
  6654. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  6655. * dayNames string[7] - names of the days from Sunday (optional)
  6656. * monthNamesShort string[12] - abbreviated names of the months (optional)
  6657. * monthNames string[12] - names of the months (optional)
  6658. * @return Date - the extracted date value or null if value is blank
  6659. */
  6660. parseDate: function (format, value, settings) {
  6661. if (format == null || value == null) {
  6662. throw "Invalid arguments";
  6663. }
  6664. value = (typeof value === "object" ? value.toString() : value + "");
  6665. if (value === "") {
  6666. return null;
  6667. }
  6668. var iFormat, dim, extra,
  6669. iValue = 0,
  6670. shortYearCutoffTemp = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff,
  6671. shortYearCutoff = (typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp :
  6672. new Date().getFullYear() % 100 + parseInt(shortYearCutoffTemp, 10)),
  6673. dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
  6674. dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
  6675. monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
  6676. monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
  6677. year = -1,
  6678. month = -1,
  6679. day = -1,
  6680. doy = -1,
  6681. literal = false,
  6682. date,
  6683. // Check whether a format character is doubled
  6684. lookAhead = function(match) {
  6685. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  6686. if (matches) {
  6687. iFormat++;
  6688. }
  6689. return matches;
  6690. },
  6691. // Extract a number from the string value
  6692. getNumber = function(match) {
  6693. var isDoubled = lookAhead(match),
  6694. size = (match === "@" ? 14 : (match === "!" ? 20 :
  6695. (match === "y" && isDoubled ? 4 : (match === "o" ? 3 : 2)))),
  6696. digits = new RegExp("^\\d{1," + size + "}"),
  6697. num = value.substring(iValue).match(digits);
  6698. if (!num) {
  6699. throw "Missing number at position " + iValue;
  6700. }
  6701. iValue += num[0].length;
  6702. return parseInt(num[0], 10);
  6703. },
  6704. // Extract a name from the string value and convert to an index
  6705. getName = function(match, shortNames, longNames) {
  6706. var index = -1,
  6707. names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) {
  6708. return [ [k, v] ];
  6709. }).sort(function (a, b) {
  6710. return -(a[1].length - b[1].length);
  6711. });
  6712. $.each(names, function (i, pair) {
  6713. var name = pair[1];
  6714. if (value.substr(iValue, name.length).toLowerCase() === name.toLowerCase()) {
  6715. index = pair[0];
  6716. iValue += name.length;
  6717. return false;
  6718. }
  6719. });
  6720. if (index !== -1) {
  6721. return index + 1;
  6722. } else {
  6723. throw "Unknown name at position " + iValue;
  6724. }
  6725. },
  6726. // Confirm that a literal character matches the string value
  6727. checkLiteral = function() {
  6728. if (value.charAt(iValue) !== format.charAt(iFormat)) {
  6729. throw "Unexpected literal at position " + iValue;
  6730. }
  6731. iValue++;
  6732. };
  6733. for (iFormat = 0; iFormat < format.length; iFormat++) {
  6734. if (literal) {
  6735. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  6736. literal = false;
  6737. } else {
  6738. checkLiteral();
  6739. }
  6740. } else {
  6741. switch (format.charAt(iFormat)) {
  6742. case "d":
  6743. day = getNumber("d");
  6744. break;
  6745. case "D":
  6746. getName("D", dayNamesShort, dayNames);
  6747. break;
  6748. case "o":
  6749. doy = getNumber("o");
  6750. break;
  6751. case "m":
  6752. month = getNumber("m");
  6753. break;
  6754. case "M":
  6755. month = getName("M", monthNamesShort, monthNames);
  6756. break;
  6757. case "y":
  6758. year = getNumber("y");
  6759. break;
  6760. case "@":
  6761. date = new Date(getNumber("@"));
  6762. year = date.getFullYear();
  6763. month = date.getMonth() + 1;
  6764. day = date.getDate();
  6765. break;
  6766. case "!":
  6767. date = new Date((getNumber("!") - this._ticksTo1970) / 10000);
  6768. year = date.getFullYear();
  6769. month = date.getMonth() + 1;
  6770. day = date.getDate();
  6771. break;
  6772. case "'":
  6773. if (lookAhead("'")){
  6774. checkLiteral();
  6775. } else {
  6776. literal = true;
  6777. }
  6778. break;
  6779. default:
  6780. checkLiteral();
  6781. }
  6782. }
  6783. }
  6784. if (iValue < value.length){
  6785. extra = value.substr(iValue);
  6786. if (!/^\s+/.test(extra)) {
  6787. throw "Extra/unparsed characters found in date: " + extra;
  6788. }
  6789. }
  6790. if (year === -1) {
  6791. year = new Date().getFullYear();
  6792. } else if (year < 100) {
  6793. year += new Date().getFullYear() - new Date().getFullYear() % 100 +
  6794. (year <= shortYearCutoff ? 0 : -100);
  6795. }
  6796. if (doy > -1) {
  6797. month = 1;
  6798. day = doy;
  6799. do {
  6800. dim = this._getDaysInMonth(year, month - 1);
  6801. if (day <= dim) {
  6802. break;
  6803. }
  6804. month++;
  6805. day -= dim;
  6806. } while (true);
  6807. }
  6808. date = this._daylightSavingAdjust(new Date(year, month - 1, day));
  6809. if (date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day) {
  6810. throw "Invalid date"; // E.g. 31/02/00
  6811. }
  6812. return date;
  6813. },
  6814. /* Standard date formats. */
  6815. ATOM: "yy-mm-dd", // RFC 3339 (ISO 8601)
  6816. COOKIE: "D, dd M yy",
  6817. ISO_8601: "yy-mm-dd",
  6818. RFC_822: "D, d M y",
  6819. RFC_850: "DD, dd-M-y",
  6820. RFC_1036: "D, d M y",
  6821. RFC_1123: "D, d M yy",
  6822. RFC_2822: "D, d M yy",
  6823. RSS: "D, d M y", // RFC 822
  6824. TICKS: "!",
  6825. TIMESTAMP: "@",
  6826. W3C: "yy-mm-dd", // ISO 8601
  6827. _ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) +
  6828. Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000),
  6829. /* Format a date object into a string value.
  6830. * The format can be combinations of the following:
  6831. * d - day of month (no leading zero)
  6832. * dd - day of month (two digit)
  6833. * o - day of year (no leading zeros)
  6834. * oo - day of year (three digit)
  6835. * D - day name short
  6836. * DD - day name long
  6837. * m - month of year (no leading zero)
  6838. * mm - month of year (two digit)
  6839. * M - month name short
  6840. * MM - month name long
  6841. * y - year (two digit)
  6842. * yy - year (four digit)
  6843. * @ - Unix timestamp (ms since 01/01/1970)
  6844. * ! - Windows ticks (100ns since 01/01/0001)
  6845. * "..." - literal text
  6846. * '' - single quote
  6847. *
  6848. * @param format string - the desired format of the date
  6849. * @param date Date - the date value to format
  6850. * @param settings Object - attributes include:
  6851. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  6852. * dayNames string[7] - names of the days from Sunday (optional)
  6853. * monthNamesShort string[12] - abbreviated names of the months (optional)
  6854. * monthNames string[12] - names of the months (optional)
  6855. * @return string - the date in the above format
  6856. */
  6857. formatDate: function (format, date, settings) {
  6858. if (!date) {
  6859. return "";
  6860. }
  6861. var iFormat,
  6862. dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
  6863. dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
  6864. monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
  6865. monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
  6866. // Check whether a format character is doubled
  6867. lookAhead = function(match) {
  6868. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  6869. if (matches) {
  6870. iFormat++;
  6871. }
  6872. return matches;
  6873. },
  6874. // Format a number, with leading zero if necessary
  6875. formatNumber = function(match, value, len) {
  6876. var num = "" + value;
  6877. if (lookAhead(match)) {
  6878. while (num.length < len) {
  6879. num = "0" + num;
  6880. }
  6881. }
  6882. return num;
  6883. },
  6884. // Format a name, short or long as requested
  6885. formatName = function(match, value, shortNames, longNames) {
  6886. return (lookAhead(match) ? longNames[value] : shortNames[value]);
  6887. },
  6888. output = "",
  6889. literal = false;
  6890. if (date) {
  6891. for (iFormat = 0; iFormat < format.length; iFormat++) {
  6892. if (literal) {
  6893. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  6894. literal = false;
  6895. } else {
  6896. output += format.charAt(iFormat);
  6897. }
  6898. } else {
  6899. switch (format.charAt(iFormat)) {
  6900. case "d":
  6901. output += formatNumber("d", date.getDate(), 2);
  6902. break;
  6903. case "D":
  6904. output += formatName("D", date.getDay(), dayNamesShort, dayNames);
  6905. break;
  6906. case "o":
  6907. output += formatNumber("o",
  6908. Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3);
  6909. break;
  6910. case "m":
  6911. output += formatNumber("m", date.getMonth() + 1, 2);
  6912. break;
  6913. case "M":
  6914. output += formatName("M", date.getMonth(), monthNamesShort, monthNames);
  6915. break;
  6916. case "y":
  6917. output += (lookAhead("y") ? date.getFullYear() :
  6918. (date.getYear() % 100 < 10 ? "0" : "") + date.getYear() % 100);
  6919. break;
  6920. case "@":
  6921. output += date.getTime();
  6922. break;
  6923. case "!":
  6924. output += date.getTime() * 10000 + this._ticksTo1970;
  6925. break;
  6926. case "'":
  6927. if (lookAhead("'")) {
  6928. output += "'";
  6929. } else {
  6930. literal = true;
  6931. }
  6932. break;
  6933. default:
  6934. output += format.charAt(iFormat);
  6935. }
  6936. }
  6937. }
  6938. }
  6939. return output;
  6940. },
  6941. /* Extract all possible characters from the date format. */
  6942. _possibleChars: function (format) {
  6943. var iFormat,
  6944. chars = "",
  6945. literal = false,
  6946. // Check whether a format character is doubled
  6947. lookAhead = function(match) {
  6948. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  6949. if (matches) {
  6950. iFormat++;
  6951. }
  6952. return matches;
  6953. };
  6954. for (iFormat = 0; iFormat < format.length; iFormat++) {
  6955. if (literal) {
  6956. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  6957. literal = false;
  6958. } else {
  6959. chars += format.charAt(iFormat);
  6960. }
  6961. } else {
  6962. switch (format.charAt(iFormat)) {
  6963. case "d": case "m": case "y": case "@":
  6964. chars += "0123456789";
  6965. break;
  6966. case "D": case "M":
  6967. return null; // Accept anything
  6968. case "'":
  6969. if (lookAhead("'")) {
  6970. chars += "'";
  6971. } else {
  6972. literal = true;
  6973. }
  6974. break;
  6975. default:
  6976. chars += format.charAt(iFormat);
  6977. }
  6978. }
  6979. }
  6980. return chars;
  6981. },
  6982. /* Get a setting value, defaulting if necessary. */
  6983. _get: function(inst, name) {
  6984. return inst.settings[name] !== undefined ?
  6985. inst.settings[name] : this._defaults[name];
  6986. },
  6987. /* Parse existing date and initialise date picker. */
  6988. _setDateFromField: function(inst, noDefault) {
  6989. if (inst.input.val() === inst.lastVal) {
  6990. return;
  6991. }
  6992. var dateFormat = this._get(inst, "dateFormat"),
  6993. dates = inst.lastVal = inst.input ? inst.input.val() : null,
  6994. defaultDate = this._getDefaultDate(inst),
  6995. date = defaultDate,
  6996. settings = this._getFormatConfig(inst);
  6997. try {
  6998. date = this.parseDate(dateFormat, dates, settings) || defaultDate;
  6999. } catch (event) {
  7000. dates = (noDefault ? "" : dates);
  7001. }
  7002. inst.selectedDay = date.getDate();
  7003. inst.drawMonth = inst.selectedMonth = date.getMonth();
  7004. inst.drawYear = inst.selectedYear = date.getFullYear();
  7005. inst.currentDay = (dates ? date.getDate() : 0);
  7006. inst.currentMonth = (dates ? date.getMonth() : 0);
  7007. inst.currentYear = (dates ? date.getFullYear() : 0);
  7008. this._adjustInstDate(inst);
  7009. },
  7010. /* Retrieve the default date shown on opening. */
  7011. _getDefaultDate: function(inst) {
  7012. return this._restrictMinMax(inst,
  7013. this._determineDate(inst, this._get(inst, "defaultDate"), new Date()));
  7014. },
  7015. /* A date may be specified as an exact value or a relative one. */
  7016. _determineDate: function(inst, date, defaultDate) {
  7017. var offsetNumeric = function(offset) {
  7018. var date = new Date();
  7019. date.setDate(date.getDate() + offset);
  7020. return date;
  7021. },
  7022. offsetString = function(offset) {
  7023. try {
  7024. return $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
  7025. offset, $.datepicker._getFormatConfig(inst));
  7026. }
  7027. catch (e) {
  7028. // Ignore
  7029. }
  7030. var date = (offset.toLowerCase().match(/^c/) ?
  7031. $.datepicker._getDate(inst) : null) || new Date(),
  7032. year = date.getFullYear(),
  7033. month = date.getMonth(),
  7034. day = date.getDate(),
  7035. pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,
  7036. matches = pattern.exec(offset);
  7037. while (matches) {
  7038. switch (matches[2] || "d") {
  7039. case "d" : case "D" :
  7040. day += parseInt(matches[1],10); break;
  7041. case "w" : case "W" :
  7042. day += parseInt(matches[1],10) * 7; break;
  7043. case "m" : case "M" :
  7044. month += parseInt(matches[1],10);
  7045. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  7046. break;
  7047. case "y": case "Y" :
  7048. year += parseInt(matches[1],10);
  7049. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  7050. break;
  7051. }
  7052. matches = pattern.exec(offset);
  7053. }
  7054. return new Date(year, month, day);
  7055. },
  7056. newDate = (date == null || date === "" ? defaultDate : (typeof date === "string" ? offsetString(date) :
  7057. (typeof date === "number" ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime()))));
  7058. newDate = (newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate);
  7059. if (newDate) {
  7060. newDate.setHours(0);
  7061. newDate.setMinutes(0);
  7062. newDate.setSeconds(0);
  7063. newDate.setMilliseconds(0);
  7064. }
  7065. return this._daylightSavingAdjust(newDate);
  7066. },
  7067. /* Handle switch to/from daylight saving.
  7068. * Hours may be non-zero on daylight saving cut-over:
  7069. * > 12 when midnight changeover, but then cannot generate
  7070. * midnight datetime, so jump to 1AM, otherwise reset.
  7071. * @param date (Date) the date to check
  7072. * @return (Date) the corrected date
  7073. */
  7074. _daylightSavingAdjust: function(date) {
  7075. if (!date) {
  7076. return null;
  7077. }
  7078. date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
  7079. return date;
  7080. },
  7081. /* Set the date(s) directly. */
  7082. _setDate: function(inst, date, noChange) {
  7083. var clear = !date,
  7084. origMonth = inst.selectedMonth,
  7085. origYear = inst.selectedYear,
  7086. newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
  7087. inst.selectedDay = inst.currentDay = newDate.getDate();
  7088. inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
  7089. inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
  7090. if ((origMonth !== inst.selectedMonth || origYear !== inst.selectedYear) && !noChange) {
  7091. this._notifyChange(inst);
  7092. }
  7093. this._adjustInstDate(inst);
  7094. if (inst.input) {
  7095. inst.input.val(clear ? "" : this._formatDate(inst));
  7096. }
  7097. },
  7098. /* Retrieve the date(s) directly. */
  7099. _getDate: function(inst) {
  7100. var startDate = (!inst.currentYear || (inst.input && inst.input.val() === "") ? null :
  7101. this._daylightSavingAdjust(new Date(
  7102. inst.currentYear, inst.currentMonth, inst.currentDay)));
  7103. return startDate;
  7104. },
  7105. /* Attach the onxxx handlers. These are declared statically so
  7106. * they work with static code transformers like Caja.
  7107. */
  7108. _attachHandlers: function(inst) {
  7109. var stepMonths = this._get(inst, "stepMonths"),
  7110. id = "#" + inst.id.replace( /\\\\/g, "\\" );
  7111. inst.dpDiv.find("[data-handler]").map(function () {
  7112. var handler = {
  7113. prev: function () {
  7114. window["DP_jQuery_" + dpuuid].datepicker._adjustDate(id, -stepMonths, "M");
  7115. },
  7116. next: function () {
  7117. window["DP_jQuery_" + dpuuid].datepicker._adjustDate(id, +stepMonths, "M");
  7118. },
  7119. hide: function () {
  7120. window["DP_jQuery_" + dpuuid].datepicker._hideDatepicker();
  7121. },
  7122. today: function () {
  7123. window["DP_jQuery_" + dpuuid].datepicker._gotoToday(id);
  7124. },
  7125. selectDay: function () {
  7126. window["DP_jQuery_" + dpuuid].datepicker._selectDay(id, +this.getAttribute("data-month"), +this.getAttribute("data-year"), this);
  7127. return false;
  7128. },
  7129. selectMonth: function () {
  7130. window["DP_jQuery_" + dpuuid].datepicker._selectMonthYear(id, this, "M");
  7131. return false;
  7132. },
  7133. selectYear: function () {
  7134. window["DP_jQuery_" + dpuuid].datepicker._selectMonthYear(id, this, "Y");
  7135. return false;
  7136. }
  7137. };
  7138. $(this).bind(this.getAttribute("data-event"), handler[this.getAttribute("data-handler")]);
  7139. });
  7140. },
  7141. /* Generate the HTML for the current state of the date picker. */
  7142. _generateHTML: function(inst) {
  7143. var maxDraw, prevText, prev, nextText, next, currentText, gotoDate,
  7144. controls, buttonPanel, firstDay, showWeek, dayNames, dayNamesMin,
  7145. monthNames, monthNamesShort, beforeShowDay, showOtherMonths,
  7146. selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate,
  7147. cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows,
  7148. printDate, dRow, tbody, daySettings, otherMonth, unselectable,
  7149. tempDate = new Date(),
  7150. today = this._daylightSavingAdjust(
  7151. new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate())), // clear time
  7152. isRTL = this._get(inst, "isRTL"),
  7153. showButtonPanel = this._get(inst, "showButtonPanel"),
  7154. hideIfNoPrevNext = this._get(inst, "hideIfNoPrevNext"),
  7155. navigationAsDateFormat = this._get(inst, "navigationAsDateFormat"),
  7156. numMonths = this._getNumberOfMonths(inst),
  7157. showCurrentAtPos = this._get(inst, "showCurrentAtPos"),
  7158. stepMonths = this._get(inst, "stepMonths"),
  7159. isMultiMonth = (numMonths[0] !== 1 || numMonths[1] !== 1),
  7160. currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
  7161. new Date(inst.currentYear, inst.currentMonth, inst.currentDay))),
  7162. minDate = this._getMinMaxDate(inst, "min"),
  7163. maxDate = this._getMinMaxDate(inst, "max"),
  7164. drawMonth = inst.drawMonth - showCurrentAtPos,
  7165. drawYear = inst.drawYear;
  7166. if (drawMonth < 0) {
  7167. drawMonth += 12;
  7168. drawYear--;
  7169. }
  7170. if (maxDate) {
  7171. maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
  7172. maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate()));
  7173. maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
  7174. while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
  7175. drawMonth--;
  7176. if (drawMonth < 0) {
  7177. drawMonth = 11;
  7178. drawYear--;
  7179. }
  7180. }
  7181. }
  7182. inst.drawMonth = drawMonth;
  7183. inst.drawYear = drawYear;
  7184. prevText = this._get(inst, "prevText");
  7185. prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText,
  7186. this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
  7187. this._getFormatConfig(inst)));
  7188. prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
  7189. "<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click'" +
  7190. " title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w") + "'>" + prevText + "</span></a>" :
  7191. (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>"));
  7192. nextText = this._get(inst, "nextText");
  7193. nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
  7194. this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
  7195. this._getFormatConfig(inst)));
  7196. next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
  7197. "<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click'" +
  7198. " title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e") + "'>" + nextText + "</span></a>" :
  7199. (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>"));
  7200. currentText = this._get(inst, "currentText");
  7201. gotoDate = (this._get(inst, "gotoCurrent") && inst.currentDay ? currentDate : today);
  7202. currentText = (!navigationAsDateFormat ? currentText :
  7203. this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
  7204. controls = (!inst.inline ? "<button type='button' class='ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all' data-handler='hide' data-event='click'>" +
  7205. this._get(inst, "closeText") + "</button>" : "");
  7206. buttonPanel = (showButtonPanel) ? "<div class='ui-datepicker-buttonpane ui-widget-content'>" + (isRTL ? controls : "") +
  7207. (this._isInRange(inst, gotoDate) ? "<button type='button' class='ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all' data-handler='today' data-event='click'" +
  7208. ">" + currentText + "</button>" : "") + (isRTL ? "" : controls) + "</div>" : "";
  7209. firstDay = parseInt(this._get(inst, "firstDay"),10);
  7210. firstDay = (isNaN(firstDay) ? 0 : firstDay);
  7211. showWeek = this._get(inst, "showWeek");
  7212. dayNames = this._get(inst, "dayNames");
  7213. dayNamesMin = this._get(inst, "dayNamesMin");
  7214. monthNames = this._get(inst, "monthNames");
  7215. monthNamesShort = this._get(inst, "monthNamesShort");
  7216. beforeShowDay = this._get(inst, "beforeShowDay");
  7217. showOtherMonths = this._get(inst, "showOtherMonths");
  7218. selectOtherMonths = this._get(inst, "selectOtherMonths");
  7219. defaultDate = this._getDefaultDate(inst);
  7220. html = "";
  7221. dow;
  7222. for (row = 0; row < numMonths[0]; row++) {
  7223. group = "";
  7224. this.maxRows = 4;
  7225. for (col = 0; col < numMonths[1]; col++) {
  7226. selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
  7227. cornerClass = " ui-corner-all";
  7228. calender = "";
  7229. if (isMultiMonth) {
  7230. calender += "<div class='ui-datepicker-group";
  7231. if (numMonths[1] > 1) {
  7232. switch (col) {
  7233. case 0: calender += " ui-datepicker-group-first";
  7234. cornerClass = " ui-corner-" + (isRTL ? "right" : "left"); break;
  7235. case numMonths[1]-1: calender += " ui-datepicker-group-last";
  7236. cornerClass = " ui-corner-" + (isRTL ? "left" : "right"); break;
  7237. default: calender += " ui-datepicker-group-middle"; cornerClass = ""; break;
  7238. }
  7239. }
  7240. calender += "'>";
  7241. }
  7242. calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" +
  7243. (/all|left/.test(cornerClass) && row === 0 ? (isRTL ? next : prev) : "") +
  7244. (/all|right/.test(cornerClass) && row === 0 ? (isRTL ? prev : next) : "") +
  7245. this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
  7246. row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers
  7247. "</div><table class='ui-datepicker-calendar'><thead>" +
  7248. "<tr>";
  7249. thead = (showWeek ? "<th class='ui-datepicker-week-col'>" + this._get(inst, "weekHeader") + "</th>" : "");
  7250. for (dow = 0; dow < 7; dow++) { // days of the week
  7251. day = (dow + firstDay) % 7;
  7252. thead += "<th" + ((dow + firstDay + 6) % 7 >= 5 ? " class='ui-datepicker-week-end'" : "") + ">" +
  7253. "<span title='" + dayNames[day] + "'>" + dayNamesMin[day] + "</span></th>";
  7254. }
  7255. calender += thead + "</tr></thead><tbody>";
  7256. daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
  7257. if (drawYear === inst.selectedYear && drawMonth === inst.selectedMonth) {
  7258. inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
  7259. }
  7260. leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
  7261. curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate
  7262. numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043)
  7263. this.maxRows = numRows;
  7264. printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
  7265. for (dRow = 0; dRow < numRows; dRow++) { // create date picker rows
  7266. calender += "<tr>";
  7267. tbody = (!showWeek ? "" : "<td class='ui-datepicker-week-col'>" +
  7268. this._get(inst, "calculateWeek")(printDate) + "</td>");
  7269. for (dow = 0; dow < 7; dow++) { // create date picker days
  7270. daySettings = (beforeShowDay ?
  7271. beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, ""]);
  7272. otherMonth = (printDate.getMonth() !== drawMonth);
  7273. unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] ||
  7274. (minDate && printDate < minDate) || (maxDate && printDate > maxDate);
  7275. tbody += "<td class='" +
  7276. ((dow + firstDay + 6) % 7 >= 5 ? " ui-datepicker-week-end" : "") + // highlight weekends
  7277. (otherMonth ? " ui-datepicker-other-month" : "") + // highlight days from other months
  7278. ((printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent) || // user pressed key
  7279. (defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime()) ?
  7280. // or defaultDate is current printedDate and defaultDate is selectedDate
  7281. " " + this._dayOverClass : "") + // highlight selected day
  7282. (unselectable ? " " + this._unselectableClass + " ui-state-disabled": "") + // highlight unselectable days
  7283. (otherMonth && !showOtherMonths ? "" : " " + daySettings[1] + // highlight custom dates
  7284. (printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "") + // highlight selected day
  7285. (printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "")) + "'" + // highlight today (if different)
  7286. ((!otherMonth || showOtherMonths) && daySettings[2] ? " title='" + daySettings[2] + "'" : "") + // cell title
  7287. (unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'") + ">" + // actions
  7288. (otherMonth && !showOtherMonths ? "&#xa0;" : // display for other months
  7289. (unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" +
  7290. (printDate.getTime() === today.getTime() ? " ui-state-highlight" : "") +
  7291. (printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "") + // highlight selected day
  7292. (otherMonth ? " ui-priority-secondary" : "") + // distinguish dates from other months
  7293. "' href='#'>" + printDate.getDate() + "</a>")) + "</td>"; // display selectable date
  7294. printDate.setDate(printDate.getDate() + 1);
  7295. printDate = this._daylightSavingAdjust(printDate);
  7296. }
  7297. calender += tbody + "</tr>";
  7298. }
  7299. drawMonth++;
  7300. if (drawMonth > 11) {
  7301. drawMonth = 0;
  7302. drawYear++;
  7303. }
  7304. calender += "</tbody></table>" + (isMultiMonth ? "</div>" +
  7305. ((numMonths[0] > 0 && col === numMonths[1]-1) ? "<div class='ui-datepicker-row-break'></div>" : "") : "");
  7306. group += calender;
  7307. }
  7308. html += group;
  7309. }
  7310. html += buttonPanel;
  7311. inst._keyEvent = false;
  7312. return html;
  7313. },
  7314. /* Generate the month and year header. */
  7315. _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
  7316. secondary, monthNames, monthNamesShort) {
  7317. var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear,
  7318. changeMonth = this._get(inst, "changeMonth"),
  7319. changeYear = this._get(inst, "changeYear"),
  7320. showMonthAfterYear = this._get(inst, "showMonthAfterYear"),
  7321. html = "<div class='ui-datepicker-title'>",
  7322. monthHtml = "";
  7323. // month selection
  7324. if (secondary || !changeMonth) {
  7325. monthHtml += "<span class='ui-datepicker-month'>" + monthNames[drawMonth] + "</span>";
  7326. } else {
  7327. inMinYear = (minDate && minDate.getFullYear() === drawYear);
  7328. inMaxYear = (maxDate && maxDate.getFullYear() === drawYear);
  7329. monthHtml += "<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>";
  7330. for ( month = 0; month < 12; month++) {
  7331. if ((!inMinYear || month >= minDate.getMonth()) && (!inMaxYear || month <= maxDate.getMonth())) {
  7332. monthHtml += "<option value='" + month + "'" +
  7333. (month === drawMonth ? " selected='selected'" : "") +
  7334. ">" + monthNamesShort[month] + "</option>";
  7335. }
  7336. }
  7337. monthHtml += "</select>";
  7338. }
  7339. if (!showMonthAfterYear) {
  7340. html += monthHtml + (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "");
  7341. }
  7342. // year selection
  7343. if ( !inst.yearshtml ) {
  7344. inst.yearshtml = "";
  7345. if (secondary || !changeYear) {
  7346. html += "<span class='ui-datepicker-year'>" + drawYear + "</span>";
  7347. } else {
  7348. // determine range of years to display
  7349. years = this._get(inst, "yearRange").split(":");
  7350. thisYear = new Date().getFullYear();
  7351. determineYear = function(value) {
  7352. var year = (value.match(/c[+\-].*/) ? drawYear + parseInt(value.substring(1), 10) :
  7353. (value.match(/[+\-].*/) ? thisYear + parseInt(value, 10) :
  7354. parseInt(value, 10)));
  7355. return (isNaN(year) ? thisYear : year);
  7356. };
  7357. year = determineYear(years[0]);
  7358. endYear = Math.max(year, determineYear(years[1] || ""));
  7359. year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
  7360. endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
  7361. inst.yearshtml += "<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>";
  7362. for (; year <= endYear; year++) {
  7363. inst.yearshtml += "<option value='" + year + "'" +
  7364. (year === drawYear ? " selected='selected'" : "") +
  7365. ">" + year + "</option>";
  7366. }
  7367. inst.yearshtml += "</select>";
  7368. html += inst.yearshtml;
  7369. inst.yearshtml = null;
  7370. }
  7371. }
  7372. html += this._get(inst, "yearSuffix");
  7373. if (showMonthAfterYear) {
  7374. html += (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "") + monthHtml;
  7375. }
  7376. html += "</div>"; // Close datepicker_header
  7377. return html;
  7378. },
  7379. /* Adjust one of the date sub-fields. */
  7380. _adjustInstDate: function(inst, offset, period) {
  7381. var year = inst.drawYear + (period === "Y" ? offset : 0),
  7382. month = inst.drawMonth + (period === "M" ? offset : 0),
  7383. day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) + (period === "D" ? offset : 0),
  7384. date = this._restrictMinMax(inst, this._daylightSavingAdjust(new Date(year, month, day)));
  7385. inst.selectedDay = date.getDate();
  7386. inst.drawMonth = inst.selectedMonth = date.getMonth();
  7387. inst.drawYear = inst.selectedYear = date.getFullYear();
  7388. if (period === "M" || period === "Y") {
  7389. this._notifyChange(inst);
  7390. }
  7391. },
  7392. /* Ensure a date is within any min/max bounds. */
  7393. _restrictMinMax: function(inst, date) {
  7394. var minDate = this._getMinMaxDate(inst, "min"),
  7395. maxDate = this._getMinMaxDate(inst, "max"),
  7396. newDate = (minDate && date < minDate ? minDate : date);
  7397. return (maxDate && newDate > maxDate ? maxDate : newDate);
  7398. },
  7399. /* Notify change of month/year. */
  7400. _notifyChange: function(inst) {
  7401. var onChange = this._get(inst, "onChangeMonthYear");
  7402. if (onChange) {
  7403. onChange.apply((inst.input ? inst.input[0] : null),
  7404. [inst.selectedYear, inst.selectedMonth + 1, inst]);
  7405. }
  7406. },
  7407. /* Determine the number of months to show. */
  7408. _getNumberOfMonths: function(inst) {
  7409. var numMonths = this._get(inst, "numberOfMonths");
  7410. return (numMonths == null ? [1, 1] : (typeof numMonths === "number" ? [1, numMonths] : numMonths));
  7411. },
  7412. /* Determine the current maximum date - ensure no time components are set. */
  7413. _getMinMaxDate: function(inst, minMax) {
  7414. return this._determineDate(inst, this._get(inst, minMax + "Date"), null);
  7415. },
  7416. /* Find the number of days in a given month. */
  7417. _getDaysInMonth: function(year, month) {
  7418. return 32 - this._daylightSavingAdjust(new Date(year, month, 32)).getDate();
  7419. },
  7420. /* Find the day of the week of the first of a month. */
  7421. _getFirstDayOfMonth: function(year, month) {
  7422. return new Date(year, month, 1).getDay();
  7423. },
  7424. /* Determines if we should allow a "next/prev" month display change. */
  7425. _canAdjustMonth: function(inst, offset, curYear, curMonth) {
  7426. var numMonths = this._getNumberOfMonths(inst),
  7427. date = this._daylightSavingAdjust(new Date(curYear,
  7428. curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1));
  7429. if (offset < 0) {
  7430. date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
  7431. }
  7432. return this._isInRange(inst, date);
  7433. },
  7434. /* Is the given date in the accepted range? */
  7435. _isInRange: function(inst, date) {
  7436. var yearSplit, currentYear,
  7437. minDate = this._getMinMaxDate(inst, "min"),
  7438. maxDate = this._getMinMaxDate(inst, "max"),
  7439. minYear = null,
  7440. maxYear = null,
  7441. years = this._get(inst, "yearRange");
  7442. if (years){
  7443. yearSplit = years.split(":");
  7444. currentYear = new Date().getFullYear();
  7445. minYear = parseInt(yearSplit[0], 10) + currentYear;
  7446. maxYear = parseInt(yearSplit[1], 10) + currentYear;
  7447. }
  7448. return ((!minDate || date.getTime() >= minDate.getTime()) &&
  7449. (!maxDate || date.getTime() <= maxDate.getTime()) &&
  7450. (!minYear || date.getFullYear() >= minYear) &&
  7451. (!maxYear || date.getFullYear() <= maxYear));
  7452. },
  7453. /* Provide the configuration settings for formatting/parsing. */
  7454. _getFormatConfig: function(inst) {
  7455. var shortYearCutoff = this._get(inst, "shortYearCutoff");
  7456. shortYearCutoff = (typeof shortYearCutoff !== "string" ? shortYearCutoff :
  7457. new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
  7458. return {shortYearCutoff: shortYearCutoff,
  7459. dayNamesShort: this._get(inst, "dayNamesShort"), dayNames: this._get(inst, "dayNames"),
  7460. monthNamesShort: this._get(inst, "monthNamesShort"), monthNames: this._get(inst, "monthNames")};
  7461. },
  7462. /* Format the given date for display. */
  7463. _formatDate: function(inst, day, month, year) {
  7464. if (!day) {
  7465. inst.currentDay = inst.selectedDay;
  7466. inst.currentMonth = inst.selectedMonth;
  7467. inst.currentYear = inst.selectedYear;
  7468. }
  7469. var date = (day ? (typeof day === "object" ? day :
  7470. this._daylightSavingAdjust(new Date(year, month, day))) :
  7471. this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
  7472. return this.formatDate(this._get(inst, "dateFormat"), date, this._getFormatConfig(inst));
  7473. }
  7474. });
  7475. /*
  7476. * Bind hover events for datepicker elements.
  7477. * Done via delegate so the binding only occurs once in the lifetime of the parent div.
  7478. * Global instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
  7479. */
  7480. function bindHover(dpDiv) {
  7481. var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";
  7482. return dpDiv.delegate(selector, "mouseout", function() {
  7483. $(this).removeClass("ui-state-hover");
  7484. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  7485. $(this).removeClass("ui-datepicker-prev-hover");
  7486. }
  7487. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  7488. $(this).removeClass("ui-datepicker-next-hover");
  7489. }
  7490. })
  7491. .delegate(selector, "mouseover", function(){
  7492. if (!$.datepicker._isDisabledDatepicker( instActive.inline ? dpDiv.parent()[0] : instActive.input[0])) {
  7493. $(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover");
  7494. $(this).addClass("ui-state-hover");
  7495. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  7496. $(this).addClass("ui-datepicker-prev-hover");
  7497. }
  7498. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  7499. $(this).addClass("ui-datepicker-next-hover");
  7500. }
  7501. }
  7502. });
  7503. }
  7504. /* jQuery extend now ignores nulls! */
  7505. function extendRemove(target, props) {
  7506. $.extend(target, props);
  7507. for (var name in props) {
  7508. if (props[name] == null) {
  7509. target[name] = props[name];
  7510. }
  7511. }
  7512. return target;
  7513. }
  7514. /* Invoke the datepicker functionality.
  7515. @param options string - a command, optionally followed by additional parameters or
  7516. Object - settings for attaching new datepicker functionality
  7517. @return jQuery object */
  7518. $.fn.datepicker = function(options){
  7519. /* Verify an empty collection wasn't passed - Fixes #6976 */
  7520. if ( !this.length ) {
  7521. return this;
  7522. }
  7523. /* Initialise the date picker. */
  7524. if (!$.datepicker.initialized) {
  7525. $(document).mousedown($.datepicker._checkExternalClick);
  7526. $.datepicker.initialized = true;
  7527. }
  7528. /* Append datepicker main container to body if not exist. */
  7529. if ($("#"+$.datepicker._mainDivId).length === 0) {
  7530. $("body").append($.datepicker.dpDiv);
  7531. }
  7532. var otherArgs = Array.prototype.slice.call(arguments, 1);
  7533. if (typeof options === "string" && (options === "isDisabled" || options === "getDate" || options === "widget")) {
  7534. return $.datepicker["_" + options + "Datepicker"].
  7535. apply($.datepicker, [this[0]].concat(otherArgs));
  7536. }
  7537. if (options === "option" && arguments.length === 2 && typeof arguments[1] === "string") {
  7538. return $.datepicker["_" + options + "Datepicker"].
  7539. apply($.datepicker, [this[0]].concat(otherArgs));
  7540. }
  7541. return this.each(function() {
  7542. typeof options === "string" ?
  7543. $.datepicker["_" + options + "Datepicker"].
  7544. apply($.datepicker, [this].concat(otherArgs)) :
  7545. $.datepicker._attachDatepicker(this, options);
  7546. });
  7547. };
  7548. $.datepicker = new Datepicker(); // singleton instance
  7549. $.datepicker.initialized = false;
  7550. $.datepicker.uuid = new Date().getTime();
  7551. $.datepicker.version = "1.10.0";
  7552. // Workaround for #4055
  7553. // Add another global to avoid noConflict issues with inline event handlers
  7554. window["DP_jQuery_" + dpuuid] = $;
  7555. })(jQuery);
  7556. (function( $, undefined ) {
  7557. var sizeRelatedOptions = {
  7558. buttons: true,
  7559. height: true,
  7560. maxHeight: true,
  7561. maxWidth: true,
  7562. minHeight: true,
  7563. minWidth: true,
  7564. width: true
  7565. },
  7566. resizableRelatedOptions = {
  7567. maxHeight: true,
  7568. maxWidth: true,
  7569. minHeight: true,
  7570. minWidth: true
  7571. };
  7572. $.widget( "ui.dialog", {
  7573. version: "1.10.0",
  7574. options: {
  7575. appendTo: "body",
  7576. autoOpen: true,
  7577. buttons: [],
  7578. closeOnEscape: true,
  7579. closeText: "close",
  7580. dialogClass: "",
  7581. draggable: true,
  7582. hide: null,
  7583. height: "auto",
  7584. maxHeight: null,
  7585. maxWidth: null,
  7586. minHeight: 150,
  7587. minWidth: 150,
  7588. modal: false,
  7589. position: {
  7590. my: "center",
  7591. at: "center",
  7592. of: window,
  7593. collision: "fit",
  7594. // Ensure the titlebar is always visible
  7595. using: function( pos ) {
  7596. var topOffset = $( this ).css( pos ).offset().top;
  7597. if ( topOffset < 0 ) {
  7598. $( this ).css( "top", pos.top - topOffset );
  7599. }
  7600. }
  7601. },
  7602. resizable: true,
  7603. show: null,
  7604. title: null,
  7605. width: 300,
  7606. // callbacks
  7607. beforeClose: null,
  7608. close: null,
  7609. drag: null,
  7610. dragStart: null,
  7611. dragStop: null,
  7612. focus: null,
  7613. open: null,
  7614. resize: null,
  7615. resizeStart: null,
  7616. resizeStop: null
  7617. },
  7618. _create: function() {
  7619. this.originalCss = {
  7620. display: this.element[0].style.display,
  7621. width: this.element[0].style.width,
  7622. minHeight: this.element[0].style.minHeight,
  7623. maxHeight: this.element[0].style.maxHeight,
  7624. height: this.element[0].style.height
  7625. };
  7626. this.originalPosition = {
  7627. parent: this.element.parent(),
  7628. index: this.element.parent().children().index( this.element )
  7629. };
  7630. this.originalTitle = this.element.attr("title");
  7631. this.options.title = this.options.title || this.originalTitle;
  7632. this._createWrapper();
  7633. this.element
  7634. .show()
  7635. .removeAttr("title")
  7636. .addClass("ui-dialog-content ui-widget-content")
  7637. .appendTo( this.uiDialog );
  7638. this._createTitlebar();
  7639. this._createButtonPane();
  7640. if ( this.options.draggable && $.fn.draggable ) {
  7641. this._makeDraggable();
  7642. }
  7643. if ( this.options.resizable && $.fn.resizable ) {
  7644. this._makeResizable();
  7645. }
  7646. this._isOpen = false;
  7647. },
  7648. _init: function() {
  7649. if ( this.options.autoOpen ) {
  7650. this.open();
  7651. }
  7652. },
  7653. _appendTo: function() {
  7654. var element = this.options.appendTo;
  7655. if ( element && (element.jquery || element.nodeType) ) {
  7656. return $( element );
  7657. }
  7658. return this.document.find( element || "body" ).eq( 0 );
  7659. },
  7660. _destroy: function() {
  7661. var next,
  7662. originalPosition = this.originalPosition;
  7663. this._destroyOverlay();
  7664. this.element
  7665. .removeUniqueId()
  7666. .removeClass("ui-dialog-content ui-widget-content")
  7667. .css( this.originalCss )
  7668. // Without detaching first, the following becomes really slow
  7669. .detach();
  7670. this.uiDialog.stop( true, true ).remove();
  7671. if ( this.originalTitle ) {
  7672. this.element.attr( "title", this.originalTitle );
  7673. }
  7674. next = originalPosition.parent.children().eq( originalPosition.index );
  7675. // Don't try to place the dialog next to itself (#8613)
  7676. if ( next.length && next[0] !== this.element[0] ) {
  7677. next.before( this.element );
  7678. } else {
  7679. originalPosition.parent.append( this.element );
  7680. }
  7681. },
  7682. widget: function() {
  7683. return this.uiDialog;
  7684. },
  7685. disable: $.noop,
  7686. enable: $.noop,
  7687. close: function( event ) {
  7688. var that = this;
  7689. if ( !this._isOpen || this._trigger( "beforeClose", event ) === false ) {
  7690. return;
  7691. }
  7692. this._isOpen = false;
  7693. this._destroyOverlay();
  7694. if ( !this.opener.filter(":focusable").focus().length ) {
  7695. // Hiding a focused element doesn't trigger blur in WebKit
  7696. // so in case we have nothing to focus on, explicitly blur the active element
  7697. // https://bugs.webkit.org/show_bug.cgi?id=47182
  7698. $( this.document[0].activeElement ).blur();
  7699. }
  7700. this._hide( this.uiDialog, this.options.hide, function() {
  7701. that._trigger( "close", event );
  7702. });
  7703. },
  7704. isOpen: function() {
  7705. return this._isOpen;
  7706. },
  7707. moveToTop: function() {
  7708. this._moveToTop();
  7709. },
  7710. _moveToTop: function( event, silent ) {
  7711. var moved = !!this.uiDialog.nextAll(":visible").insertBefore( this.uiDialog ).length;
  7712. if ( moved && !silent ) {
  7713. this._trigger( "focus", event );
  7714. }
  7715. return moved;
  7716. },
  7717. open: function() {
  7718. if ( this._isOpen ) {
  7719. if ( this._moveToTop() ) {
  7720. this._focusTabbable();
  7721. }
  7722. return;
  7723. }
  7724. this.opener = $( this.document[0].activeElement );
  7725. this._size();
  7726. this._position();
  7727. this._createOverlay();
  7728. this._moveToTop( null, true );
  7729. this._show( this.uiDialog, this.options.show );
  7730. this._focusTabbable();
  7731. this._isOpen = true;
  7732. this._trigger("open");
  7733. this._trigger("focus");
  7734. },
  7735. _focusTabbable: function() {
  7736. // Set focus to the first match:
  7737. // 1. First element inside the dialog matching [autofocus]
  7738. // 2. Tabbable element inside the content element
  7739. // 3. Tabbable element inside the buttonpane
  7740. // 4. The close button
  7741. // 5. The dialog itself
  7742. var hasFocus = this.element.find("[autofocus]");
  7743. if ( !hasFocus.length ) {
  7744. hasFocus = this.element.find(":tabbable");
  7745. }
  7746. if ( !hasFocus.length ) {
  7747. hasFocus = this.uiDialogButtonPane.find(":tabbable");
  7748. }
  7749. if ( !hasFocus.length ) {
  7750. hasFocus = this.uiDialogTitlebarClose.filter(":tabbable");
  7751. }
  7752. if ( !hasFocus.length ) {
  7753. hasFocus = this.uiDialog;
  7754. }
  7755. hasFocus.eq( 0 ).focus();
  7756. },
  7757. _keepFocus: function( event ) {
  7758. function checkFocus() {
  7759. var activeElement = this.document[0].activeElement,
  7760. isActive = this.uiDialog[0] === activeElement ||
  7761. $.contains( this.uiDialog[0], activeElement );
  7762. if ( !isActive ) {
  7763. this._focusTabbable();
  7764. }
  7765. }
  7766. event.preventDefault();
  7767. checkFocus.call( this );
  7768. // support: IE
  7769. // IE <= 8 doesn't prevent moving focus even with event.preventDefault()
  7770. // so we check again later
  7771. this._delay( checkFocus );
  7772. },
  7773. _createWrapper: function() {
  7774. this.uiDialog = $("<div>")
  7775. .addClass( "ui-dialog ui-widget ui-widget-content ui-corner-all ui-front " +
  7776. this.options.dialogClass )
  7777. .hide()
  7778. .attr({
  7779. // Setting tabIndex makes the div focusable
  7780. tabIndex: -1,
  7781. role: "dialog"
  7782. })
  7783. .appendTo( this._appendTo() );
  7784. this._on( this.uiDialog, {
  7785. keydown: function( event ) {
  7786. if ( this.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
  7787. event.keyCode === $.ui.keyCode.ESCAPE ) {
  7788. event.preventDefault();
  7789. this.close( event );
  7790. return;
  7791. }
  7792. // prevent tabbing out of dialogs
  7793. if ( event.keyCode !== $.ui.keyCode.TAB ) {
  7794. return;
  7795. }
  7796. var tabbables = this.uiDialog.find(":tabbable"),
  7797. first = tabbables.filter(":first"),
  7798. last = tabbables.filter(":last");
  7799. if ( ( event.target === last[0] || event.target === this.uiDialog[0] ) && !event.shiftKey ) {
  7800. first.focus( 1 );
  7801. event.preventDefault();
  7802. } else if ( ( event.target === first[0] || event.target === this.uiDialog[0] ) && event.shiftKey ) {
  7803. last.focus( 1 );
  7804. event.preventDefault();
  7805. }
  7806. },
  7807. mousedown: function( event ) {
  7808. if ( this._moveToTop( event ) ) {
  7809. this._focusTabbable();
  7810. }
  7811. }
  7812. });
  7813. // We assume that any existing aria-describedby attribute means
  7814. // that the dialog content is marked up properly
  7815. // otherwise we brute force the content as the description
  7816. if ( !this.element.find("[aria-describedby]").length ) {
  7817. this.uiDialog.attr({
  7818. "aria-describedby": this.element.uniqueId().attr("id")
  7819. });
  7820. }
  7821. },
  7822. _createTitlebar: function() {
  7823. var uiDialogTitle;
  7824. this.uiDialogTitlebar = $("<div>")
  7825. .addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix")
  7826. .prependTo( this.uiDialog );
  7827. this._on( this.uiDialogTitlebar, {
  7828. mousedown: function( event ) {
  7829. // Don't prevent click on close button (#8838)
  7830. // Focusing a dialog that is partially scrolled out of view
  7831. // causes the browser to scroll it into view, preventing the click event
  7832. if ( !$( event.target ).closest(".ui-dialog-titlebar-close") ) {
  7833. // Dialog isn't getting focus when dragging (#8063)
  7834. this.uiDialog.focus();
  7835. }
  7836. }
  7837. });
  7838. this.uiDialogTitlebarClose = $("<button></button>")
  7839. .button({
  7840. label: this.options.closeText,
  7841. icons: {
  7842. primary: "ui-icon-closethick"
  7843. },
  7844. text: false
  7845. })
  7846. .addClass("ui-dialog-titlebar-close")
  7847. .appendTo( this.uiDialogTitlebar );
  7848. this._on( this.uiDialogTitlebarClose, {
  7849. click: function( event ) {
  7850. event.preventDefault();
  7851. this.close( event );
  7852. }
  7853. });
  7854. uiDialogTitle = $("<span>")
  7855. .uniqueId()
  7856. .addClass("ui-dialog-title")
  7857. .prependTo( this.uiDialogTitlebar );
  7858. this._title( uiDialogTitle );
  7859. this.uiDialog.attr({
  7860. "aria-labelledby": uiDialogTitle.attr("id")
  7861. });
  7862. },
  7863. _title: function( title ) {
  7864. if ( !this.options.title ) {
  7865. title.html("&#160;");
  7866. }
  7867. title.text( this.options.title );
  7868. },
  7869. _createButtonPane: function() {
  7870. this.uiDialogButtonPane = $("<div>")
  7871. .addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix");
  7872. this.uiButtonSet = $("<div>")
  7873. .addClass("ui-dialog-buttonset")
  7874. .appendTo( this.uiDialogButtonPane );
  7875. this._createButtons();
  7876. },
  7877. _createButtons: function() {
  7878. var that = this,
  7879. buttons = this.options.buttons;
  7880. // if we already have a button pane, remove it
  7881. this.uiDialogButtonPane.remove();
  7882. this.uiButtonSet.empty();
  7883. if ( $.isEmptyObject( buttons ) ) {
  7884. this.uiDialog.removeClass("ui-dialog-buttons");
  7885. return;
  7886. }
  7887. $.each( buttons, function( name, props ) {
  7888. var click, buttonOptions;
  7889. props = $.isFunction( props ) ?
  7890. { click: props, text: name } :
  7891. props;
  7892. // Default to a non-submitting button
  7893. props = $.extend( { type: "button" }, props );
  7894. // Change the context for the click callback to be the main element
  7895. click = props.click;
  7896. props.click = function() {
  7897. click.apply( that.element[0], arguments );
  7898. };
  7899. buttonOptions = {
  7900. icons: props.icons,
  7901. text: props.showText
  7902. };
  7903. delete props.icons;
  7904. delete props.showText;
  7905. $( "<button></button>", props )
  7906. .button( buttonOptions )
  7907. .appendTo( that.uiButtonSet );
  7908. });
  7909. this.uiDialog.addClass("ui-dialog-buttons");
  7910. this.uiDialogButtonPane.appendTo( this.uiDialog );
  7911. },
  7912. _makeDraggable: function() {
  7913. var that = this,
  7914. options = this.options;
  7915. function filteredUi( ui ) {
  7916. return {
  7917. position: ui.position,
  7918. offset: ui.offset
  7919. };
  7920. }
  7921. this.uiDialog.draggable({
  7922. cancel: ".ui-dialog-content, .ui-dialog-titlebar-close",
  7923. handle: ".ui-dialog-titlebar",
  7924. containment: "document",
  7925. start: function( event, ui ) {
  7926. $( this ).addClass("ui-dialog-dragging");
  7927. that._trigger( "dragStart", event, filteredUi( ui ) );
  7928. },
  7929. drag: function( event, ui ) {
  7930. that._trigger( "drag", event, filteredUi( ui ) );
  7931. },
  7932. stop: function( event, ui ) {
  7933. options.position = [
  7934. ui.position.left - that.document.scrollLeft(),
  7935. ui.position.top - that.document.scrollTop()
  7936. ];
  7937. $( this ).removeClass("ui-dialog-dragging");
  7938. that._trigger( "dragStop", event, filteredUi( ui ) );
  7939. }
  7940. });
  7941. },
  7942. _makeResizable: function() {
  7943. var that = this,
  7944. options = this.options,
  7945. handles = options.resizable,
  7946. // .ui-resizable has position: relative defined in the stylesheet
  7947. // but dialogs have to use absolute or fixed positioning
  7948. position = this.uiDialog.css("position"),
  7949. resizeHandles = typeof handles === "string" ?
  7950. handles :
  7951. "n,e,s,w,se,sw,ne,nw";
  7952. function filteredUi( ui ) {
  7953. return {
  7954. originalPosition: ui.originalPosition,
  7955. originalSize: ui.originalSize,
  7956. position: ui.position,
  7957. size: ui.size
  7958. };
  7959. }
  7960. this.uiDialog.resizable({
  7961. cancel: ".ui-dialog-content",
  7962. containment: "document",
  7963. alsoResize: this.element,
  7964. maxWidth: options.maxWidth,
  7965. maxHeight: options.maxHeight,
  7966. minWidth: options.minWidth,
  7967. minHeight: this._minHeight(),
  7968. handles: resizeHandles,
  7969. start: function( event, ui ) {
  7970. $( this ).addClass("ui-dialog-resizing");
  7971. that._trigger( "resizeStart", event, filteredUi( ui ) );
  7972. },
  7973. resize: function( event, ui ) {
  7974. that._trigger( "resize", event, filteredUi( ui ) );
  7975. },
  7976. stop: function( event, ui ) {
  7977. options.height = $( this ).height();
  7978. options.width = $( this ).width();
  7979. $( this ).removeClass("ui-dialog-resizing");
  7980. that._trigger( "resizeStop", event, filteredUi( ui ) );
  7981. }
  7982. })
  7983. .css( "position", position );
  7984. },
  7985. _minHeight: function() {
  7986. var options = this.options;
  7987. return options.height === "auto" ?
  7988. options.minHeight :
  7989. Math.min( options.minHeight, options.height );
  7990. },
  7991. _position: function() {
  7992. // Need to show the dialog to get the actual offset in the position plugin
  7993. var isVisible = this.uiDialog.is(":visible");
  7994. if ( !isVisible ) {
  7995. this.uiDialog.show();
  7996. }
  7997. this.uiDialog.position( this.options.position );
  7998. if ( !isVisible ) {
  7999. this.uiDialog.hide();
  8000. }
  8001. },
  8002. _setOptions: function( options ) {
  8003. var that = this,
  8004. resize = false,
  8005. resizableOptions = {};
  8006. $.each( options, function( key, value ) {
  8007. that._setOption( key, value );
  8008. if ( key in sizeRelatedOptions ) {
  8009. resize = true;
  8010. }
  8011. if ( key in resizableRelatedOptions ) {
  8012. resizableOptions[ key ] = value;
  8013. }
  8014. });
  8015. if ( resize ) {
  8016. this._size();
  8017. this._position();
  8018. }
  8019. if ( this.uiDialog.is(":data(ui-resizable)") ) {
  8020. this.uiDialog.resizable( "option", resizableOptions );
  8021. }
  8022. },
  8023. _setOption: function( key, value ) {
  8024. /*jshint maxcomplexity:15*/
  8025. var isDraggable, isResizable,
  8026. uiDialog = this.uiDialog;
  8027. if ( key === "dialogClass" ) {
  8028. uiDialog
  8029. .removeClass( this.options.dialogClass )
  8030. .addClass( value );
  8031. }
  8032. if ( key === "disabled" ) {
  8033. return;
  8034. }
  8035. this._super( key, value );
  8036. if ( key === "appendTo" ) {
  8037. this.uiDialog.appendTo( this._appendTo() );
  8038. }
  8039. if ( key === "buttons" ) {
  8040. this._createButtons();
  8041. }
  8042. if ( key === "closeText" ) {
  8043. this.uiDialogTitlebarClose.button({
  8044. // Ensure that we always pass a string
  8045. label: "" + value
  8046. });
  8047. }
  8048. if ( key === "draggable" ) {
  8049. isDraggable = uiDialog.is(":data(ui-draggable)");
  8050. if ( isDraggable && !value ) {
  8051. uiDialog.draggable("destroy");
  8052. }
  8053. if ( !isDraggable && value ) {
  8054. this._makeDraggable();
  8055. }
  8056. }
  8057. if ( key === "position" ) {
  8058. this._position();
  8059. }
  8060. if ( key === "resizable" ) {
  8061. // currently resizable, becoming non-resizable
  8062. isResizable = uiDialog.is(":data(ui-resizable)");
  8063. if ( isResizable && !value ) {
  8064. uiDialog.resizable("destroy");
  8065. }
  8066. // currently resizable, changing handles
  8067. if ( isResizable && typeof value === "string" ) {
  8068. uiDialog.resizable( "option", "handles", value );
  8069. }
  8070. // currently non-resizable, becoming resizable
  8071. if ( !isResizable && value !== false ) {
  8072. this._makeResizable();
  8073. }
  8074. }
  8075. if ( key === "title" ) {
  8076. this._title( this.uiDialogTitlebar.find(".ui-dialog-title") );
  8077. }
  8078. },
  8079. _size: function() {
  8080. // If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
  8081. // divs will both have width and height set, so we need to reset them
  8082. var nonContentHeight, minContentHeight, maxContentHeight,
  8083. options = this.options;
  8084. // Reset content sizing
  8085. this.element.show().css({
  8086. width: "auto",
  8087. minHeight: 0,
  8088. maxHeight: "none",
  8089. height: 0
  8090. });
  8091. if ( options.minWidth > options.width ) {
  8092. options.width = options.minWidth;
  8093. }
  8094. // reset wrapper sizing
  8095. // determine the height of all the non-content elements
  8096. nonContentHeight = this.uiDialog.css({
  8097. height: "auto",
  8098. width: options.width
  8099. })
  8100. .outerHeight();
  8101. minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
  8102. maxContentHeight = typeof options.maxHeight === "number" ?
  8103. Math.max( 0, options.maxHeight - nonContentHeight ) :
  8104. "none";
  8105. if ( options.height === "auto" ) {
  8106. this.element.css({
  8107. minHeight: minContentHeight,
  8108. maxHeight: maxContentHeight,
  8109. height: "auto"
  8110. });
  8111. } else {
  8112. this.element.height( Math.max( 0, options.height - nonContentHeight ) );
  8113. }
  8114. if (this.uiDialog.is(":data(ui-resizable)") ) {
  8115. this.uiDialog.resizable( "option", "minHeight", this._minHeight() );
  8116. }
  8117. },
  8118. _createOverlay: function() {
  8119. if ( !this.options.modal ) {
  8120. return;
  8121. }
  8122. if ( !$.ui.dialog.overlayInstances ) {
  8123. // Prevent use of anchors and inputs.
  8124. // We use a delay in case the overlay is created from an
  8125. // event that we're going to be cancelling. (#2804)
  8126. this._delay(function() {
  8127. // Handle .dialog().dialog("close") (#4065)
  8128. if ( $.ui.dialog.overlayInstances ) {
  8129. this._on( this.document, {
  8130. focusin: function( event ) {
  8131. if ( !$( event.target ).closest(".ui-dialog").length ) {
  8132. event.preventDefault();
  8133. $(".ui-dialog:visible:last .ui-dialog-content")
  8134. .data("ui-dialog")._focusTabbable();
  8135. }
  8136. }
  8137. });
  8138. }
  8139. });
  8140. }
  8141. this.overlay = $("<div>")
  8142. .addClass("ui-widget-overlay ui-front")
  8143. .appendTo( this.document[0].body );
  8144. this._on( this.overlay, {
  8145. mousedown: "_keepFocus"
  8146. });
  8147. $.ui.dialog.overlayInstances++;
  8148. },
  8149. _destroyOverlay: function() {
  8150. if ( !this.options.modal ) {
  8151. return;
  8152. }
  8153. $.ui.dialog.overlayInstances--;
  8154. if ( !$.ui.dialog.overlayInstances ) {
  8155. this._off( this.document, "focusin" );
  8156. }
  8157. this.overlay.remove();
  8158. }
  8159. });
  8160. $.ui.dialog.overlayInstances = 0;
  8161. // DEPRECATED
  8162. if ( $.uiBackCompat !== false ) {
  8163. // position option with array notation
  8164. // just override with old implementation
  8165. $.widget( "ui.dialog", $.ui.dialog, {
  8166. _position: function() {
  8167. var position = this.options.position,
  8168. myAt = [],
  8169. offset = [ 0, 0 ],
  8170. isVisible;
  8171. if ( position ) {
  8172. if ( typeof position === "string" || (typeof position === "object" && "0" in position ) ) {
  8173. myAt = position.split ? position.split(" ") : [ position[0], position[1] ];
  8174. if ( myAt.length === 1 ) {
  8175. myAt[1] = myAt[0];
  8176. }
  8177. $.each( [ "left", "top" ], function( i, offsetPosition ) {
  8178. if ( +myAt[ i ] === myAt[ i ] ) {
  8179. offset[ i ] = myAt[ i ];
  8180. myAt[ i ] = offsetPosition;
  8181. }
  8182. });
  8183. position = {
  8184. my: myAt[0] + (offset[0] < 0 ? offset[0] : "+" + offset[0]) + " " +
  8185. myAt[1] + (offset[1] < 0 ? offset[1] : "+" + offset[1]),
  8186. at: myAt.join(" ")
  8187. };
  8188. }
  8189. position = $.extend( {}, $.ui.dialog.prototype.options.position, position );
  8190. } else {
  8191. position = $.ui.dialog.prototype.options.position;
  8192. }
  8193. // need to show the dialog to get the actual offset in the position plugin
  8194. isVisible = this.uiDialog.is(":visible");
  8195. if ( !isVisible ) {
  8196. this.uiDialog.show();
  8197. }
  8198. this.uiDialog.position( position );
  8199. if ( !isVisible ) {
  8200. this.uiDialog.hide();
  8201. }
  8202. }
  8203. });
  8204. }
  8205. }( jQuery ) );
  8206. (function( $, undefined ) {
  8207. $.widget( "ui.menu", {
  8208. version: "1.10.0",
  8209. defaultElement: "<ul>",
  8210. delay: 300,
  8211. options: {
  8212. icons: {
  8213. submenu: "ui-icon-carat-1-e"
  8214. },
  8215. menus: "ul",
  8216. position: {
  8217. my: "left top",
  8218. at: "right top"
  8219. },
  8220. role: "menu",
  8221. // callbacks
  8222. blur: null,
  8223. focus: null,
  8224. select: null
  8225. },
  8226. _create: function() {
  8227. this.activeMenu = this.element;
  8228. // flag used to prevent firing of the click handler
  8229. // as the event bubbles up through nested menus
  8230. this.mouseHandled = false;
  8231. this.element
  8232. .uniqueId()
  8233. .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
  8234. .toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length )
  8235. .attr({
  8236. role: this.options.role,
  8237. tabIndex: 0
  8238. })
  8239. // need to catch all clicks on disabled menu
  8240. // not possible through _on
  8241. .bind( "click" + this.eventNamespace, $.proxy(function( event ) {
  8242. if ( this.options.disabled ) {
  8243. event.preventDefault();
  8244. }
  8245. }, this ));
  8246. if ( this.options.disabled ) {
  8247. this.element
  8248. .addClass( "ui-state-disabled" )
  8249. .attr( "aria-disabled", "true" );
  8250. }
  8251. this._on({
  8252. // Prevent focus from sticking to links inside menu after clicking
  8253. // them (focus should always stay on UL during navigation).
  8254. "mousedown .ui-menu-item > a": function( event ) {
  8255. event.preventDefault();
  8256. },
  8257. "click .ui-state-disabled > a": function( event ) {
  8258. event.preventDefault();
  8259. },
  8260. "click .ui-menu-item:has(a)": function( event ) {
  8261. var target = $( event.target ).closest( ".ui-menu-item" );
  8262. if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
  8263. this.mouseHandled = true;
  8264. this.select( event );
  8265. // Open submenu on click
  8266. if ( target.has( ".ui-menu" ).length ) {
  8267. this.expand( event );
  8268. } else if ( !this.element.is( ":focus" ) ) {
  8269. // Redirect focus to the menu
  8270. this.element.trigger( "focus", [ true ] );
  8271. // If the active item is on the top level, let it stay active.
  8272. // Otherwise, blur the active item since it is no longer visible.
  8273. if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
  8274. clearTimeout( this.timer );
  8275. }
  8276. }
  8277. }
  8278. },
  8279. "mouseenter .ui-menu-item": function( event ) {
  8280. var target = $( event.currentTarget );
  8281. // Remove ui-state-active class from siblings of the newly focused menu item
  8282. // to avoid a jump caused by adjacent elements both having a class with a border
  8283. target.siblings().children( ".ui-state-active" ).removeClass( "ui-state-active" );
  8284. this.focus( event, target );
  8285. },
  8286. mouseleave: "collapseAll",
  8287. "mouseleave .ui-menu": "collapseAll",
  8288. focus: function( event, keepActiveItem ) {
  8289. // If there's already an active item, keep it active
  8290. // If not, activate the first item
  8291. var item = this.active || this.element.children( ".ui-menu-item" ).eq( 0 );
  8292. if ( !keepActiveItem ) {
  8293. this.focus( event, item );
  8294. }
  8295. },
  8296. blur: function( event ) {
  8297. this._delay(function() {
  8298. if ( !$.contains( this.element[0], this.document[0].activeElement ) ) {
  8299. this.collapseAll( event );
  8300. }
  8301. });
  8302. },
  8303. keydown: "_keydown"
  8304. });
  8305. this.refresh();
  8306. // Clicks outside of a menu collapse any open menus
  8307. this._on( this.document, {
  8308. click: function( event ) {
  8309. if ( !$( event.target ).closest( ".ui-menu" ).length ) {
  8310. this.collapseAll( event );
  8311. }
  8312. // Reset the mouseHandled flag
  8313. this.mouseHandled = false;
  8314. }
  8315. });
  8316. },
  8317. _destroy: function() {
  8318. // Destroy (sub)menus
  8319. this.element
  8320. .removeAttr( "aria-activedescendant" )
  8321. .find( ".ui-menu" ).addBack()
  8322. .removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all ui-menu-icons" )
  8323. .removeAttr( "role" )
  8324. .removeAttr( "tabIndex" )
  8325. .removeAttr( "aria-labelledby" )
  8326. .removeAttr( "aria-expanded" )
  8327. .removeAttr( "aria-hidden" )
  8328. .removeAttr( "aria-disabled" )
  8329. .removeUniqueId()
  8330. .show();
  8331. // Destroy menu items
  8332. this.element.find( ".ui-menu-item" )
  8333. .removeClass( "ui-menu-item" )
  8334. .removeAttr( "role" )
  8335. .removeAttr( "aria-disabled" )
  8336. .children( "a" )
  8337. .removeUniqueId()
  8338. .removeClass( "ui-corner-all ui-state-hover" )
  8339. .removeAttr( "tabIndex" )
  8340. .removeAttr( "role" )
  8341. .removeAttr( "aria-haspopup" )
  8342. .children().each( function() {
  8343. var elem = $( this );
  8344. if ( elem.data( "ui-menu-submenu-carat" ) ) {
  8345. elem.remove();
  8346. }
  8347. });
  8348. // Destroy menu dividers
  8349. this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" );
  8350. },
  8351. _keydown: function( event ) {
  8352. /*jshint maxcomplexity:20*/
  8353. var match, prev, character, skip, regex,
  8354. preventDefault = true;
  8355. function escape( value ) {
  8356. return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
  8357. }
  8358. switch ( event.keyCode ) {
  8359. case $.ui.keyCode.PAGE_UP:
  8360. this.previousPage( event );
  8361. break;
  8362. case $.ui.keyCode.PAGE_DOWN:
  8363. this.nextPage( event );
  8364. break;
  8365. case $.ui.keyCode.HOME:
  8366. this._move( "first", "first", event );
  8367. break;
  8368. case $.ui.keyCode.END:
  8369. this._move( "last", "last", event );
  8370. break;
  8371. case $.ui.keyCode.UP:
  8372. this.previous( event );
  8373. break;
  8374. case $.ui.keyCode.DOWN:
  8375. this.next( event );
  8376. break;
  8377. case $.ui.keyCode.LEFT:
  8378. this.collapse( event );
  8379. break;
  8380. case $.ui.keyCode.RIGHT:
  8381. if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
  8382. this.expand( event );
  8383. }
  8384. break;
  8385. case $.ui.keyCode.ENTER:
  8386. case $.ui.keyCode.SPACE:
  8387. this._activate( event );
  8388. break;
  8389. case $.ui.keyCode.ESCAPE:
  8390. this.collapse( event );
  8391. break;
  8392. default:
  8393. preventDefault = false;
  8394. prev = this.previousFilter || "";
  8395. character = String.fromCharCode( event.keyCode );
  8396. skip = false;
  8397. clearTimeout( this.filterTimer );
  8398. if ( character === prev ) {
  8399. skip = true;
  8400. } else {
  8401. character = prev + character;
  8402. }
  8403. regex = new RegExp( "^" + escape( character ), "i" );
  8404. match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
  8405. return regex.test( $( this ).children( "a" ).text() );
  8406. });
  8407. match = skip && match.index( this.active.next() ) !== -1 ?
  8408. this.active.nextAll( ".ui-menu-item" ) :
  8409. match;
  8410. // If no matches on the current filter, reset to the last character pressed
  8411. // to move down the menu to the first item that starts with that character
  8412. if ( !match.length ) {
  8413. character = String.fromCharCode( event.keyCode );
  8414. regex = new RegExp( "^" + escape( character ), "i" );
  8415. match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
  8416. return regex.test( $( this ).children( "a" ).text() );
  8417. });
  8418. }
  8419. if ( match.length ) {
  8420. this.focus( event, match );
  8421. if ( match.length > 1 ) {
  8422. this.previousFilter = character;
  8423. this.filterTimer = this._delay(function() {
  8424. delete this.previousFilter;
  8425. }, 1000 );
  8426. } else {
  8427. delete this.previousFilter;
  8428. }
  8429. } else {
  8430. delete this.previousFilter;
  8431. }
  8432. }
  8433. if ( preventDefault ) {
  8434. event.preventDefault();
  8435. }
  8436. },
  8437. _activate: function( event ) {
  8438. if ( !this.active.is( ".ui-state-disabled" ) ) {
  8439. if ( this.active.children( "a[aria-haspopup='true']" ).length ) {
  8440. this.expand( event );
  8441. } else {
  8442. this.select( event );
  8443. }
  8444. }
  8445. },
  8446. refresh: function() {
  8447. var menus,
  8448. icon = this.options.icons.submenu,
  8449. submenus = this.element.find( this.options.menus );
  8450. // Initialize nested menus
  8451. submenus.filter( ":not(.ui-menu)" )
  8452. .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
  8453. .hide()
  8454. .attr({
  8455. role: this.options.role,
  8456. "aria-hidden": "true",
  8457. "aria-expanded": "false"
  8458. })
  8459. .each(function() {
  8460. var menu = $( this ),
  8461. item = menu.prev( "a" ),
  8462. submenuCarat = $( "<span>" )
  8463. .addClass( "ui-menu-icon ui-icon " + icon )
  8464. .data( "ui-menu-submenu-carat", true );
  8465. item
  8466. .attr( "aria-haspopup", "true" )
  8467. .prepend( submenuCarat );
  8468. menu.attr( "aria-labelledby", item.attr( "id" ) );
  8469. });
  8470. menus = submenus.add( this.element );
  8471. // Don't refresh list items that are already adapted
  8472. menus.children( ":not(.ui-menu-item):has(a)" )
  8473. .addClass( "ui-menu-item" )
  8474. .attr( "role", "presentation" )
  8475. .children( "a" )
  8476. .uniqueId()
  8477. .addClass( "ui-corner-all" )
  8478. .attr({
  8479. tabIndex: -1,
  8480. role: this._itemRole()
  8481. });
  8482. // Initialize unlinked menu-items containing spaces and/or dashes only as dividers
  8483. menus.children( ":not(.ui-menu-item)" ).each(function() {
  8484. var item = $( this );
  8485. // hyphen, em dash, en dash
  8486. if ( !/[^\-—–\s]/.test( item.text() ) ) {
  8487. item.addClass( "ui-widget-content ui-menu-divider" );
  8488. }
  8489. });
  8490. // Add aria-disabled attribute to any disabled menu item
  8491. menus.children( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
  8492. // If the active item has been removed, blur the menu
  8493. if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  8494. this.blur();
  8495. }
  8496. },
  8497. _itemRole: function() {
  8498. return {
  8499. menu: "menuitem",
  8500. listbox: "option"
  8501. }[ this.options.role ];
  8502. },
  8503. _setOption: function( key, value ) {
  8504. if ( key === "icons" ) {
  8505. this.element.find( ".ui-menu-icon" )
  8506. .removeClass( this.options.icons.submenu )
  8507. .addClass( value.submenu );
  8508. }
  8509. this._super( key, value );
  8510. },
  8511. focus: function( event, item ) {
  8512. var nested, focused;
  8513. this.blur( event, event && event.type === "focus" );
  8514. this._scrollIntoView( item );
  8515. this.active = item.first();
  8516. focused = this.active.children( "a" ).addClass( "ui-state-focus" );
  8517. // Only update aria-activedescendant if there's a role
  8518. // otherwise we assume focus is managed elsewhere
  8519. if ( this.options.role ) {
  8520. this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
  8521. }
  8522. // Highlight active parent menu item, if any
  8523. this.active
  8524. .parent()
  8525. .closest( ".ui-menu-item" )
  8526. .children( "a:first" )
  8527. .addClass( "ui-state-active" );
  8528. if ( event && event.type === "keydown" ) {
  8529. this._close();
  8530. } else {
  8531. this.timer = this._delay(function() {
  8532. this._close();
  8533. }, this.delay );
  8534. }
  8535. nested = item.children( ".ui-menu" );
  8536. if ( nested.length && ( /^mouse/.test( event.type ) ) ) {
  8537. this._startOpening(nested);
  8538. }
  8539. this.activeMenu = item.parent();
  8540. this._trigger( "focus", event, { item: item } );
  8541. },
  8542. _scrollIntoView: function( item ) {
  8543. var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
  8544. if ( this._hasScroll() ) {
  8545. borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0;
  8546. paddingTop = parseFloat( $.css( this.activeMenu[0], "paddingTop" ) ) || 0;
  8547. offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
  8548. scroll = this.activeMenu.scrollTop();
  8549. elementHeight = this.activeMenu.height();
  8550. itemHeight = item.height();
  8551. if ( offset < 0 ) {
  8552. this.activeMenu.scrollTop( scroll + offset );
  8553. } else if ( offset + itemHeight > elementHeight ) {
  8554. this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
  8555. }
  8556. }
  8557. },
  8558. blur: function( event, fromFocus ) {
  8559. if ( !fromFocus ) {
  8560. clearTimeout( this.timer );
  8561. }
  8562. if ( !this.active ) {
  8563. return;
  8564. }
  8565. this.active.children( "a" ).removeClass( "ui-state-focus" );
  8566. this.active = null;
  8567. this._trigger( "blur", event, { item: this.active } );
  8568. },
  8569. _startOpening: function( submenu ) {
  8570. clearTimeout( this.timer );
  8571. // Don't open if already open fixes a Firefox bug that caused a .5 pixel
  8572. // shift in the submenu position when mousing over the carat icon
  8573. if ( submenu.attr( "aria-hidden" ) !== "true" ) {
  8574. return;
  8575. }
  8576. this.timer = this._delay(function() {
  8577. this._close();
  8578. this._open( submenu );
  8579. }, this.delay );
  8580. },
  8581. _open: function( submenu ) {
  8582. var position = $.extend({
  8583. of: this.active
  8584. }, this.options.position );
  8585. clearTimeout( this.timer );
  8586. this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
  8587. .hide()
  8588. .attr( "aria-hidden", "true" );
  8589. submenu
  8590. .show()
  8591. .removeAttr( "aria-hidden" )
  8592. .attr( "aria-expanded", "true" )
  8593. .position( position );
  8594. },
  8595. collapseAll: function( event, all ) {
  8596. clearTimeout( this.timer );
  8597. this.timer = this._delay(function() {
  8598. // If we were passed an event, look for the submenu that contains the event
  8599. var currentMenu = all ? this.element :
  8600. $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
  8601. // If we found no valid submenu ancestor, use the main menu to close all sub menus anyway
  8602. if ( !currentMenu.length ) {
  8603. currentMenu = this.element;
  8604. }
  8605. this._close( currentMenu );
  8606. this.blur( event );
  8607. this.activeMenu = currentMenu;
  8608. }, this.delay );
  8609. },
  8610. // With no arguments, closes the currently active menu - if nothing is active
  8611. // it closes all menus. If passed an argument, it will search for menus BELOW
  8612. _close: function( startMenu ) {
  8613. if ( !startMenu ) {
  8614. startMenu = this.active ? this.active.parent() : this.element;
  8615. }
  8616. startMenu
  8617. .find( ".ui-menu" )
  8618. .hide()
  8619. .attr( "aria-hidden", "true" )
  8620. .attr( "aria-expanded", "false" )
  8621. .end()
  8622. .find( "a.ui-state-active" )
  8623. .removeClass( "ui-state-active" );
  8624. },
  8625. collapse: function( event ) {
  8626. var newItem = this.active &&
  8627. this.active.parent().closest( ".ui-menu-item", this.element );
  8628. if ( newItem && newItem.length ) {
  8629. this._close();
  8630. this.focus( event, newItem );
  8631. }
  8632. },
  8633. expand: function( event ) {
  8634. var newItem = this.active &&
  8635. this.active
  8636. .children( ".ui-menu " )
  8637. .children( ".ui-menu-item" )
  8638. .first();
  8639. if ( newItem && newItem.length ) {
  8640. this._open( newItem.parent() );
  8641. // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
  8642. this._delay(function() {
  8643. this.focus( event, newItem );
  8644. });
  8645. }
  8646. },
  8647. next: function( event ) {
  8648. this._move( "next", "first", event );
  8649. },
  8650. previous: function( event ) {
  8651. this._move( "prev", "last", event );
  8652. },
  8653. isFirstItem: function() {
  8654. return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
  8655. },
  8656. isLastItem: function() {
  8657. return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
  8658. },
  8659. _move: function( direction, filter, event ) {
  8660. var next;
  8661. if ( this.active ) {
  8662. if ( direction === "first" || direction === "last" ) {
  8663. next = this.active
  8664. [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
  8665. .eq( -1 );
  8666. } else {
  8667. next = this.active
  8668. [ direction + "All" ]( ".ui-menu-item" )
  8669. .eq( 0 );
  8670. }
  8671. }
  8672. if ( !next || !next.length || !this.active ) {
  8673. next = this.activeMenu.children( ".ui-menu-item" )[ filter ]();
  8674. }
  8675. this.focus( event, next );
  8676. },
  8677. nextPage: function( event ) {
  8678. var item, base, height;
  8679. if ( !this.active ) {
  8680. this.next( event );
  8681. return;
  8682. }
  8683. if ( this.isLastItem() ) {
  8684. return;
  8685. }
  8686. if ( this._hasScroll() ) {
  8687. base = this.active.offset().top;
  8688. height = this.element.height();
  8689. this.active.nextAll( ".ui-menu-item" ).each(function() {
  8690. item = $( this );
  8691. return item.offset().top - base - height < 0;
  8692. });
  8693. this.focus( event, item );
  8694. } else {
  8695. this.focus( event, this.activeMenu.children( ".ui-menu-item" )
  8696. [ !this.active ? "first" : "last" ]() );
  8697. }
  8698. },
  8699. previousPage: function( event ) {
  8700. var item, base, height;
  8701. if ( !this.active ) {
  8702. this.next( event );
  8703. return;
  8704. }
  8705. if ( this.isFirstItem() ) {
  8706. return;
  8707. }
  8708. if ( this._hasScroll() ) {
  8709. base = this.active.offset().top;
  8710. height = this.element.height();
  8711. this.active.prevAll( ".ui-menu-item" ).each(function() {
  8712. item = $( this );
  8713. return item.offset().top - base + height > 0;
  8714. });
  8715. this.focus( event, item );
  8716. } else {
  8717. this.focus( event, this.activeMenu.children( ".ui-menu-item" ).first() );
  8718. }
  8719. },
  8720. _hasScroll: function() {
  8721. return this.element.outerHeight() < this.element.prop( "scrollHeight" );
  8722. },
  8723. select: function( event ) {
  8724. // TODO: It should never be possible to not have an active item at this
  8725. // point, but the tests don't trigger mouseenter before click.
  8726. this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
  8727. var ui = { item: this.active };
  8728. if ( !this.active.has( ".ui-menu" ).length ) {
  8729. this.collapseAll( event, true );
  8730. }
  8731. this._trigger( "select", event, ui );
  8732. }
  8733. });
  8734. }( jQuery ));
  8735. (function( $, undefined ) {
  8736. $.widget( "ui.progressbar", {
  8737. version: "1.10.0",
  8738. options: {
  8739. max: 100,
  8740. value: 0,
  8741. change: null,
  8742. complete: null
  8743. },
  8744. min: 0,
  8745. _create: function() {
  8746. // Constrain initial value
  8747. this.oldValue = this.options.value = this._constrainedValue();
  8748. this.element
  8749. .addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  8750. .attr({
  8751. // Only set static values, aria-valuenow and aria-valuemax are
  8752. // set inside _refreshValue()
  8753. role: "progressbar",
  8754. "aria-valuemin": this.min
  8755. });
  8756. this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
  8757. .appendTo( this.element );
  8758. this._refreshValue();
  8759. },
  8760. _destroy: function() {
  8761. this.element
  8762. .removeClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  8763. .removeAttr( "role" )
  8764. .removeAttr( "aria-valuemin" )
  8765. .removeAttr( "aria-valuemax" )
  8766. .removeAttr( "aria-valuenow" );
  8767. this.valueDiv.remove();
  8768. },
  8769. value: function( newValue ) {
  8770. if ( newValue === undefined ) {
  8771. return this.options.value;
  8772. }
  8773. this.options.value = this._constrainedValue( newValue );
  8774. this._refreshValue();
  8775. },
  8776. _constrainedValue: function( newValue ) {
  8777. if ( newValue === undefined ) {
  8778. newValue = this.options.value;
  8779. }
  8780. this.indeterminate = newValue === false;
  8781. // sanitize value
  8782. if ( typeof newValue !== "number" ) {
  8783. newValue = 0;
  8784. }
  8785. return this.indeterminate ? false :
  8786. Math.min( this.options.max, Math.max( this.min, newValue ) );
  8787. },
  8788. _setOptions: function( options ) {
  8789. // Ensure "value" option is set after other values (like max)
  8790. var value = options.value;
  8791. delete options.value;
  8792. this._super( options );
  8793. this.options.value = this._constrainedValue( value );
  8794. this._refreshValue();
  8795. },
  8796. _setOption: function( key, value ) {
  8797. if ( key === "max" ) {
  8798. // Don't allow a max less than min
  8799. value = Math.max( this.min, value );
  8800. }
  8801. this._super( key, value );
  8802. },
  8803. _percentage: function() {
  8804. return this.indeterminate ? 100 : 100 * ( this.options.value - this.min ) / ( this.options.max - this.min );
  8805. },
  8806. _refreshValue: function() {
  8807. var value = this.options.value,
  8808. percentage = this._percentage();
  8809. this.valueDiv
  8810. .toggle( this.indeterminate || value > this.min )
  8811. .toggleClass( "ui-corner-right", value === this.options.max )
  8812. .width( percentage.toFixed(0) + "%" );
  8813. this.element.toggleClass( "ui-progressbar-indeterminate", this.indeterminate );
  8814. if ( this.indeterminate ) {
  8815. this.element.removeAttr( "aria-valuenow" );
  8816. if ( !this.overlayDiv ) {
  8817. this.overlayDiv = $( "<div class='ui-progressbar-overlay'></div>" ).appendTo( this.valueDiv );
  8818. }
  8819. } else {
  8820. this.element.attr({
  8821. "aria-valuemax": this.options.max,
  8822. "aria-valuenow": value
  8823. });
  8824. if ( this.overlayDiv ) {
  8825. this.overlayDiv.remove();
  8826. this.overlayDiv = null;
  8827. }
  8828. }
  8829. if ( this.oldValue !== value ) {
  8830. this.oldValue = value;
  8831. this._trigger( "change" );
  8832. }
  8833. if ( value === this.options.max ) {
  8834. this._trigger( "complete" );
  8835. }
  8836. }
  8837. });
  8838. })( jQuery );
  8839. (function( $, undefined ) {
  8840. // number of pages in a slider
  8841. // (how many times can you page up/down to go through the whole range)
  8842. var numPages = 5;
  8843. $.widget( "ui.slider", $.ui.mouse, {
  8844. version: "1.10.0",
  8845. widgetEventPrefix: "slide",
  8846. options: {
  8847. animate: false,
  8848. distance: 0,
  8849. max: 100,
  8850. min: 0,
  8851. orientation: "horizontal",
  8852. range: false,
  8853. step: 1,
  8854. value: 0,
  8855. values: null,
  8856. // callbacks
  8857. change: null,
  8858. slide: null,
  8859. start: null,
  8860. stop: null
  8861. },
  8862. _create: function() {
  8863. var i, handleCount,
  8864. o = this.options,
  8865. existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ),
  8866. handle = "<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>",
  8867. handles = [];
  8868. this._keySliding = false;
  8869. this._mouseSliding = false;
  8870. this._animateOff = true;
  8871. this._handleIndex = null;
  8872. this._detectOrientation();
  8873. this._mouseInit();
  8874. this.element
  8875. .addClass( "ui-slider" +
  8876. " ui-slider-" + this.orientation +
  8877. " ui-widget" +
  8878. " ui-widget-content" +
  8879. " ui-corner-all");
  8880. this.range = $([]);
  8881. if ( o.range ) {
  8882. if ( o.range === true ) {
  8883. if ( !o.values ) {
  8884. o.values = [ this._valueMin(), this._valueMin() ];
  8885. } else if ( o.values.length && o.values.length !== 2 ) {
  8886. o.values = [ o.values[0], o.values[0] ];
  8887. } else if ( $.isArray( o.values ) ) {
  8888. o.values = o.values.slice(0);
  8889. }
  8890. }
  8891. this.range = $( "<div></div>" )
  8892. .appendTo( this.element )
  8893. .addClass( "ui-slider-range" +
  8894. // note: this isn't the most fittingly semantic framework class for this element,
  8895. // but worked best visually with a variety of themes
  8896. " ui-widget-header" +
  8897. ( ( o.range === "min" || o.range === "max" ) ? " ui-slider-range-" + o.range : "" ) );
  8898. }
  8899. handleCount = ( o.values && o.values.length ) || 1;
  8900. for ( i = existingHandles.length; i < handleCount; i++ ) {
  8901. handles.push( handle );
  8902. }
  8903. this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );
  8904. this.handle = this.handles.eq( 0 );
  8905. this.handles.add( this.range ).filter( "a" )
  8906. .click(function( event ) {
  8907. event.preventDefault();
  8908. })
  8909. .mouseenter(function() {
  8910. if ( !o.disabled ) {
  8911. $( this ).addClass( "ui-state-hover" );
  8912. }
  8913. })
  8914. .mouseleave(function() {
  8915. $( this ).removeClass( "ui-state-hover" );
  8916. })
  8917. .focus(function() {
  8918. if ( !o.disabled ) {
  8919. $( ".ui-slider .ui-state-focus" ).removeClass( "ui-state-focus" );
  8920. $( this ).addClass( "ui-state-focus" );
  8921. } else {
  8922. $( this ).blur();
  8923. }
  8924. })
  8925. .blur(function() {
  8926. $( this ).removeClass( "ui-state-focus" );
  8927. });
  8928. this.handles.each(function( i ) {
  8929. $( this ).data( "ui-slider-handle-index", i );
  8930. });
  8931. this._setOption( "disabled", o.disabled );
  8932. this._on( this.handles, this._handleEvents );
  8933. this._refreshValue();
  8934. this._animateOff = false;
  8935. },
  8936. _destroy: function() {
  8937. this.handles.remove();
  8938. this.range.remove();
  8939. this.element
  8940. .removeClass( "ui-slider" +
  8941. " ui-slider-horizontal" +
  8942. " ui-slider-vertical" +
  8943. " ui-widget" +
  8944. " ui-widget-content" +
  8945. " ui-corner-all" );
  8946. this._mouseDestroy();
  8947. },
  8948. _mouseCapture: function( event ) {
  8949. var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
  8950. that = this,
  8951. o = this.options;
  8952. if ( o.disabled ) {
  8953. return false;
  8954. }
  8955. this.elementSize = {
  8956. width: this.element.outerWidth(),
  8957. height: this.element.outerHeight()
  8958. };
  8959. this.elementOffset = this.element.offset();
  8960. position = { x: event.pageX, y: event.pageY };
  8961. normValue = this._normValueFromMouse( position );
  8962. distance = this._valueMax() - this._valueMin() + 1;
  8963. this.handles.each(function( i ) {
  8964. var thisDistance = Math.abs( normValue - that.values(i) );
  8965. if (( distance > thisDistance ) ||
  8966. ( distance === thisDistance &&
  8967. (i === that._lastChangedValue || that.values(i) === o.min ))) {
  8968. distance = thisDistance;
  8969. closestHandle = $( this );
  8970. index = i;
  8971. }
  8972. });
  8973. allowed = this._start( event, index );
  8974. if ( allowed === false ) {
  8975. return false;
  8976. }
  8977. this._mouseSliding = true;
  8978. this._handleIndex = index;
  8979. closestHandle
  8980. .addClass( "ui-state-active" )
  8981. .focus();
  8982. offset = closestHandle.offset();
  8983. mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" );
  8984. this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
  8985. left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
  8986. top: event.pageY - offset.top -
  8987. ( closestHandle.height() / 2 ) -
  8988. ( parseInt( closestHandle.css("borderTopWidth"), 10 ) || 0 ) -
  8989. ( parseInt( closestHandle.css("borderBottomWidth"), 10 ) || 0) +
  8990. ( parseInt( closestHandle.css("marginTop"), 10 ) || 0)
  8991. };
  8992. if ( !this.handles.hasClass( "ui-state-hover" ) ) {
  8993. this._slide( event, index, normValue );
  8994. }
  8995. this._animateOff = true;
  8996. return true;
  8997. },
  8998. _mouseStart: function() {
  8999. return true;
  9000. },
  9001. _mouseDrag: function( event ) {
  9002. var position = { x: event.pageX, y: event.pageY },
  9003. normValue = this._normValueFromMouse( position );
  9004. this._slide( event, this._handleIndex, normValue );
  9005. return false;
  9006. },
  9007. _mouseStop: function( event ) {
  9008. this.handles.removeClass( "ui-state-active" );
  9009. this._mouseSliding = false;
  9010. this._stop( event, this._handleIndex );
  9011. this._change( event, this._handleIndex );
  9012. this._handleIndex = null;
  9013. this._clickOffset = null;
  9014. this._animateOff = false;
  9015. return false;
  9016. },
  9017. _detectOrientation: function() {
  9018. this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
  9019. },
  9020. _normValueFromMouse: function( position ) {
  9021. var pixelTotal,
  9022. pixelMouse,
  9023. percentMouse,
  9024. valueTotal,
  9025. valueMouse;
  9026. if ( this.orientation === "horizontal" ) {
  9027. pixelTotal = this.elementSize.width;
  9028. pixelMouse = position.x - this.elementOffset.left - ( this._clickOffset ? this._clickOffset.left : 0 );
  9029. } else {
  9030. pixelTotal = this.elementSize.height;
  9031. pixelMouse = position.y - this.elementOffset.top - ( this._clickOffset ? this._clickOffset.top : 0 );
  9032. }
  9033. percentMouse = ( pixelMouse / pixelTotal );
  9034. if ( percentMouse > 1 ) {
  9035. percentMouse = 1;
  9036. }
  9037. if ( percentMouse < 0 ) {
  9038. percentMouse = 0;
  9039. }
  9040. if ( this.orientation === "vertical" ) {
  9041. percentMouse = 1 - percentMouse;
  9042. }
  9043. valueTotal = this._valueMax() - this._valueMin();
  9044. valueMouse = this._valueMin() + percentMouse * valueTotal;
  9045. return this._trimAlignValue( valueMouse );
  9046. },
  9047. _start: function( event, index ) {
  9048. var uiHash = {
  9049. handle: this.handles[ index ],
  9050. value: this.value()
  9051. };
  9052. if ( this.options.values && this.options.values.length ) {
  9053. uiHash.value = this.values( index );
  9054. uiHash.values = this.values();
  9055. }
  9056. return this._trigger( "start", event, uiHash );
  9057. },
  9058. _slide: function( event, index, newVal ) {
  9059. var otherVal,
  9060. newValues,
  9061. allowed;
  9062. if ( this.options.values && this.options.values.length ) {
  9063. otherVal = this.values( index ? 0 : 1 );
  9064. if ( ( this.options.values.length === 2 && this.options.range === true ) &&
  9065. ( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) )
  9066. ) {
  9067. newVal = otherVal;
  9068. }
  9069. if ( newVal !== this.values( index ) ) {
  9070. newValues = this.values();
  9071. newValues[ index ] = newVal;
  9072. // A slide can be canceled by returning false from the slide callback
  9073. allowed = this._trigger( "slide", event, {
  9074. handle: this.handles[ index ],
  9075. value: newVal,
  9076. values: newValues
  9077. } );
  9078. otherVal = this.values( index ? 0 : 1 );
  9079. if ( allowed !== false ) {
  9080. this.values( index, newVal, true );
  9081. }
  9082. }
  9083. } else {
  9084. if ( newVal !== this.value() ) {
  9085. // A slide can be canceled by returning false from the slide callback
  9086. allowed = this._trigger( "slide", event, {
  9087. handle: this.handles[ index ],
  9088. value: newVal
  9089. } );
  9090. if ( allowed !== false ) {
  9091. this.value( newVal );
  9092. }
  9093. }
  9094. }
  9095. },
  9096. _stop: function( event, index ) {
  9097. var uiHash = {
  9098. handle: this.handles[ index ],
  9099. value: this.value()
  9100. };
  9101. if ( this.options.values && this.options.values.length ) {
  9102. uiHash.value = this.values( index );
  9103. uiHash.values = this.values();
  9104. }
  9105. this._trigger( "stop", event, uiHash );
  9106. },
  9107. _change: function( event, index ) {
  9108. if ( !this._keySliding && !this._mouseSliding ) {
  9109. var uiHash = {
  9110. handle: this.handles[ index ],
  9111. value: this.value()
  9112. };
  9113. if ( this.options.values && this.options.values.length ) {
  9114. uiHash.value = this.values( index );
  9115. uiHash.values = this.values();
  9116. }
  9117. //store the last changed value index for reference when handles overlap
  9118. this._lastChangedValue = index;
  9119. this._trigger( "change", event, uiHash );
  9120. }
  9121. },
  9122. value: function( newValue ) {
  9123. if ( arguments.length ) {
  9124. this.options.value = this._trimAlignValue( newValue );
  9125. this._refreshValue();
  9126. this._change( null, 0 );
  9127. return;
  9128. }
  9129. return this._value();
  9130. },
  9131. values: function( index, newValue ) {
  9132. var vals,
  9133. newValues,
  9134. i;
  9135. if ( arguments.length > 1 ) {
  9136. this.options.values[ index ] = this._trimAlignValue( newValue );
  9137. this._refreshValue();
  9138. this._change( null, index );
  9139. return;
  9140. }
  9141. if ( arguments.length ) {
  9142. if ( $.isArray( arguments[ 0 ] ) ) {
  9143. vals = this.options.values;
  9144. newValues = arguments[ 0 ];
  9145. for ( i = 0; i < vals.length; i += 1 ) {
  9146. vals[ i ] = this._trimAlignValue( newValues[ i ] );
  9147. this._change( null, i );
  9148. }
  9149. this._refreshValue();
  9150. } else {
  9151. if ( this.options.values && this.options.values.length ) {
  9152. return this._values( index );
  9153. } else {
  9154. return this.value();
  9155. }
  9156. }
  9157. } else {
  9158. return this._values();
  9159. }
  9160. },
  9161. _setOption: function( key, value ) {
  9162. var i,
  9163. valsLength = 0;
  9164. if ( $.isArray( this.options.values ) ) {
  9165. valsLength = this.options.values.length;
  9166. }
  9167. $.Widget.prototype._setOption.apply( this, arguments );
  9168. switch ( key ) {
  9169. case "disabled":
  9170. if ( value ) {
  9171. this.handles.filter( ".ui-state-focus" ).blur();
  9172. this.handles.removeClass( "ui-state-hover" );
  9173. this.handles.prop( "disabled", true );
  9174. } else {
  9175. this.handles.prop( "disabled", false );
  9176. }
  9177. break;
  9178. case "orientation":
  9179. this._detectOrientation();
  9180. this.element
  9181. .removeClass( "ui-slider-horizontal ui-slider-vertical" )
  9182. .addClass( "ui-slider-" + this.orientation );
  9183. this._refreshValue();
  9184. break;
  9185. case "value":
  9186. this._animateOff = true;
  9187. this._refreshValue();
  9188. this._change( null, 0 );
  9189. this._animateOff = false;
  9190. break;
  9191. case "values":
  9192. this._animateOff = true;
  9193. this._refreshValue();
  9194. for ( i = 0; i < valsLength; i += 1 ) {
  9195. this._change( null, i );
  9196. }
  9197. this._animateOff = false;
  9198. break;
  9199. case "min":
  9200. case "max":
  9201. this._animateOff = true;
  9202. this._refreshValue();
  9203. this._animateOff = false;
  9204. break;
  9205. }
  9206. },
  9207. //internal value getter
  9208. // _value() returns value trimmed by min and max, aligned by step
  9209. _value: function() {
  9210. var val = this.options.value;
  9211. val = this._trimAlignValue( val );
  9212. return val;
  9213. },
  9214. //internal values getter
  9215. // _values() returns array of values trimmed by min and max, aligned by step
  9216. // _values( index ) returns single value trimmed by min and max, aligned by step
  9217. _values: function( index ) {
  9218. var val,
  9219. vals,
  9220. i;
  9221. if ( arguments.length ) {
  9222. val = this.options.values[ index ];
  9223. val = this._trimAlignValue( val );
  9224. return val;
  9225. } else {
  9226. // .slice() creates a copy of the array
  9227. // this copy gets trimmed by min and max and then returned
  9228. vals = this.options.values.slice();
  9229. for ( i = 0; i < vals.length; i+= 1) {
  9230. vals[ i ] = this._trimAlignValue( vals[ i ] );
  9231. }
  9232. return vals;
  9233. }
  9234. },
  9235. // returns the step-aligned value that val is closest to, between (inclusive) min and max
  9236. _trimAlignValue: function( val ) {
  9237. if ( val <= this._valueMin() ) {
  9238. return this._valueMin();
  9239. }
  9240. if ( val >= this._valueMax() ) {
  9241. return this._valueMax();
  9242. }
  9243. var step = ( this.options.step > 0 ) ? this.options.step : 1,
  9244. valModStep = (val - this._valueMin()) % step,
  9245. alignValue = val - valModStep;
  9246. if ( Math.abs(valModStep) * 2 >= step ) {
  9247. alignValue += ( valModStep > 0 ) ? step : ( -step );
  9248. }
  9249. // Since JavaScript has problems with large floats, round
  9250. // the final value to 5 digits after the decimal point (see #4124)
  9251. return parseFloat( alignValue.toFixed(5) );
  9252. },
  9253. _valueMin: function() {
  9254. return this.options.min;
  9255. },
  9256. _valueMax: function() {
  9257. return this.options.max;
  9258. },
  9259. _refreshValue: function() {
  9260. var lastValPercent, valPercent, value, valueMin, valueMax,
  9261. oRange = this.options.range,
  9262. o = this.options,
  9263. that = this,
  9264. animate = ( !this._animateOff ) ? o.animate : false,
  9265. _set = {};
  9266. if ( this.options.values && this.options.values.length ) {
  9267. this.handles.each(function( i ) {
  9268. valPercent = ( that.values(i) - that._valueMin() ) / ( that._valueMax() - that._valueMin() ) * 100;
  9269. _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  9270. $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  9271. if ( that.options.range === true ) {
  9272. if ( that.orientation === "horizontal" ) {
  9273. if ( i === 0 ) {
  9274. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate );
  9275. }
  9276. if ( i === 1 ) {
  9277. that.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  9278. }
  9279. } else {
  9280. if ( i === 0 ) {
  9281. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate );
  9282. }
  9283. if ( i === 1 ) {
  9284. that.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  9285. }
  9286. }
  9287. }
  9288. lastValPercent = valPercent;
  9289. });
  9290. } else {
  9291. value = this.value();
  9292. valueMin = this._valueMin();
  9293. valueMax = this._valueMax();
  9294. valPercent = ( valueMax !== valueMin ) ?
  9295. ( value - valueMin ) / ( valueMax - valueMin ) * 100 :
  9296. 0;
  9297. _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  9298. this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  9299. if ( oRange === "min" && this.orientation === "horizontal" ) {
  9300. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { width: valPercent + "%" }, o.animate );
  9301. }
  9302. if ( oRange === "max" && this.orientation === "horizontal" ) {
  9303. this.range[ animate ? "animate" : "css" ]( { width: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  9304. }
  9305. if ( oRange === "min" && this.orientation === "vertical" ) {
  9306. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { height: valPercent + "%" }, o.animate );
  9307. }
  9308. if ( oRange === "max" && this.orientation === "vertical" ) {
  9309. this.range[ animate ? "animate" : "css" ]( { height: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  9310. }
  9311. }
  9312. },
  9313. _handleEvents: {
  9314. keydown: function( event ) {
  9315. /*jshint maxcomplexity:25*/
  9316. var allowed, curVal, newVal, step,
  9317. index = $( event.target ).data( "ui-slider-handle-index" );
  9318. switch ( event.keyCode ) {
  9319. case $.ui.keyCode.HOME:
  9320. case $.ui.keyCode.END:
  9321. case $.ui.keyCode.PAGE_UP:
  9322. case $.ui.keyCode.PAGE_DOWN:
  9323. case $.ui.keyCode.UP:
  9324. case $.ui.keyCode.RIGHT:
  9325. case $.ui.keyCode.DOWN:
  9326. case $.ui.keyCode.LEFT:
  9327. event.preventDefault();
  9328. if ( !this._keySliding ) {
  9329. this._keySliding = true;
  9330. $( event.target ).addClass( "ui-state-active" );
  9331. allowed = this._start( event, index );
  9332. if ( allowed === false ) {
  9333. return;
  9334. }
  9335. }
  9336. break;
  9337. }
  9338. step = this.options.step;
  9339. if ( this.options.values && this.options.values.length ) {
  9340. curVal = newVal = this.values( index );
  9341. } else {
  9342. curVal = newVal = this.value();
  9343. }
  9344. switch ( event.keyCode ) {
  9345. case $.ui.keyCode.HOME:
  9346. newVal = this._valueMin();
  9347. break;
  9348. case $.ui.keyCode.END:
  9349. newVal = this._valueMax();
  9350. break;
  9351. case $.ui.keyCode.PAGE_UP:
  9352. newVal = this._trimAlignValue( curVal + ( (this._valueMax() - this._valueMin()) / numPages ) );
  9353. break;
  9354. case $.ui.keyCode.PAGE_DOWN:
  9355. newVal = this._trimAlignValue( curVal - ( (this._valueMax() - this._valueMin()) / numPages ) );
  9356. break;
  9357. case $.ui.keyCode.UP:
  9358. case $.ui.keyCode.RIGHT:
  9359. if ( curVal === this._valueMax() ) {
  9360. return;
  9361. }
  9362. newVal = this._trimAlignValue( curVal + step );
  9363. break;
  9364. case $.ui.keyCode.DOWN:
  9365. case $.ui.keyCode.LEFT:
  9366. if ( curVal === this._valueMin() ) {
  9367. return;
  9368. }
  9369. newVal = this._trimAlignValue( curVal - step );
  9370. break;
  9371. }
  9372. this._slide( event, index, newVal );
  9373. },
  9374. keyup: function( event ) {
  9375. var index = $( event.target ).data( "ui-slider-handle-index" );
  9376. if ( this._keySliding ) {
  9377. this._keySliding = false;
  9378. this._stop( event, index );
  9379. this._change( event, index );
  9380. $( event.target ).removeClass( "ui-state-active" );
  9381. }
  9382. }
  9383. }
  9384. });
  9385. }(jQuery));
  9386. (function( $ ) {
  9387. function modifier( fn ) {
  9388. return function() {
  9389. var previous = this.element.val();
  9390. fn.apply( this, arguments );
  9391. this._refresh();
  9392. if ( previous !== this.element.val() ) {
  9393. this._trigger( "change" );
  9394. }
  9395. };
  9396. }
  9397. $.widget( "ui.spinner", {
  9398. version: "1.10.0",
  9399. defaultElement: "<input>",
  9400. widgetEventPrefix: "spin",
  9401. options: {
  9402. culture: null,
  9403. icons: {
  9404. down: "ui-icon-triangle-1-s",
  9405. up: "ui-icon-triangle-1-n"
  9406. },
  9407. incremental: true,
  9408. max: null,
  9409. min: null,
  9410. numberFormat: null,
  9411. page: 10,
  9412. step: 1,
  9413. change: null,
  9414. spin: null,
  9415. start: null,
  9416. stop: null
  9417. },
  9418. _create: function() {
  9419. // handle string values that need to be parsed
  9420. this._setOption( "max", this.options.max );
  9421. this._setOption( "min", this.options.min );
  9422. this._setOption( "step", this.options.step );
  9423. // format the value, but don't constrain
  9424. this._value( this.element.val(), true );
  9425. this._draw();
  9426. this._on( this._events );
  9427. this._refresh();
  9428. // turning off autocomplete prevents the browser from remembering the
  9429. // value when navigating through history, so we re-enable autocomplete
  9430. // if the page is unloaded before the widget is destroyed. #7790
  9431. this._on( this.window, {
  9432. beforeunload: function() {
  9433. this.element.removeAttr( "autocomplete" );
  9434. }
  9435. });
  9436. },
  9437. _getCreateOptions: function() {
  9438. var options = {},
  9439. element = this.element;
  9440. $.each( [ "min", "max", "step" ], function( i, option ) {
  9441. var value = element.attr( option );
  9442. if ( value !== undefined && value.length ) {
  9443. options[ option ] = value;
  9444. }
  9445. });
  9446. return options;
  9447. },
  9448. _events: {
  9449. keydown: function( event ) {
  9450. if ( this._start( event ) && this._keydown( event ) ) {
  9451. event.preventDefault();
  9452. }
  9453. },
  9454. keyup: "_stop",
  9455. focus: function() {
  9456. this.previous = this.element.val();
  9457. },
  9458. blur: function( event ) {
  9459. if ( this.cancelBlur ) {
  9460. delete this.cancelBlur;
  9461. return;
  9462. }
  9463. this._refresh();
  9464. if ( this.previous !== this.element.val() ) {
  9465. this._trigger( "change", event );
  9466. }
  9467. },
  9468. mousewheel: function( event, delta ) {
  9469. if ( !delta ) {
  9470. return;
  9471. }
  9472. if ( !this.spinning && !this._start( event ) ) {
  9473. return false;
  9474. }
  9475. this._spin( (delta > 0 ? 1 : -1) * this.options.step, event );
  9476. clearTimeout( this.mousewheelTimer );
  9477. this.mousewheelTimer = this._delay(function() {
  9478. if ( this.spinning ) {
  9479. this._stop( event );
  9480. }
  9481. }, 100 );
  9482. event.preventDefault();
  9483. },
  9484. "mousedown .ui-spinner-button": function( event ) {
  9485. var previous;
  9486. // We never want the buttons to have focus; whenever the user is
  9487. // interacting with the spinner, the focus should be on the input.
  9488. // If the input is focused then this.previous is properly set from
  9489. // when the input first received focus. If the input is not focused
  9490. // then we need to set this.previous based on the value before spinning.
  9491. previous = this.element[0] === this.document[0].activeElement ?
  9492. this.previous : this.element.val();
  9493. function checkFocus() {
  9494. var isActive = this.element[0] === this.document[0].activeElement;
  9495. if ( !isActive ) {
  9496. this.element.focus();
  9497. this.previous = previous;
  9498. // support: IE
  9499. // IE sets focus asynchronously, so we need to check if focus
  9500. // moved off of the input because the user clicked on the button.
  9501. this._delay(function() {
  9502. this.previous = previous;
  9503. });
  9504. }
  9505. }
  9506. // ensure focus is on (or stays on) the text field
  9507. event.preventDefault();
  9508. checkFocus.call( this );
  9509. // support: IE
  9510. // IE doesn't prevent moving focus even with event.preventDefault()
  9511. // so we set a flag to know when we should ignore the blur event
  9512. // and check (again) if focus moved off of the input.
  9513. this.cancelBlur = true;
  9514. this._delay(function() {
  9515. delete this.cancelBlur;
  9516. checkFocus.call( this );
  9517. });
  9518. if ( this._start( event ) === false ) {
  9519. return;
  9520. }
  9521. this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  9522. },
  9523. "mouseup .ui-spinner-button": "_stop",
  9524. "mouseenter .ui-spinner-button": function( event ) {
  9525. // button will add ui-state-active if mouse was down while mouseleave and kept down
  9526. if ( !$( event.currentTarget ).hasClass( "ui-state-active" ) ) {
  9527. return;
  9528. }
  9529. if ( this._start( event ) === false ) {
  9530. return false;
  9531. }
  9532. this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  9533. },
  9534. // TODO: do we really want to consider this a stop?
  9535. // shouldn't we just stop the repeater and wait until mouseup before
  9536. // we trigger the stop event?
  9537. "mouseleave .ui-spinner-button": "_stop"
  9538. },
  9539. _draw: function() {
  9540. var uiSpinner = this.uiSpinner = this.element
  9541. .addClass( "ui-spinner-input" )
  9542. .attr( "autocomplete", "off" )
  9543. .wrap( this._uiSpinnerHtml() )
  9544. .parent()
  9545. // add buttons
  9546. .append( this._buttonHtml() );
  9547. this.element.attr( "role", "spinbutton" );
  9548. // button bindings
  9549. this.buttons = uiSpinner.find( ".ui-spinner-button" )
  9550. .attr( "tabIndex", -1 )
  9551. .button()
  9552. .removeClass( "ui-corner-all" );
  9553. // IE 6 doesn't understand height: 50% for the buttons
  9554. // unless the wrapper has an explicit height
  9555. if ( this.buttons.height() > Math.ceil( uiSpinner.height() * 0.5 ) &&
  9556. uiSpinner.height() > 0 ) {
  9557. uiSpinner.height( uiSpinner.height() );
  9558. }
  9559. // disable spinner if element was already disabled
  9560. if ( this.options.disabled ) {
  9561. this.disable();
  9562. }
  9563. },
  9564. _keydown: function( event ) {
  9565. var options = this.options,
  9566. keyCode = $.ui.keyCode;
  9567. switch ( event.keyCode ) {
  9568. case keyCode.UP:
  9569. this._repeat( null, 1, event );
  9570. return true;
  9571. case keyCode.DOWN:
  9572. this._repeat( null, -1, event );
  9573. return true;
  9574. case keyCode.PAGE_UP:
  9575. this._repeat( null, options.page, event );
  9576. return true;
  9577. case keyCode.PAGE_DOWN:
  9578. this._repeat( null, -options.page, event );
  9579. return true;
  9580. }
  9581. return false;
  9582. },
  9583. _uiSpinnerHtml: function() {
  9584. return "<span class='ui-spinner ui-widget ui-widget-content ui-corner-all'></span>";
  9585. },
  9586. _buttonHtml: function() {
  9587. return "" +
  9588. "<a class='ui-spinner-button ui-spinner-up ui-corner-tr'>" +
  9589. "<span class='ui-icon " + this.options.icons.up + "'>&#9650;</span>" +
  9590. "</a>" +
  9591. "<a class='ui-spinner-button ui-spinner-down ui-corner-br'>" +
  9592. "<span class='ui-icon " + this.options.icons.down + "'>&#9660;</span>" +
  9593. "</a>";
  9594. },
  9595. _start: function( event ) {
  9596. if ( !this.spinning && this._trigger( "start", event ) === false ) {
  9597. return false;
  9598. }
  9599. if ( !this.counter ) {
  9600. this.counter = 1;
  9601. }
  9602. this.spinning = true;
  9603. return true;
  9604. },
  9605. _repeat: function( i, steps, event ) {
  9606. i = i || 500;
  9607. clearTimeout( this.timer );
  9608. this.timer = this._delay(function() {
  9609. this._repeat( 40, steps, event );
  9610. }, i );
  9611. this._spin( steps * this.options.step, event );
  9612. },
  9613. _spin: function( step, event ) {
  9614. var value = this.value() || 0;
  9615. if ( !this.counter ) {
  9616. this.counter = 1;
  9617. }
  9618. value = this._adjustValue( value + step * this._increment( this.counter ) );
  9619. if ( !this.spinning || this._trigger( "spin", event, { value: value } ) !== false) {
  9620. this._value( value );
  9621. this.counter++;
  9622. }
  9623. },
  9624. _increment: function( i ) {
  9625. var incremental = this.options.incremental;
  9626. if ( incremental ) {
  9627. return $.isFunction( incremental ) ?
  9628. incremental( i ) :
  9629. Math.floor( i*i*i/50000 - i*i/500 + 17*i/200 + 1 );
  9630. }
  9631. return 1;
  9632. },
  9633. _precision: function() {
  9634. var precision = this._precisionOf( this.options.step );
  9635. if ( this.options.min !== null ) {
  9636. precision = Math.max( precision, this._precisionOf( this.options.min ) );
  9637. }
  9638. return precision;
  9639. },
  9640. _precisionOf: function( num ) {
  9641. var str = num.toString(),
  9642. decimal = str.indexOf( "." );
  9643. return decimal === -1 ? 0 : str.length - decimal - 1;
  9644. },
  9645. _adjustValue: function( value ) {
  9646. var base, aboveMin,
  9647. options = this.options;
  9648. // make sure we're at a valid step
  9649. // - find out where we are relative to the base (min or 0)
  9650. base = options.min !== null ? options.min : 0;
  9651. aboveMin = value - base;
  9652. // - round to the nearest step
  9653. aboveMin = Math.round(aboveMin / options.step) * options.step;
  9654. // - rounding is based on 0, so adjust back to our base
  9655. value = base + aboveMin;
  9656. // fix precision from bad JS floating point math
  9657. value = parseFloat( value.toFixed( this._precision() ) );
  9658. // clamp the value
  9659. if ( options.max !== null && value > options.max) {
  9660. return options.max;
  9661. }
  9662. if ( options.min !== null && value < options.min ) {
  9663. return options.min;
  9664. }
  9665. return value;
  9666. },
  9667. _stop: function( event ) {
  9668. if ( !this.spinning ) {
  9669. return;
  9670. }
  9671. clearTimeout( this.timer );
  9672. clearTimeout( this.mousewheelTimer );
  9673. this.counter = 0;
  9674. this.spinning = false;
  9675. this._trigger( "stop", event );
  9676. },
  9677. _setOption: function( key, value ) {
  9678. if ( key === "culture" || key === "numberFormat" ) {
  9679. var prevValue = this._parse( this.element.val() );
  9680. this.options[ key ] = value;
  9681. this.element.val( this._format( prevValue ) );
  9682. return;
  9683. }
  9684. if ( key === "max" || key === "min" || key === "step" ) {
  9685. if ( typeof value === "string" ) {
  9686. value = this._parse( value );
  9687. }
  9688. }
  9689. if ( key === "icons" ) {
  9690. this.buttons.first().find( ".ui-icon" )
  9691. .removeClass( this.options.icons.up )
  9692. .addClass( value.up );
  9693. this.buttons.last().find( ".ui-icon" )
  9694. .removeClass( this.options.icons.down )
  9695. .addClass( value.down );
  9696. }
  9697. this._super( key, value );
  9698. if ( key === "disabled" ) {
  9699. if ( value ) {
  9700. this.element.prop( "disabled", true );
  9701. this.buttons.button( "disable" );
  9702. } else {
  9703. this.element.prop( "disabled", false );
  9704. this.buttons.button( "enable" );
  9705. }
  9706. }
  9707. },
  9708. _setOptions: modifier(function( options ) {
  9709. this._super( options );
  9710. this._value( this.element.val() );
  9711. }),
  9712. _parse: function( val ) {
  9713. if ( typeof val === "string" && val !== "" ) {
  9714. val = window.Globalize && this.options.numberFormat ?
  9715. Globalize.parseFloat( val, 10, this.options.culture ) : +val;
  9716. }
  9717. return val === "" || isNaN( val ) ? null : val;
  9718. },
  9719. _format: function( value ) {
  9720. if ( value === "" ) {
  9721. return "";
  9722. }
  9723. return window.Globalize && this.options.numberFormat ?
  9724. Globalize.format( value, this.options.numberFormat, this.options.culture ) :
  9725. value;
  9726. },
  9727. _refresh: function() {
  9728. this.element.attr({
  9729. "aria-valuemin": this.options.min,
  9730. "aria-valuemax": this.options.max,
  9731. // TODO: what should we do with values that can't be parsed?
  9732. "aria-valuenow": this._parse( this.element.val() )
  9733. });
  9734. },
  9735. // update the value without triggering change
  9736. _value: function( value, allowAny ) {
  9737. var parsed;
  9738. if ( value !== "" ) {
  9739. parsed = this._parse( value );
  9740. if ( parsed !== null ) {
  9741. if ( !allowAny ) {
  9742. parsed = this._adjustValue( parsed );
  9743. }
  9744. value = this._format( parsed );
  9745. }
  9746. }
  9747. this.element.val( value );
  9748. this._refresh();
  9749. },
  9750. _destroy: function() {
  9751. this.element
  9752. .removeClass( "ui-spinner-input" )
  9753. .prop( "disabled", false )
  9754. .removeAttr( "autocomplete" )
  9755. .removeAttr( "role" )
  9756. .removeAttr( "aria-valuemin" )
  9757. .removeAttr( "aria-valuemax" )
  9758. .removeAttr( "aria-valuenow" );
  9759. this.uiSpinner.replaceWith( this.element );
  9760. },
  9761. stepUp: modifier(function( steps ) {
  9762. this._stepUp( steps );
  9763. }),
  9764. _stepUp: function( steps ) {
  9765. if ( this._start() ) {
  9766. this._spin( (steps || 1) * this.options.step );
  9767. this._stop();
  9768. }
  9769. },
  9770. stepDown: modifier(function( steps ) {
  9771. this._stepDown( steps );
  9772. }),
  9773. _stepDown: function( steps ) {
  9774. if ( this._start() ) {
  9775. this._spin( (steps || 1) * -this.options.step );
  9776. this._stop();
  9777. }
  9778. },
  9779. pageUp: modifier(function( pages ) {
  9780. this._stepUp( (pages || 1) * this.options.page );
  9781. }),
  9782. pageDown: modifier(function( pages ) {
  9783. this._stepDown( (pages || 1) * this.options.page );
  9784. }),
  9785. value: function( newVal ) {
  9786. if ( !arguments.length ) {
  9787. return this._parse( this.element.val() );
  9788. }
  9789. modifier( this._value ).call( this, newVal );
  9790. },
  9791. widget: function() {
  9792. return this.uiSpinner;
  9793. }
  9794. });
  9795. }( jQuery ) );
  9796. (function( $, undefined ) {
  9797. var tabId = 0,
  9798. rhash = /#.*$/;
  9799. function getNextTabId() {
  9800. return ++tabId;
  9801. }
  9802. function isLocal( anchor ) {
  9803. return anchor.hash.length > 1 &&
  9804. decodeURIComponent( anchor.href.replace( rhash, "" ) ) ===
  9805. decodeURIComponent( location.href.replace( rhash, "" ) );
  9806. }
  9807. $.widget( "ui.tabs", {
  9808. version: "1.10.0",
  9809. delay: 300,
  9810. options: {
  9811. active: null,
  9812. collapsible: false,
  9813. event: "click",
  9814. heightStyle: "content",
  9815. hide: null,
  9816. show: null,
  9817. // callbacks
  9818. activate: null,
  9819. beforeActivate: null,
  9820. beforeLoad: null,
  9821. load: null
  9822. },
  9823. _create: function() {
  9824. var that = this,
  9825. options = this.options;
  9826. this.running = false;
  9827. this.element
  9828. .addClass( "ui-tabs ui-widget ui-widget-content ui-corner-all" )
  9829. .toggleClass( "ui-tabs-collapsible", options.collapsible )
  9830. // Prevent users from focusing disabled tabs via click
  9831. .delegate( ".ui-tabs-nav > li", "mousedown" + this.eventNamespace, function( event ) {
  9832. if ( $( this ).is( ".ui-state-disabled" ) ) {
  9833. event.preventDefault();
  9834. }
  9835. })
  9836. // support: IE <9
  9837. // Preventing the default action in mousedown doesn't prevent IE
  9838. // from focusing the element, so if the anchor gets focused, blur.
  9839. // We don't have to worry about focusing the previously focused
  9840. // element since clicking on a non-focusable element should focus
  9841. // the body anyway.
  9842. .delegate( ".ui-tabs-anchor", "focus" + this.eventNamespace, function() {
  9843. if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) {
  9844. this.blur();
  9845. }
  9846. });
  9847. this._processTabs();
  9848. options.active = this._initialActive();
  9849. // Take disabling tabs via class attribute from HTML
  9850. // into account and update option properly.
  9851. if ( $.isArray( options.disabled ) ) {
  9852. options.disabled = $.unique( options.disabled.concat(
  9853. $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
  9854. return that.tabs.index( li );
  9855. })
  9856. ) ).sort();
  9857. }
  9858. // check for length avoids error when initializing empty list
  9859. if ( this.options.active !== false && this.anchors.length ) {
  9860. this.active = this._findActive( options.active );
  9861. } else {
  9862. this.active = $();
  9863. }
  9864. this._refresh();
  9865. if ( this.active.length ) {
  9866. this.load( options.active );
  9867. }
  9868. },
  9869. _initialActive: function() {
  9870. var active = this.options.active,
  9871. collapsible = this.options.collapsible,
  9872. locationHash = location.hash.substring( 1 );
  9873. if ( active === null ) {
  9874. // check the fragment identifier in the URL
  9875. if ( locationHash ) {
  9876. this.tabs.each(function( i, tab ) {
  9877. if ( $( tab ).attr( "aria-controls" ) === locationHash ) {
  9878. active = i;
  9879. return false;
  9880. }
  9881. });
  9882. }
  9883. // check for a tab marked active via a class
  9884. if ( active === null ) {
  9885. active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) );
  9886. }
  9887. // no active tab, set to false
  9888. if ( active === null || active === -1 ) {
  9889. active = this.tabs.length ? 0 : false;
  9890. }
  9891. }
  9892. // handle numbers: negative, out of range
  9893. if ( active !== false ) {
  9894. active = this.tabs.index( this.tabs.eq( active ) );
  9895. if ( active === -1 ) {
  9896. active = collapsible ? false : 0;
  9897. }
  9898. }
  9899. // don't allow collapsible: false and active: false
  9900. if ( !collapsible && active === false && this.anchors.length ) {
  9901. active = 0;
  9902. }
  9903. return active;
  9904. },
  9905. _getCreateEventData: function() {
  9906. return {
  9907. tab: this.active,
  9908. panel: !this.active.length ? $() : this._getPanelForTab( this.active )
  9909. };
  9910. },
  9911. _tabKeydown: function( event ) {
  9912. /*jshint maxcomplexity:15*/
  9913. var focusedTab = $( this.document[0].activeElement ).closest( "li" ),
  9914. selectedIndex = this.tabs.index( focusedTab ),
  9915. goingForward = true;
  9916. if ( this._handlePageNav( event ) ) {
  9917. return;
  9918. }
  9919. switch ( event.keyCode ) {
  9920. case $.ui.keyCode.RIGHT:
  9921. case $.ui.keyCode.DOWN:
  9922. selectedIndex++;
  9923. break;
  9924. case $.ui.keyCode.UP:
  9925. case $.ui.keyCode.LEFT:
  9926. goingForward = false;
  9927. selectedIndex--;
  9928. break;
  9929. case $.ui.keyCode.END:
  9930. selectedIndex = this.anchors.length - 1;
  9931. break;
  9932. case $.ui.keyCode.HOME:
  9933. selectedIndex = 0;
  9934. break;
  9935. case $.ui.keyCode.SPACE:
  9936. // Activate only, no collapsing
  9937. event.preventDefault();
  9938. clearTimeout( this.activating );
  9939. this._activate( selectedIndex );
  9940. return;
  9941. case $.ui.keyCode.ENTER:
  9942. // Toggle (cancel delayed activation, allow collapsing)
  9943. event.preventDefault();
  9944. clearTimeout( this.activating );
  9945. // Determine if we should collapse or activate
  9946. this._activate( selectedIndex === this.options.active ? false : selectedIndex );
  9947. return;
  9948. default:
  9949. return;
  9950. }
  9951. // Focus the appropriate tab, based on which key was pressed
  9952. event.preventDefault();
  9953. clearTimeout( this.activating );
  9954. selectedIndex = this._focusNextTab( selectedIndex, goingForward );
  9955. // Navigating with control key will prevent automatic activation
  9956. if ( !event.ctrlKey ) {
  9957. // Update aria-selected immediately so that AT think the tab is already selected.
  9958. // Otherwise AT may confuse the user by stating that they need to activate the tab,
  9959. // but the tab will already be activated by the time the announcement finishes.
  9960. focusedTab.attr( "aria-selected", "false" );
  9961. this.tabs.eq( selectedIndex ).attr( "aria-selected", "true" );
  9962. this.activating = this._delay(function() {
  9963. this.option( "active", selectedIndex );
  9964. }, this.delay );
  9965. }
  9966. },
  9967. _panelKeydown: function( event ) {
  9968. if ( this._handlePageNav( event ) ) {
  9969. return;
  9970. }
  9971. // Ctrl+up moves focus to the current tab
  9972. if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) {
  9973. event.preventDefault();
  9974. this.active.focus();
  9975. }
  9976. },
  9977. // Alt+page up/down moves focus to the previous/next tab (and activates)
  9978. _handlePageNav: function( event ) {
  9979. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP ) {
  9980. this._activate( this._focusNextTab( this.options.active - 1, false ) );
  9981. return true;
  9982. }
  9983. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN ) {
  9984. this._activate( this._focusNextTab( this.options.active + 1, true ) );
  9985. return true;
  9986. }
  9987. },
  9988. _findNextTab: function( index, goingForward ) {
  9989. var lastTabIndex = this.tabs.length - 1;
  9990. function constrain() {
  9991. if ( index > lastTabIndex ) {
  9992. index = 0;
  9993. }
  9994. if ( index < 0 ) {
  9995. index = lastTabIndex;
  9996. }
  9997. return index;
  9998. }
  9999. while ( $.inArray( constrain(), this.options.disabled ) !== -1 ) {
  10000. index = goingForward ? index + 1 : index - 1;
  10001. }
  10002. return index;
  10003. },
  10004. _focusNextTab: function( index, goingForward ) {
  10005. index = this._findNextTab( index, goingForward );
  10006. this.tabs.eq( index ).focus();
  10007. return index;
  10008. },
  10009. _setOption: function( key, value ) {
  10010. if ( key === "active" ) {
  10011. // _activate() will handle invalid values and update this.options
  10012. this._activate( value );
  10013. return;
  10014. }
  10015. if ( key === "disabled" ) {
  10016. // don't use the widget factory's disabled handling
  10017. this._setupDisabled( value );
  10018. return;
  10019. }
  10020. this._super( key, value);
  10021. if ( key === "collapsible" ) {
  10022. this.element.toggleClass( "ui-tabs-collapsible", value );
  10023. // Setting collapsible: false while collapsed; open first panel
  10024. if ( !value && this.options.active === false ) {
  10025. this._activate( 0 );
  10026. }
  10027. }
  10028. if ( key === "event" ) {
  10029. this._setupEvents( value );
  10030. }
  10031. if ( key === "heightStyle" ) {
  10032. this._setupHeightStyle( value );
  10033. }
  10034. },
  10035. _tabId: function( tab ) {
  10036. return tab.attr( "aria-controls" ) || "ui-tabs-" + getNextTabId();
  10037. },
  10038. _sanitizeSelector: function( hash ) {
  10039. return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
  10040. },
  10041. refresh: function() {
  10042. var options = this.options,
  10043. lis = this.tablist.children( ":has(a[href])" );
  10044. // get disabled tabs from class attribute from HTML
  10045. // this will get converted to a boolean if needed in _refresh()
  10046. options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) {
  10047. return lis.index( tab );
  10048. });
  10049. this._processTabs();
  10050. // was collapsed or no tabs
  10051. if ( options.active === false || !this.anchors.length ) {
  10052. options.active = false;
  10053. this.active = $();
  10054. // was active, but active tab is gone
  10055. } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) {
  10056. // all remaining tabs are disabled
  10057. if ( this.tabs.length === options.disabled.length ) {
  10058. options.active = false;
  10059. this.active = $();
  10060. // activate previous tab
  10061. } else {
  10062. this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) );
  10063. }
  10064. // was active, active tab still exists
  10065. } else {
  10066. // make sure active index is correct
  10067. options.active = this.tabs.index( this.active );
  10068. }
  10069. this._refresh();
  10070. },
  10071. _refresh: function() {
  10072. this._setupDisabled( this.options.disabled );
  10073. this._setupEvents( this.options.event );
  10074. this._setupHeightStyle( this.options.heightStyle );
  10075. this.tabs.not( this.active ).attr({
  10076. "aria-selected": "false",
  10077. tabIndex: -1
  10078. });
  10079. this.panels.not( this._getPanelForTab( this.active ) )
  10080. .hide()
  10081. .attr({
  10082. "aria-expanded": "false",
  10083. "aria-hidden": "true"
  10084. });
  10085. // Make sure one tab is in the tab order
  10086. if ( !this.active.length ) {
  10087. this.tabs.eq( 0 ).attr( "tabIndex", 0 );
  10088. } else {
  10089. this.active
  10090. .addClass( "ui-tabs-active ui-state-active" )
  10091. .attr({
  10092. "aria-selected": "true",
  10093. tabIndex: 0
  10094. });
  10095. this._getPanelForTab( this.active )
  10096. .show()
  10097. .attr({
  10098. "aria-expanded": "true",
  10099. "aria-hidden": "false"
  10100. });
  10101. }
  10102. },
  10103. _processTabs: function() {
  10104. var that = this;
  10105. this.tablist = this._getList()
  10106. .addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  10107. .attr( "role", "tablist" );
  10108. this.tabs = this.tablist.find( "> li:has(a[href])" )
  10109. .addClass( "ui-state-default ui-corner-top" )
  10110. .attr({
  10111. role: "tab",
  10112. tabIndex: -1
  10113. });
  10114. this.anchors = this.tabs.map(function() {
  10115. return $( "a", this )[ 0 ];
  10116. })
  10117. .addClass( "ui-tabs-anchor" )
  10118. .attr({
  10119. role: "presentation",
  10120. tabIndex: -1
  10121. });
  10122. this.panels = $();
  10123. this.anchors.each(function( i, anchor ) {
  10124. var selector, panel, panelId,
  10125. anchorId = $( anchor ).uniqueId().attr( "id" ),
  10126. tab = $( anchor ).closest( "li" ),
  10127. originalAriaControls = tab.attr( "aria-controls" );
  10128. // inline tab
  10129. if ( isLocal( anchor ) ) {
  10130. selector = anchor.hash;
  10131. panel = that.element.find( that._sanitizeSelector( selector ) );
  10132. // remote tab
  10133. } else {
  10134. panelId = that._tabId( tab );
  10135. selector = "#" + panelId;
  10136. panel = that.element.find( selector );
  10137. if ( !panel.length ) {
  10138. panel = that._createPanel( panelId );
  10139. panel.insertAfter( that.panels[ i - 1 ] || that.tablist );
  10140. }
  10141. panel.attr( "aria-live", "polite" );
  10142. }
  10143. if ( panel.length) {
  10144. that.panels = that.panels.add( panel );
  10145. }
  10146. if ( originalAriaControls ) {
  10147. tab.data( "ui-tabs-aria-controls", originalAriaControls );
  10148. }
  10149. tab.attr({
  10150. "aria-controls": selector.substring( 1 ),
  10151. "aria-labelledby": anchorId
  10152. });
  10153. panel.attr( "aria-labelledby", anchorId );
  10154. });
  10155. this.panels
  10156. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  10157. .attr( "role", "tabpanel" );
  10158. },
  10159. // allow overriding how to find the list for rare usage scenarios (#7715)
  10160. _getList: function() {
  10161. return this.element.find( "ol,ul" ).eq( 0 );
  10162. },
  10163. _createPanel: function( id ) {
  10164. return $( "<div>" )
  10165. .attr( "id", id )
  10166. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  10167. .data( "ui-tabs-destroy", true );
  10168. },
  10169. _setupDisabled: function( disabled ) {
  10170. if ( $.isArray( disabled ) ) {
  10171. if ( !disabled.length ) {
  10172. disabled = false;
  10173. } else if ( disabled.length === this.anchors.length ) {
  10174. disabled = true;
  10175. }
  10176. }
  10177. // disable tabs
  10178. for ( var i = 0, li; ( li = this.tabs[ i ] ); i++ ) {
  10179. if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
  10180. $( li )
  10181. .addClass( "ui-state-disabled" )
  10182. .attr( "aria-disabled", "true" );
  10183. } else {
  10184. $( li )
  10185. .removeClass( "ui-state-disabled" )
  10186. .removeAttr( "aria-disabled" );
  10187. }
  10188. }
  10189. this.options.disabled = disabled;
  10190. },
  10191. _setupEvents: function( event ) {
  10192. var events = {
  10193. click: function( event ) {
  10194. event.preventDefault();
  10195. }
  10196. };
  10197. if ( event ) {
  10198. $.each( event.split(" "), function( index, eventName ) {
  10199. events[ eventName ] = "_eventHandler";
  10200. });
  10201. }
  10202. this._off( this.anchors.add( this.tabs ).add( this.panels ) );
  10203. this._on( this.anchors, events );
  10204. this._on( this.tabs, { keydown: "_tabKeydown" } );
  10205. this._on( this.panels, { keydown: "_panelKeydown" } );
  10206. this._focusable( this.tabs );
  10207. this._hoverable( this.tabs );
  10208. },
  10209. _setupHeightStyle: function( heightStyle ) {
  10210. var maxHeight,
  10211. parent = this.element.parent();
  10212. if ( heightStyle === "fill" ) {
  10213. maxHeight = parent.height();
  10214. maxHeight -= this.element.outerHeight() - this.element.height();
  10215. this.element.siblings( ":visible" ).each(function() {
  10216. var elem = $( this ),
  10217. position = elem.css( "position" );
  10218. if ( position === "absolute" || position === "fixed" ) {
  10219. return;
  10220. }
  10221. maxHeight -= elem.outerHeight( true );
  10222. });
  10223. this.element.children().not( this.panels ).each(function() {
  10224. maxHeight -= $( this ).outerHeight( true );
  10225. });
  10226. this.panels.each(function() {
  10227. $( this ).height( Math.max( 0, maxHeight -
  10228. $( this ).innerHeight() + $( this ).height() ) );
  10229. })
  10230. .css( "overflow", "auto" );
  10231. } else if ( heightStyle === "auto" ) {
  10232. maxHeight = 0;
  10233. this.panels.each(function() {
  10234. maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
  10235. }).height( maxHeight );
  10236. }
  10237. },
  10238. _eventHandler: function( event ) {
  10239. var options = this.options,
  10240. active = this.active,
  10241. anchor = $( event.currentTarget ),
  10242. tab = anchor.closest( "li" ),
  10243. clickedIsActive = tab[ 0 ] === active[ 0 ],
  10244. collapsing = clickedIsActive && options.collapsible,
  10245. toShow = collapsing ? $() : this._getPanelForTab( tab ),
  10246. toHide = !active.length ? $() : this._getPanelForTab( active ),
  10247. eventData = {
  10248. oldTab: active,
  10249. oldPanel: toHide,
  10250. newTab: collapsing ? $() : tab,
  10251. newPanel: toShow
  10252. };
  10253. event.preventDefault();
  10254. if ( tab.hasClass( "ui-state-disabled" ) ||
  10255. // tab is already loading
  10256. tab.hasClass( "ui-tabs-loading" ) ||
  10257. // can't switch durning an animation
  10258. this.running ||
  10259. // click on active header, but not collapsible
  10260. ( clickedIsActive && !options.collapsible ) ||
  10261. // allow canceling activation
  10262. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  10263. return;
  10264. }
  10265. options.active = collapsing ? false : this.tabs.index( tab );
  10266. this.active = clickedIsActive ? $() : tab;
  10267. if ( this.xhr ) {
  10268. this.xhr.abort();
  10269. }
  10270. if ( !toHide.length && !toShow.length ) {
  10271. $.error( "jQuery UI Tabs: Mismatching fragment identifier." );
  10272. }
  10273. if ( toShow.length ) {
  10274. this.load( this.tabs.index( tab ), event );
  10275. }
  10276. this._toggle( event, eventData );
  10277. },
  10278. // handles show/hide for selecting tabs
  10279. _toggle: function( event, eventData ) {
  10280. var that = this,
  10281. toShow = eventData.newPanel,
  10282. toHide = eventData.oldPanel;
  10283. this.running = true;
  10284. function complete() {
  10285. that.running = false;
  10286. that._trigger( "activate", event, eventData );
  10287. }
  10288. function show() {
  10289. eventData.newTab.closest( "li" ).addClass( "ui-tabs-active ui-state-active" );
  10290. if ( toShow.length && that.options.show ) {
  10291. that._show( toShow, that.options.show, complete );
  10292. } else {
  10293. toShow.show();
  10294. complete();
  10295. }
  10296. }
  10297. // start out by hiding, then showing, then completing
  10298. if ( toHide.length && this.options.hide ) {
  10299. this._hide( toHide, this.options.hide, function() {
  10300. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  10301. show();
  10302. });
  10303. } else {
  10304. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  10305. toHide.hide();
  10306. show();
  10307. }
  10308. toHide.attr({
  10309. "aria-expanded": "false",
  10310. "aria-hidden": "true"
  10311. });
  10312. eventData.oldTab.attr( "aria-selected", "false" );
  10313. // If we're switching tabs, remove the old tab from the tab order.
  10314. // If we're opening from collapsed state, remove the previous tab from the tab order.
  10315. // If we're collapsing, then keep the collapsing tab in the tab order.
  10316. if ( toShow.length && toHide.length ) {
  10317. eventData.oldTab.attr( "tabIndex", -1 );
  10318. } else if ( toShow.length ) {
  10319. this.tabs.filter(function() {
  10320. return $( this ).attr( "tabIndex" ) === 0;
  10321. })
  10322. .attr( "tabIndex", -1 );
  10323. }
  10324. toShow.attr({
  10325. "aria-expanded": "true",
  10326. "aria-hidden": "false"
  10327. });
  10328. eventData.newTab.attr({
  10329. "aria-selected": "true",
  10330. tabIndex: 0
  10331. });
  10332. },
  10333. _activate: function( index ) {
  10334. var anchor,
  10335. active = this._findActive( index );
  10336. // trying to activate the already active panel
  10337. if ( active[ 0 ] === this.active[ 0 ] ) {
  10338. return;
  10339. }
  10340. // trying to collapse, simulate a click on the current active header
  10341. if ( !active.length ) {
  10342. active = this.active;
  10343. }
  10344. anchor = active.find( ".ui-tabs-anchor" )[ 0 ];
  10345. this._eventHandler({
  10346. target: anchor,
  10347. currentTarget: anchor,
  10348. preventDefault: $.noop
  10349. });
  10350. },
  10351. _findActive: function( index ) {
  10352. return index === false ? $() : this.tabs.eq( index );
  10353. },
  10354. _getIndex: function( index ) {
  10355. // meta-function to give users option to provide a href string instead of a numerical index.
  10356. if ( typeof index === "string" ) {
  10357. index = this.anchors.index( this.anchors.filter( "[href$='" + index + "']" ) );
  10358. }
  10359. return index;
  10360. },
  10361. _destroy: function() {
  10362. if ( this.xhr ) {
  10363. this.xhr.abort();
  10364. }
  10365. this.element.removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" );
  10366. this.tablist
  10367. .removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  10368. .removeAttr( "role" );
  10369. this.anchors
  10370. .removeClass( "ui-tabs-anchor" )
  10371. .removeAttr( "role" )
  10372. .removeAttr( "tabIndex" )
  10373. .removeUniqueId();
  10374. this.tabs.add( this.panels ).each(function() {
  10375. if ( $.data( this, "ui-tabs-destroy" ) ) {
  10376. $( this ).remove();
  10377. } else {
  10378. $( this )
  10379. .removeClass( "ui-state-default ui-state-active ui-state-disabled " +
  10380. "ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel" )
  10381. .removeAttr( "tabIndex" )
  10382. .removeAttr( "aria-live" )
  10383. .removeAttr( "aria-busy" )
  10384. .removeAttr( "aria-selected" )
  10385. .removeAttr( "aria-labelledby" )
  10386. .removeAttr( "aria-hidden" )
  10387. .removeAttr( "aria-expanded" )
  10388. .removeAttr( "role" );
  10389. }
  10390. });
  10391. this.tabs.each(function() {
  10392. var li = $( this ),
  10393. prev = li.data( "ui-tabs-aria-controls" );
  10394. if ( prev ) {
  10395. li
  10396. .attr( "aria-controls", prev )
  10397. .removeData( "ui-tabs-aria-controls" );
  10398. } else {
  10399. li.removeAttr( "aria-controls" );
  10400. }
  10401. });
  10402. this.panels.show();
  10403. if ( this.options.heightStyle !== "content" ) {
  10404. this.panels.css( "height", "" );
  10405. }
  10406. },
  10407. enable: function( index ) {
  10408. var disabled = this.options.disabled;
  10409. if ( disabled === false ) {
  10410. return;
  10411. }
  10412. if ( index === undefined ) {
  10413. disabled = false;
  10414. } else {
  10415. index = this._getIndex( index );
  10416. if ( $.isArray( disabled ) ) {
  10417. disabled = $.map( disabled, function( num ) {
  10418. return num !== index ? num : null;
  10419. });
  10420. } else {
  10421. disabled = $.map( this.tabs, function( li, num ) {
  10422. return num !== index ? num : null;
  10423. });
  10424. }
  10425. }
  10426. this._setupDisabled( disabled );
  10427. },
  10428. disable: function( index ) {
  10429. var disabled = this.options.disabled;
  10430. if ( disabled === true ) {
  10431. return;
  10432. }
  10433. if ( index === undefined ) {
  10434. disabled = true;
  10435. } else {
  10436. index = this._getIndex( index );
  10437. if ( $.inArray( index, disabled ) !== -1 ) {
  10438. return;
  10439. }
  10440. if ( $.isArray( disabled ) ) {
  10441. disabled = $.merge( [ index ], disabled ).sort();
  10442. } else {
  10443. disabled = [ index ];
  10444. }
  10445. }
  10446. this._setupDisabled( disabled );
  10447. },
  10448. load: function( index, event ) {
  10449. index = this._getIndex( index );
  10450. var that = this,
  10451. tab = this.tabs.eq( index ),
  10452. anchor = tab.find( ".ui-tabs-anchor" ),
  10453. panel = this._getPanelForTab( tab ),
  10454. eventData = {
  10455. tab: tab,
  10456. panel: panel
  10457. };
  10458. // not remote
  10459. if ( isLocal( anchor[ 0 ] ) ) {
  10460. return;
  10461. }
  10462. this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
  10463. // support: jQuery <1.8
  10464. // jQuery <1.8 returns false if the request is canceled in beforeSend,
  10465. // but as of 1.8, $.ajax() always returns a jqXHR object.
  10466. if ( this.xhr && this.xhr.statusText !== "canceled" ) {
  10467. tab.addClass( "ui-tabs-loading" );
  10468. panel.attr( "aria-busy", "true" );
  10469. this.xhr
  10470. .success(function( response ) {
  10471. // support: jQuery <1.8
  10472. // http://bugs.jquery.com/ticket/11778
  10473. setTimeout(function() {
  10474. panel.html( response );
  10475. that._trigger( "load", event, eventData );
  10476. }, 1 );
  10477. })
  10478. .complete(function( jqXHR, status ) {
  10479. // support: jQuery <1.8
  10480. // http://bugs.jquery.com/ticket/11778
  10481. setTimeout(function() {
  10482. if ( status === "abort" ) {
  10483. that.panels.stop( false, true );
  10484. }
  10485. tab.removeClass( "ui-tabs-loading" );
  10486. panel.removeAttr( "aria-busy" );
  10487. if ( jqXHR === that.xhr ) {
  10488. delete that.xhr;
  10489. }
  10490. }, 1 );
  10491. });
  10492. }
  10493. },
  10494. _ajaxSettings: function( anchor, event, eventData ) {
  10495. var that = this;
  10496. return {
  10497. url: anchor.attr( "href" ),
  10498. beforeSend: function( jqXHR, settings ) {
  10499. return that._trigger( "beforeLoad", event,
  10500. $.extend( { jqXHR : jqXHR, ajaxSettings: settings }, eventData ) );
  10501. }
  10502. };
  10503. },
  10504. _getPanelForTab: function( tab ) {
  10505. var id = $( tab ).attr( "aria-controls" );
  10506. return this.element.find( this._sanitizeSelector( "#" + id ) );
  10507. }
  10508. });
  10509. })( jQuery );
  10510. (function( $ ) {
  10511. var increments = 0;
  10512. function addDescribedBy( elem, id ) {
  10513. var describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ );
  10514. describedby.push( id );
  10515. elem
  10516. .data( "ui-tooltip-id", id )
  10517. .attr( "aria-describedby", $.trim( describedby.join( " " ) ) );
  10518. }
  10519. function removeDescribedBy( elem ) {
  10520. var id = elem.data( "ui-tooltip-id" ),
  10521. describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ ),
  10522. index = $.inArray( id, describedby );
  10523. if ( index !== -1 ) {
  10524. describedby.splice( index, 1 );
  10525. }
  10526. elem.removeData( "ui-tooltip-id" );
  10527. describedby = $.trim( describedby.join( " " ) );
  10528. if ( describedby ) {
  10529. elem.attr( "aria-describedby", describedby );
  10530. } else {
  10531. elem.removeAttr( "aria-describedby" );
  10532. }
  10533. }
  10534. $.widget( "ui.tooltip", {
  10535. version: "1.10.0",
  10536. options: {
  10537. content: function() {
  10538. // support: IE<9, Opera in jQuery <1.7
  10539. // .text() can't accept undefined, so coerce to a string
  10540. var title = $( this ).attr( "title" ) || "";
  10541. // Escape title, since we're going from an attribute to raw HTML
  10542. return $( "<a>" ).text( title ).html();
  10543. },
  10544. hide: true,
  10545. // Disabled elements have inconsistent behavior across browsers (#8661)
  10546. items: "[title]:not([disabled])",
  10547. position: {
  10548. my: "left top+15",
  10549. at: "left bottom",
  10550. collision: "flipfit flip"
  10551. },
  10552. show: true,
  10553. tooltipClass: null,
  10554. track: false,
  10555. // callbacks
  10556. close: null,
  10557. open: null
  10558. },
  10559. _create: function() {
  10560. this._on({
  10561. mouseover: "open",
  10562. focusin: "open"
  10563. });
  10564. // IDs of generated tooltips, needed for destroy
  10565. this.tooltips = {};
  10566. // IDs of parent tooltips where we removed the title attribute
  10567. this.parents = {};
  10568. if ( this.options.disabled ) {
  10569. this._disable();
  10570. }
  10571. },
  10572. _setOption: function( key, value ) {
  10573. var that = this;
  10574. if ( key === "disabled" ) {
  10575. this[ value ? "_disable" : "_enable" ]();
  10576. this.options[ key ] = value;
  10577. // disable element style changes
  10578. return;
  10579. }
  10580. this._super( key, value );
  10581. if ( key === "content" ) {
  10582. $.each( this.tooltips, function( id, element ) {
  10583. that._updateContent( element );
  10584. });
  10585. }
  10586. },
  10587. _disable: function() {
  10588. var that = this;
  10589. // close open tooltips
  10590. $.each( this.tooltips, function( id, element ) {
  10591. var event = $.Event( "blur" );
  10592. event.target = event.currentTarget = element[0];
  10593. that.close( event, true );
  10594. });
  10595. // remove title attributes to prevent native tooltips
  10596. this.element.find( this.options.items ).addBack().each(function() {
  10597. var element = $( this );
  10598. if ( element.is( "[title]" ) ) {
  10599. element
  10600. .data( "ui-tooltip-title", element.attr( "title" ) )
  10601. .attr( "title", "" );
  10602. }
  10603. });
  10604. },
  10605. _enable: function() {
  10606. // restore title attributes
  10607. this.element.find( this.options.items ).addBack().each(function() {
  10608. var element = $( this );
  10609. if ( element.data( "ui-tooltip-title" ) ) {
  10610. element.attr( "title", element.data( "ui-tooltip-title" ) );
  10611. }
  10612. });
  10613. },
  10614. open: function( event ) {
  10615. var that = this,
  10616. target = $( event ? event.target : this.element )
  10617. // we need closest here due to mouseover bubbling,
  10618. // but always pointing at the same event target
  10619. .closest( this.options.items );
  10620. // No element to show a tooltip for or the tooltip is already open
  10621. if ( !target.length || target.data( "ui-tooltip-id" ) ) {
  10622. return;
  10623. }
  10624. if ( target.attr( "title" ) ) {
  10625. target.data( "ui-tooltip-title", target.attr( "title" ) );
  10626. }
  10627. target.data( "ui-tooltip-open", true );
  10628. // kill parent tooltips, custom or native, for hover
  10629. if ( event && event.type === "mouseover" ) {
  10630. target.parents().each(function() {
  10631. var parent = $( this ),
  10632. blurEvent;
  10633. if ( parent.data( "ui-tooltip-open" ) ) {
  10634. blurEvent = $.Event( "blur" );
  10635. blurEvent.target = blurEvent.currentTarget = this;
  10636. that.close( blurEvent, true );
  10637. }
  10638. if ( parent.attr( "title" ) ) {
  10639. parent.uniqueId();
  10640. that.parents[ this.id ] = {
  10641. element: this,
  10642. title: parent.attr( "title" )
  10643. };
  10644. parent.attr( "title", "" );
  10645. }
  10646. });
  10647. }
  10648. this._updateContent( target, event );
  10649. },
  10650. _updateContent: function( target, event ) {
  10651. var content,
  10652. contentOption = this.options.content,
  10653. that = this,
  10654. eventType = event ? event.type : null;
  10655. if ( typeof contentOption === "string" ) {
  10656. return this._open( event, target, contentOption );
  10657. }
  10658. content = contentOption.call( target[0], function( response ) {
  10659. // ignore async response if tooltip was closed already
  10660. if ( !target.data( "ui-tooltip-open" ) ) {
  10661. return;
  10662. }
  10663. // IE may instantly serve a cached response for ajax requests
  10664. // delay this call to _open so the other call to _open runs first
  10665. that._delay(function() {
  10666. // jQuery creates a special event for focusin when it doesn't
  10667. // exist natively. To improve performance, the native event
  10668. // object is reused and the type is changed. Therefore, we can't
  10669. // rely on the type being correct after the event finished
  10670. // bubbling, so we set it back to the previous value. (#8740)
  10671. if ( event ) {
  10672. event.type = eventType;
  10673. }
  10674. this._open( event, target, response );
  10675. });
  10676. });
  10677. if ( content ) {
  10678. this._open( event, target, content );
  10679. }
  10680. },
  10681. _open: function( event, target, content ) {
  10682. var tooltip, events, delayedShow,
  10683. positionOption = $.extend( {}, this.options.position );
  10684. if ( !content ) {
  10685. return;
  10686. }
  10687. // Content can be updated multiple times. If the tooltip already
  10688. // exists, then just update the content and bail.
  10689. tooltip = this._find( target );
  10690. if ( tooltip.length ) {
  10691. tooltip.find( ".ui-tooltip-content" ).html( content );
  10692. return;
  10693. }
  10694. // if we have a title, clear it to prevent the native tooltip
  10695. // we have to check first to avoid defining a title if none exists
  10696. // (we don't want to cause an element to start matching [title])
  10697. //
  10698. // We use removeAttr only for key events, to allow IE to export the correct
  10699. // accessible attributes. For mouse events, set to empty string to avoid
  10700. // native tooltip showing up (happens only when removing inside mouseover).
  10701. if ( target.is( "[title]" ) ) {
  10702. if ( event && event.type === "mouseover" ) {
  10703. target.attr( "title", "" );
  10704. } else {
  10705. target.removeAttr( "title" );
  10706. }
  10707. }
  10708. tooltip = this._tooltip( target );
  10709. addDescribedBy( target, tooltip.attr( "id" ) );
  10710. tooltip.find( ".ui-tooltip-content" ).html( content );
  10711. function position( event ) {
  10712. positionOption.of = event;
  10713. if ( tooltip.is( ":hidden" ) ) {
  10714. return;
  10715. }
  10716. tooltip.position( positionOption );
  10717. }
  10718. if ( this.options.track && event && /^mouse/.test( event.type ) ) {
  10719. this._on( this.document, {
  10720. mousemove: position
  10721. });
  10722. // trigger once to override element-relative positioning
  10723. position( event );
  10724. } else {
  10725. tooltip.position( $.extend({
  10726. of: target
  10727. }, this.options.position ) );
  10728. }
  10729. tooltip.hide();
  10730. this._show( tooltip, this.options.show );
  10731. // Handle tracking tooltips that are shown with a delay (#8644). As soon
  10732. // as the tooltip is visible, position the tooltip using the most recent
  10733. // event.
  10734. if ( this.options.show && this.options.show.delay ) {
  10735. delayedShow = this.delayedShow = setInterval(function() {
  10736. if ( tooltip.is( ":visible" ) ) {
  10737. position( positionOption.of );
  10738. clearInterval( delayedShow );
  10739. }
  10740. }, $.fx.interval );
  10741. }
  10742. this._trigger( "open", event, { tooltip: tooltip } );
  10743. events = {
  10744. keyup: function( event ) {
  10745. if ( event.keyCode === $.ui.keyCode.ESCAPE ) {
  10746. var fakeEvent = $.Event(event);
  10747. fakeEvent.currentTarget = target[0];
  10748. this.close( fakeEvent, true );
  10749. }
  10750. },
  10751. remove: function() {
  10752. this._removeTooltip( tooltip );
  10753. }
  10754. };
  10755. if ( !event || event.type === "mouseover" ) {
  10756. events.mouseleave = "close";
  10757. }
  10758. if ( !event || event.type === "focusin" ) {
  10759. events.focusout = "close";
  10760. }
  10761. this._on( true, target, events );
  10762. },
  10763. close: function( event ) {
  10764. var that = this,
  10765. target = $( event ? event.currentTarget : this.element ),
  10766. tooltip = this._find( target );
  10767. // disabling closes the tooltip, so we need to track when we're closing
  10768. // to avoid an infinite loop in case the tooltip becomes disabled on close
  10769. if ( this.closing ) {
  10770. return;
  10771. }
  10772. // Clear the interval for delayed tracking tooltips
  10773. clearInterval( this.delayedShow );
  10774. // only set title if we had one before (see comment in _open())
  10775. if ( target.data( "ui-tooltip-title" ) ) {
  10776. target.attr( "title", target.data( "ui-tooltip-title" ) );
  10777. }
  10778. removeDescribedBy( target );
  10779. tooltip.stop( true );
  10780. this._hide( tooltip, this.options.hide, function() {
  10781. that._removeTooltip( $( this ) );
  10782. });
  10783. target.removeData( "ui-tooltip-open" );
  10784. this._off( target, "mouseleave focusout keyup" );
  10785. // Remove 'remove' binding only on delegated targets
  10786. if ( target[0] !== this.element[0] ) {
  10787. this._off( target, "remove" );
  10788. }
  10789. this._off( this.document, "mousemove" );
  10790. if ( event && event.type === "mouseleave" ) {
  10791. $.each( this.parents, function( id, parent ) {
  10792. $( parent.element ).attr( "title", parent.title );
  10793. delete that.parents[ id ];
  10794. });
  10795. }
  10796. this.closing = true;
  10797. this._trigger( "close", event, { tooltip: tooltip } );
  10798. this.closing = false;
  10799. },
  10800. _tooltip: function( element ) {
  10801. var id = "ui-tooltip-" + increments++,
  10802. tooltip = $( "<div>" )
  10803. .attr({
  10804. id: id,
  10805. role: "tooltip"
  10806. })
  10807. .addClass( "ui-tooltip ui-widget ui-corner-all ui-widget-content " +
  10808. ( this.options.tooltipClass || "" ) );
  10809. $( "<div>" )
  10810. .addClass( "ui-tooltip-content" )
  10811. .appendTo( tooltip );
  10812. tooltip.appendTo( this.document[0].body );
  10813. this.tooltips[ id ] = element;
  10814. return tooltip;
  10815. },
  10816. _find: function( target ) {
  10817. var id = target.data( "ui-tooltip-id" );
  10818. return id ? $( "#" + id ) : $();
  10819. },
  10820. _removeTooltip: function( tooltip ) {
  10821. tooltip.remove();
  10822. delete this.tooltips[ tooltip.attr( "id" ) ];
  10823. },
  10824. _destroy: function() {
  10825. var that = this;
  10826. // close open tooltips
  10827. $.each( this.tooltips, function( id, element ) {
  10828. // Delegate to close method to handle common cleanup
  10829. var event = $.Event( "blur" );
  10830. event.target = event.currentTarget = element[0];
  10831. that.close( event, true );
  10832. // Remove immediately; destroying an open tooltip doesn't use the
  10833. // hide animation
  10834. $( "#" + id ).remove();
  10835. // Restore the title
  10836. if ( element.data( "ui-tooltip-title" ) ) {
  10837. element.attr( "title", element.data( "ui-tooltip-title" ) );
  10838. element.removeData( "ui-tooltip-title" );
  10839. }
  10840. });
  10841. }
  10842. });
  10843. }( jQuery ) );
  10844. ;(jQuery.effects || (function($, undefined) {
  10845. var dataSpace = "ui-effects-";
  10846. $.effects = {
  10847. effect: {}
  10848. };
  10849. /*!
  10850. * jQuery Color Animations v2.1.2
  10851. * https://github.com/jquery/jquery-color
  10852. *
  10853. * Copyright 2013 jQuery Foundation and other contributors
  10854. * Released under the MIT license.
  10855. * http://jquery.org/license
  10856. *
  10857. * Date: Wed Jan 16 08:47:09 2013 -0600
  10858. */
  10859. (function( jQuery, undefined ) {
  10860. var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
  10861. // plusequals test for += 100 -= 100
  10862. rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
  10863. // a set of RE's that can match strings and generate color tuples.
  10864. stringParsers = [{
  10865. re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  10866. parse: function( execResult ) {
  10867. return [
  10868. execResult[ 1 ],
  10869. execResult[ 2 ],
  10870. execResult[ 3 ],
  10871. execResult[ 4 ]
  10872. ];
  10873. }
  10874. }, {
  10875. re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  10876. parse: function( execResult ) {
  10877. return [
  10878. execResult[ 1 ] * 2.55,
  10879. execResult[ 2 ] * 2.55,
  10880. execResult[ 3 ] * 2.55,
  10881. execResult[ 4 ]
  10882. ];
  10883. }
  10884. }, {
  10885. // this regex ignores A-F because it's compared against an already lowercased string
  10886. re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
  10887. parse: function( execResult ) {
  10888. return [
  10889. parseInt( execResult[ 1 ], 16 ),
  10890. parseInt( execResult[ 2 ], 16 ),
  10891. parseInt( execResult[ 3 ], 16 )
  10892. ];
  10893. }
  10894. }, {
  10895. // this regex ignores A-F because it's compared against an already lowercased string
  10896. re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
  10897. parse: function( execResult ) {
  10898. return [
  10899. parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
  10900. parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
  10901. parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
  10902. ];
  10903. }
  10904. }, {
  10905. re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  10906. space: "hsla",
  10907. parse: function( execResult ) {
  10908. return [
  10909. execResult[ 1 ],
  10910. execResult[ 2 ] / 100,
  10911. execResult[ 3 ] / 100,
  10912. execResult[ 4 ]
  10913. ];
  10914. }
  10915. }],
  10916. // jQuery.Color( )
  10917. color = jQuery.Color = function( color, green, blue, alpha ) {
  10918. return new jQuery.Color.fn.parse( color, green, blue, alpha );
  10919. },
  10920. spaces = {
  10921. rgba: {
  10922. props: {
  10923. red: {
  10924. idx: 0,
  10925. type: "byte"
  10926. },
  10927. green: {
  10928. idx: 1,
  10929. type: "byte"
  10930. },
  10931. blue: {
  10932. idx: 2,
  10933. type: "byte"
  10934. }
  10935. }
  10936. },
  10937. hsla: {
  10938. props: {
  10939. hue: {
  10940. idx: 0,
  10941. type: "degrees"
  10942. },
  10943. saturation: {
  10944. idx: 1,
  10945. type: "percent"
  10946. },
  10947. lightness: {
  10948. idx: 2,
  10949. type: "percent"
  10950. }
  10951. }
  10952. }
  10953. },
  10954. propTypes = {
  10955. "byte": {
  10956. floor: true,
  10957. max: 255
  10958. },
  10959. "percent": {
  10960. max: 1
  10961. },
  10962. "degrees": {
  10963. mod: 360,
  10964. floor: true
  10965. }
  10966. },
  10967. support = color.support = {},
  10968. // element for support tests
  10969. supportElem = jQuery( "<p>" )[ 0 ],
  10970. // colors = jQuery.Color.names
  10971. colors,
  10972. // local aliases of functions called often
  10973. each = jQuery.each;
  10974. // determine rgba support immediately
  10975. supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
  10976. support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
  10977. // define cache name and alpha properties
  10978. // for rgba and hsla spaces
  10979. each( spaces, function( spaceName, space ) {
  10980. space.cache = "_" + spaceName;
  10981. space.props.alpha = {
  10982. idx: 3,
  10983. type: "percent",
  10984. def: 1
  10985. };
  10986. });
  10987. function clamp( value, prop, allowEmpty ) {
  10988. var type = propTypes[ prop.type ] || {};
  10989. if ( value == null ) {
  10990. return (allowEmpty || !prop.def) ? null : prop.def;
  10991. }
  10992. // ~~ is an short way of doing floor for positive numbers
  10993. value = type.floor ? ~~value : parseFloat( value );
  10994. // IE will pass in empty strings as value for alpha,
  10995. // which will hit this case
  10996. if ( isNaN( value ) ) {
  10997. return prop.def;
  10998. }
  10999. if ( type.mod ) {
  11000. // we add mod before modding to make sure that negatives values
  11001. // get converted properly: -10 -> 350
  11002. return (value + type.mod) % type.mod;
  11003. }
  11004. // for now all property types without mod have min and max
  11005. return 0 > value ? 0 : type.max < value ? type.max : value;
  11006. }
  11007. function stringParse( string ) {
  11008. var inst = color(),
  11009. rgba = inst._rgba = [];
  11010. string = string.toLowerCase();
  11011. each( stringParsers, function( i, parser ) {
  11012. var parsed,
  11013. match = parser.re.exec( string ),
  11014. values = match && parser.parse( match ),
  11015. spaceName = parser.space || "rgba";
  11016. if ( values ) {
  11017. parsed = inst[ spaceName ]( values );
  11018. // if this was an rgba parse the assignment might happen twice
  11019. // oh well....
  11020. inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
  11021. rgba = inst._rgba = parsed._rgba;
  11022. // exit each( stringParsers ) here because we matched
  11023. return false;
  11024. }
  11025. });
  11026. // Found a stringParser that handled it
  11027. if ( rgba.length ) {
  11028. // if this came from a parsed string, force "transparent" when alpha is 0
  11029. // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
  11030. if ( rgba.join() === "0,0,0,0" ) {
  11031. jQuery.extend( rgba, colors.transparent );
  11032. }
  11033. return inst;
  11034. }
  11035. // named colors
  11036. return colors[ string ];
  11037. }
  11038. color.fn = jQuery.extend( color.prototype, {
  11039. parse: function( red, green, blue, alpha ) {
  11040. if ( red === undefined ) {
  11041. this._rgba = [ null, null, null, null ];
  11042. return this;
  11043. }
  11044. if ( red.jquery || red.nodeType ) {
  11045. red = jQuery( red ).css( green );
  11046. green = undefined;
  11047. }
  11048. var inst = this,
  11049. type = jQuery.type( red ),
  11050. rgba = this._rgba = [];
  11051. // more than 1 argument specified - assume ( red, green, blue, alpha )
  11052. if ( green !== undefined ) {
  11053. red = [ red, green, blue, alpha ];
  11054. type = "array";
  11055. }
  11056. if ( type === "string" ) {
  11057. return this.parse( stringParse( red ) || colors._default );
  11058. }
  11059. if ( type === "array" ) {
  11060. each( spaces.rgba.props, function( key, prop ) {
  11061. rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
  11062. });
  11063. return this;
  11064. }
  11065. if ( type === "object" ) {
  11066. if ( red instanceof color ) {
  11067. each( spaces, function( spaceName, space ) {
  11068. if ( red[ space.cache ] ) {
  11069. inst[ space.cache ] = red[ space.cache ].slice();
  11070. }
  11071. });
  11072. } else {
  11073. each( spaces, function( spaceName, space ) {
  11074. var cache = space.cache;
  11075. each( space.props, function( key, prop ) {
  11076. // if the cache doesn't exist, and we know how to convert
  11077. if ( !inst[ cache ] && space.to ) {
  11078. // if the value was null, we don't need to copy it
  11079. // if the key was alpha, we don't need to copy it either
  11080. if ( key === "alpha" || red[ key ] == null ) {
  11081. return;
  11082. }
  11083. inst[ cache ] = space.to( inst._rgba );
  11084. }
  11085. // this is the only case where we allow nulls for ALL properties.
  11086. // call clamp with alwaysAllowEmpty
  11087. inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
  11088. });
  11089. // everything defined but alpha?
  11090. if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
  11091. // use the default of 1
  11092. inst[ cache ][ 3 ] = 1;
  11093. if ( space.from ) {
  11094. inst._rgba = space.from( inst[ cache ] );
  11095. }
  11096. }
  11097. });
  11098. }
  11099. return this;
  11100. }
  11101. },
  11102. is: function( compare ) {
  11103. var is = color( compare ),
  11104. same = true,
  11105. inst = this;
  11106. each( spaces, function( _, space ) {
  11107. var localCache,
  11108. isCache = is[ space.cache ];
  11109. if (isCache) {
  11110. localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
  11111. each( space.props, function( _, prop ) {
  11112. if ( isCache[ prop.idx ] != null ) {
  11113. same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
  11114. return same;
  11115. }
  11116. });
  11117. }
  11118. return same;
  11119. });
  11120. return same;
  11121. },
  11122. _space: function() {
  11123. var used = [],
  11124. inst = this;
  11125. each( spaces, function( spaceName, space ) {
  11126. if ( inst[ space.cache ] ) {
  11127. used.push( spaceName );
  11128. }
  11129. });
  11130. return used.pop();
  11131. },
  11132. transition: function( other, distance ) {
  11133. var end = color( other ),
  11134. spaceName = end._space(),
  11135. space = spaces[ spaceName ],
  11136. startColor = this.alpha() === 0 ? color( "transparent" ) : this,
  11137. start = startColor[ space.cache ] || space.to( startColor._rgba ),
  11138. result = start.slice();
  11139. end = end[ space.cache ];
  11140. each( space.props, function( key, prop ) {
  11141. var index = prop.idx,
  11142. startValue = start[ index ],
  11143. endValue = end[ index ],
  11144. type = propTypes[ prop.type ] || {};
  11145. // if null, don't override start value
  11146. if ( endValue === null ) {
  11147. return;
  11148. }
  11149. // if null - use end
  11150. if ( startValue === null ) {
  11151. result[ index ] = endValue;
  11152. } else {
  11153. if ( type.mod ) {
  11154. if ( endValue - startValue > type.mod / 2 ) {
  11155. startValue += type.mod;
  11156. } else if ( startValue - endValue > type.mod / 2 ) {
  11157. startValue -= type.mod;
  11158. }
  11159. }
  11160. result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
  11161. }
  11162. });
  11163. return this[ spaceName ]( result );
  11164. },
  11165. blend: function( opaque ) {
  11166. // if we are already opaque - return ourself
  11167. if ( this._rgba[ 3 ] === 1 ) {
  11168. return this;
  11169. }
  11170. var rgb = this._rgba.slice(),
  11171. a = rgb.pop(),
  11172. blend = color( opaque )._rgba;
  11173. return color( jQuery.map( rgb, function( v, i ) {
  11174. return ( 1 - a ) * blend[ i ] + a * v;
  11175. }));
  11176. },
  11177. toRgbaString: function() {
  11178. var prefix = "rgba(",
  11179. rgba = jQuery.map( this._rgba, function( v, i ) {
  11180. return v == null ? ( i > 2 ? 1 : 0 ) : v;
  11181. });
  11182. if ( rgba[ 3 ] === 1 ) {
  11183. rgba.pop();
  11184. prefix = "rgb(";
  11185. }
  11186. return prefix + rgba.join() + ")";
  11187. },
  11188. toHslaString: function() {
  11189. var prefix = "hsla(",
  11190. hsla = jQuery.map( this.hsla(), function( v, i ) {
  11191. if ( v == null ) {
  11192. v = i > 2 ? 1 : 0;
  11193. }
  11194. // catch 1 and 2
  11195. if ( i && i < 3 ) {
  11196. v = Math.round( v * 100 ) + "%";
  11197. }
  11198. return v;
  11199. });
  11200. if ( hsla[ 3 ] === 1 ) {
  11201. hsla.pop();
  11202. prefix = "hsl(";
  11203. }
  11204. return prefix + hsla.join() + ")";
  11205. },
  11206. toHexString: function( includeAlpha ) {
  11207. var rgba = this._rgba.slice(),
  11208. alpha = rgba.pop();
  11209. if ( includeAlpha ) {
  11210. rgba.push( ~~( alpha * 255 ) );
  11211. }
  11212. return "#" + jQuery.map( rgba, function( v ) {
  11213. // default to 0 when nulls exist
  11214. v = ( v || 0 ).toString( 16 );
  11215. return v.length === 1 ? "0" + v : v;
  11216. }).join("");
  11217. },
  11218. toString: function() {
  11219. return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
  11220. }
  11221. });
  11222. color.fn.parse.prototype = color.fn;
  11223. // hsla conversions adapted from:
  11224. // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
  11225. function hue2rgb( p, q, h ) {
  11226. h = ( h + 1 ) % 1;
  11227. if ( h * 6 < 1 ) {
  11228. return p + (q - p) * h * 6;
  11229. }
  11230. if ( h * 2 < 1) {
  11231. return q;
  11232. }
  11233. if ( h * 3 < 2 ) {
  11234. return p + (q - p) * ((2/3) - h) * 6;
  11235. }
  11236. return p;
  11237. }
  11238. spaces.hsla.to = function ( rgba ) {
  11239. if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
  11240. return [ null, null, null, rgba[ 3 ] ];
  11241. }
  11242. var r = rgba[ 0 ] / 255,
  11243. g = rgba[ 1 ] / 255,
  11244. b = rgba[ 2 ] / 255,
  11245. a = rgba[ 3 ],
  11246. max = Math.max( r, g, b ),
  11247. min = Math.min( r, g, b ),
  11248. diff = max - min,
  11249. add = max + min,
  11250. l = add * 0.5,
  11251. h, s;
  11252. if ( min === max ) {
  11253. h = 0;
  11254. } else if ( r === max ) {
  11255. h = ( 60 * ( g - b ) / diff ) + 360;
  11256. } else if ( g === max ) {
  11257. h = ( 60 * ( b - r ) / diff ) + 120;
  11258. } else {
  11259. h = ( 60 * ( r - g ) / diff ) + 240;
  11260. }
  11261. // chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
  11262. // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
  11263. if ( diff === 0 ) {
  11264. s = 0;
  11265. } else if ( l <= 0.5 ) {
  11266. s = diff / add;
  11267. } else {
  11268. s = diff / ( 2 - add );
  11269. }
  11270. return [ Math.round(h) % 360, s, l, a == null ? 1 : a ];
  11271. };
  11272. spaces.hsla.from = function ( hsla ) {
  11273. if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
  11274. return [ null, null, null, hsla[ 3 ] ];
  11275. }
  11276. var h = hsla[ 0 ] / 360,
  11277. s = hsla[ 1 ],
  11278. l = hsla[ 2 ],
  11279. a = hsla[ 3 ],
  11280. q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
  11281. p = 2 * l - q;
  11282. return [
  11283. Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
  11284. Math.round( hue2rgb( p, q, h ) * 255 ),
  11285. Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
  11286. a
  11287. ];
  11288. };
  11289. each( spaces, function( spaceName, space ) {
  11290. var props = space.props,
  11291. cache = space.cache,
  11292. to = space.to,
  11293. from = space.from;
  11294. // makes rgba() and hsla()
  11295. color.fn[ spaceName ] = function( value ) {
  11296. // generate a cache for this space if it doesn't exist
  11297. if ( to && !this[ cache ] ) {
  11298. this[ cache ] = to( this._rgba );
  11299. }
  11300. if ( value === undefined ) {
  11301. return this[ cache ].slice();
  11302. }
  11303. var ret,
  11304. type = jQuery.type( value ),
  11305. arr = ( type === "array" || type === "object" ) ? value : arguments,
  11306. local = this[ cache ].slice();
  11307. each( props, function( key, prop ) {
  11308. var val = arr[ type === "object" ? key : prop.idx ];
  11309. if ( val == null ) {
  11310. val = local[ prop.idx ];
  11311. }
  11312. local[ prop.idx ] = clamp( val, prop );
  11313. });
  11314. if ( from ) {
  11315. ret = color( from( local ) );
  11316. ret[ cache ] = local;
  11317. return ret;
  11318. } else {
  11319. return color( local );
  11320. }
  11321. };
  11322. // makes red() green() blue() alpha() hue() saturation() lightness()
  11323. each( props, function( key, prop ) {
  11324. // alpha is included in more than one space
  11325. if ( color.fn[ key ] ) {
  11326. return;
  11327. }
  11328. color.fn[ key ] = function( value ) {
  11329. var vtype = jQuery.type( value ),
  11330. fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
  11331. local = this[ fn ](),
  11332. cur = local[ prop.idx ],
  11333. match;
  11334. if ( vtype === "undefined" ) {
  11335. return cur;
  11336. }
  11337. if ( vtype === "function" ) {
  11338. value = value.call( this, cur );
  11339. vtype = jQuery.type( value );
  11340. }
  11341. if ( value == null && prop.empty ) {
  11342. return this;
  11343. }
  11344. if ( vtype === "string" ) {
  11345. match = rplusequals.exec( value );
  11346. if ( match ) {
  11347. value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
  11348. }
  11349. }
  11350. local[ prop.idx ] = value;
  11351. return this[ fn ]( local );
  11352. };
  11353. });
  11354. });
  11355. // add cssHook and .fx.step function for each named hook.
  11356. // accept a space separated string of properties
  11357. color.hook = function( hook ) {
  11358. var hooks = hook.split( " " );
  11359. each( hooks, function( i, hook ) {
  11360. jQuery.cssHooks[ hook ] = {
  11361. set: function( elem, value ) {
  11362. var parsed, curElem,
  11363. backgroundColor = "";
  11364. if ( value !== "transparent" && ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) ) {
  11365. value = color( parsed || value );
  11366. if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
  11367. curElem = hook === "backgroundColor" ? elem.parentNode : elem;
  11368. while (
  11369. (backgroundColor === "" || backgroundColor === "transparent") &&
  11370. curElem && curElem.style
  11371. ) {
  11372. try {
  11373. backgroundColor = jQuery.css( curElem, "backgroundColor" );
  11374. curElem = curElem.parentNode;
  11375. } catch ( e ) {
  11376. }
  11377. }
  11378. value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
  11379. backgroundColor :
  11380. "_default" );
  11381. }
  11382. value = value.toRgbaString();
  11383. }
  11384. try {
  11385. elem.style[ hook ] = value;
  11386. } catch( e ) {
  11387. // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
  11388. }
  11389. }
  11390. };
  11391. jQuery.fx.step[ hook ] = function( fx ) {
  11392. if ( !fx.colorInit ) {
  11393. fx.start = color( fx.elem, hook );
  11394. fx.end = color( fx.end );
  11395. fx.colorInit = true;
  11396. }
  11397. jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
  11398. };
  11399. });
  11400. };
  11401. color.hook( stepHooks );
  11402. jQuery.cssHooks.borderColor = {
  11403. expand: function( value ) {
  11404. var expanded = {};
  11405. each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
  11406. expanded[ "border" + part + "Color" ] = value;
  11407. });
  11408. return expanded;
  11409. }
  11410. };
  11411. // Basic color names only.
  11412. // Usage of any of the other color names requires adding yourself or including
  11413. // jquery.color.svg-names.js.
  11414. colors = jQuery.Color.names = {
  11415. // 4.1. Basic color keywords
  11416. aqua: "#00ffff",
  11417. black: "#000000",
  11418. blue: "#0000ff",
  11419. fuchsia: "#ff00ff",
  11420. gray: "#808080",
  11421. green: "#008000",
  11422. lime: "#00ff00",
  11423. maroon: "#800000",
  11424. navy: "#000080",
  11425. olive: "#808000",
  11426. purple: "#800080",
  11427. red: "#ff0000",
  11428. silver: "#c0c0c0",
  11429. teal: "#008080",
  11430. white: "#ffffff",
  11431. yellow: "#ffff00",
  11432. // 4.2.3. "transparent" color keyword
  11433. transparent: [ null, null, null, 0 ],
  11434. _default: "#ffffff"
  11435. };
  11436. })( jQuery );
  11437. /******************************************************************************/
  11438. /****************************** CLASS ANIMATIONS ******************************/
  11439. /******************************************************************************/
  11440. (function() {
  11441. var classAnimationActions = [ "add", "remove", "toggle" ],
  11442. shorthandStyles = {
  11443. border: 1,
  11444. borderBottom: 1,
  11445. borderColor: 1,
  11446. borderLeft: 1,
  11447. borderRight: 1,
  11448. borderTop: 1,
  11449. borderWidth: 1,
  11450. margin: 1,
  11451. padding: 1
  11452. };
  11453. $.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) {
  11454. $.fx.step[ prop ] = function( fx ) {
  11455. if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
  11456. jQuery.style( fx.elem, prop, fx.end );
  11457. fx.setAttr = true;
  11458. }
  11459. };
  11460. });
  11461. function getElementStyles( elem ) {
  11462. var key, len,
  11463. style = elem.ownerDocument.defaultView ?
  11464. elem.ownerDocument.defaultView.getComputedStyle( elem, null ) :
  11465. elem.currentStyle,
  11466. styles = {};
  11467. if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
  11468. len = style.length;
  11469. while ( len-- ) {
  11470. key = style[ len ];
  11471. if ( typeof style[ key ] === "string" ) {
  11472. styles[ $.camelCase( key ) ] = style[ key ];
  11473. }
  11474. }
  11475. // support: Opera, IE <9
  11476. } else {
  11477. for ( key in style ) {
  11478. if ( typeof style[ key ] === "string" ) {
  11479. styles[ key ] = style[ key ];
  11480. }
  11481. }
  11482. }
  11483. return styles;
  11484. }
  11485. function styleDifference( oldStyle, newStyle ) {
  11486. var diff = {},
  11487. name, value;
  11488. for ( name in newStyle ) {
  11489. value = newStyle[ name ];
  11490. if ( oldStyle[ name ] !== value ) {
  11491. if ( !shorthandStyles[ name ] ) {
  11492. if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
  11493. diff[ name ] = value;
  11494. }
  11495. }
  11496. }
  11497. }
  11498. return diff;
  11499. }
  11500. // support: jQuery <1.8
  11501. if ( !$.fn.addBack ) {
  11502. $.fn.addBack = function( selector ) {
  11503. return this.add( selector == null ?
  11504. this.prevObject : this.prevObject.filter( selector )
  11505. );
  11506. };
  11507. }
  11508. $.effects.animateClass = function( value, duration, easing, callback ) {
  11509. var o = $.speed( duration, easing, callback );
  11510. return this.queue( function() {
  11511. var animated = $( this ),
  11512. baseClass = animated.attr( "class" ) || "",
  11513. applyClassChange,
  11514. allAnimations = o.children ? animated.find( "*" ).addBack() : animated;
  11515. // map the animated objects to store the original styles.
  11516. allAnimations = allAnimations.map(function() {
  11517. var el = $( this );
  11518. return {
  11519. el: el,
  11520. start: getElementStyles( this )
  11521. };
  11522. });
  11523. // apply class change
  11524. applyClassChange = function() {
  11525. $.each( classAnimationActions, function(i, action) {
  11526. if ( value[ action ] ) {
  11527. animated[ action + "Class" ]( value[ action ] );
  11528. }
  11529. });
  11530. };
  11531. applyClassChange();
  11532. // map all animated objects again - calculate new styles and diff
  11533. allAnimations = allAnimations.map(function() {
  11534. this.end = getElementStyles( this.el[ 0 ] );
  11535. this.diff = styleDifference( this.start, this.end );
  11536. return this;
  11537. });
  11538. // apply original class
  11539. animated.attr( "class", baseClass );
  11540. // map all animated objects again - this time collecting a promise
  11541. allAnimations = allAnimations.map(function() {
  11542. var styleInfo = this,
  11543. dfd = $.Deferred(),
  11544. opts = $.extend({}, o, {
  11545. queue: false,
  11546. complete: function() {
  11547. dfd.resolve( styleInfo );
  11548. }
  11549. });
  11550. this.el.animate( this.diff, opts );
  11551. return dfd.promise();
  11552. });
  11553. // once all animations have completed:
  11554. $.when.apply( $, allAnimations.get() ).done(function() {
  11555. // set the final class
  11556. applyClassChange();
  11557. // for each animated element,
  11558. // clear all css properties that were animated
  11559. $.each( arguments, function() {
  11560. var el = this.el;
  11561. $.each( this.diff, function(key) {
  11562. el.css( key, "" );
  11563. });
  11564. });
  11565. // this is guarnteed to be there if you use jQuery.speed()
  11566. // it also handles dequeuing the next anim...
  11567. o.complete.call( animated[ 0 ] );
  11568. });
  11569. });
  11570. };
  11571. $.fn.extend({
  11572. _addClass: $.fn.addClass,
  11573. addClass: function( classNames, speed, easing, callback ) {
  11574. return speed ?
  11575. $.effects.animateClass.call( this,
  11576. { add: classNames }, speed, easing, callback ) :
  11577. this._addClass( classNames );
  11578. },
  11579. _removeClass: $.fn.removeClass,
  11580. removeClass: function( classNames, speed, easing, callback ) {
  11581. return speed ?
  11582. $.effects.animateClass.call( this,
  11583. { remove: classNames }, speed, easing, callback ) :
  11584. this._removeClass( classNames );
  11585. },
  11586. _toggleClass: $.fn.toggleClass,
  11587. toggleClass: function( classNames, force, speed, easing, callback ) {
  11588. if ( typeof force === "boolean" || force === undefined ) {
  11589. if ( !speed ) {
  11590. // without speed parameter
  11591. return this._toggleClass( classNames, force );
  11592. } else {
  11593. return $.effects.animateClass.call( this,
  11594. (force ? { add: classNames } : { remove: classNames }),
  11595. speed, easing, callback );
  11596. }
  11597. } else {
  11598. // without force parameter
  11599. return $.effects.animateClass.call( this,
  11600. { toggle: classNames }, force, speed, easing );
  11601. }
  11602. },
  11603. switchClass: function( remove, add, speed, easing, callback) {
  11604. return $.effects.animateClass.call( this, {
  11605. add: add,
  11606. remove: remove
  11607. }, speed, easing, callback );
  11608. }
  11609. });
  11610. })();
  11611. /******************************************************************************/
  11612. /*********************************** EFFECTS **********************************/
  11613. /******************************************************************************/
  11614. (function() {
  11615. $.extend( $.effects, {
  11616. version: "1.10.0",
  11617. // Saves a set of properties in a data storage
  11618. save: function( element, set ) {
  11619. for( var i=0; i < set.length; i++ ) {
  11620. if ( set[ i ] !== null ) {
  11621. element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
  11622. }
  11623. }
  11624. },
  11625. // Restores a set of previously saved properties from a data storage
  11626. restore: function( element, set ) {
  11627. var val, i;
  11628. for( i=0; i < set.length; i++ ) {
  11629. if ( set[ i ] !== null ) {
  11630. val = element.data( dataSpace + set[ i ] );
  11631. // support: jQuery 1.6.2
  11632. // http://bugs.jquery.com/ticket/9917
  11633. // jQuery 1.6.2 incorrectly returns undefined for any falsy value.
  11634. // We can't differentiate between "" and 0 here, so we just assume
  11635. // empty string since it's likely to be a more common value...
  11636. if ( val === undefined ) {
  11637. val = "";
  11638. }
  11639. element.css( set[ i ], val );
  11640. }
  11641. }
  11642. },
  11643. setMode: function( el, mode ) {
  11644. if (mode === "toggle") {
  11645. mode = el.is( ":hidden" ) ? "show" : "hide";
  11646. }
  11647. return mode;
  11648. },
  11649. // Translates a [top,left] array into a baseline value
  11650. // this should be a little more flexible in the future to handle a string & hash
  11651. getBaseline: function( origin, original ) {
  11652. var y, x;
  11653. switch ( origin[ 0 ] ) {
  11654. case "top": y = 0; break;
  11655. case "middle": y = 0.5; break;
  11656. case "bottom": y = 1; break;
  11657. default: y = origin[ 0 ] / original.height;
  11658. }
  11659. switch ( origin[ 1 ] ) {
  11660. case "left": x = 0; break;
  11661. case "center": x = 0.5; break;
  11662. case "right": x = 1; break;
  11663. default: x = origin[ 1 ] / original.width;
  11664. }
  11665. return {
  11666. x: x,
  11667. y: y
  11668. };
  11669. },
  11670. // Wraps the element around a wrapper that copies position properties
  11671. createWrapper: function( element ) {
  11672. // if the element is already wrapped, return it
  11673. if ( element.parent().is( ".ui-effects-wrapper" )) {
  11674. return element.parent();
  11675. }
  11676. // wrap the element
  11677. var props = {
  11678. width: element.outerWidth(true),
  11679. height: element.outerHeight(true),
  11680. "float": element.css( "float" )
  11681. },
  11682. wrapper = $( "<div></div>" )
  11683. .addClass( "ui-effects-wrapper" )
  11684. .css({
  11685. fontSize: "100%",
  11686. background: "transparent",
  11687. border: "none",
  11688. margin: 0,
  11689. padding: 0
  11690. }),
  11691. // Store the size in case width/height are defined in % - Fixes #5245
  11692. size = {
  11693. width: element.width(),
  11694. height: element.height()
  11695. },
  11696. active = document.activeElement;
  11697. // support: Firefox
  11698. // Firefox incorrectly exposes anonymous content
  11699. // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
  11700. try {
  11701. active.id;
  11702. } catch( e ) {
  11703. active = document.body;
  11704. }
  11705. element.wrap( wrapper );
  11706. // Fixes #7595 - Elements lose focus when wrapped.
  11707. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  11708. $( active ).focus();
  11709. }
  11710. wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element
  11711. // transfer positioning properties to the wrapper
  11712. if ( element.css( "position" ) === "static" ) {
  11713. wrapper.css({ position: "relative" });
  11714. element.css({ position: "relative" });
  11715. } else {
  11716. $.extend( props, {
  11717. position: element.css( "position" ),
  11718. zIndex: element.css( "z-index" )
  11719. });
  11720. $.each([ "top", "left", "bottom", "right" ], function(i, pos) {
  11721. props[ pos ] = element.css( pos );
  11722. if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
  11723. props[ pos ] = "auto";
  11724. }
  11725. });
  11726. element.css({
  11727. position: "relative",
  11728. top: 0,
  11729. left: 0,
  11730. right: "auto",
  11731. bottom: "auto"
  11732. });
  11733. }
  11734. element.css(size);
  11735. return wrapper.css( props ).show();
  11736. },
  11737. removeWrapper: function( element ) {
  11738. var active = document.activeElement;
  11739. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  11740. element.parent().replaceWith( element );
  11741. // Fixes #7595 - Elements lose focus when wrapped.
  11742. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  11743. $( active ).focus();
  11744. }
  11745. }
  11746. return element;
  11747. },
  11748. setTransition: function( element, list, factor, value ) {
  11749. value = value || {};
  11750. $.each( list, function( i, x ) {
  11751. var unit = element.cssUnit( x );
  11752. if ( unit[ 0 ] > 0 ) {
  11753. value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
  11754. }
  11755. });
  11756. return value;
  11757. }
  11758. });
  11759. // return an effect options object for the given parameters:
  11760. function _normalizeArguments( effect, options, speed, callback ) {
  11761. // allow passing all options as the first parameter
  11762. if ( $.isPlainObject( effect ) ) {
  11763. options = effect;
  11764. effect = effect.effect;
  11765. }
  11766. // convert to an object
  11767. effect = { effect: effect };
  11768. // catch (effect, null, ...)
  11769. if ( options == null ) {
  11770. options = {};
  11771. }
  11772. // catch (effect, callback)
  11773. if ( $.isFunction( options ) ) {
  11774. callback = options;
  11775. speed = null;
  11776. options = {};
  11777. }
  11778. // catch (effect, speed, ?)
  11779. if ( typeof options === "number" || $.fx.speeds[ options ] ) {
  11780. callback = speed;
  11781. speed = options;
  11782. options = {};
  11783. }
  11784. // catch (effect, options, callback)
  11785. if ( $.isFunction( speed ) ) {
  11786. callback = speed;
  11787. speed = null;
  11788. }
  11789. // add options to effect
  11790. if ( options ) {
  11791. $.extend( effect, options );
  11792. }
  11793. speed = speed || options.duration;
  11794. effect.duration = $.fx.off ? 0 :
  11795. typeof speed === "number" ? speed :
  11796. speed in $.fx.speeds ? $.fx.speeds[ speed ] :
  11797. $.fx.speeds._default;
  11798. effect.complete = callback || options.complete;
  11799. return effect;
  11800. }
  11801. function standardSpeed( speed ) {
  11802. // valid standard speeds
  11803. if ( !speed || typeof speed === "number" || $.fx.speeds[ speed ] ) {
  11804. return true;
  11805. }
  11806. // invalid strings - treat as "normal" speed
  11807. return typeof speed === "string" && !$.effects.effect[ speed ];
  11808. }
  11809. $.fn.extend({
  11810. effect: function( /* effect, options, speed, callback */ ) {
  11811. var args = _normalizeArguments.apply( this, arguments ),
  11812. mode = args.mode,
  11813. queue = args.queue,
  11814. effectMethod = $.effects.effect[ args.effect ];
  11815. if ( $.fx.off || !effectMethod ) {
  11816. // delegate to the original method (e.g., .show()) if possible
  11817. if ( mode ) {
  11818. return this[ mode ]( args.duration, args.complete );
  11819. } else {
  11820. return this.each( function() {
  11821. if ( args.complete ) {
  11822. args.complete.call( this );
  11823. }
  11824. });
  11825. }
  11826. }
  11827. function run( next ) {
  11828. var elem = $( this ),
  11829. complete = args.complete,
  11830. mode = args.mode;
  11831. function done() {
  11832. if ( $.isFunction( complete ) ) {
  11833. complete.call( elem[0] );
  11834. }
  11835. if ( $.isFunction( next ) ) {
  11836. next();
  11837. }
  11838. }
  11839. // if the element is hiddden and mode is hide,
  11840. // or element is visible and mode is show
  11841. if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
  11842. done();
  11843. } else {
  11844. effectMethod.call( elem[0], args, done );
  11845. }
  11846. }
  11847. return queue === false ? this.each( run ) : this.queue( queue || "fx", run );
  11848. },
  11849. _show: $.fn.show,
  11850. show: function( speed ) {
  11851. if ( standardSpeed( speed ) ) {
  11852. return this._show.apply( this, arguments );
  11853. } else {
  11854. var args = _normalizeArguments.apply( this, arguments );
  11855. args.mode = "show";
  11856. return this.effect.call( this, args );
  11857. }
  11858. },
  11859. _hide: $.fn.hide,
  11860. hide: function( speed ) {
  11861. if ( standardSpeed( speed ) ) {
  11862. return this._hide.apply( this, arguments );
  11863. } else {
  11864. var args = _normalizeArguments.apply( this, arguments );
  11865. args.mode = "hide";
  11866. return this.effect.call( this, args );
  11867. }
  11868. },
  11869. // jQuery core overloads toggle and creates _toggle
  11870. __toggle: $.fn.toggle,
  11871. toggle: function( speed ) {
  11872. if ( standardSpeed( speed ) || typeof speed === "boolean" || $.isFunction( speed ) ) {
  11873. return this.__toggle.apply( this, arguments );
  11874. } else {
  11875. var args = _normalizeArguments.apply( this, arguments );
  11876. args.mode = "toggle";
  11877. return this.effect.call( this, args );
  11878. }
  11879. },
  11880. // helper functions
  11881. cssUnit: function(key) {
  11882. var style = this.css( key ),
  11883. val = [];
  11884. $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
  11885. if ( style.indexOf( unit ) > 0 ) {
  11886. val = [ parseFloat( style ), unit ];
  11887. }
  11888. });
  11889. return val;
  11890. }
  11891. });
  11892. })();
  11893. /******************************************************************************/
  11894. /*********************************** EASING ***********************************/
  11895. /******************************************************************************/
  11896. (function() {
  11897. // based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
  11898. var baseEasings = {};
  11899. $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
  11900. baseEasings[ name ] = function( p ) {
  11901. return Math.pow( p, i + 2 );
  11902. };
  11903. });
  11904. $.extend( baseEasings, {
  11905. Sine: function ( p ) {
  11906. return 1 - Math.cos( p * Math.PI / 2 );
  11907. },
  11908. Circ: function ( p ) {
  11909. return 1 - Math.sqrt( 1 - p * p );
  11910. },
  11911. Elastic: function( p ) {
  11912. return p === 0 || p === 1 ? p :
  11913. -Math.pow( 2, 8 * (p - 1) ) * Math.sin( ( (p - 1) * 80 - 7.5 ) * Math.PI / 15 );
  11914. },
  11915. Back: function( p ) {
  11916. return p * p * ( 3 * p - 2 );
  11917. },
  11918. Bounce: function ( p ) {
  11919. var pow2,
  11920. bounce = 4;
  11921. while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
  11922. return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
  11923. }
  11924. });
  11925. $.each( baseEasings, function( name, easeIn ) {
  11926. $.easing[ "easeIn" + name ] = easeIn;
  11927. $.easing[ "easeOut" + name ] = function( p ) {
  11928. return 1 - easeIn( 1 - p );
  11929. };
  11930. $.easing[ "easeInOut" + name ] = function( p ) {
  11931. return p < 0.5 ?
  11932. easeIn( p * 2 ) / 2 :
  11933. 1 - easeIn( p * -2 + 2 ) / 2;
  11934. };
  11935. });
  11936. })();
  11937. })(jQuery));
  11938. (function( $, undefined ) {
  11939. var rvertical = /up|down|vertical/,
  11940. rpositivemotion = /up|left|vertical|horizontal/;
  11941. $.effects.effect.blind = function( o, done ) {
  11942. // Create element
  11943. var el = $( this ),
  11944. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  11945. mode = $.effects.setMode( el, o.mode || "hide" ),
  11946. direction = o.direction || "up",
  11947. vertical = rvertical.test( direction ),
  11948. ref = vertical ? "height" : "width",
  11949. ref2 = vertical ? "top" : "left",
  11950. motion = rpositivemotion.test( direction ),
  11951. animation = {},
  11952. show = mode === "show",
  11953. wrapper, distance, margin;
  11954. // if already wrapped, the wrapper's properties are my property. #6245
  11955. if ( el.parent().is( ".ui-effects-wrapper" ) ) {
  11956. $.effects.save( el.parent(), props );
  11957. } else {
  11958. $.effects.save( el, props );
  11959. }
  11960. el.show();
  11961. wrapper = $.effects.createWrapper( el ).css({
  11962. overflow: "hidden"
  11963. });
  11964. distance = wrapper[ ref ]();
  11965. margin = parseFloat( wrapper.css( ref2 ) ) || 0;
  11966. animation[ ref ] = show ? distance : 0;
  11967. if ( !motion ) {
  11968. el
  11969. .css( vertical ? "bottom" : "right", 0 )
  11970. .css( vertical ? "top" : "left", "auto" )
  11971. .css({ position: "absolute" });
  11972. animation[ ref2 ] = show ? margin : distance + margin;
  11973. }
  11974. // start at 0 if we are showing
  11975. if ( show ) {
  11976. wrapper.css( ref, 0 );
  11977. if ( ! motion ) {
  11978. wrapper.css( ref2, margin + distance );
  11979. }
  11980. }
  11981. // Animate
  11982. wrapper.animate( animation, {
  11983. duration: o.duration,
  11984. easing: o.easing,
  11985. queue: false,
  11986. complete: function() {
  11987. if ( mode === "hide" ) {
  11988. el.hide();
  11989. }
  11990. $.effects.restore( el, props );
  11991. $.effects.removeWrapper( el );
  11992. done();
  11993. }
  11994. });
  11995. };
  11996. })(jQuery);
  11997. (function( $, undefined ) {
  11998. $.effects.effect.bounce = function( o, done ) {
  11999. var el = $( this ),
  12000. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  12001. // defaults:
  12002. mode = $.effects.setMode( el, o.mode || "effect" ),
  12003. hide = mode === "hide",
  12004. show = mode === "show",
  12005. direction = o.direction || "up",
  12006. distance = o.distance,
  12007. times = o.times || 5,
  12008. // number of internal animations
  12009. anims = times * 2 + ( show || hide ? 1 : 0 ),
  12010. speed = o.duration / anims,
  12011. easing = o.easing,
  12012. // utility:
  12013. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  12014. motion = ( direction === "up" || direction === "left" ),
  12015. i,
  12016. upAnim,
  12017. downAnim,
  12018. // we will need to re-assemble the queue to stack our animations in place
  12019. queue = el.queue(),
  12020. queuelen = queue.length;
  12021. // Avoid touching opacity to prevent clearType and PNG issues in IE
  12022. if ( show || hide ) {
  12023. props.push( "opacity" );
  12024. }
  12025. $.effects.save( el, props );
  12026. el.show();
  12027. $.effects.createWrapper( el ); // Create Wrapper
  12028. // default distance for the BIGGEST bounce is the outer Distance / 3
  12029. if ( !distance ) {
  12030. distance = el[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
  12031. }
  12032. if ( show ) {
  12033. downAnim = { opacity: 1 };
  12034. downAnim[ ref ] = 0;
  12035. // if we are showing, force opacity 0 and set the initial position
  12036. // then do the "first" animation
  12037. el.css( "opacity", 0 )
  12038. .css( ref, motion ? -distance * 2 : distance * 2 )
  12039. .animate( downAnim, speed, easing );
  12040. }
  12041. // start at the smallest distance if we are hiding
  12042. if ( hide ) {
  12043. distance = distance / Math.pow( 2, times - 1 );
  12044. }
  12045. downAnim = {};
  12046. downAnim[ ref ] = 0;
  12047. // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
  12048. for ( i = 0; i < times; i++ ) {
  12049. upAnim = {};
  12050. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  12051. el.animate( upAnim, speed, easing )
  12052. .animate( downAnim, speed, easing );
  12053. distance = hide ? distance * 2 : distance / 2;
  12054. }
  12055. // Last Bounce when Hiding
  12056. if ( hide ) {
  12057. upAnim = { opacity: 0 };
  12058. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  12059. el.animate( upAnim, speed, easing );
  12060. }
  12061. el.queue(function() {
  12062. if ( hide ) {
  12063. el.hide();
  12064. }
  12065. $.effects.restore( el, props );
  12066. $.effects.removeWrapper( el );
  12067. done();
  12068. });
  12069. // inject all the animations we just queued to be first in line (after "inprogress")
  12070. if ( queuelen > 1) {
  12071. queue.splice.apply( queue,
  12072. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  12073. }
  12074. el.dequeue();
  12075. };
  12076. })(jQuery);
  12077. (function( $, undefined ) {
  12078. $.effects.effect.clip = function( o, done ) {
  12079. // Create element
  12080. var el = $( this ),
  12081. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  12082. mode = $.effects.setMode( el, o.mode || "hide" ),
  12083. show = mode === "show",
  12084. direction = o.direction || "vertical",
  12085. vert = direction === "vertical",
  12086. size = vert ? "height" : "width",
  12087. position = vert ? "top" : "left",
  12088. animation = {},
  12089. wrapper, animate, distance;
  12090. // Save & Show
  12091. $.effects.save( el, props );
  12092. el.show();
  12093. // Create Wrapper
  12094. wrapper = $.effects.createWrapper( el ).css({
  12095. overflow: "hidden"
  12096. });
  12097. animate = ( el[0].tagName === "IMG" ) ? wrapper : el;
  12098. distance = animate[ size ]();
  12099. // Shift
  12100. if ( show ) {
  12101. animate.css( size, 0 );
  12102. animate.css( position, distance / 2 );
  12103. }
  12104. // Create Animation Object:
  12105. animation[ size ] = show ? distance : 0;
  12106. animation[ position ] = show ? 0 : distance / 2;
  12107. // Animate
  12108. animate.animate( animation, {
  12109. queue: false,
  12110. duration: o.duration,
  12111. easing: o.easing,
  12112. complete: function() {
  12113. if ( !show ) {
  12114. el.hide();
  12115. }
  12116. $.effects.restore( el, props );
  12117. $.effects.removeWrapper( el );
  12118. done();
  12119. }
  12120. });
  12121. };
  12122. })(jQuery);
  12123. (function( $, undefined ) {
  12124. $.effects.effect.drop = function( o, done ) {
  12125. var el = $( this ),
  12126. props = [ "position", "top", "bottom", "left", "right", "opacity", "height", "width" ],
  12127. mode = $.effects.setMode( el, o.mode || "hide" ),
  12128. show = mode === "show",
  12129. direction = o.direction || "left",
  12130. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  12131. motion = ( direction === "up" || direction === "left" ) ? "pos" : "neg",
  12132. animation = {
  12133. opacity: show ? 1 : 0
  12134. },
  12135. distance;
  12136. // Adjust
  12137. $.effects.save( el, props );
  12138. el.show();
  12139. $.effects.createWrapper( el );
  12140. distance = o.distance || el[ ref === "top" ? "outerHeight": "outerWidth" ]( true ) / 2;
  12141. if ( show ) {
  12142. el
  12143. .css( "opacity", 0 )
  12144. .css( ref, motion === "pos" ? -distance : distance );
  12145. }
  12146. // Animation
  12147. animation[ ref ] = ( show ?
  12148. ( motion === "pos" ? "+=" : "-=" ) :
  12149. ( motion === "pos" ? "-=" : "+=" ) ) +
  12150. distance;
  12151. // Animate
  12152. el.animate( animation, {
  12153. queue: false,
  12154. duration: o.duration,
  12155. easing: o.easing,
  12156. complete: function() {
  12157. if ( mode === "hide" ) {
  12158. el.hide();
  12159. }
  12160. $.effects.restore( el, props );
  12161. $.effects.removeWrapper( el );
  12162. done();
  12163. }
  12164. });
  12165. };
  12166. })(jQuery);
  12167. (function( $, undefined ) {
  12168. $.effects.effect.explode = function( o, done ) {
  12169. var rows = o.pieces ? Math.round( Math.sqrt( o.pieces ) ) : 3,
  12170. cells = rows,
  12171. el = $( this ),
  12172. mode = $.effects.setMode( el, o.mode || "hide" ),
  12173. show = mode === "show",
  12174. // show and then visibility:hidden the element before calculating offset
  12175. offset = el.show().css( "visibility", "hidden" ).offset(),
  12176. // width and height of a piece
  12177. width = Math.ceil( el.outerWidth() / cells ),
  12178. height = Math.ceil( el.outerHeight() / rows ),
  12179. pieces = [],
  12180. // loop
  12181. i, j, left, top, mx, my;
  12182. // children animate complete:
  12183. function childComplete() {
  12184. pieces.push( this );
  12185. if ( pieces.length === rows * cells ) {
  12186. animComplete();
  12187. }
  12188. }
  12189. // clone the element for each row and cell.
  12190. for( i = 0; i < rows ; i++ ) { // ===>
  12191. top = offset.top + i * height;
  12192. my = i - ( rows - 1 ) / 2 ;
  12193. for( j = 0; j < cells ; j++ ) { // |||
  12194. left = offset.left + j * width;
  12195. mx = j - ( cells - 1 ) / 2 ;
  12196. // Create a clone of the now hidden main element that will be absolute positioned
  12197. // within a wrapper div off the -left and -top equal to size of our pieces
  12198. el
  12199. .clone()
  12200. .appendTo( "body" )
  12201. .wrap( "<div></div>" )
  12202. .css({
  12203. position: "absolute",
  12204. visibility: "visible",
  12205. left: -j * width,
  12206. top: -i * height
  12207. })
  12208. // select the wrapper - make it overflow: hidden and absolute positioned based on
  12209. // where the original was located +left and +top equal to the size of pieces
  12210. .parent()
  12211. .addClass( "ui-effects-explode" )
  12212. .css({
  12213. position: "absolute",
  12214. overflow: "hidden",
  12215. width: width,
  12216. height: height,
  12217. left: left + ( show ? mx * width : 0 ),
  12218. top: top + ( show ? my * height : 0 ),
  12219. opacity: show ? 0 : 1
  12220. }).animate({
  12221. left: left + ( show ? 0 : mx * width ),
  12222. top: top + ( show ? 0 : my * height ),
  12223. opacity: show ? 1 : 0
  12224. }, o.duration || 500, o.easing, childComplete );
  12225. }
  12226. }
  12227. function animComplete() {
  12228. el.css({
  12229. visibility: "visible"
  12230. });
  12231. $( pieces ).remove();
  12232. if ( !show ) {
  12233. el.hide();
  12234. }
  12235. done();
  12236. }
  12237. };
  12238. })(jQuery);
  12239. (function( $, undefined ) {
  12240. $.effects.effect.fade = function( o, done ) {
  12241. var el = $( this ),
  12242. mode = $.effects.setMode( el, o.mode || "toggle" );
  12243. el.animate({
  12244. opacity: mode
  12245. }, {
  12246. queue: false,
  12247. duration: o.duration,
  12248. easing: o.easing,
  12249. complete: done
  12250. });
  12251. };
  12252. })( jQuery );
  12253. (function( $, undefined ) {
  12254. $.effects.effect.fold = function( o, done ) {
  12255. // Create element
  12256. var el = $( this ),
  12257. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  12258. mode = $.effects.setMode( el, o.mode || "hide" ),
  12259. show = mode === "show",
  12260. hide = mode === "hide",
  12261. size = o.size || 15,
  12262. percent = /([0-9]+)%/.exec( size ),
  12263. horizFirst = !!o.horizFirst,
  12264. widthFirst = show !== horizFirst,
  12265. ref = widthFirst ? [ "width", "height" ] : [ "height", "width" ],
  12266. duration = o.duration / 2,
  12267. wrapper, distance,
  12268. animation1 = {},
  12269. animation2 = {};
  12270. $.effects.save( el, props );
  12271. el.show();
  12272. // Create Wrapper
  12273. wrapper = $.effects.createWrapper( el ).css({
  12274. overflow: "hidden"
  12275. });
  12276. distance = widthFirst ?
  12277. [ wrapper.width(), wrapper.height() ] :
  12278. [ wrapper.height(), wrapper.width() ];
  12279. if ( percent ) {
  12280. size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
  12281. }
  12282. if ( show ) {
  12283. wrapper.css( horizFirst ? {
  12284. height: 0,
  12285. width: size
  12286. } : {
  12287. height: size,
  12288. width: 0
  12289. });
  12290. }
  12291. // Animation
  12292. animation1[ ref[ 0 ] ] = show ? distance[ 0 ] : size;
  12293. animation2[ ref[ 1 ] ] = show ? distance[ 1 ] : 0;
  12294. // Animate
  12295. wrapper
  12296. .animate( animation1, duration, o.easing )
  12297. .animate( animation2, duration, o.easing, function() {
  12298. if ( hide ) {
  12299. el.hide();
  12300. }
  12301. $.effects.restore( el, props );
  12302. $.effects.removeWrapper( el );
  12303. done();
  12304. });
  12305. };
  12306. })(jQuery);
  12307. (function( $, undefined ) {
  12308. $.effects.effect.highlight = function( o, done ) {
  12309. var elem = $( this ),
  12310. props = [ "backgroundImage", "backgroundColor", "opacity" ],
  12311. mode = $.effects.setMode( elem, o.mode || "show" ),
  12312. animation = {
  12313. backgroundColor: elem.css( "backgroundColor" )
  12314. };
  12315. if (mode === "hide") {
  12316. animation.opacity = 0;
  12317. }
  12318. $.effects.save( elem, props );
  12319. elem
  12320. .show()
  12321. .css({
  12322. backgroundImage: "none",
  12323. backgroundColor: o.color || "#ffff99"
  12324. })
  12325. .animate( animation, {
  12326. queue: false,
  12327. duration: o.duration,
  12328. easing: o.easing,
  12329. complete: function() {
  12330. if ( mode === "hide" ) {
  12331. elem.hide();
  12332. }
  12333. $.effects.restore( elem, props );
  12334. done();
  12335. }
  12336. });
  12337. };
  12338. })(jQuery);
  12339. (function( $, undefined ) {
  12340. $.effects.effect.pulsate = function( o, done ) {
  12341. var elem = $( this ),
  12342. mode = $.effects.setMode( elem, o.mode || "show" ),
  12343. show = mode === "show",
  12344. hide = mode === "hide",
  12345. showhide = ( show || mode === "hide" ),
  12346. // showing or hiding leaves of the "last" animation
  12347. anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
  12348. duration = o.duration / anims,
  12349. animateTo = 0,
  12350. queue = elem.queue(),
  12351. queuelen = queue.length,
  12352. i;
  12353. if ( show || !elem.is(":visible")) {
  12354. elem.css( "opacity", 0 ).show();
  12355. animateTo = 1;
  12356. }
  12357. // anims - 1 opacity "toggles"
  12358. for ( i = 1; i < anims; i++ ) {
  12359. elem.animate({
  12360. opacity: animateTo
  12361. }, duration, o.easing );
  12362. animateTo = 1 - animateTo;
  12363. }
  12364. elem.animate({
  12365. opacity: animateTo
  12366. }, duration, o.easing);
  12367. elem.queue(function() {
  12368. if ( hide ) {
  12369. elem.hide();
  12370. }
  12371. done();
  12372. });
  12373. // We just queued up "anims" animations, we need to put them next in the queue
  12374. if ( queuelen > 1 ) {
  12375. queue.splice.apply( queue,
  12376. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  12377. }
  12378. elem.dequeue();
  12379. };
  12380. })(jQuery);
  12381. (function( $, undefined ) {
  12382. $.effects.effect.puff = function( o, done ) {
  12383. var elem = $( this ),
  12384. mode = $.effects.setMode( elem, o.mode || "hide" ),
  12385. hide = mode === "hide",
  12386. percent = parseInt( o.percent, 10 ) || 150,
  12387. factor = percent / 100,
  12388. original = {
  12389. height: elem.height(),
  12390. width: elem.width(),
  12391. outerHeight: elem.outerHeight(),
  12392. outerWidth: elem.outerWidth()
  12393. };
  12394. $.extend( o, {
  12395. effect: "scale",
  12396. queue: false,
  12397. fade: true,
  12398. mode: mode,
  12399. complete: done,
  12400. percent: hide ? percent : 100,
  12401. from: hide ?
  12402. original :
  12403. {
  12404. height: original.height * factor,
  12405. width: original.width * factor,
  12406. outerHeight: original.outerHeight * factor,
  12407. outerWidth: original.outerWidth * factor
  12408. }
  12409. });
  12410. elem.effect( o );
  12411. };
  12412. $.effects.effect.scale = function( o, done ) {
  12413. // Create element
  12414. var el = $( this ),
  12415. options = $.extend( true, {}, o ),
  12416. mode = $.effects.setMode( el, o.mode || "effect" ),
  12417. percent = parseInt( o.percent, 10 ) ||
  12418. ( parseInt( o.percent, 10 ) === 0 ? 0 : ( mode === "hide" ? 0 : 100 ) ),
  12419. direction = o.direction || "both",
  12420. origin = o.origin,
  12421. original = {
  12422. height: el.height(),
  12423. width: el.width(),
  12424. outerHeight: el.outerHeight(),
  12425. outerWidth: el.outerWidth()
  12426. },
  12427. factor = {
  12428. y: direction !== "horizontal" ? (percent / 100) : 1,
  12429. x: direction !== "vertical" ? (percent / 100) : 1
  12430. };
  12431. // We are going to pass this effect to the size effect:
  12432. options.effect = "size";
  12433. options.queue = false;
  12434. options.complete = done;
  12435. // Set default origin and restore for show/hide
  12436. if ( mode !== "effect" ) {
  12437. options.origin = origin || ["middle","center"];
  12438. options.restore = true;
  12439. }
  12440. options.from = o.from || ( mode === "show" ? {
  12441. height: 0,
  12442. width: 0,
  12443. outerHeight: 0,
  12444. outerWidth: 0
  12445. } : original );
  12446. options.to = {
  12447. height: original.height * factor.y,
  12448. width: original.width * factor.x,
  12449. outerHeight: original.outerHeight * factor.y,
  12450. outerWidth: original.outerWidth * factor.x
  12451. };
  12452. // Fade option to support puff
  12453. if ( options.fade ) {
  12454. if ( mode === "show" ) {
  12455. options.from.opacity = 0;
  12456. options.to.opacity = 1;
  12457. }
  12458. if ( mode === "hide" ) {
  12459. options.from.opacity = 1;
  12460. options.to.opacity = 0;
  12461. }
  12462. }
  12463. // Animate
  12464. el.effect( options );
  12465. };
  12466. $.effects.effect.size = function( o, done ) {
  12467. // Create element
  12468. var original, baseline, factor,
  12469. el = $( this ),
  12470. props0 = [ "position", "top", "bottom", "left", "right", "width", "height", "overflow", "opacity" ],
  12471. // Always restore
  12472. props1 = [ "position", "top", "bottom", "left", "right", "overflow", "opacity" ],
  12473. // Copy for children
  12474. props2 = [ "width", "height", "overflow" ],
  12475. cProps = [ "fontSize" ],
  12476. vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ],
  12477. hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ],
  12478. // Set options
  12479. mode = $.effects.setMode( el, o.mode || "effect" ),
  12480. restore = o.restore || mode !== "effect",
  12481. scale = o.scale || "both",
  12482. origin = o.origin || [ "middle", "center" ],
  12483. position = el.css( "position" ),
  12484. props = restore ? props0 : props1,
  12485. zero = {
  12486. height: 0,
  12487. width: 0,
  12488. outerHeight: 0,
  12489. outerWidth: 0
  12490. };
  12491. if ( mode === "show" ) {
  12492. el.show();
  12493. }
  12494. original = {
  12495. height: el.height(),
  12496. width: el.width(),
  12497. outerHeight: el.outerHeight(),
  12498. outerWidth: el.outerWidth()
  12499. };
  12500. if ( o.mode === "toggle" && mode === "show" ) {
  12501. el.from = o.to || zero;
  12502. el.to = o.from || original;
  12503. } else {
  12504. el.from = o.from || ( mode === "show" ? zero : original );
  12505. el.to = o.to || ( mode === "hide" ? zero : original );
  12506. }
  12507. // Set scaling factor
  12508. factor = {
  12509. from: {
  12510. y: el.from.height / original.height,
  12511. x: el.from.width / original.width
  12512. },
  12513. to: {
  12514. y: el.to.height / original.height,
  12515. x: el.to.width / original.width
  12516. }
  12517. };
  12518. // Scale the css box
  12519. if ( scale === "box" || scale === "both" ) {
  12520. // Vertical props scaling
  12521. if ( factor.from.y !== factor.to.y ) {
  12522. props = props.concat( vProps );
  12523. el.from = $.effects.setTransition( el, vProps, factor.from.y, el.from );
  12524. el.to = $.effects.setTransition( el, vProps, factor.to.y, el.to );
  12525. }
  12526. // Horizontal props scaling
  12527. if ( factor.from.x !== factor.to.x ) {
  12528. props = props.concat( hProps );
  12529. el.from = $.effects.setTransition( el, hProps, factor.from.x, el.from );
  12530. el.to = $.effects.setTransition( el, hProps, factor.to.x, el.to );
  12531. }
  12532. }
  12533. // Scale the content
  12534. if ( scale === "content" || scale === "both" ) {
  12535. // Vertical props scaling
  12536. if ( factor.from.y !== factor.to.y ) {
  12537. props = props.concat( cProps ).concat( props2 );
  12538. el.from = $.effects.setTransition( el, cProps, factor.from.y, el.from );
  12539. el.to = $.effects.setTransition( el, cProps, factor.to.y, el.to );
  12540. }
  12541. }
  12542. $.effects.save( el, props );
  12543. el.show();
  12544. $.effects.createWrapper( el );
  12545. el.css( "overflow", "hidden" ).css( el.from );
  12546. // Adjust
  12547. if (origin) { // Calculate baseline shifts
  12548. baseline = $.effects.getBaseline( origin, original );
  12549. el.from.top = ( original.outerHeight - el.outerHeight() ) * baseline.y;
  12550. el.from.left = ( original.outerWidth - el.outerWidth() ) * baseline.x;
  12551. el.to.top = ( original.outerHeight - el.to.outerHeight ) * baseline.y;
  12552. el.to.left = ( original.outerWidth - el.to.outerWidth ) * baseline.x;
  12553. }
  12554. el.css( el.from ); // set top & left
  12555. // Animate
  12556. if ( scale === "content" || scale === "both" ) { // Scale the children
  12557. // Add margins/font-size
  12558. vProps = vProps.concat([ "marginTop", "marginBottom" ]).concat(cProps);
  12559. hProps = hProps.concat([ "marginLeft", "marginRight" ]);
  12560. props2 = props0.concat(vProps).concat(hProps);
  12561. el.find( "*[width]" ).each( function(){
  12562. var child = $( this ),
  12563. c_original = {
  12564. height: child.height(),
  12565. width: child.width(),
  12566. outerHeight: child.outerHeight(),
  12567. outerWidth: child.outerWidth()
  12568. };
  12569. if (restore) {
  12570. $.effects.save(child, props2);
  12571. }
  12572. child.from = {
  12573. height: c_original.height * factor.from.y,
  12574. width: c_original.width * factor.from.x,
  12575. outerHeight: c_original.outerHeight * factor.from.y,
  12576. outerWidth: c_original.outerWidth * factor.from.x
  12577. };
  12578. child.to = {
  12579. height: c_original.height * factor.to.y,
  12580. width: c_original.width * factor.to.x,
  12581. outerHeight: c_original.height * factor.to.y,
  12582. outerWidth: c_original.width * factor.to.x
  12583. };
  12584. // Vertical props scaling
  12585. if ( factor.from.y !== factor.to.y ) {
  12586. child.from = $.effects.setTransition( child, vProps, factor.from.y, child.from );
  12587. child.to = $.effects.setTransition( child, vProps, factor.to.y, child.to );
  12588. }
  12589. // Horizontal props scaling
  12590. if ( factor.from.x !== factor.to.x ) {
  12591. child.from = $.effects.setTransition( child, hProps, factor.from.x, child.from );
  12592. child.to = $.effects.setTransition( child, hProps, factor.to.x, child.to );
  12593. }
  12594. // Animate children
  12595. child.css( child.from );
  12596. child.animate( child.to, o.duration, o.easing, function() {
  12597. // Restore children
  12598. if ( restore ) {
  12599. $.effects.restore( child, props2 );
  12600. }
  12601. });
  12602. });
  12603. }
  12604. // Animate
  12605. el.animate( el.to, {
  12606. queue: false,
  12607. duration: o.duration,
  12608. easing: o.easing,
  12609. complete: function() {
  12610. if ( el.to.opacity === 0 ) {
  12611. el.css( "opacity", el.from.opacity );
  12612. }
  12613. if( mode === "hide" ) {
  12614. el.hide();
  12615. }
  12616. $.effects.restore( el, props );
  12617. if ( !restore ) {
  12618. // we need to calculate our new positioning based on the scaling
  12619. if ( position === "static" ) {
  12620. el.css({
  12621. position: "relative",
  12622. top: el.to.top,
  12623. left: el.to.left
  12624. });
  12625. } else {
  12626. $.each([ "top", "left" ], function( idx, pos ) {
  12627. el.css( pos, function( _, str ) {
  12628. var val = parseInt( str, 10 ),
  12629. toRef = idx ? el.to.left : el.to.top;
  12630. // if original was "auto", recalculate the new value from wrapper
  12631. if ( str === "auto" ) {
  12632. return toRef + "px";
  12633. }
  12634. return val + toRef + "px";
  12635. });
  12636. });
  12637. }
  12638. }
  12639. $.effects.removeWrapper( el );
  12640. done();
  12641. }
  12642. });
  12643. };
  12644. })(jQuery);
  12645. (function( $, undefined ) {
  12646. $.effects.effect.shake = function( o, done ) {
  12647. var el = $( this ),
  12648. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  12649. mode = $.effects.setMode( el, o.mode || "effect" ),
  12650. direction = o.direction || "left",
  12651. distance = o.distance || 20,
  12652. times = o.times || 3,
  12653. anims = times * 2 + 1,
  12654. speed = Math.round(o.duration/anims),
  12655. ref = (direction === "up" || direction === "down") ? "top" : "left",
  12656. positiveMotion = (direction === "up" || direction === "left"),
  12657. animation = {},
  12658. animation1 = {},
  12659. animation2 = {},
  12660. i,
  12661. // we will need to re-assemble the queue to stack our animations in place
  12662. queue = el.queue(),
  12663. queuelen = queue.length;
  12664. $.effects.save( el, props );
  12665. el.show();
  12666. $.effects.createWrapper( el );
  12667. // Animation
  12668. animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance;
  12669. animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2;
  12670. animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2;
  12671. // Animate
  12672. el.animate( animation, speed, o.easing );
  12673. // Shakes
  12674. for ( i = 1; i < times; i++ ) {
  12675. el.animate( animation1, speed, o.easing ).animate( animation2, speed, o.easing );
  12676. }
  12677. el
  12678. .animate( animation1, speed, o.easing )
  12679. .animate( animation, speed / 2, o.easing )
  12680. .queue(function() {
  12681. if ( mode === "hide" ) {
  12682. el.hide();
  12683. }
  12684. $.effects.restore( el, props );
  12685. $.effects.removeWrapper( el );
  12686. done();
  12687. });
  12688. // inject all the animations we just queued to be first in line (after "inprogress")
  12689. if ( queuelen > 1) {
  12690. queue.splice.apply( queue,
  12691. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  12692. }
  12693. el.dequeue();
  12694. };
  12695. })(jQuery);
  12696. (function( $, undefined ) {
  12697. $.effects.effect.slide = function( o, done ) {
  12698. // Create element
  12699. var el = $( this ),
  12700. props = [ "position", "top", "bottom", "left", "right", "width", "height" ],
  12701. mode = $.effects.setMode( el, o.mode || "show" ),
  12702. show = mode === "show",
  12703. direction = o.direction || "left",
  12704. ref = (direction === "up" || direction === "down") ? "top" : "left",
  12705. positiveMotion = (direction === "up" || direction === "left"),
  12706. distance,
  12707. animation = {};
  12708. // Adjust
  12709. $.effects.save( el, props );
  12710. el.show();
  12711. distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]( true );
  12712. $.effects.createWrapper( el ).css({
  12713. overflow: "hidden"
  12714. });
  12715. if ( show ) {
  12716. el.css( ref, positiveMotion ? (isNaN(distance) ? "-" + distance : -distance) : distance );
  12717. }
  12718. // Animation
  12719. animation[ ref ] = ( show ?
  12720. ( positiveMotion ? "+=" : "-=") :
  12721. ( positiveMotion ? "-=" : "+=")) +
  12722. distance;
  12723. // Animate
  12724. el.animate( animation, {
  12725. queue: false,
  12726. duration: o.duration,
  12727. easing: o.easing,
  12728. complete: function() {
  12729. if ( mode === "hide" ) {
  12730. el.hide();
  12731. }
  12732. $.effects.restore( el, props );
  12733. $.effects.removeWrapper( el );
  12734. done();
  12735. }
  12736. });
  12737. };
  12738. })(jQuery);
  12739. (function( $, undefined ) {
  12740. $.effects.effect.transfer = function( o, done ) {
  12741. var elem = $( this ),
  12742. target = $( o.to ),
  12743. targetFixed = target.css( "position" ) === "fixed",
  12744. body = $("body"),
  12745. fixTop = targetFixed ? body.scrollTop() : 0,
  12746. fixLeft = targetFixed ? body.scrollLeft() : 0,
  12747. endPosition = target.offset(),
  12748. animation = {
  12749. top: endPosition.top - fixTop ,
  12750. left: endPosition.left - fixLeft ,
  12751. height: target.innerHeight(),
  12752. width: target.innerWidth()
  12753. },
  12754. startPosition = elem.offset(),
  12755. transfer = $( "<div class='ui-effects-transfer'></div>" )
  12756. .appendTo( document.body )
  12757. .addClass( o.className )
  12758. .css({
  12759. top: startPosition.top - fixTop ,
  12760. left: startPosition.left - fixLeft ,
  12761. height: elem.innerHeight(),
  12762. width: elem.innerWidth(),
  12763. position: targetFixed ? "fixed" : "absolute"
  12764. })
  12765. .animate( animation, o.duration, o.easing, function() {
  12766. transfer.remove();
  12767. done();
  12768. });
  12769. };
  12770. })(jQuery);