jquery-ui.js 426 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004
  1. /*! jQuery UI - v1.10.3 - 2013-05-03
  2. * http://jqueryui.com
  3. * Includes: jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.draggable.js, jquery.ui.droppable.js, jquery.ui.resizable.js, jquery.ui.selectable.js, jquery.ui.sortable.js, jquery.ui.effect.js, jquery.ui.accordion.js, jquery.ui.autocomplete.js, jquery.ui.button.js, jquery.ui.datepicker.js, jquery.ui.dialog.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, jquery.ui.menu.js, jquery.ui.position.js, jquery.ui.progressbar.js, jquery.ui.slider.js, jquery.ui.spinner.js, jquery.ui.tabs.js, jquery.ui.tooltip.js
  4. * Copyright 2013 jQuery Foundation and other contributors; Licensed MIT */
  5. (function( $, undefined ) {
  6. var uuid = 0,
  7. runiqueId = /^ui-id-\d+$/;
  8. // $.ui might exist from components with no dependencies, e.g., $.ui.position
  9. $.ui = $.ui || {};
  10. $.extend( $.ui, {
  11. version: "1.10.3",
  12. keyCode: {
  13. BACKSPACE: 8,
  14. COMMA: 188,
  15. DELETE: 46,
  16. DOWN: 40,
  17. END: 35,
  18. ENTER: 13,
  19. ESCAPE: 27,
  20. HOME: 36,
  21. LEFT: 37,
  22. NUMPAD_ADD: 107,
  23. NUMPAD_DECIMAL: 110,
  24. NUMPAD_DIVIDE: 111,
  25. NUMPAD_ENTER: 108,
  26. NUMPAD_MULTIPLY: 106,
  27. NUMPAD_SUBTRACT: 109,
  28. PAGE_DOWN: 34,
  29. PAGE_UP: 33,
  30. PERIOD: 190,
  31. RIGHT: 39,
  32. SPACE: 32,
  33. TAB: 9,
  34. UP: 38
  35. }
  36. });
  37. // plugins
  38. $.fn.extend({
  39. focus: (function( orig ) {
  40. return function( delay, fn ) {
  41. return typeof delay === "number" ?
  42. this.each(function() {
  43. var elem = this;
  44. setTimeout(function() {
  45. $( elem ).focus();
  46. if ( fn ) {
  47. fn.call( elem );
  48. }
  49. }, delay );
  50. }) :
  51. orig.apply( this, arguments );
  52. };
  53. })( $.fn.focus ),
  54. scrollParent: function() {
  55. var scrollParent;
  56. if (($.ui.ie && (/(static|relative)/).test(this.css("position"))) || (/absolute/).test(this.css("position"))) {
  57. scrollParent = this.parents().filter(function() {
  58. return (/(relative|absolute|fixed)/).test($.css(this,"position")) && (/(auto|scroll)/).test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x"));
  59. }).eq(0);
  60. } else {
  61. scrollParent = this.parents().filter(function() {
  62. return (/(auto|scroll)/).test($.css(this,"overflow")+$.css(this,"overflow-y")+$.css(this,"overflow-x"));
  63. }).eq(0);
  64. }
  65. return (/fixed/).test(this.css("position")) || !scrollParent.length ? $(document) : scrollParent;
  66. },
  67. zIndex: function( zIndex ) {
  68. if ( zIndex !== undefined ) {
  69. return this.css( "zIndex", zIndex );
  70. }
  71. if ( this.length ) {
  72. var elem = $( this[ 0 ] ), position, value;
  73. while ( elem.length && elem[ 0 ] !== document ) {
  74. // Ignore z-index if position is set to a value where z-index is ignored by the browser
  75. // This makes behavior of this function consistent across browsers
  76. // WebKit always returns auto if the element is positioned
  77. position = elem.css( "position" );
  78. if ( position === "absolute" || position === "relative" || position === "fixed" ) {
  79. // IE returns 0 when zIndex is not specified
  80. // other browsers return a string
  81. // we ignore the case of nested elements with an explicit value of 0
  82. // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
  83. value = parseInt( elem.css( "zIndex" ), 10 );
  84. if ( !isNaN( value ) && value !== 0 ) {
  85. return value;
  86. }
  87. }
  88. elem = elem.parent();
  89. }
  90. }
  91. return 0;
  92. },
  93. uniqueId: function() {
  94. return this.each(function() {
  95. if ( !this.id ) {
  96. this.id = "ui-id-" + (++uuid);
  97. }
  98. });
  99. },
  100. removeUniqueId: function() {
  101. return this.each(function() {
  102. if ( runiqueId.test( this.id ) ) {
  103. $( this ).removeAttr( "id" );
  104. }
  105. });
  106. }
  107. });
  108. // selectors
  109. function focusable( element, isTabIndexNotNaN ) {
  110. var map, mapName, img,
  111. nodeName = element.nodeName.toLowerCase();
  112. if ( "area" === nodeName ) {
  113. map = element.parentNode;
  114. mapName = map.name;
  115. if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
  116. return false;
  117. }
  118. img = $( "img[usemap=#" + mapName + "]" )[0];
  119. return !!img && visible( img );
  120. }
  121. return ( /input|select|textarea|button|object/.test( nodeName ) ?
  122. !element.disabled :
  123. "a" === nodeName ?
  124. element.href || isTabIndexNotNaN :
  125. isTabIndexNotNaN) &&
  126. // the element and all of its ancestors must be visible
  127. visible( element );
  128. }
  129. function visible( element ) {
  130. return $.expr.filters.visible( element ) &&
  131. !$( element ).parents().addBack().filter(function() {
  132. return $.css( this, "visibility" ) === "hidden";
  133. }).length;
  134. }
  135. $.extend( $.expr[ ":" ], {
  136. data: $.expr.createPseudo ?
  137. $.expr.createPseudo(function( dataName ) {
  138. return function( elem ) {
  139. return !!$.data( elem, dataName );
  140. };
  141. }) :
  142. // support: jQuery <1.8
  143. function( elem, i, match ) {
  144. return !!$.data( elem, match[ 3 ] );
  145. },
  146. focusable: function( element ) {
  147. return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
  148. },
  149. tabbable: function( element ) {
  150. var tabIndex = $.attr( element, "tabindex" ),
  151. isTabIndexNaN = isNaN( tabIndex );
  152. return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
  153. }
  154. });
  155. // support: jQuery <1.8
  156. if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
  157. $.each( [ "Width", "Height" ], function( i, name ) {
  158. var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
  159. type = name.toLowerCase(),
  160. orig = {
  161. innerWidth: $.fn.innerWidth,
  162. innerHeight: $.fn.innerHeight,
  163. outerWidth: $.fn.outerWidth,
  164. outerHeight: $.fn.outerHeight
  165. };
  166. function reduce( elem, size, border, margin ) {
  167. $.each( side, function() {
  168. size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
  169. if ( border ) {
  170. size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
  171. }
  172. if ( margin ) {
  173. size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
  174. }
  175. });
  176. return size;
  177. }
  178. $.fn[ "inner" + name ] = function( size ) {
  179. if ( size === undefined ) {
  180. return orig[ "inner" + name ].call( this );
  181. }
  182. return this.each(function() {
  183. $( this ).css( type, reduce( this, size ) + "px" );
  184. });
  185. };
  186. $.fn[ "outer" + name] = function( size, margin ) {
  187. if ( typeof size !== "number" ) {
  188. return orig[ "outer" + name ].call( this, size );
  189. }
  190. return this.each(function() {
  191. $( this).css( type, reduce( this, size, true, margin ) + "px" );
  192. });
  193. };
  194. });
  195. }
  196. // support: jQuery <1.8
  197. if ( !$.fn.addBack ) {
  198. $.fn.addBack = function( selector ) {
  199. return this.add( selector == null ?
  200. this.prevObject : this.prevObject.filter( selector )
  201. );
  202. };
  203. }
  204. // support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413)
  205. if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
  206. $.fn.removeData = (function( removeData ) {
  207. return function( key ) {
  208. if ( arguments.length ) {
  209. return removeData.call( this, $.camelCase( key ) );
  210. } else {
  211. return removeData.call( this );
  212. }
  213. };
  214. })( $.fn.removeData );
  215. }
  216. // deprecated
  217. $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
  218. $.support.selectstart = "onselectstart" in document.createElement( "div" );
  219. $.fn.extend({
  220. disableSelection: function() {
  221. return this.bind( ( $.support.selectstart ? "selectstart" : "mousedown" ) +
  222. ".ui-disableSelection", function( event ) {
  223. event.preventDefault();
  224. });
  225. },
  226. enableSelection: function() {
  227. return this.unbind( ".ui-disableSelection" );
  228. }
  229. });
  230. $.extend( $.ui, {
  231. // $.ui.plugin is deprecated. Use $.widget() extensions instead.
  232. plugin: {
  233. add: function( module, option, set ) {
  234. var i,
  235. proto = $.ui[ module ].prototype;
  236. for ( i in set ) {
  237. proto.plugins[ i ] = proto.plugins[ i ] || [];
  238. proto.plugins[ i ].push( [ option, set[ i ] ] );
  239. }
  240. },
  241. call: function( instance, name, args ) {
  242. var i,
  243. set = instance.plugins[ name ];
  244. if ( !set || !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) {
  245. return;
  246. }
  247. for ( i = 0; i < set.length; i++ ) {
  248. if ( instance.options[ set[ i ][ 0 ] ] ) {
  249. set[ i ][ 1 ].apply( instance.element, args );
  250. }
  251. }
  252. }
  253. },
  254. // only used by resizable
  255. hasScroll: function( el, a ) {
  256. //If overflow is hidden, the element might have extra content, but the user wants to hide it
  257. if ( $( el ).css( "overflow" ) === "hidden") {
  258. return false;
  259. }
  260. var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
  261. has = false;
  262. if ( el[ scroll ] > 0 ) {
  263. return true;
  264. }
  265. // TODO: determine which cases actually cause this to happen
  266. // if the element doesn't have the scroll set, see if it's possible to
  267. // set the scroll
  268. el[ scroll ] = 1;
  269. has = ( el[ scroll ] > 0 );
  270. el[ scroll ] = 0;
  271. return has;
  272. }
  273. });
  274. })( jQuery );
  275. (function( $, undefined ) {
  276. var uuid = 0,
  277. slice = Array.prototype.slice,
  278. _cleanData = $.cleanData;
  279. $.cleanData = function( elems ) {
  280. for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
  281. try {
  282. $( elem ).triggerHandler( "remove" );
  283. // http://bugs.jquery.com/ticket/8235
  284. } catch( e ) {}
  285. }
  286. _cleanData( elems );
  287. };
  288. $.widget = function( name, base, prototype ) {
  289. var fullName, existingConstructor, constructor, basePrototype,
  290. // proxiedPrototype allows the provided prototype to remain unmodified
  291. // so that it can be used as a mixin for multiple widgets (#8876)
  292. proxiedPrototype = {},
  293. namespace = name.split( "." )[ 0 ];
  294. name = name.split( "." )[ 1 ];
  295. fullName = namespace + "-" + name;
  296. if ( !prototype ) {
  297. prototype = base;
  298. base = $.Widget;
  299. }
  300. // create selector for plugin
  301. $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
  302. return !!$.data( elem, fullName );
  303. };
  304. $[ namespace ] = $[ namespace ] || {};
  305. existingConstructor = $[ namespace ][ name ];
  306. constructor = $[ namespace ][ name ] = function( options, element ) {
  307. // allow instantiation without "new" keyword
  308. if ( !this._createWidget ) {
  309. return new constructor( options, element );
  310. }
  311. // allow instantiation without initializing for simple inheritance
  312. // must use "new" keyword (the code above always passes args)
  313. if ( arguments.length ) {
  314. this._createWidget( options, element );
  315. }
  316. };
  317. // extend with the existing constructor to carry over any static properties
  318. $.extend( constructor, existingConstructor, {
  319. version: prototype.version,
  320. // copy the object used to create the prototype in case we need to
  321. // redefine the widget later
  322. _proto: $.extend( {}, prototype ),
  323. // track widgets that inherit from this widget in case this widget is
  324. // redefined after a widget inherits from it
  325. _childConstructors: []
  326. });
  327. basePrototype = new base();
  328. // we need to make the options hash a property directly on the new instance
  329. // otherwise we'll modify the options hash on the prototype that we're
  330. // inheriting from
  331. basePrototype.options = $.widget.extend( {}, basePrototype.options );
  332. $.each( prototype, function( prop, value ) {
  333. if ( !$.isFunction( value ) ) {
  334. proxiedPrototype[ prop ] = value;
  335. return;
  336. }
  337. proxiedPrototype[ prop ] = (function() {
  338. var _super = function() {
  339. return base.prototype[ prop ].apply( this, arguments );
  340. },
  341. _superApply = function( args ) {
  342. return base.prototype[ prop ].apply( this, args );
  343. };
  344. return function() {
  345. var __super = this._super,
  346. __superApply = this._superApply,
  347. returnValue;
  348. this._super = _super;
  349. this._superApply = _superApply;
  350. returnValue = value.apply( this, arguments );
  351. this._super = __super;
  352. this._superApply = __superApply;
  353. return returnValue;
  354. };
  355. })();
  356. });
  357. constructor.prototype = $.widget.extend( basePrototype, {
  358. // TODO: remove support for widgetEventPrefix
  359. // always use the name + a colon as the prefix, e.g., draggable:start
  360. // don't prefix for widgets that aren't DOM-based
  361. widgetEventPrefix: existingConstructor ? basePrototype.widgetEventPrefix : name
  362. }, proxiedPrototype, {
  363. constructor: constructor,
  364. namespace: namespace,
  365. widgetName: name,
  366. widgetFullName: fullName
  367. });
  368. // If this widget is being redefined then we need to find all widgets that
  369. // are inheriting from it and redefine all of them so that they inherit from
  370. // the new version of this widget. We're essentially trying to replace one
  371. // level in the prototype chain.
  372. if ( existingConstructor ) {
  373. $.each( existingConstructor._childConstructors, function( i, child ) {
  374. var childPrototype = child.prototype;
  375. // redefine the child widget using the same prototype that was
  376. // originally used, but inherit from the new version of the base
  377. $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto );
  378. });
  379. // remove the list of existing child constructors from the old constructor
  380. // so the old child constructors can be garbage collected
  381. delete existingConstructor._childConstructors;
  382. } else {
  383. base._childConstructors.push( constructor );
  384. }
  385. $.widget.bridge( name, constructor );
  386. };
  387. $.widget.extend = function( target ) {
  388. var input = slice.call( arguments, 1 ),
  389. inputIndex = 0,
  390. inputLength = input.length,
  391. key,
  392. value;
  393. for ( ; inputIndex < inputLength; inputIndex++ ) {
  394. for ( key in input[ inputIndex ] ) {
  395. value = input[ inputIndex ][ key ];
  396. if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
  397. // Clone objects
  398. if ( $.isPlainObject( value ) ) {
  399. target[ key ] = $.isPlainObject( target[ key ] ) ?
  400. $.widget.extend( {}, target[ key ], value ) :
  401. // Don't extend strings, arrays, etc. with objects
  402. $.widget.extend( {}, value );
  403. // Copy everything else by reference
  404. } else {
  405. target[ key ] = value;
  406. }
  407. }
  408. }
  409. }
  410. return target;
  411. };
  412. $.widget.bridge = function( name, object ) {
  413. var fullName = object.prototype.widgetFullName || name;
  414. $.fn[ name ] = function( options ) {
  415. var isMethodCall = typeof options === "string",
  416. args = slice.call( arguments, 1 ),
  417. returnValue = this;
  418. // allow multiple hashes to be passed on init
  419. options = !isMethodCall && args.length ?
  420. $.widget.extend.apply( null, [ options ].concat(args) ) :
  421. options;
  422. if ( isMethodCall ) {
  423. this.each(function() {
  424. var methodValue,
  425. instance = $.data( this, fullName );
  426. if ( !instance ) {
  427. return $.error( "cannot call methods on " + name + " prior to initialization; " +
  428. "attempted to call method '" + options + "'" );
  429. }
  430. if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) {
  431. return $.error( "no such method '" + options + "' for " + name + " widget instance" );
  432. }
  433. methodValue = instance[ options ].apply( instance, args );
  434. if ( methodValue !== instance && methodValue !== undefined ) {
  435. returnValue = methodValue && methodValue.jquery ?
  436. returnValue.pushStack( methodValue.get() ) :
  437. methodValue;
  438. return false;
  439. }
  440. });
  441. } else {
  442. this.each(function() {
  443. var instance = $.data( this, fullName );
  444. if ( instance ) {
  445. instance.option( options || {} )._init();
  446. } else {
  447. $.data( this, fullName, new object( options, this ) );
  448. }
  449. });
  450. }
  451. return returnValue;
  452. };
  453. };
  454. $.Widget = function( /* options, element */ ) {};
  455. $.Widget._childConstructors = [];
  456. $.Widget.prototype = {
  457. widgetName: "widget",
  458. widgetEventPrefix: "",
  459. defaultElement: "<div>",
  460. options: {
  461. disabled: false,
  462. // callbacks
  463. create: null
  464. },
  465. _createWidget: function( options, element ) {
  466. element = $( element || this.defaultElement || this )[ 0 ];
  467. this.element = $( element );
  468. this.uuid = uuid++;
  469. this.eventNamespace = "." + this.widgetName + this.uuid;
  470. this.options = $.widget.extend( {},
  471. this.options,
  472. this._getCreateOptions(),
  473. options );
  474. this.bindings = $();
  475. this.hoverable = $();
  476. this.focusable = $();
  477. if ( element !== this ) {
  478. $.data( element, this.widgetFullName, this );
  479. this._on( true, this.element, {
  480. remove: function( event ) {
  481. if ( event.target === element ) {
  482. this.destroy();
  483. }
  484. }
  485. });
  486. this.document = $( element.style ?
  487. // element within the document
  488. element.ownerDocument :
  489. // element is window or document
  490. element.document || element );
  491. this.window = $( this.document[0].defaultView || this.document[0].parentWindow );
  492. }
  493. this._create();
  494. this._trigger( "create", null, this._getCreateEventData() );
  495. this._init();
  496. },
  497. _getCreateOptions: $.noop,
  498. _getCreateEventData: $.noop,
  499. _create: $.noop,
  500. _init: $.noop,
  501. destroy: function() {
  502. this._destroy();
  503. // we can probably remove the unbind calls in 2.0
  504. // all event bindings should go through this._on()
  505. this.element
  506. .unbind( this.eventNamespace )
  507. // 1.9 BC for #7810
  508. // TODO remove dual storage
  509. .removeData( this.widgetName )
  510. .removeData( this.widgetFullName )
  511. // support: jquery <1.6.3
  512. // http://bugs.jquery.com/ticket/9413
  513. .removeData( $.camelCase( this.widgetFullName ) );
  514. this.widget()
  515. .unbind( this.eventNamespace )
  516. .removeAttr( "aria-disabled" )
  517. .removeClass(
  518. this.widgetFullName + "-disabled " +
  519. "ui-state-disabled" );
  520. // clean up events and states
  521. this.bindings.unbind( this.eventNamespace );
  522. this.hoverable.removeClass( "ui-state-hover" );
  523. this.focusable.removeClass( "ui-state-focus" );
  524. },
  525. _destroy: $.noop,
  526. widget: function() {
  527. return this.element;
  528. },
  529. option: function( key, value ) {
  530. var options = key,
  531. parts,
  532. curOption,
  533. i;
  534. if ( arguments.length === 0 ) {
  535. // don't return a reference to the internal hash
  536. return $.widget.extend( {}, this.options );
  537. }
  538. if ( typeof key === "string" ) {
  539. // handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
  540. options = {};
  541. parts = key.split( "." );
  542. key = parts.shift();
  543. if ( parts.length ) {
  544. curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
  545. for ( i = 0; i < parts.length - 1; i++ ) {
  546. curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
  547. curOption = curOption[ parts[ i ] ];
  548. }
  549. key = parts.pop();
  550. if ( value === undefined ) {
  551. return curOption[ key ] === undefined ? null : curOption[ key ];
  552. }
  553. curOption[ key ] = value;
  554. } else {
  555. if ( value === undefined ) {
  556. return this.options[ key ] === undefined ? null : this.options[ key ];
  557. }
  558. options[ key ] = value;
  559. }
  560. }
  561. this._setOptions( options );
  562. return this;
  563. },
  564. _setOptions: function( options ) {
  565. var key;
  566. for ( key in options ) {
  567. this._setOption( key, options[ key ] );
  568. }
  569. return this;
  570. },
  571. _setOption: function( key, value ) {
  572. this.options[ key ] = value;
  573. if ( key === "disabled" ) {
  574. this.widget()
  575. .toggleClass( this.widgetFullName + "-disabled ui-state-disabled", !!value )
  576. .attr( "aria-disabled", value );
  577. this.hoverable.removeClass( "ui-state-hover" );
  578. this.focusable.removeClass( "ui-state-focus" );
  579. }
  580. return this;
  581. },
  582. enable: function() {
  583. return this._setOption( "disabled", false );
  584. },
  585. disable: function() {
  586. return this._setOption( "disabled", true );
  587. },
  588. _on: function( suppressDisabledCheck, element, handlers ) {
  589. var delegateElement,
  590. instance = this;
  591. // no suppressDisabledCheck flag, shuffle arguments
  592. if ( typeof suppressDisabledCheck !== "boolean" ) {
  593. handlers = element;
  594. element = suppressDisabledCheck;
  595. suppressDisabledCheck = false;
  596. }
  597. // no element argument, shuffle and use this.element
  598. if ( !handlers ) {
  599. handlers = element;
  600. element = this.element;
  601. delegateElement = this.widget();
  602. } else {
  603. // accept selectors, DOM elements
  604. element = delegateElement = $( element );
  605. this.bindings = this.bindings.add( element );
  606. }
  607. $.each( handlers, function( event, handler ) {
  608. function handlerProxy() {
  609. // allow widgets to customize the disabled handling
  610. // - disabled as an array instead of boolean
  611. // - disabled class as method for disabling individual parts
  612. if ( !suppressDisabledCheck &&
  613. ( instance.options.disabled === true ||
  614. $( this ).hasClass( "ui-state-disabled" ) ) ) {
  615. return;
  616. }
  617. return ( typeof handler === "string" ? instance[ handler ] : handler )
  618. .apply( instance, arguments );
  619. }
  620. // copy the guid so direct unbinding works
  621. if ( typeof handler !== "string" ) {
  622. handlerProxy.guid = handler.guid =
  623. handler.guid || handlerProxy.guid || $.guid++;
  624. }
  625. var match = event.match( /^(\w+)\s*(.*)$/ ),
  626. eventName = match[1] + instance.eventNamespace,
  627. selector = match[2];
  628. if ( selector ) {
  629. delegateElement.delegate( selector, eventName, handlerProxy );
  630. } else {
  631. element.bind( eventName, handlerProxy );
  632. }
  633. });
  634. },
  635. _off: function( element, eventName ) {
  636. eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) + this.eventNamespace;
  637. element.unbind( eventName ).undelegate( eventName );
  638. },
  639. _delay: function( handler, delay ) {
  640. function handlerProxy() {
  641. return ( typeof handler === "string" ? instance[ handler ] : handler )
  642. .apply( instance, arguments );
  643. }
  644. var instance = this;
  645. return setTimeout( handlerProxy, delay || 0 );
  646. },
  647. _hoverable: function( element ) {
  648. this.hoverable = this.hoverable.add( element );
  649. this._on( element, {
  650. mouseenter: function( event ) {
  651. $( event.currentTarget ).addClass( "ui-state-hover" );
  652. },
  653. mouseleave: function( event ) {
  654. $( event.currentTarget ).removeClass( "ui-state-hover" );
  655. }
  656. });
  657. },
  658. _focusable: function( element ) {
  659. this.focusable = this.focusable.add( element );
  660. this._on( element, {
  661. focusin: function( event ) {
  662. $( event.currentTarget ).addClass( "ui-state-focus" );
  663. },
  664. focusout: function( event ) {
  665. $( event.currentTarget ).removeClass( "ui-state-focus" );
  666. }
  667. });
  668. },
  669. _trigger: function( type, event, data ) {
  670. var prop, orig,
  671. callback = this.options[ type ];
  672. data = data || {};
  673. event = $.Event( event );
  674. event.type = ( type === this.widgetEventPrefix ?
  675. type :
  676. this.widgetEventPrefix + type ).toLowerCase();
  677. // the original event may come from any element
  678. // so we need to reset the target on the new event
  679. event.target = this.element[ 0 ];
  680. // copy original event properties over to the new event
  681. orig = event.originalEvent;
  682. if ( orig ) {
  683. for ( prop in orig ) {
  684. if ( !( prop in event ) ) {
  685. event[ prop ] = orig[ prop ];
  686. }
  687. }
  688. }
  689. this.element.trigger( event, data );
  690. return !( $.isFunction( callback ) &&
  691. callback.apply( this.element[0], [ event ].concat( data ) ) === false ||
  692. event.isDefaultPrevented() );
  693. }
  694. };
  695. $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
  696. $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
  697. if ( typeof options === "string" ) {
  698. options = { effect: options };
  699. }
  700. var hasOptions,
  701. effectName = !options ?
  702. method :
  703. options === true || typeof options === "number" ?
  704. defaultEffect :
  705. options.effect || defaultEffect;
  706. options = options || {};
  707. if ( typeof options === "number" ) {
  708. options = { duration: options };
  709. }
  710. hasOptions = !$.isEmptyObject( options );
  711. options.complete = callback;
  712. if ( options.delay ) {
  713. element.delay( options.delay );
  714. }
  715. if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
  716. element[ method ]( options );
  717. } else if ( effectName !== method && element[ effectName ] ) {
  718. element[ effectName ]( options.duration, options.easing, callback );
  719. } else {
  720. element.queue(function( next ) {
  721. $( this )[ method ]();
  722. if ( callback ) {
  723. callback.call( element[ 0 ] );
  724. }
  725. next();
  726. });
  727. }
  728. };
  729. });
  730. })( jQuery );
  731. (function( $, undefined ) {
  732. var mouseHandled = false;
  733. $( document ).mouseup( function() {
  734. mouseHandled = false;
  735. });
  736. $.widget("ui.mouse", {
  737. version: "1.10.3",
  738. options: {
  739. cancel: "input,textarea,button,select,option",
  740. distance: 1,
  741. delay: 0
  742. },
  743. _mouseInit: function() {
  744. var that = this;
  745. this.element
  746. .bind("mousedown."+this.widgetName, function(event) {
  747. return that._mouseDown(event);
  748. })
  749. .bind("click."+this.widgetName, function(event) {
  750. if (true === $.data(event.target, that.widgetName + ".preventClickEvent")) {
  751. $.removeData(event.target, that.widgetName + ".preventClickEvent");
  752. event.stopImmediatePropagation();
  753. return false;
  754. }
  755. });
  756. this.started = false;
  757. },
  758. // TODO: make sure destroying one instance of mouse doesn't mess with
  759. // other instances of mouse
  760. _mouseDestroy: function() {
  761. this.element.unbind("."+this.widgetName);
  762. if ( this._mouseMoveDelegate ) {
  763. $(document)
  764. .unbind("mousemove."+this.widgetName, this._mouseMoveDelegate)
  765. .unbind("mouseup."+this.widgetName, this._mouseUpDelegate);
  766. }
  767. },
  768. _mouseDown: function(event) {
  769. // don't let more than one widget handle mouseStart
  770. if( mouseHandled ) { return; }
  771. // we may have missed mouseup (out of window)
  772. (this._mouseStarted && this._mouseUp(event));
  773. this._mouseDownEvent = event;
  774. var that = this,
  775. btnIsLeft = (event.which === 1),
  776. // event.target.nodeName works around a bug in IE 8 with
  777. // disabled inputs (#7620)
  778. elIsCancel = (typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false);
  779. if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
  780. return true;
  781. }
  782. this.mouseDelayMet = !this.options.delay;
  783. if (!this.mouseDelayMet) {
  784. this._mouseDelayTimer = setTimeout(function() {
  785. that.mouseDelayMet = true;
  786. }, this.options.delay);
  787. }
  788. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  789. this._mouseStarted = (this._mouseStart(event) !== false);
  790. if (!this._mouseStarted) {
  791. event.preventDefault();
  792. return true;
  793. }
  794. }
  795. // Click event may never have fired (Gecko & Opera)
  796. if (true === $.data(event.target, this.widgetName + ".preventClickEvent")) {
  797. $.removeData(event.target, this.widgetName + ".preventClickEvent");
  798. }
  799. // these delegates are required to keep context
  800. this._mouseMoveDelegate = function(event) {
  801. return that._mouseMove(event);
  802. };
  803. this._mouseUpDelegate = function(event) {
  804. return that._mouseUp(event);
  805. };
  806. $(document)
  807. .bind("mousemove."+this.widgetName, this._mouseMoveDelegate)
  808. .bind("mouseup."+this.widgetName, this._mouseUpDelegate);
  809. event.preventDefault();
  810. mouseHandled = true;
  811. return true;
  812. },
  813. _mouseMove: function(event) {
  814. // IE mouseup check - mouseup happened when mouse was out of window
  815. if ($.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && !event.button) {
  816. return this._mouseUp(event);
  817. }
  818. if (this._mouseStarted) {
  819. this._mouseDrag(event);
  820. return event.preventDefault();
  821. }
  822. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  823. this._mouseStarted =
  824. (this._mouseStart(this._mouseDownEvent, event) !== false);
  825. (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
  826. }
  827. return !this._mouseStarted;
  828. },
  829. _mouseUp: function(event) {
  830. $(document)
  831. .unbind("mousemove."+this.widgetName, this._mouseMoveDelegate)
  832. .unbind("mouseup."+this.widgetName, this._mouseUpDelegate);
  833. if (this._mouseStarted) {
  834. this._mouseStarted = false;
  835. if (event.target === this._mouseDownEvent.target) {
  836. $.data(event.target, this.widgetName + ".preventClickEvent", true);
  837. }
  838. this._mouseStop(event);
  839. }
  840. return false;
  841. },
  842. _mouseDistanceMet: function(event) {
  843. return (Math.max(
  844. Math.abs(this._mouseDownEvent.pageX - event.pageX),
  845. Math.abs(this._mouseDownEvent.pageY - event.pageY)
  846. ) >= this.options.distance
  847. );
  848. },
  849. _mouseDelayMet: function(/* event */) {
  850. return this.mouseDelayMet;
  851. },
  852. // These are placeholder methods, to be overriden by extending plugin
  853. _mouseStart: function(/* event */) {},
  854. _mouseDrag: function(/* event */) {},
  855. _mouseStop: function(/* event */) {},
  856. _mouseCapture: function(/* event */) { return true; }
  857. });
  858. })(jQuery);
  859. (function( $, undefined ) {
  860. $.widget("ui.draggable", $.ui.mouse, {
  861. version: "1.10.3",
  862. widgetEventPrefix: "drag",
  863. options: {
  864. addClasses: true,
  865. appendTo: "parent",
  866. axis: false,
  867. connectToSortable: false,
  868. containment: false,
  869. cursor: "auto",
  870. cursorAt: false,
  871. grid: false,
  872. handle: false,
  873. helper: "original",
  874. iframeFix: false,
  875. opacity: false,
  876. refreshPositions: false,
  877. revert: false,
  878. revertDuration: 500,
  879. scope: "default",
  880. scroll: true,
  881. scrollSensitivity: 20,
  882. scrollSpeed: 20,
  883. snap: false,
  884. snapMode: "both",
  885. snapTolerance: 20,
  886. stack: false,
  887. zIndex: false,
  888. // callbacks
  889. drag: null,
  890. start: null,
  891. stop: null
  892. },
  893. _create: function() {
  894. if (this.options.helper === "original" && !(/^(?:r|a|f)/).test(this.element.css("position"))) {
  895. this.element[0].style.position = "relative";
  896. }
  897. if (this.options.addClasses){
  898. this.element.addClass("ui-draggable");
  899. }
  900. if (this.options.disabled){
  901. this.element.addClass("ui-draggable-disabled");
  902. }
  903. this._mouseInit();
  904. },
  905. _destroy: function() {
  906. this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" );
  907. this._mouseDestroy();
  908. },
  909. _mouseCapture: function(event) {
  910. var o = this.options;
  911. // among others, prevent a drag on a resizable-handle
  912. if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) {
  913. return false;
  914. }
  915. //Quit if we're not on a valid handle
  916. this.handle = this._getHandle(event);
  917. if (!this.handle) {
  918. return false;
  919. }
  920. $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function() {
  921. $("<div class='ui-draggable-iframeFix' style='background: #fff;'></div>")
  922. .css({
  923. width: this.offsetWidth+"px", height: this.offsetHeight+"px",
  924. position: "absolute", opacity: "0.001", zIndex: 1000
  925. })
  926. .css($(this).offset())
  927. .appendTo("body");
  928. });
  929. return true;
  930. },
  931. _mouseStart: function(event) {
  932. var o = this.options;
  933. //Create and append the visible helper
  934. this.helper = this._createHelper(event);
  935. this.helper.addClass("ui-draggable-dragging");
  936. //Cache the helper size
  937. this._cacheHelperProportions();
  938. //If ddmanager is used for droppables, set the global draggable
  939. if($.ui.ddmanager) {
  940. $.ui.ddmanager.current = this;
  941. }
  942. /*
  943. * - Position generation -
  944. * This block generates everything position related - it's the core of draggables.
  945. */
  946. //Cache the margins of the original element
  947. this._cacheMargins();
  948. //Store the helper's css position
  949. this.cssPosition = this.helper.css( "position" );
  950. this.scrollParent = this.helper.scrollParent();
  951. this.offsetParent = this.helper.offsetParent();
  952. this.offsetParentCssPosition = this.offsetParent.css( "position" );
  953. //The element's absolute position on the page minus margins
  954. this.offset = this.positionAbs = this.element.offset();
  955. this.offset = {
  956. top: this.offset.top - this.margins.top,
  957. left: this.offset.left - this.margins.left
  958. };
  959. //Reset scroll cache
  960. this.offset.scroll = false;
  961. $.extend(this.offset, {
  962. click: { //Where the click happened, relative to the element
  963. left: event.pageX - this.offset.left,
  964. top: event.pageY - this.offset.top
  965. },
  966. parent: this._getParentOffset(),
  967. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  968. });
  969. //Generate the original position
  970. this.originalPosition = this.position = this._generatePosition(event);
  971. this.originalPageX = event.pageX;
  972. this.originalPageY = event.pageY;
  973. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  974. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  975. //Set a containment if given in the options
  976. this._setContainment();
  977. //Trigger event + callbacks
  978. if(this._trigger("start", event) === false) {
  979. this._clear();
  980. return false;
  981. }
  982. //Recache the helper size
  983. this._cacheHelperProportions();
  984. //Prepare the droppable offsets
  985. if ($.ui.ddmanager && !o.dropBehaviour) {
  986. $.ui.ddmanager.prepareOffsets(this, event);
  987. }
  988. this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  989. //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
  990. if ( $.ui.ddmanager ) {
  991. $.ui.ddmanager.dragStart(this, event);
  992. }
  993. return true;
  994. },
  995. _mouseDrag: function(event, noPropagation) {
  996. // reset any necessary cached properties (see #5009)
  997. if ( this.offsetParentCssPosition === "fixed" ) {
  998. this.offset.parent = this._getParentOffset();
  999. }
  1000. //Compute the helpers position
  1001. this.position = this._generatePosition(event);
  1002. this.positionAbs = this._convertPositionTo("absolute");
  1003. //Call plugins and callbacks and use the resulting position if something is returned
  1004. if (!noPropagation) {
  1005. var ui = this._uiHash();
  1006. if(this._trigger("drag", event, ui) === false) {
  1007. this._mouseUp({});
  1008. return false;
  1009. }
  1010. this.position = ui.position;
  1011. }
  1012. if(!this.options.axis || this.options.axis !== "y") {
  1013. this.helper[0].style.left = this.position.left+"px";
  1014. }
  1015. if(!this.options.axis || this.options.axis !== "x") {
  1016. this.helper[0].style.top = this.position.top+"px";
  1017. }
  1018. if($.ui.ddmanager) {
  1019. $.ui.ddmanager.drag(this, event);
  1020. }
  1021. return false;
  1022. },
  1023. _mouseStop: function(event) {
  1024. //If we are using droppables, inform the manager about the drop
  1025. var that = this,
  1026. dropped = false;
  1027. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  1028. dropped = $.ui.ddmanager.drop(this, event);
  1029. }
  1030. //if a drop comes from outside (a sortable)
  1031. if(this.dropped) {
  1032. dropped = this.dropped;
  1033. this.dropped = false;
  1034. }
  1035. //if the original element is no longer in the DOM don't bother to continue (see #8269)
  1036. if ( this.options.helper === "original" && !$.contains( this.element[ 0 ].ownerDocument, this.element[ 0 ] ) ) {
  1037. return false;
  1038. }
  1039. 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))) {
  1040. $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
  1041. if(that._trigger("stop", event) !== false) {
  1042. that._clear();
  1043. }
  1044. });
  1045. } else {
  1046. if(this._trigger("stop", event) !== false) {
  1047. this._clear();
  1048. }
  1049. }
  1050. return false;
  1051. },
  1052. _mouseUp: function(event) {
  1053. //Remove frame helpers
  1054. $("div.ui-draggable-iframeFix").each(function() {
  1055. this.parentNode.removeChild(this);
  1056. });
  1057. //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
  1058. if( $.ui.ddmanager ) {
  1059. $.ui.ddmanager.dragStop(this, event);
  1060. }
  1061. return $.ui.mouse.prototype._mouseUp.call(this, event);
  1062. },
  1063. cancel: function() {
  1064. if(this.helper.is(".ui-draggable-dragging")) {
  1065. this._mouseUp({});
  1066. } else {
  1067. this._clear();
  1068. }
  1069. return this;
  1070. },
  1071. _getHandle: function(event) {
  1072. return this.options.handle ?
  1073. !!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
  1074. true;
  1075. },
  1076. _createHelper: function(event) {
  1077. var o = this.options,
  1078. helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper === "clone" ? this.element.clone().removeAttr("id") : this.element);
  1079. if(!helper.parents("body").length) {
  1080. helper.appendTo((o.appendTo === "parent" ? this.element[0].parentNode : o.appendTo));
  1081. }
  1082. if(helper[0] !== this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) {
  1083. helper.css("position", "absolute");
  1084. }
  1085. return helper;
  1086. },
  1087. _adjustOffsetFromHelper: function(obj) {
  1088. if (typeof obj === "string") {
  1089. obj = obj.split(" ");
  1090. }
  1091. if ($.isArray(obj)) {
  1092. obj = {left: +obj[0], top: +obj[1] || 0};
  1093. }
  1094. if ("left" in obj) {
  1095. this.offset.click.left = obj.left + this.margins.left;
  1096. }
  1097. if ("right" in obj) {
  1098. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  1099. }
  1100. if ("top" in obj) {
  1101. this.offset.click.top = obj.top + this.margins.top;
  1102. }
  1103. if ("bottom" in obj) {
  1104. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  1105. }
  1106. },
  1107. _getParentOffset: function() {
  1108. //Get the offsetParent and cache its position
  1109. var po = this.offsetParent.offset();
  1110. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  1111. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  1112. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  1113. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  1114. if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  1115. po.left += this.scrollParent.scrollLeft();
  1116. po.top += this.scrollParent.scrollTop();
  1117. }
  1118. //This needs to be actually done for all browsers, since pageX/pageY includes this information
  1119. //Ugly IE fix
  1120. if((this.offsetParent[0] === document.body) ||
  1121. (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
  1122. po = { top: 0, left: 0 };
  1123. }
  1124. return {
  1125. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  1126. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  1127. };
  1128. },
  1129. _getRelativeOffset: function() {
  1130. if(this.cssPosition === "relative") {
  1131. var p = this.element.position();
  1132. return {
  1133. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  1134. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  1135. };
  1136. } else {
  1137. return { top: 0, left: 0 };
  1138. }
  1139. },
  1140. _cacheMargins: function() {
  1141. this.margins = {
  1142. left: (parseInt(this.element.css("marginLeft"),10) || 0),
  1143. top: (parseInt(this.element.css("marginTop"),10) || 0),
  1144. right: (parseInt(this.element.css("marginRight"),10) || 0),
  1145. bottom: (parseInt(this.element.css("marginBottom"),10) || 0)
  1146. };
  1147. },
  1148. _cacheHelperProportions: function() {
  1149. this.helperProportions = {
  1150. width: this.helper.outerWidth(),
  1151. height: this.helper.outerHeight()
  1152. };
  1153. },
  1154. _setContainment: function() {
  1155. var over, c, ce,
  1156. o = this.options;
  1157. if ( !o.containment ) {
  1158. this.containment = null;
  1159. return;
  1160. }
  1161. if ( o.containment === "window" ) {
  1162. this.containment = [
  1163. $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
  1164. $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top,
  1165. $( window ).scrollLeft() + $( window ).width() - this.helperProportions.width - this.margins.left,
  1166. $( window ).scrollTop() + ( $( window ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
  1167. ];
  1168. return;
  1169. }
  1170. if ( o.containment === "document") {
  1171. this.containment = [
  1172. 0,
  1173. 0,
  1174. $( document ).width() - this.helperProportions.width - this.margins.left,
  1175. ( $( document ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
  1176. ];
  1177. return;
  1178. }
  1179. if ( o.containment.constructor === Array ) {
  1180. this.containment = o.containment;
  1181. return;
  1182. }
  1183. if ( o.containment === "parent" ) {
  1184. o.containment = this.helper[ 0 ].parentNode;
  1185. }
  1186. c = $( o.containment );
  1187. ce = c[ 0 ];
  1188. if( !ce ) {
  1189. return;
  1190. }
  1191. over = c.css( "overflow" ) !== "hidden";
  1192. this.containment = [
  1193. ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ),
  1194. ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ) ,
  1195. ( over ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) - ( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) - ( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) - this.helperProportions.width - this.margins.left - this.margins.right,
  1196. ( over ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) - ( parseInt( c.css( "borderBottomWidth" ), 10 ) || 0 ) - ( parseInt( c.css( "paddingBottom" ), 10 ) || 0 ) - this.helperProportions.height - this.margins.top - this.margins.bottom
  1197. ];
  1198. this.relative_container = c;
  1199. },
  1200. _convertPositionTo: function(d, pos) {
  1201. if(!pos) {
  1202. pos = this.position;
  1203. }
  1204. var mod = d === "absolute" ? 1 : -1,
  1205. scroll = this.cssPosition === "absolute" && !( this.scrollParent[ 0 ] !== document && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? this.offsetParent : this.scrollParent;
  1206. //Cache the scroll
  1207. if (!this.offset.scroll) {
  1208. this.offset.scroll = {top : scroll.scrollTop(), left : scroll.scrollLeft()};
  1209. }
  1210. return {
  1211. top: (
  1212. pos.top + // The absolute mouse position
  1213. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  1214. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  1215. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : this.offset.scroll.top ) * mod )
  1216. ),
  1217. left: (
  1218. pos.left + // The absolute mouse position
  1219. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  1220. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  1221. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : this.offset.scroll.left ) * mod )
  1222. )
  1223. };
  1224. },
  1225. _generatePosition: function(event) {
  1226. var containment, co, top, left,
  1227. o = this.options,
  1228. scroll = this.cssPosition === "absolute" && !( this.scrollParent[ 0 ] !== document && $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ? this.offsetParent : this.scrollParent,
  1229. pageX = event.pageX,
  1230. pageY = event.pageY;
  1231. //Cache the scroll
  1232. if (!this.offset.scroll) {
  1233. this.offset.scroll = {top : scroll.scrollTop(), left : scroll.scrollLeft()};
  1234. }
  1235. /*
  1236. * - Position constraining -
  1237. * Constrain the position to a mix of grid, containment.
  1238. */
  1239. // If we are not dragging yet, we won't check for options
  1240. if ( this.originalPosition ) {
  1241. if ( this.containment ) {
  1242. if ( this.relative_container ){
  1243. co = this.relative_container.offset();
  1244. containment = [
  1245. this.containment[ 0 ] + co.left,
  1246. this.containment[ 1 ] + co.top,
  1247. this.containment[ 2 ] + co.left,
  1248. this.containment[ 3 ] + co.top
  1249. ];
  1250. }
  1251. else {
  1252. containment = this.containment;
  1253. }
  1254. if(event.pageX - this.offset.click.left < containment[0]) {
  1255. pageX = containment[0] + this.offset.click.left;
  1256. }
  1257. if(event.pageY - this.offset.click.top < containment[1]) {
  1258. pageY = containment[1] + this.offset.click.top;
  1259. }
  1260. if(event.pageX - this.offset.click.left > containment[2]) {
  1261. pageX = containment[2] + this.offset.click.left;
  1262. }
  1263. if(event.pageY - this.offset.click.top > containment[3]) {
  1264. pageY = containment[3] + this.offset.click.top;
  1265. }
  1266. }
  1267. if(o.grid) {
  1268. //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
  1269. top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
  1270. 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;
  1271. left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
  1272. 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;
  1273. }
  1274. }
  1275. return {
  1276. top: (
  1277. pageY - // The absolute mouse position
  1278. this.offset.click.top - // Click offset (relative to the element)
  1279. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  1280. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  1281. ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : this.offset.scroll.top )
  1282. ),
  1283. left: (
  1284. pageX - // The absolute mouse position
  1285. this.offset.click.left - // Click offset (relative to the element)
  1286. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  1287. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  1288. ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : this.offset.scroll.left )
  1289. )
  1290. };
  1291. },
  1292. _clear: function() {
  1293. this.helper.removeClass("ui-draggable-dragging");
  1294. if(this.helper[0] !== this.element[0] && !this.cancelHelperRemoval) {
  1295. this.helper.remove();
  1296. }
  1297. this.helper = null;
  1298. this.cancelHelperRemoval = false;
  1299. },
  1300. // From now on bulk stuff - mainly helpers
  1301. _trigger: function(type, event, ui) {
  1302. ui = ui || this._uiHash();
  1303. $.ui.plugin.call(this, type, [event, ui]);
  1304. //The absolute position has to be recalculated after plugins
  1305. if(type === "drag") {
  1306. this.positionAbs = this._convertPositionTo("absolute");
  1307. }
  1308. return $.Widget.prototype._trigger.call(this, type, event, ui);
  1309. },
  1310. plugins: {},
  1311. _uiHash: function() {
  1312. return {
  1313. helper: this.helper,
  1314. position: this.position,
  1315. originalPosition: this.originalPosition,
  1316. offset: this.positionAbs
  1317. };
  1318. }
  1319. });
  1320. $.ui.plugin.add("draggable", "connectToSortable", {
  1321. start: function(event, ui) {
  1322. var inst = $(this).data("ui-draggable"), o = inst.options,
  1323. uiSortable = $.extend({}, ui, { item: inst.element });
  1324. inst.sortables = [];
  1325. $(o.connectToSortable).each(function() {
  1326. var sortable = $.data(this, "ui-sortable");
  1327. if (sortable && !sortable.options.disabled) {
  1328. inst.sortables.push({
  1329. instance: sortable,
  1330. shouldRevert: sortable.options.revert
  1331. });
  1332. 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).
  1333. sortable._trigger("activate", event, uiSortable);
  1334. }
  1335. });
  1336. },
  1337. stop: function(event, ui) {
  1338. //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
  1339. var inst = $(this).data("ui-draggable"),
  1340. uiSortable = $.extend({}, ui, { item: inst.element });
  1341. $.each(inst.sortables, function() {
  1342. if(this.instance.isOver) {
  1343. this.instance.isOver = 0;
  1344. inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance
  1345. this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
  1346. //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: "valid/invalid"
  1347. if(this.shouldRevert) {
  1348. this.instance.options.revert = this.shouldRevert;
  1349. }
  1350. //Trigger the stop of the sortable
  1351. this.instance._mouseStop(event);
  1352. this.instance.options.helper = this.instance.options._helper;
  1353. //If the helper has been the original item, restore properties in the sortable
  1354. if(inst.options.helper === "original") {
  1355. this.instance.currentItem.css({ top: "auto", left: "auto" });
  1356. }
  1357. } else {
  1358. this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance
  1359. this.instance._trigger("deactivate", event, uiSortable);
  1360. }
  1361. });
  1362. },
  1363. drag: function(event, ui) {
  1364. var inst = $(this).data("ui-draggable"), that = this;
  1365. $.each(inst.sortables, function() {
  1366. var innermostIntersecting = false,
  1367. thisSortable = this;
  1368. //Copy over some variables to allow calling the sortable's native _intersectsWith
  1369. this.instance.positionAbs = inst.positionAbs;
  1370. this.instance.helperProportions = inst.helperProportions;
  1371. this.instance.offset.click = inst.offset.click;
  1372. if(this.instance._intersectsWith(this.instance.containerCache)) {
  1373. innermostIntersecting = true;
  1374. $.each(inst.sortables, function () {
  1375. this.instance.positionAbs = inst.positionAbs;
  1376. this.instance.helperProportions = inst.helperProportions;
  1377. this.instance.offset.click = inst.offset.click;
  1378. if (this !== thisSortable &&
  1379. this.instance._intersectsWith(this.instance.containerCache) &&
  1380. $.contains(thisSortable.instance.element[0], this.instance.element[0])
  1381. ) {
  1382. innermostIntersecting = false;
  1383. }
  1384. return innermostIntersecting;
  1385. });
  1386. }
  1387. if(innermostIntersecting) {
  1388. //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once
  1389. if(!this.instance.isOver) {
  1390. this.instance.isOver = 1;
  1391. //Now we fake the start of dragging for the sortable instance,
  1392. //by cloning the list group item, appending it to the sortable and using it as inst.currentItem
  1393. //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)
  1394. this.instance.currentItem = $(that).clone().removeAttr("id").appendTo(this.instance.element).data("ui-sortable-item", true);
  1395. this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it
  1396. this.instance.options.helper = function() { return ui.helper[0]; };
  1397. event.target = this.instance.currentItem[0];
  1398. this.instance._mouseCapture(event, true);
  1399. this.instance._mouseStart(event, true, true);
  1400. //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes
  1401. this.instance.offset.click.top = inst.offset.click.top;
  1402. this.instance.offset.click.left = inst.offset.click.left;
  1403. this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left;
  1404. this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top;
  1405. inst._trigger("toSortable", event);
  1406. inst.dropped = this.instance.element; //draggable revert needs that
  1407. //hack so receive/update callbacks work (mostly)
  1408. inst.currentItem = inst.element;
  1409. this.instance.fromOutside = inst;
  1410. }
  1411. //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
  1412. if(this.instance.currentItem) {
  1413. this.instance._mouseDrag(event);
  1414. }
  1415. } else {
  1416. //If it doesn't intersect with the sortable, and it intersected before,
  1417. //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval
  1418. if(this.instance.isOver) {
  1419. this.instance.isOver = 0;
  1420. this.instance.cancelHelperRemoval = true;
  1421. //Prevent reverting on this forced stop
  1422. this.instance.options.revert = false;
  1423. // The out event needs to be triggered independently
  1424. this.instance._trigger("out", event, this.instance._uiHash(this.instance));
  1425. this.instance._mouseStop(event, true);
  1426. this.instance.options.helper = this.instance.options._helper;
  1427. //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size
  1428. this.instance.currentItem.remove();
  1429. if(this.instance.placeholder) {
  1430. this.instance.placeholder.remove();
  1431. }
  1432. inst._trigger("fromSortable", event);
  1433. inst.dropped = false; //draggable revert needs that
  1434. }
  1435. }
  1436. });
  1437. }
  1438. });
  1439. $.ui.plugin.add("draggable", "cursor", {
  1440. start: function() {
  1441. var t = $("body"), o = $(this).data("ui-draggable").options;
  1442. if (t.css("cursor")) {
  1443. o._cursor = t.css("cursor");
  1444. }
  1445. t.css("cursor", o.cursor);
  1446. },
  1447. stop: function() {
  1448. var o = $(this).data("ui-draggable").options;
  1449. if (o._cursor) {
  1450. $("body").css("cursor", o._cursor);
  1451. }
  1452. }
  1453. });
  1454. $.ui.plugin.add("draggable", "opacity", {
  1455. start: function(event, ui) {
  1456. var t = $(ui.helper), o = $(this).data("ui-draggable").options;
  1457. if(t.css("opacity")) {
  1458. o._opacity = t.css("opacity");
  1459. }
  1460. t.css("opacity", o.opacity);
  1461. },
  1462. stop: function(event, ui) {
  1463. var o = $(this).data("ui-draggable").options;
  1464. if(o._opacity) {
  1465. $(ui.helper).css("opacity", o._opacity);
  1466. }
  1467. }
  1468. });
  1469. $.ui.plugin.add("draggable", "scroll", {
  1470. start: function() {
  1471. var i = $(this).data("ui-draggable");
  1472. if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") {
  1473. i.overflowOffset = i.scrollParent.offset();
  1474. }
  1475. },
  1476. drag: function( event ) {
  1477. var i = $(this).data("ui-draggable"), o = i.options, scrolled = false;
  1478. if(i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") {
  1479. if(!o.axis || o.axis !== "x") {
  1480. if((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
  1481. i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed;
  1482. } else if(event.pageY - i.overflowOffset.top < o.scrollSensitivity) {
  1483. i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed;
  1484. }
  1485. }
  1486. if(!o.axis || o.axis !== "y") {
  1487. if((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
  1488. i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed;
  1489. } else if(event.pageX - i.overflowOffset.left < o.scrollSensitivity) {
  1490. i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed;
  1491. }
  1492. }
  1493. } else {
  1494. if(!o.axis || o.axis !== "x") {
  1495. if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
  1496. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  1497. } else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
  1498. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  1499. }
  1500. }
  1501. if(!o.axis || o.axis !== "y") {
  1502. if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
  1503. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  1504. } else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
  1505. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  1506. }
  1507. }
  1508. }
  1509. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  1510. $.ui.ddmanager.prepareOffsets(i, event);
  1511. }
  1512. }
  1513. });
  1514. $.ui.plugin.add("draggable", "snap", {
  1515. start: function() {
  1516. var i = $(this).data("ui-draggable"),
  1517. o = i.options;
  1518. i.snapElements = [];
  1519. $(o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap).each(function() {
  1520. var $t = $(this),
  1521. $o = $t.offset();
  1522. if(this !== i.element[0]) {
  1523. i.snapElements.push({
  1524. item: this,
  1525. width: $t.outerWidth(), height: $t.outerHeight(),
  1526. top: $o.top, left: $o.left
  1527. });
  1528. }
  1529. });
  1530. },
  1531. drag: function(event, ui) {
  1532. var ts, bs, ls, rs, l, r, t, b, i, first,
  1533. inst = $(this).data("ui-draggable"),
  1534. o = inst.options,
  1535. d = o.snapTolerance,
  1536. x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
  1537. y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
  1538. for (i = inst.snapElements.length - 1; i >= 0; i--){
  1539. l = inst.snapElements[i].left;
  1540. r = l + inst.snapElements[i].width;
  1541. t = inst.snapElements[i].top;
  1542. b = t + inst.snapElements[i].height;
  1543. if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains( inst.snapElements[ i ].item.ownerDocument, inst.snapElements[ i ].item ) ) {
  1544. if(inst.snapElements[i].snapping) {
  1545. (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  1546. }
  1547. inst.snapElements[i].snapping = false;
  1548. continue;
  1549. }
  1550. if(o.snapMode !== "inner") {
  1551. ts = Math.abs(t - y2) <= d;
  1552. bs = Math.abs(b - y1) <= d;
  1553. ls = Math.abs(l - x2) <= d;
  1554. rs = Math.abs(r - x1) <= d;
  1555. if(ts) {
  1556. ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
  1557. }
  1558. if(bs) {
  1559. ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top;
  1560. }
  1561. if(ls) {
  1562. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left;
  1563. }
  1564. if(rs) {
  1565. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left;
  1566. }
  1567. }
  1568. first = (ts || bs || ls || rs);
  1569. if(o.snapMode !== "outer") {
  1570. ts = Math.abs(t - y1) <= d;
  1571. bs = Math.abs(b - y2) <= d;
  1572. ls = Math.abs(l - x1) <= d;
  1573. rs = Math.abs(r - x2) <= d;
  1574. if(ts) {
  1575. ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top;
  1576. }
  1577. if(bs) {
  1578. ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
  1579. }
  1580. if(ls) {
  1581. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left;
  1582. }
  1583. if(rs) {
  1584. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left;
  1585. }
  1586. }
  1587. if(!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) {
  1588. (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  1589. }
  1590. inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
  1591. }
  1592. }
  1593. });
  1594. $.ui.plugin.add("draggable", "stack", {
  1595. start: function() {
  1596. var min,
  1597. o = this.data("ui-draggable").options,
  1598. group = $.makeArray($(o.stack)).sort(function(a,b) {
  1599. return (parseInt($(a).css("zIndex"),10) || 0) - (parseInt($(b).css("zIndex"),10) || 0);
  1600. });
  1601. if (!group.length) { return; }
  1602. min = parseInt($(group[0]).css("zIndex"), 10) || 0;
  1603. $(group).each(function(i) {
  1604. $(this).css("zIndex", min + i);
  1605. });
  1606. this.css("zIndex", (min + group.length));
  1607. }
  1608. });
  1609. $.ui.plugin.add("draggable", "zIndex", {
  1610. start: function(event, ui) {
  1611. var t = $(ui.helper), o = $(this).data("ui-draggable").options;
  1612. if(t.css("zIndex")) {
  1613. o._zIndex = t.css("zIndex");
  1614. }
  1615. t.css("zIndex", o.zIndex);
  1616. },
  1617. stop: function(event, ui) {
  1618. var o = $(this).data("ui-draggable").options;
  1619. if(o._zIndex) {
  1620. $(ui.helper).css("zIndex", o._zIndex);
  1621. }
  1622. }
  1623. });
  1624. })(jQuery);
  1625. (function( $, undefined ) {
  1626. function isOverAxis( x, reference, size ) {
  1627. return ( x > reference ) && ( x < ( reference + size ) );
  1628. }
  1629. $.widget("ui.droppable", {
  1630. version: "1.10.3",
  1631. widgetEventPrefix: "drop",
  1632. options: {
  1633. accept: "*",
  1634. activeClass: false,
  1635. addClasses: true,
  1636. greedy: false,
  1637. hoverClass: false,
  1638. scope: "default",
  1639. tolerance: "intersect",
  1640. // callbacks
  1641. activate: null,
  1642. deactivate: null,
  1643. drop: null,
  1644. out: null,
  1645. over: null
  1646. },
  1647. _create: function() {
  1648. var o = this.options,
  1649. accept = o.accept;
  1650. this.isover = false;
  1651. this.isout = true;
  1652. this.accept = $.isFunction(accept) ? accept : function(d) {
  1653. return d.is(accept);
  1654. };
  1655. //Store the droppable's proportions
  1656. this.proportions = { width: this.element[0].offsetWidth, height: this.element[0].offsetHeight };
  1657. // Add the reference and positions to the manager
  1658. $.ui.ddmanager.droppables[o.scope] = $.ui.ddmanager.droppables[o.scope] || [];
  1659. $.ui.ddmanager.droppables[o.scope].push(this);
  1660. (o.addClasses && this.element.addClass("ui-droppable"));
  1661. },
  1662. _destroy: function() {
  1663. var i = 0,
  1664. drop = $.ui.ddmanager.droppables[this.options.scope];
  1665. for ( ; i < drop.length; i++ ) {
  1666. if ( drop[i] === this ) {
  1667. drop.splice(i, 1);
  1668. }
  1669. }
  1670. this.element.removeClass("ui-droppable ui-droppable-disabled");
  1671. },
  1672. _setOption: function(key, value) {
  1673. if(key === "accept") {
  1674. this.accept = $.isFunction(value) ? value : function(d) {
  1675. return d.is(value);
  1676. };
  1677. }
  1678. $.Widget.prototype._setOption.apply(this, arguments);
  1679. },
  1680. _activate: function(event) {
  1681. var draggable = $.ui.ddmanager.current;
  1682. if(this.options.activeClass) {
  1683. this.element.addClass(this.options.activeClass);
  1684. }
  1685. if(draggable){
  1686. this._trigger("activate", event, this.ui(draggable));
  1687. }
  1688. },
  1689. _deactivate: function(event) {
  1690. var draggable = $.ui.ddmanager.current;
  1691. if(this.options.activeClass) {
  1692. this.element.removeClass(this.options.activeClass);
  1693. }
  1694. if(draggable){
  1695. this._trigger("deactivate", event, this.ui(draggable));
  1696. }
  1697. },
  1698. _over: function(event) {
  1699. var draggable = $.ui.ddmanager.current;
  1700. // Bail if draggable and droppable are same element
  1701. if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
  1702. return;
  1703. }
  1704. if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  1705. if(this.options.hoverClass) {
  1706. this.element.addClass(this.options.hoverClass);
  1707. }
  1708. this._trigger("over", event, this.ui(draggable));
  1709. }
  1710. },
  1711. _out: function(event) {
  1712. var draggable = $.ui.ddmanager.current;
  1713. // Bail if draggable and droppable are same element
  1714. if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
  1715. return;
  1716. }
  1717. if (this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  1718. if(this.options.hoverClass) {
  1719. this.element.removeClass(this.options.hoverClass);
  1720. }
  1721. this._trigger("out", event, this.ui(draggable));
  1722. }
  1723. },
  1724. _drop: function(event,custom) {
  1725. var draggable = custom || $.ui.ddmanager.current,
  1726. childrenIntersection = false;
  1727. // Bail if draggable and droppable are same element
  1728. if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
  1729. return false;
  1730. }
  1731. this.element.find(":data(ui-droppable)").not(".ui-draggable-dragging").each(function() {
  1732. var inst = $.data(this, "ui-droppable");
  1733. if(
  1734. inst.options.greedy &&
  1735. !inst.options.disabled &&
  1736. inst.options.scope === draggable.options.scope &&
  1737. inst.accept.call(inst.element[0], (draggable.currentItem || draggable.element)) &&
  1738. $.ui.intersect(draggable, $.extend(inst, { offset: inst.element.offset() }), inst.options.tolerance)
  1739. ) { childrenIntersection = true; return false; }
  1740. });
  1741. if(childrenIntersection) {
  1742. return false;
  1743. }
  1744. if(this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  1745. if(this.options.activeClass) {
  1746. this.element.removeClass(this.options.activeClass);
  1747. }
  1748. if(this.options.hoverClass) {
  1749. this.element.removeClass(this.options.hoverClass);
  1750. }
  1751. this._trigger("drop", event, this.ui(draggable));
  1752. return this.element;
  1753. }
  1754. return false;
  1755. },
  1756. ui: function(c) {
  1757. return {
  1758. draggable: (c.currentItem || c.element),
  1759. helper: c.helper,
  1760. position: c.position,
  1761. offset: c.positionAbs
  1762. };
  1763. }
  1764. });
  1765. $.ui.intersect = function(draggable, droppable, toleranceMode) {
  1766. if (!droppable.offset) {
  1767. return false;
  1768. }
  1769. var draggableLeft, draggableTop,
  1770. x1 = (draggable.positionAbs || draggable.position.absolute).left, x2 = x1 + draggable.helperProportions.width,
  1771. y1 = (draggable.positionAbs || draggable.position.absolute).top, y2 = y1 + draggable.helperProportions.height,
  1772. l = droppable.offset.left, r = l + droppable.proportions.width,
  1773. t = droppable.offset.top, b = t + droppable.proportions.height;
  1774. switch (toleranceMode) {
  1775. case "fit":
  1776. return (l <= x1 && x2 <= r && t <= y1 && y2 <= b);
  1777. case "intersect":
  1778. return (l < x1 + (draggable.helperProportions.width / 2) && // Right Half
  1779. x2 - (draggable.helperProportions.width / 2) < r && // Left Half
  1780. t < y1 + (draggable.helperProportions.height / 2) && // Bottom Half
  1781. y2 - (draggable.helperProportions.height / 2) < b ); // Top Half
  1782. case "pointer":
  1783. draggableLeft = ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left);
  1784. draggableTop = ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top);
  1785. return isOverAxis( draggableTop, t, droppable.proportions.height ) && isOverAxis( draggableLeft, l, droppable.proportions.width );
  1786. case "touch":
  1787. return (
  1788. (y1 >= t && y1 <= b) || // Top edge touching
  1789. (y2 >= t && y2 <= b) || // Bottom edge touching
  1790. (y1 < t && y2 > b) // Surrounded vertically
  1791. ) && (
  1792. (x1 >= l && x1 <= r) || // Left edge touching
  1793. (x2 >= l && x2 <= r) || // Right edge touching
  1794. (x1 < l && x2 > r) // Surrounded horizontally
  1795. );
  1796. default:
  1797. return false;
  1798. }
  1799. };
  1800. /*
  1801. This manager tracks offsets of draggables and droppables
  1802. */
  1803. $.ui.ddmanager = {
  1804. current: null,
  1805. droppables: { "default": [] },
  1806. prepareOffsets: function(t, event) {
  1807. var i, j,
  1808. m = $.ui.ddmanager.droppables[t.options.scope] || [],
  1809. type = event ? event.type : null, // workaround for #2317
  1810. list = (t.currentItem || t.element).find(":data(ui-droppable)").addBack();
  1811. droppablesLoop: for (i = 0; i < m.length; i++) {
  1812. //No disabled and non-accepted
  1813. if(m[i].options.disabled || (t && !m[i].accept.call(m[i].element[0],(t.currentItem || t.element)))) {
  1814. continue;
  1815. }
  1816. // Filter out elements in the current dragged item
  1817. for (j=0; j < list.length; j++) {
  1818. if(list[j] === m[i].element[0]) {
  1819. m[i].proportions.height = 0;
  1820. continue droppablesLoop;
  1821. }
  1822. }
  1823. m[i].visible = m[i].element.css("display") !== "none";
  1824. if(!m[i].visible) {
  1825. continue;
  1826. }
  1827. //Activate the droppable if used directly from draggables
  1828. if(type === "mousedown") {
  1829. m[i]._activate.call(m[i], event);
  1830. }
  1831. m[i].offset = m[i].element.offset();
  1832. m[i].proportions = { width: m[i].element[0].offsetWidth, height: m[i].element[0].offsetHeight };
  1833. }
  1834. },
  1835. drop: function(draggable, event) {
  1836. var dropped = false;
  1837. // Create a copy of the droppables in case the list changes during the drop (#9116)
  1838. $.each(($.ui.ddmanager.droppables[draggable.options.scope] || []).slice(), function() {
  1839. if(!this.options) {
  1840. return;
  1841. }
  1842. if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance)) {
  1843. dropped = this._drop.call(this, event) || dropped;
  1844. }
  1845. if (!this.options.disabled && this.visible && this.accept.call(this.element[0],(draggable.currentItem || draggable.element))) {
  1846. this.isout = true;
  1847. this.isover = false;
  1848. this._deactivate.call(this, event);
  1849. }
  1850. });
  1851. return dropped;
  1852. },
  1853. dragStart: function( draggable, event ) {
  1854. //Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003)
  1855. draggable.element.parentsUntil( "body" ).bind( "scroll.droppable", function() {
  1856. if( !draggable.options.refreshPositions ) {
  1857. $.ui.ddmanager.prepareOffsets( draggable, event );
  1858. }
  1859. });
  1860. },
  1861. drag: function(draggable, event) {
  1862. //If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
  1863. if(draggable.options.refreshPositions) {
  1864. $.ui.ddmanager.prepareOffsets(draggable, event);
  1865. }
  1866. //Run through all droppables and check their positions based on specific tolerance options
  1867. $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function() {
  1868. if(this.options.disabled || this.greedyChild || !this.visible) {
  1869. return;
  1870. }
  1871. var parentInstance, scope, parent,
  1872. intersects = $.ui.intersect(draggable, this, this.options.tolerance),
  1873. c = !intersects && this.isover ? "isout" : (intersects && !this.isover ? "isover" : null);
  1874. if(!c) {
  1875. return;
  1876. }
  1877. if (this.options.greedy) {
  1878. // find droppable parents with same scope
  1879. scope = this.options.scope;
  1880. parent = this.element.parents(":data(ui-droppable)").filter(function () {
  1881. return $.data(this, "ui-droppable").options.scope === scope;
  1882. });
  1883. if (parent.length) {
  1884. parentInstance = $.data(parent[0], "ui-droppable");
  1885. parentInstance.greedyChild = (c === "isover");
  1886. }
  1887. }
  1888. // we just moved into a greedy child
  1889. if (parentInstance && c === "isover") {
  1890. parentInstance.isover = false;
  1891. parentInstance.isout = true;
  1892. parentInstance._out.call(parentInstance, event);
  1893. }
  1894. this[c] = true;
  1895. this[c === "isout" ? "isover" : "isout"] = false;
  1896. this[c === "isover" ? "_over" : "_out"].call(this, event);
  1897. // we just moved out of a greedy child
  1898. if (parentInstance && c === "isout") {
  1899. parentInstance.isout = false;
  1900. parentInstance.isover = true;
  1901. parentInstance._over.call(parentInstance, event);
  1902. }
  1903. });
  1904. },
  1905. dragStop: function( draggable, event ) {
  1906. draggable.element.parentsUntil( "body" ).unbind( "scroll.droppable" );
  1907. //Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003)
  1908. if( !draggable.options.refreshPositions ) {
  1909. $.ui.ddmanager.prepareOffsets( draggable, event );
  1910. }
  1911. }
  1912. };
  1913. })(jQuery);
  1914. (function( $, undefined ) {
  1915. function num(v) {
  1916. return parseInt(v, 10) || 0;
  1917. }
  1918. function isNumber(value) {
  1919. return !isNaN(parseInt(value, 10));
  1920. }
  1921. $.widget("ui.resizable", $.ui.mouse, {
  1922. version: "1.10.3",
  1923. widgetEventPrefix: "resize",
  1924. options: {
  1925. alsoResize: false,
  1926. animate: false,
  1927. animateDuration: "slow",
  1928. animateEasing: "swing",
  1929. aspectRatio: false,
  1930. autoHide: false,
  1931. containment: false,
  1932. ghost: false,
  1933. grid: false,
  1934. handles: "e,s,se",
  1935. helper: false,
  1936. maxHeight: null,
  1937. maxWidth: null,
  1938. minHeight: 10,
  1939. minWidth: 10,
  1940. // See #7960
  1941. zIndex: 90,
  1942. // callbacks
  1943. resize: null,
  1944. start: null,
  1945. stop: null
  1946. },
  1947. _create: function() {
  1948. var n, i, handle, axis, hname,
  1949. that = this,
  1950. o = this.options;
  1951. this.element.addClass("ui-resizable");
  1952. $.extend(this, {
  1953. _aspectRatio: !!(o.aspectRatio),
  1954. aspectRatio: o.aspectRatio,
  1955. originalElement: this.element,
  1956. _proportionallyResizeElements: [],
  1957. _helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
  1958. });
  1959. //Wrap the element if it cannot hold child nodes
  1960. if(this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)) {
  1961. //Create a wrapper element and set the wrapper to the new current internal element
  1962. this.element.wrap(
  1963. $("<div class='ui-wrapper' style='overflow: hidden;'></div>").css({
  1964. position: this.element.css("position"),
  1965. width: this.element.outerWidth(),
  1966. height: this.element.outerHeight(),
  1967. top: this.element.css("top"),
  1968. left: this.element.css("left")
  1969. })
  1970. );
  1971. //Overwrite the original this.element
  1972. this.element = this.element.parent().data(
  1973. "ui-resizable", this.element.data("ui-resizable")
  1974. );
  1975. this.elementIsWrapper = true;
  1976. //Move margins to the wrapper
  1977. this.element.css({ marginLeft: this.originalElement.css("marginLeft"), marginTop: this.originalElement.css("marginTop"), marginRight: this.originalElement.css("marginRight"), marginBottom: this.originalElement.css("marginBottom") });
  1978. this.originalElement.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0});
  1979. //Prevent Safari textarea resize
  1980. this.originalResizeStyle = this.originalElement.css("resize");
  1981. this.originalElement.css("resize", "none");
  1982. //Push the actual element to our proportionallyResize internal array
  1983. this._proportionallyResizeElements.push(this.originalElement.css({ position: "static", zoom: 1, display: "block" }));
  1984. // avoid IE jump (hard set the margin)
  1985. this.originalElement.css({ margin: this.originalElement.css("margin") });
  1986. // fix handlers offset
  1987. this._proportionallyResize();
  1988. }
  1989. 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" });
  1990. if(this.handles.constructor === String) {
  1991. if ( this.handles === "all") {
  1992. this.handles = "n,e,s,w,se,sw,ne,nw";
  1993. }
  1994. n = this.handles.split(",");
  1995. this.handles = {};
  1996. for(i = 0; i < n.length; i++) {
  1997. handle = $.trim(n[i]);
  1998. hname = "ui-resizable-"+handle;
  1999. axis = $("<div class='ui-resizable-handle " + hname + "'></div>");
  2000. // Apply zIndex to all handles - see #7960
  2001. axis.css({ zIndex: o.zIndex });
  2002. //TODO : What's going on here?
  2003. if ("se" === handle) {
  2004. axis.addClass("ui-icon ui-icon-gripsmall-diagonal-se");
  2005. }
  2006. //Insert into internal handles object and append to element
  2007. this.handles[handle] = ".ui-resizable-"+handle;
  2008. this.element.append(axis);
  2009. }
  2010. }
  2011. this._renderAxis = function(target) {
  2012. var i, axis, padPos, padWrapper;
  2013. target = target || this.element;
  2014. for(i in this.handles) {
  2015. if(this.handles[i].constructor === String) {
  2016. this.handles[i] = $(this.handles[i], this.element).show();
  2017. }
  2018. //Apply pad to wrapper element, needed to fix axis position (textarea, inputs, scrolls)
  2019. if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/textarea|input|select|button/i)) {
  2020. axis = $(this.handles[i], this.element);
  2021. //Checking the correct pad and border
  2022. padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
  2023. //The padding type i have to apply...
  2024. padPos = [ "padding",
  2025. /ne|nw|n/.test(i) ? "Top" :
  2026. /se|sw|s/.test(i) ? "Bottom" :
  2027. /^e$/.test(i) ? "Right" : "Left" ].join("");
  2028. target.css(padPos, padWrapper);
  2029. this._proportionallyResize();
  2030. }
  2031. //TODO: What's that good for? There's not anything to be executed left
  2032. if(!$(this.handles[i]).length) {
  2033. continue;
  2034. }
  2035. }
  2036. };
  2037. //TODO: make renderAxis a prototype function
  2038. this._renderAxis(this.element);
  2039. this._handles = $(".ui-resizable-handle", this.element)
  2040. .disableSelection();
  2041. //Matching axis name
  2042. this._handles.mouseover(function() {
  2043. if (!that.resizing) {
  2044. if (this.className) {
  2045. axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
  2046. }
  2047. //Axis, default = se
  2048. that.axis = axis && axis[1] ? axis[1] : "se";
  2049. }
  2050. });
  2051. //If we want to auto hide the elements
  2052. if (o.autoHide) {
  2053. this._handles.hide();
  2054. $(this.element)
  2055. .addClass("ui-resizable-autohide")
  2056. .mouseenter(function() {
  2057. if (o.disabled) {
  2058. return;
  2059. }
  2060. $(this).removeClass("ui-resizable-autohide");
  2061. that._handles.show();
  2062. })
  2063. .mouseleave(function(){
  2064. if (o.disabled) {
  2065. return;
  2066. }
  2067. if (!that.resizing) {
  2068. $(this).addClass("ui-resizable-autohide");
  2069. that._handles.hide();
  2070. }
  2071. });
  2072. }
  2073. //Initialize the mouse interaction
  2074. this._mouseInit();
  2075. },
  2076. _destroy: function() {
  2077. this._mouseDestroy();
  2078. var wrapper,
  2079. _destroy = function(exp) {
  2080. $(exp).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing")
  2081. .removeData("resizable").removeData("ui-resizable").unbind(".resizable").find(".ui-resizable-handle").remove();
  2082. };
  2083. //TODO: Unwrap at same DOM position
  2084. if (this.elementIsWrapper) {
  2085. _destroy(this.element);
  2086. wrapper = this.element;
  2087. this.originalElement.css({
  2088. position: wrapper.css("position"),
  2089. width: wrapper.outerWidth(),
  2090. height: wrapper.outerHeight(),
  2091. top: wrapper.css("top"),
  2092. left: wrapper.css("left")
  2093. }).insertAfter( wrapper );
  2094. wrapper.remove();
  2095. }
  2096. this.originalElement.css("resize", this.originalResizeStyle);
  2097. _destroy(this.originalElement);
  2098. return this;
  2099. },
  2100. _mouseCapture: function(event) {
  2101. var i, handle,
  2102. capture = false;
  2103. for (i in this.handles) {
  2104. handle = $(this.handles[i])[0];
  2105. if (handle === event.target || $.contains(handle, event.target)) {
  2106. capture = true;
  2107. }
  2108. }
  2109. return !this.options.disabled && capture;
  2110. },
  2111. _mouseStart: function(event) {
  2112. var curleft, curtop, cursor,
  2113. o = this.options,
  2114. iniPos = this.element.position(),
  2115. el = this.element;
  2116. this.resizing = true;
  2117. // bugfix for http://dev.jquery.com/ticket/1749
  2118. if ( (/absolute/).test( el.css("position") ) ) {
  2119. el.css({ position: "absolute", top: el.css("top"), left: el.css("left") });
  2120. } else if (el.is(".ui-draggable")) {
  2121. el.css({ position: "absolute", top: iniPos.top, left: iniPos.left });
  2122. }
  2123. this._renderProxy();
  2124. curleft = num(this.helper.css("left"));
  2125. curtop = num(this.helper.css("top"));
  2126. if (o.containment) {
  2127. curleft += $(o.containment).scrollLeft() || 0;
  2128. curtop += $(o.containment).scrollTop() || 0;
  2129. }
  2130. //Store needed variables
  2131. this.offset = this.helper.offset();
  2132. this.position = { left: curleft, top: curtop };
  2133. this.size = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
  2134. this.originalSize = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
  2135. this.originalPosition = { left: curleft, top: curtop };
  2136. this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() };
  2137. this.originalMousePosition = { left: event.pageX, top: event.pageY };
  2138. //Aspect Ratio
  2139. this.aspectRatio = (typeof o.aspectRatio === "number") ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height) || 1);
  2140. cursor = $(".ui-resizable-" + this.axis).css("cursor");
  2141. $("body").css("cursor", cursor === "auto" ? this.axis + "-resize" : cursor);
  2142. el.addClass("ui-resizable-resizing");
  2143. this._propagate("start", event);
  2144. return true;
  2145. },
  2146. _mouseDrag: function(event) {
  2147. //Increase performance, avoid regex
  2148. var data,
  2149. el = this.helper, props = {},
  2150. smp = this.originalMousePosition,
  2151. a = this.axis,
  2152. prevTop = this.position.top,
  2153. prevLeft = this.position.left,
  2154. prevWidth = this.size.width,
  2155. prevHeight = this.size.height,
  2156. dx = (event.pageX-smp.left)||0,
  2157. dy = (event.pageY-smp.top)||0,
  2158. trigger = this._change[a];
  2159. if (!trigger) {
  2160. return false;
  2161. }
  2162. // Calculate the attrs that will be change
  2163. data = trigger.apply(this, [event, dx, dy]);
  2164. // Put this in the mouseDrag handler since the user can start pressing shift while resizing
  2165. this._updateVirtualBoundaries(event.shiftKey);
  2166. if (this._aspectRatio || event.shiftKey) {
  2167. data = this._updateRatio(data, event);
  2168. }
  2169. data = this._respectSize(data, event);
  2170. this._updateCache(data);
  2171. // plugins callbacks need to be called first
  2172. this._propagate("resize", event);
  2173. if (this.position.top !== prevTop) {
  2174. props.top = this.position.top + "px";
  2175. }
  2176. if (this.position.left !== prevLeft) {
  2177. props.left = this.position.left + "px";
  2178. }
  2179. if (this.size.width !== prevWidth) {
  2180. props.width = this.size.width + "px";
  2181. }
  2182. if (this.size.height !== prevHeight) {
  2183. props.height = this.size.height + "px";
  2184. }
  2185. el.css(props);
  2186. if (!this._helper && this._proportionallyResizeElements.length) {
  2187. this._proportionallyResize();
  2188. }
  2189. // Call the user callback if the element was resized
  2190. if ( ! $.isEmptyObject(props) ) {
  2191. this._trigger("resize", event, this.ui());
  2192. }
  2193. return false;
  2194. },
  2195. _mouseStop: function(event) {
  2196. this.resizing = false;
  2197. var pr, ista, soffseth, soffsetw, s, left, top,
  2198. o = this.options, that = this;
  2199. if(this._helper) {
  2200. pr = this._proportionallyResizeElements;
  2201. ista = pr.length && (/textarea/i).test(pr[0].nodeName);
  2202. soffseth = ista && $.ui.hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height;
  2203. soffsetw = ista ? 0 : that.sizeDiff.width;
  2204. s = { width: (that.helper.width() - soffsetw), height: (that.helper.height() - soffseth) };
  2205. left = (parseInt(that.element.css("left"), 10) + (that.position.left - that.originalPosition.left)) || null;
  2206. top = (parseInt(that.element.css("top"), 10) + (that.position.top - that.originalPosition.top)) || null;
  2207. if (!o.animate) {
  2208. this.element.css($.extend(s, { top: top, left: left }));
  2209. }
  2210. that.helper.height(that.size.height);
  2211. that.helper.width(that.size.width);
  2212. if (this._helper && !o.animate) {
  2213. this._proportionallyResize();
  2214. }
  2215. }
  2216. $("body").css("cursor", "auto");
  2217. this.element.removeClass("ui-resizable-resizing");
  2218. this._propagate("stop", event);
  2219. if (this._helper) {
  2220. this.helper.remove();
  2221. }
  2222. return false;
  2223. },
  2224. _updateVirtualBoundaries: function(forceAspectRatio) {
  2225. var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b,
  2226. o = this.options;
  2227. b = {
  2228. minWidth: isNumber(o.minWidth) ? o.minWidth : 0,
  2229. maxWidth: isNumber(o.maxWidth) ? o.maxWidth : Infinity,
  2230. minHeight: isNumber(o.minHeight) ? o.minHeight : 0,
  2231. maxHeight: isNumber(o.maxHeight) ? o.maxHeight : Infinity
  2232. };
  2233. if(this._aspectRatio || forceAspectRatio) {
  2234. // We want to create an enclosing box whose aspect ration is the requested one
  2235. // First, compute the "projected" size for each dimension based on the aspect ratio and other dimension
  2236. pMinWidth = b.minHeight * this.aspectRatio;
  2237. pMinHeight = b.minWidth / this.aspectRatio;
  2238. pMaxWidth = b.maxHeight * this.aspectRatio;
  2239. pMaxHeight = b.maxWidth / this.aspectRatio;
  2240. if(pMinWidth > b.minWidth) {
  2241. b.minWidth = pMinWidth;
  2242. }
  2243. if(pMinHeight > b.minHeight) {
  2244. b.minHeight = pMinHeight;
  2245. }
  2246. if(pMaxWidth < b.maxWidth) {
  2247. b.maxWidth = pMaxWidth;
  2248. }
  2249. if(pMaxHeight < b.maxHeight) {
  2250. b.maxHeight = pMaxHeight;
  2251. }
  2252. }
  2253. this._vBoundaries = b;
  2254. },
  2255. _updateCache: function(data) {
  2256. this.offset = this.helper.offset();
  2257. if (isNumber(data.left)) {
  2258. this.position.left = data.left;
  2259. }
  2260. if (isNumber(data.top)) {
  2261. this.position.top = data.top;
  2262. }
  2263. if (isNumber(data.height)) {
  2264. this.size.height = data.height;
  2265. }
  2266. if (isNumber(data.width)) {
  2267. this.size.width = data.width;
  2268. }
  2269. },
  2270. _updateRatio: function( data ) {
  2271. var cpos = this.position,
  2272. csize = this.size,
  2273. a = this.axis;
  2274. if (isNumber(data.height)) {
  2275. data.width = (data.height * this.aspectRatio);
  2276. } else if (isNumber(data.width)) {
  2277. data.height = (data.width / this.aspectRatio);
  2278. }
  2279. if (a === "sw") {
  2280. data.left = cpos.left + (csize.width - data.width);
  2281. data.top = null;
  2282. }
  2283. if (a === "nw") {
  2284. data.top = cpos.top + (csize.height - data.height);
  2285. data.left = cpos.left + (csize.width - data.width);
  2286. }
  2287. return data;
  2288. },
  2289. _respectSize: function( data ) {
  2290. var o = this._vBoundaries,
  2291. a = this.axis,
  2292. ismaxw = isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width), ismaxh = isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height),
  2293. isminw = isNumber(data.width) && o.minWidth && (o.minWidth > data.width), isminh = isNumber(data.height) && o.minHeight && (o.minHeight > data.height),
  2294. dw = this.originalPosition.left + this.originalSize.width,
  2295. dh = this.position.top + this.size.height,
  2296. cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);
  2297. if (isminw) {
  2298. data.width = o.minWidth;
  2299. }
  2300. if (isminh) {
  2301. data.height = o.minHeight;
  2302. }
  2303. if (ismaxw) {
  2304. data.width = o.maxWidth;
  2305. }
  2306. if (ismaxh) {
  2307. data.height = o.maxHeight;
  2308. }
  2309. if (isminw && cw) {
  2310. data.left = dw - o.minWidth;
  2311. }
  2312. if (ismaxw && cw) {
  2313. data.left = dw - o.maxWidth;
  2314. }
  2315. if (isminh && ch) {
  2316. data.top = dh - o.minHeight;
  2317. }
  2318. if (ismaxh && ch) {
  2319. data.top = dh - o.maxHeight;
  2320. }
  2321. // fixing jump error on top/left - bug #2330
  2322. if (!data.width && !data.height && !data.left && data.top) {
  2323. data.top = null;
  2324. } else if (!data.width && !data.height && !data.top && data.left) {
  2325. data.left = null;
  2326. }
  2327. return data;
  2328. },
  2329. _proportionallyResize: function() {
  2330. if (!this._proportionallyResizeElements.length) {
  2331. return;
  2332. }
  2333. var i, j, borders, paddings, prel,
  2334. element = this.helper || this.element;
  2335. for ( i=0; i < this._proportionallyResizeElements.length; i++) {
  2336. prel = this._proportionallyResizeElements[i];
  2337. if (!this.borderDif) {
  2338. this.borderDif = [];
  2339. borders = [prel.css("borderTopWidth"), prel.css("borderRightWidth"), prel.css("borderBottomWidth"), prel.css("borderLeftWidth")];
  2340. paddings = [prel.css("paddingTop"), prel.css("paddingRight"), prel.css("paddingBottom"), prel.css("paddingLeft")];
  2341. for ( j = 0; j < borders.length; j++ ) {
  2342. this.borderDif[ j ] = ( parseInt( borders[ j ], 10 ) || 0 ) + ( parseInt( paddings[ j ], 10 ) || 0 );
  2343. }
  2344. }
  2345. prel.css({
  2346. height: (element.height() - this.borderDif[0] - this.borderDif[2]) || 0,
  2347. width: (element.width() - this.borderDif[1] - this.borderDif[3]) || 0
  2348. });
  2349. }
  2350. },
  2351. _renderProxy: function() {
  2352. var el = this.element, o = this.options;
  2353. this.elementOffset = el.offset();
  2354. if(this._helper) {
  2355. this.helper = this.helper || $("<div style='overflow:hidden;'></div>");
  2356. this.helper.addClass(this._helper).css({
  2357. width: this.element.outerWidth() - 1,
  2358. height: this.element.outerHeight() - 1,
  2359. position: "absolute",
  2360. left: this.elementOffset.left +"px",
  2361. top: this.elementOffset.top +"px",
  2362. zIndex: ++o.zIndex //TODO: Don't modify option
  2363. });
  2364. this.helper
  2365. .appendTo("body")
  2366. .disableSelection();
  2367. } else {
  2368. this.helper = this.element;
  2369. }
  2370. },
  2371. _change: {
  2372. e: function(event, dx) {
  2373. return { width: this.originalSize.width + dx };
  2374. },
  2375. w: function(event, dx) {
  2376. var cs = this.originalSize, sp = this.originalPosition;
  2377. return { left: sp.left + dx, width: cs.width - dx };
  2378. },
  2379. n: function(event, dx, dy) {
  2380. var cs = this.originalSize, sp = this.originalPosition;
  2381. return { top: sp.top + dy, height: cs.height - dy };
  2382. },
  2383. s: function(event, dx, dy) {
  2384. return { height: this.originalSize.height + dy };
  2385. },
  2386. se: function(event, dx, dy) {
  2387. return $.extend(this._change.s.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
  2388. },
  2389. sw: function(event, dx, dy) {
  2390. return $.extend(this._change.s.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
  2391. },
  2392. ne: function(event, dx, dy) {
  2393. return $.extend(this._change.n.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
  2394. },
  2395. nw: function(event, dx, dy) {
  2396. return $.extend(this._change.n.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
  2397. }
  2398. },
  2399. _propagate: function(n, event) {
  2400. $.ui.plugin.call(this, n, [event, this.ui()]);
  2401. (n !== "resize" && this._trigger(n, event, this.ui()));
  2402. },
  2403. plugins: {},
  2404. ui: function() {
  2405. return {
  2406. originalElement: this.originalElement,
  2407. element: this.element,
  2408. helper: this.helper,
  2409. position: this.position,
  2410. size: this.size,
  2411. originalSize: this.originalSize,
  2412. originalPosition: this.originalPosition
  2413. };
  2414. }
  2415. });
  2416. /*
  2417. * Resizable Extensions
  2418. */
  2419. $.ui.plugin.add("resizable", "animate", {
  2420. stop: function( event ) {
  2421. var that = $(this).data("ui-resizable"),
  2422. o = that.options,
  2423. pr = that._proportionallyResizeElements,
  2424. ista = pr.length && (/textarea/i).test(pr[0].nodeName),
  2425. soffseth = ista && $.ui.hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height,
  2426. soffsetw = ista ? 0 : that.sizeDiff.width,
  2427. style = { width: (that.size.width - soffsetw), height: (that.size.height - soffseth) },
  2428. left = (parseInt(that.element.css("left"), 10) + (that.position.left - that.originalPosition.left)) || null,
  2429. top = (parseInt(that.element.css("top"), 10) + (that.position.top - that.originalPosition.top)) || null;
  2430. that.element.animate(
  2431. $.extend(style, top && left ? { top: top, left: left } : {}), {
  2432. duration: o.animateDuration,
  2433. easing: o.animateEasing,
  2434. step: function() {
  2435. var data = {
  2436. width: parseInt(that.element.css("width"), 10),
  2437. height: parseInt(that.element.css("height"), 10),
  2438. top: parseInt(that.element.css("top"), 10),
  2439. left: parseInt(that.element.css("left"), 10)
  2440. };
  2441. if (pr && pr.length) {
  2442. $(pr[0]).css({ width: data.width, height: data.height });
  2443. }
  2444. // propagating resize, and updating values for each animation step
  2445. that._updateCache(data);
  2446. that._propagate("resize", event);
  2447. }
  2448. }
  2449. );
  2450. }
  2451. });
  2452. $.ui.plugin.add("resizable", "containment", {
  2453. start: function() {
  2454. var element, p, co, ch, cw, width, height,
  2455. that = $(this).data("ui-resizable"),
  2456. o = that.options,
  2457. el = that.element,
  2458. oc = o.containment,
  2459. ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc;
  2460. if (!ce) {
  2461. return;
  2462. }
  2463. that.containerElement = $(ce);
  2464. if (/document/.test(oc) || oc === document) {
  2465. that.containerOffset = { left: 0, top: 0 };
  2466. that.containerPosition = { left: 0, top: 0 };
  2467. that.parentData = {
  2468. element: $(document), left: 0, top: 0,
  2469. width: $(document).width(), height: $(document).height() || document.body.parentNode.scrollHeight
  2470. };
  2471. }
  2472. // i'm a node, so compute top, left, right, bottom
  2473. else {
  2474. element = $(ce);
  2475. p = [];
  2476. $([ "Top", "Right", "Left", "Bottom" ]).each(function(i, name) { p[i] = num(element.css("padding" + name)); });
  2477. that.containerOffset = element.offset();
  2478. that.containerPosition = element.position();
  2479. that.containerSize = { height: (element.innerHeight() - p[3]), width: (element.innerWidth() - p[1]) };
  2480. co = that.containerOffset;
  2481. ch = that.containerSize.height;
  2482. cw = that.containerSize.width;
  2483. width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw );
  2484. height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch);
  2485. that.parentData = {
  2486. element: ce, left: co.left, top: co.top, width: width, height: height
  2487. };
  2488. }
  2489. },
  2490. resize: function( event ) {
  2491. var woset, hoset, isParent, isOffsetRelative,
  2492. that = $(this).data("ui-resizable"),
  2493. o = that.options,
  2494. co = that.containerOffset, cp = that.position,
  2495. pRatio = that._aspectRatio || event.shiftKey,
  2496. cop = { top:0, left:0 }, ce = that.containerElement;
  2497. if (ce[0] !== document && (/static/).test(ce.css("position"))) {
  2498. cop = co;
  2499. }
  2500. if (cp.left < (that._helper ? co.left : 0)) {
  2501. that.size.width = that.size.width + (that._helper ? (that.position.left - co.left) : (that.position.left - cop.left));
  2502. if (pRatio) {
  2503. that.size.height = that.size.width / that.aspectRatio;
  2504. }
  2505. that.position.left = o.helper ? co.left : 0;
  2506. }
  2507. if (cp.top < (that._helper ? co.top : 0)) {
  2508. that.size.height = that.size.height + (that._helper ? (that.position.top - co.top) : that.position.top);
  2509. if (pRatio) {
  2510. that.size.width = that.size.height * that.aspectRatio;
  2511. }
  2512. that.position.top = that._helper ? co.top : 0;
  2513. }
  2514. that.offset.left = that.parentData.left+that.position.left;
  2515. that.offset.top = that.parentData.top+that.position.top;
  2516. woset = Math.abs( (that._helper ? that.offset.left - cop.left : (that.offset.left - cop.left)) + that.sizeDiff.width );
  2517. hoset = Math.abs( (that._helper ? that.offset.top - cop.top : (that.offset.top - co.top)) + that.sizeDiff.height );
  2518. isParent = that.containerElement.get(0) === that.element.parent().get(0);
  2519. isOffsetRelative = /relative|absolute/.test(that.containerElement.css("position"));
  2520. if(isParent && isOffsetRelative) {
  2521. woset -= that.parentData.left;
  2522. }
  2523. if (woset + that.size.width >= that.parentData.width) {
  2524. that.size.width = that.parentData.width - woset;
  2525. if (pRatio) {
  2526. that.size.height = that.size.width / that.aspectRatio;
  2527. }
  2528. }
  2529. if (hoset + that.size.height >= that.parentData.height) {
  2530. that.size.height = that.parentData.height - hoset;
  2531. if (pRatio) {
  2532. that.size.width = that.size.height * that.aspectRatio;
  2533. }
  2534. }
  2535. },
  2536. stop: function(){
  2537. var that = $(this).data("ui-resizable"),
  2538. o = that.options,
  2539. co = that.containerOffset,
  2540. cop = that.containerPosition,
  2541. ce = that.containerElement,
  2542. helper = $(that.helper),
  2543. ho = helper.offset(),
  2544. w = helper.outerWidth() - that.sizeDiff.width,
  2545. h = helper.outerHeight() - that.sizeDiff.height;
  2546. if (that._helper && !o.animate && (/relative/).test(ce.css("position"))) {
  2547. $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
  2548. }
  2549. if (that._helper && !o.animate && (/static/).test(ce.css("position"))) {
  2550. $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
  2551. }
  2552. }
  2553. });
  2554. $.ui.plugin.add("resizable", "alsoResize", {
  2555. start: function () {
  2556. var that = $(this).data("ui-resizable"),
  2557. o = that.options,
  2558. _store = function (exp) {
  2559. $(exp).each(function() {
  2560. var el = $(this);
  2561. el.data("ui-resizable-alsoresize", {
  2562. width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
  2563. left: parseInt(el.css("left"), 10), top: parseInt(el.css("top"), 10)
  2564. });
  2565. });
  2566. };
  2567. if (typeof(o.alsoResize) === "object" && !o.alsoResize.parentNode) {
  2568. if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); }
  2569. else { $.each(o.alsoResize, function (exp) { _store(exp); }); }
  2570. }else{
  2571. _store(o.alsoResize);
  2572. }
  2573. },
  2574. resize: function (event, ui) {
  2575. var that = $(this).data("ui-resizable"),
  2576. o = that.options,
  2577. os = that.originalSize,
  2578. op = that.originalPosition,
  2579. delta = {
  2580. height: (that.size.height - os.height) || 0, width: (that.size.width - os.width) || 0,
  2581. top: (that.position.top - op.top) || 0, left: (that.position.left - op.left) || 0
  2582. },
  2583. _alsoResize = function (exp, c) {
  2584. $(exp).each(function() {
  2585. var el = $(this), start = $(this).data("ui-resizable-alsoresize"), style = {},
  2586. css = c && c.length ? c : el.parents(ui.originalElement[0]).length ? ["width", "height"] : ["width", "height", "top", "left"];
  2587. $.each(css, function (i, prop) {
  2588. var sum = (start[prop]||0) + (delta[prop]||0);
  2589. if (sum && sum >= 0) {
  2590. style[prop] = sum || null;
  2591. }
  2592. });
  2593. el.css(style);
  2594. });
  2595. };
  2596. if (typeof(o.alsoResize) === "object" && !o.alsoResize.nodeType) {
  2597. $.each(o.alsoResize, function (exp, c) { _alsoResize(exp, c); });
  2598. }else{
  2599. _alsoResize(o.alsoResize);
  2600. }
  2601. },
  2602. stop: function () {
  2603. $(this).removeData("resizable-alsoresize");
  2604. }
  2605. });
  2606. $.ui.plugin.add("resizable", "ghost", {
  2607. start: function() {
  2608. var that = $(this).data("ui-resizable"), o = that.options, cs = that.size;
  2609. that.ghost = that.originalElement.clone();
  2610. that.ghost
  2611. .css({ opacity: 0.25, display: "block", position: "relative", height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 })
  2612. .addClass("ui-resizable-ghost")
  2613. .addClass(typeof o.ghost === "string" ? o.ghost : "");
  2614. that.ghost.appendTo(that.helper);
  2615. },
  2616. resize: function(){
  2617. var that = $(this).data("ui-resizable");
  2618. if (that.ghost) {
  2619. that.ghost.css({ position: "relative", height: that.size.height, width: that.size.width });
  2620. }
  2621. },
  2622. stop: function() {
  2623. var that = $(this).data("ui-resizable");
  2624. if (that.ghost && that.helper) {
  2625. that.helper.get(0).removeChild(that.ghost.get(0));
  2626. }
  2627. }
  2628. });
  2629. $.ui.plugin.add("resizable", "grid", {
  2630. resize: function() {
  2631. var that = $(this).data("ui-resizable"),
  2632. o = that.options,
  2633. cs = that.size,
  2634. os = that.originalSize,
  2635. op = that.originalPosition,
  2636. a = that.axis,
  2637. grid = typeof o.grid === "number" ? [o.grid, o.grid] : o.grid,
  2638. gridX = (grid[0]||1),
  2639. gridY = (grid[1]||1),
  2640. ox = Math.round((cs.width - os.width) / gridX) * gridX,
  2641. oy = Math.round((cs.height - os.height) / gridY) * gridY,
  2642. newWidth = os.width + ox,
  2643. newHeight = os.height + oy,
  2644. isMaxWidth = o.maxWidth && (o.maxWidth < newWidth),
  2645. isMaxHeight = o.maxHeight && (o.maxHeight < newHeight),
  2646. isMinWidth = o.minWidth && (o.minWidth > newWidth),
  2647. isMinHeight = o.minHeight && (o.minHeight > newHeight);
  2648. o.grid = grid;
  2649. if (isMinWidth) {
  2650. newWidth = newWidth + gridX;
  2651. }
  2652. if (isMinHeight) {
  2653. newHeight = newHeight + gridY;
  2654. }
  2655. if (isMaxWidth) {
  2656. newWidth = newWidth - gridX;
  2657. }
  2658. if (isMaxHeight) {
  2659. newHeight = newHeight - gridY;
  2660. }
  2661. if (/^(se|s|e)$/.test(a)) {
  2662. that.size.width = newWidth;
  2663. that.size.height = newHeight;
  2664. } else if (/^(ne)$/.test(a)) {
  2665. that.size.width = newWidth;
  2666. that.size.height = newHeight;
  2667. that.position.top = op.top - oy;
  2668. } else if (/^(sw)$/.test(a)) {
  2669. that.size.width = newWidth;
  2670. that.size.height = newHeight;
  2671. that.position.left = op.left - ox;
  2672. } else {
  2673. that.size.width = newWidth;
  2674. that.size.height = newHeight;
  2675. that.position.top = op.top - oy;
  2676. that.position.left = op.left - ox;
  2677. }
  2678. }
  2679. });
  2680. })(jQuery);
  2681. (function( $, undefined ) {
  2682. $.widget("ui.selectable", $.ui.mouse, {
  2683. version: "1.10.3",
  2684. options: {
  2685. appendTo: "body",
  2686. autoRefresh: true,
  2687. distance: 0,
  2688. filter: "*",
  2689. tolerance: "touch",
  2690. // callbacks
  2691. selected: null,
  2692. selecting: null,
  2693. start: null,
  2694. stop: null,
  2695. unselected: null,
  2696. unselecting: null
  2697. },
  2698. _create: function() {
  2699. var selectees,
  2700. that = this;
  2701. this.element.addClass("ui-selectable");
  2702. this.dragged = false;
  2703. // cache selectee children based on filter
  2704. this.refresh = function() {
  2705. selectees = $(that.options.filter, that.element[0]);
  2706. selectees.addClass("ui-selectee");
  2707. selectees.each(function() {
  2708. var $this = $(this),
  2709. pos = $this.offset();
  2710. $.data(this, "selectable-item", {
  2711. element: this,
  2712. $element: $this,
  2713. left: pos.left,
  2714. top: pos.top,
  2715. right: pos.left + $this.outerWidth(),
  2716. bottom: pos.top + $this.outerHeight(),
  2717. startselected: false,
  2718. selected: $this.hasClass("ui-selected"),
  2719. selecting: $this.hasClass("ui-selecting"),
  2720. unselecting: $this.hasClass("ui-unselecting")
  2721. });
  2722. });
  2723. };
  2724. this.refresh();
  2725. this.selectees = selectees.addClass("ui-selectee");
  2726. this._mouseInit();
  2727. this.helper = $("<div class='ui-selectable-helper'></div>");
  2728. },
  2729. _destroy: function() {
  2730. this.selectees
  2731. .removeClass("ui-selectee")
  2732. .removeData("selectable-item");
  2733. this.element
  2734. .removeClass("ui-selectable ui-selectable-disabled");
  2735. this._mouseDestroy();
  2736. },
  2737. _mouseStart: function(event) {
  2738. var that = this,
  2739. options = this.options;
  2740. this.opos = [event.pageX, event.pageY];
  2741. if (this.options.disabled) {
  2742. return;
  2743. }
  2744. this.selectees = $(options.filter, this.element[0]);
  2745. this._trigger("start", event);
  2746. $(options.appendTo).append(this.helper);
  2747. // position helper (lasso)
  2748. this.helper.css({
  2749. "left": event.pageX,
  2750. "top": event.pageY,
  2751. "width": 0,
  2752. "height": 0
  2753. });
  2754. if (options.autoRefresh) {
  2755. this.refresh();
  2756. }
  2757. this.selectees.filter(".ui-selected").each(function() {
  2758. var selectee = $.data(this, "selectable-item");
  2759. selectee.startselected = true;
  2760. if (!event.metaKey && !event.ctrlKey) {
  2761. selectee.$element.removeClass("ui-selected");
  2762. selectee.selected = false;
  2763. selectee.$element.addClass("ui-unselecting");
  2764. selectee.unselecting = true;
  2765. // selectable UNSELECTING callback
  2766. that._trigger("unselecting", event, {
  2767. unselecting: selectee.element
  2768. });
  2769. }
  2770. });
  2771. $(event.target).parents().addBack().each(function() {
  2772. var doSelect,
  2773. selectee = $.data(this, "selectable-item");
  2774. if (selectee) {
  2775. doSelect = (!event.metaKey && !event.ctrlKey) || !selectee.$element.hasClass("ui-selected");
  2776. selectee.$element
  2777. .removeClass(doSelect ? "ui-unselecting" : "ui-selected")
  2778. .addClass(doSelect ? "ui-selecting" : "ui-unselecting");
  2779. selectee.unselecting = !doSelect;
  2780. selectee.selecting = doSelect;
  2781. selectee.selected = doSelect;
  2782. // selectable (UN)SELECTING callback
  2783. if (doSelect) {
  2784. that._trigger("selecting", event, {
  2785. selecting: selectee.element
  2786. });
  2787. } else {
  2788. that._trigger("unselecting", event, {
  2789. unselecting: selectee.element
  2790. });
  2791. }
  2792. return false;
  2793. }
  2794. });
  2795. },
  2796. _mouseDrag: function(event) {
  2797. this.dragged = true;
  2798. if (this.options.disabled) {
  2799. return;
  2800. }
  2801. var tmp,
  2802. that = this,
  2803. options = this.options,
  2804. x1 = this.opos[0],
  2805. y1 = this.opos[1],
  2806. x2 = event.pageX,
  2807. y2 = event.pageY;
  2808. if (x1 > x2) { tmp = x2; x2 = x1; x1 = tmp; }
  2809. if (y1 > y2) { tmp = y2; y2 = y1; y1 = tmp; }
  2810. this.helper.css({left: x1, top: y1, width: x2-x1, height: y2-y1});
  2811. this.selectees.each(function() {
  2812. var selectee = $.data(this, "selectable-item"),
  2813. hit = false;
  2814. //prevent helper from being selected if appendTo: selectable
  2815. if (!selectee || selectee.element === that.element[0]) {
  2816. return;
  2817. }
  2818. if (options.tolerance === "touch") {
  2819. hit = ( !(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1) );
  2820. } else if (options.tolerance === "fit") {
  2821. hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
  2822. }
  2823. if (hit) {
  2824. // SELECT
  2825. if (selectee.selected) {
  2826. selectee.$element.removeClass("ui-selected");
  2827. selectee.selected = false;
  2828. }
  2829. if (selectee.unselecting) {
  2830. selectee.$element.removeClass("ui-unselecting");
  2831. selectee.unselecting = false;
  2832. }
  2833. if (!selectee.selecting) {
  2834. selectee.$element.addClass("ui-selecting");
  2835. selectee.selecting = true;
  2836. // selectable SELECTING callback
  2837. that._trigger("selecting", event, {
  2838. selecting: selectee.element
  2839. });
  2840. }
  2841. } else {
  2842. // UNSELECT
  2843. if (selectee.selecting) {
  2844. if ((event.metaKey || event.ctrlKey) && selectee.startselected) {
  2845. selectee.$element.removeClass("ui-selecting");
  2846. selectee.selecting = false;
  2847. selectee.$element.addClass("ui-selected");
  2848. selectee.selected = true;
  2849. } else {
  2850. selectee.$element.removeClass("ui-selecting");
  2851. selectee.selecting = false;
  2852. if (selectee.startselected) {
  2853. selectee.$element.addClass("ui-unselecting");
  2854. selectee.unselecting = true;
  2855. }
  2856. // selectable UNSELECTING callback
  2857. that._trigger("unselecting", event, {
  2858. unselecting: selectee.element
  2859. });
  2860. }
  2861. }
  2862. if (selectee.selected) {
  2863. if (!event.metaKey && !event.ctrlKey && !selectee.startselected) {
  2864. selectee.$element.removeClass("ui-selected");
  2865. selectee.selected = false;
  2866. selectee.$element.addClass("ui-unselecting");
  2867. selectee.unselecting = true;
  2868. // selectable UNSELECTING callback
  2869. that._trigger("unselecting", event, {
  2870. unselecting: selectee.element
  2871. });
  2872. }
  2873. }
  2874. }
  2875. });
  2876. return false;
  2877. },
  2878. _mouseStop: function(event) {
  2879. var that = this;
  2880. this.dragged = false;
  2881. $(".ui-unselecting", this.element[0]).each(function() {
  2882. var selectee = $.data(this, "selectable-item");
  2883. selectee.$element.removeClass("ui-unselecting");
  2884. selectee.unselecting = false;
  2885. selectee.startselected = false;
  2886. that._trigger("unselected", event, {
  2887. unselected: selectee.element
  2888. });
  2889. });
  2890. $(".ui-selecting", this.element[0]).each(function() {
  2891. var selectee = $.data(this, "selectable-item");
  2892. selectee.$element.removeClass("ui-selecting").addClass("ui-selected");
  2893. selectee.selecting = false;
  2894. selectee.selected = true;
  2895. selectee.startselected = true;
  2896. that._trigger("selected", event, {
  2897. selected: selectee.element
  2898. });
  2899. });
  2900. this._trigger("stop", event);
  2901. this.helper.remove();
  2902. return false;
  2903. }
  2904. });
  2905. })(jQuery);
  2906. (function( $, undefined ) {
  2907. /*jshint loopfunc: true */
  2908. function isOverAxis( x, reference, size ) {
  2909. return ( x > reference ) && ( x < ( reference + size ) );
  2910. }
  2911. function isFloating(item) {
  2912. return (/left|right/).test(item.css("float")) || (/inline|table-cell/).test(item.css("display"));
  2913. }
  2914. $.widget("ui.sortable", $.ui.mouse, {
  2915. version: "1.10.3",
  2916. widgetEventPrefix: "sort",
  2917. ready: false,
  2918. options: {
  2919. appendTo: "parent",
  2920. axis: false,
  2921. connectWith: false,
  2922. containment: false,
  2923. cursor: "auto",
  2924. cursorAt: false,
  2925. dropOnEmpty: true,
  2926. forcePlaceholderSize: false,
  2927. forceHelperSize: false,
  2928. grid: false,
  2929. handle: false,
  2930. helper: "original",
  2931. items: "> *",
  2932. opacity: false,
  2933. placeholder: false,
  2934. revert: false,
  2935. scroll: true,
  2936. scrollSensitivity: 20,
  2937. scrollSpeed: 20,
  2938. scope: "default",
  2939. tolerance: "intersect",
  2940. zIndex: 1000,
  2941. // callbacks
  2942. activate: null,
  2943. beforeStop: null,
  2944. change: null,
  2945. deactivate: null,
  2946. out: null,
  2947. over: null,
  2948. receive: null,
  2949. remove: null,
  2950. sort: null,
  2951. start: null,
  2952. stop: null,
  2953. update: null
  2954. },
  2955. _create: function() {
  2956. var o = this.options;
  2957. this.containerCache = {};
  2958. this.element.addClass("ui-sortable");
  2959. //Get the items
  2960. this.refresh();
  2961. //Let's determine if the items are being displayed horizontally
  2962. this.floating = this.items.length ? o.axis === "x" || isFloating(this.items[0].item) : false;
  2963. //Let's determine the parent's offset
  2964. this.offset = this.element.offset();
  2965. //Initialize mouse events for interaction
  2966. this._mouseInit();
  2967. //We're ready to go
  2968. this.ready = true;
  2969. },
  2970. _destroy: function() {
  2971. this.element
  2972. .removeClass("ui-sortable ui-sortable-disabled");
  2973. this._mouseDestroy();
  2974. for ( var i = this.items.length - 1; i >= 0; i-- ) {
  2975. this.items[i].item.removeData(this.widgetName + "-item");
  2976. }
  2977. return this;
  2978. },
  2979. _setOption: function(key, value){
  2980. if ( key === "disabled" ) {
  2981. this.options[ key ] = value;
  2982. this.widget().toggleClass( "ui-sortable-disabled", !!value );
  2983. } else {
  2984. // Don't call widget base _setOption for disable as it adds ui-state-disabled class
  2985. $.Widget.prototype._setOption.apply(this, arguments);
  2986. }
  2987. },
  2988. _mouseCapture: function(event, overrideHandle) {
  2989. var currentItem = null,
  2990. validHandle = false,
  2991. that = this;
  2992. if (this.reverting) {
  2993. return false;
  2994. }
  2995. if(this.options.disabled || this.options.type === "static") {
  2996. return false;
  2997. }
  2998. //We have to refresh the items data once first
  2999. this._refreshItems(event);
  3000. //Find out if the clicked node (or one of its parents) is a actual item in this.items
  3001. $(event.target).parents().each(function() {
  3002. if($.data(this, that.widgetName + "-item") === that) {
  3003. currentItem = $(this);
  3004. return false;
  3005. }
  3006. });
  3007. if($.data(event.target, that.widgetName + "-item") === that) {
  3008. currentItem = $(event.target);
  3009. }
  3010. if(!currentItem) {
  3011. return false;
  3012. }
  3013. if(this.options.handle && !overrideHandle) {
  3014. $(this.options.handle, currentItem).find("*").addBack().each(function() {
  3015. if(this === event.target) {
  3016. validHandle = true;
  3017. }
  3018. });
  3019. if(!validHandle) {
  3020. return false;
  3021. }
  3022. }
  3023. this.currentItem = currentItem;
  3024. this._removeCurrentsFromItems();
  3025. return true;
  3026. },
  3027. _mouseStart: function(event, overrideHandle, noActivation) {
  3028. var i, body,
  3029. o = this.options;
  3030. this.currentContainer = this;
  3031. //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
  3032. this.refreshPositions();
  3033. //Create and append the visible helper
  3034. this.helper = this._createHelper(event);
  3035. //Cache the helper size
  3036. this._cacheHelperProportions();
  3037. /*
  3038. * - Position generation -
  3039. * This block generates everything position related - it's the core of draggables.
  3040. */
  3041. //Cache the margins of the original element
  3042. this._cacheMargins();
  3043. //Get the next scrolling parent
  3044. this.scrollParent = this.helper.scrollParent();
  3045. //The element's absolute position on the page minus margins
  3046. this.offset = this.currentItem.offset();
  3047. this.offset = {
  3048. top: this.offset.top - this.margins.top,
  3049. left: this.offset.left - this.margins.left
  3050. };
  3051. $.extend(this.offset, {
  3052. click: { //Where the click happened, relative to the element
  3053. left: event.pageX - this.offset.left,
  3054. top: event.pageY - this.offset.top
  3055. },
  3056. parent: this._getParentOffset(),
  3057. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  3058. });
  3059. // Only after we got the offset, we can change the helper's position to absolute
  3060. // TODO: Still need to figure out a way to make relative sorting possible
  3061. this.helper.css("position", "absolute");
  3062. this.cssPosition = this.helper.css("position");
  3063. //Generate the original position
  3064. this.originalPosition = this._generatePosition(event);
  3065. this.originalPageX = event.pageX;
  3066. this.originalPageY = event.pageY;
  3067. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  3068. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  3069. //Cache the former DOM position
  3070. this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
  3071. //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
  3072. if(this.helper[0] !== this.currentItem[0]) {
  3073. this.currentItem.hide();
  3074. }
  3075. //Create the placeholder
  3076. this._createPlaceholder();
  3077. //Set a containment if given in the options
  3078. if(o.containment) {
  3079. this._setContainment();
  3080. }
  3081. if( o.cursor && o.cursor !== "auto" ) { // cursor option
  3082. body = this.document.find( "body" );
  3083. // support: IE
  3084. this.storedCursor = body.css( "cursor" );
  3085. body.css( "cursor", o.cursor );
  3086. this.storedStylesheet = $( "<style>*{ cursor: "+o.cursor+" !important; }</style>" ).appendTo( body );
  3087. }
  3088. if(o.opacity) { // opacity option
  3089. if (this.helper.css("opacity")) {
  3090. this._storedOpacity = this.helper.css("opacity");
  3091. }
  3092. this.helper.css("opacity", o.opacity);
  3093. }
  3094. if(o.zIndex) { // zIndex option
  3095. if (this.helper.css("zIndex")) {
  3096. this._storedZIndex = this.helper.css("zIndex");
  3097. }
  3098. this.helper.css("zIndex", o.zIndex);
  3099. }
  3100. //Prepare scrolling
  3101. if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
  3102. this.overflowOffset = this.scrollParent.offset();
  3103. }
  3104. //Call callbacks
  3105. this._trigger("start", event, this._uiHash());
  3106. //Recache the helper size
  3107. if(!this._preserveHelperProportions) {
  3108. this._cacheHelperProportions();
  3109. }
  3110. //Post "activate" events to possible containers
  3111. if( !noActivation ) {
  3112. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  3113. this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
  3114. }
  3115. }
  3116. //Prepare possible droppables
  3117. if($.ui.ddmanager) {
  3118. $.ui.ddmanager.current = this;
  3119. }
  3120. if ($.ui.ddmanager && !o.dropBehaviour) {
  3121. $.ui.ddmanager.prepareOffsets(this, event);
  3122. }
  3123. this.dragging = true;
  3124. this.helper.addClass("ui-sortable-helper");
  3125. this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  3126. return true;
  3127. },
  3128. _mouseDrag: function(event) {
  3129. var i, item, itemElement, intersection,
  3130. o = this.options,
  3131. scrolled = false;
  3132. //Compute the helpers position
  3133. this.position = this._generatePosition(event);
  3134. this.positionAbs = this._convertPositionTo("absolute");
  3135. if (!this.lastPositionAbs) {
  3136. this.lastPositionAbs = this.positionAbs;
  3137. }
  3138. //Do scrolling
  3139. if(this.options.scroll) {
  3140. if(this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
  3141. if((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
  3142. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
  3143. } else if(event.pageY - this.overflowOffset.top < o.scrollSensitivity) {
  3144. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
  3145. }
  3146. if((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
  3147. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
  3148. } else if(event.pageX - this.overflowOffset.left < o.scrollSensitivity) {
  3149. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
  3150. }
  3151. } else {
  3152. if(event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
  3153. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  3154. } else if($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
  3155. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  3156. }
  3157. if(event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
  3158. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  3159. } else if($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
  3160. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  3161. }
  3162. }
  3163. if(scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  3164. $.ui.ddmanager.prepareOffsets(this, event);
  3165. }
  3166. }
  3167. //Regenerate the absolute position used for position checks
  3168. this.positionAbs = this._convertPositionTo("absolute");
  3169. //Set the helper position
  3170. if(!this.options.axis || this.options.axis !== "y") {
  3171. this.helper[0].style.left = this.position.left+"px";
  3172. }
  3173. if(!this.options.axis || this.options.axis !== "x") {
  3174. this.helper[0].style.top = this.position.top+"px";
  3175. }
  3176. //Rearrange
  3177. for (i = this.items.length - 1; i >= 0; i--) {
  3178. //Cache variables and intersection, continue if no intersection
  3179. item = this.items[i];
  3180. itemElement = item.item[0];
  3181. intersection = this._intersectsWithPointer(item);
  3182. if (!intersection) {
  3183. continue;
  3184. }
  3185. // Only put the placeholder inside the current Container, skip all
  3186. // items form other containers. This works because when moving
  3187. // an item from one container to another the
  3188. // currentContainer is switched before the placeholder is moved.
  3189. //
  3190. // Without this moving items in "sub-sortables" can cause the placeholder to jitter
  3191. // beetween the outer and inner container.
  3192. if (item.instance !== this.currentContainer) {
  3193. continue;
  3194. }
  3195. // cannot intersect with itself
  3196. // no useless actions that have been done before
  3197. // no action if the item moved is the parent of the item checked
  3198. if (itemElement !== this.currentItem[0] &&
  3199. this.placeholder[intersection === 1 ? "next" : "prev"]()[0] !== itemElement &&
  3200. !$.contains(this.placeholder[0], itemElement) &&
  3201. (this.options.type === "semi-dynamic" ? !$.contains(this.element[0], itemElement) : true)
  3202. ) {
  3203. this.direction = intersection === 1 ? "down" : "up";
  3204. if (this.options.tolerance === "pointer" || this._intersectsWithSides(item)) {
  3205. this._rearrange(event, item);
  3206. } else {
  3207. break;
  3208. }
  3209. this._trigger("change", event, this._uiHash());
  3210. break;
  3211. }
  3212. }
  3213. //Post events to containers
  3214. this._contactContainers(event);
  3215. //Interconnect with droppables
  3216. if($.ui.ddmanager) {
  3217. $.ui.ddmanager.drag(this, event);
  3218. }
  3219. //Call callbacks
  3220. this._trigger("sort", event, this._uiHash());
  3221. this.lastPositionAbs = this.positionAbs;
  3222. return false;
  3223. },
  3224. _mouseStop: function(event, noPropagation) {
  3225. if(!event) {
  3226. return;
  3227. }
  3228. //If we are using droppables, inform the manager about the drop
  3229. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  3230. $.ui.ddmanager.drop(this, event);
  3231. }
  3232. if(this.options.revert) {
  3233. var that = this,
  3234. cur = this.placeholder.offset(),
  3235. axis = this.options.axis,
  3236. animation = {};
  3237. if ( !axis || axis === "x" ) {
  3238. animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollLeft);
  3239. }
  3240. if ( !axis || axis === "y" ) {
  3241. animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollTop);
  3242. }
  3243. this.reverting = true;
  3244. $(this.helper).animate( animation, parseInt(this.options.revert, 10) || 500, function() {
  3245. that._clear(event);
  3246. });
  3247. } else {
  3248. this._clear(event, noPropagation);
  3249. }
  3250. return false;
  3251. },
  3252. cancel: function() {
  3253. if(this.dragging) {
  3254. this._mouseUp({ target: null });
  3255. if(this.options.helper === "original") {
  3256. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  3257. } else {
  3258. this.currentItem.show();
  3259. }
  3260. //Post deactivating events to containers
  3261. for (var i = this.containers.length - 1; i >= 0; i--){
  3262. this.containers[i]._trigger("deactivate", null, this._uiHash(this));
  3263. if(this.containers[i].containerCache.over) {
  3264. this.containers[i]._trigger("out", null, this._uiHash(this));
  3265. this.containers[i].containerCache.over = 0;
  3266. }
  3267. }
  3268. }
  3269. if (this.placeholder) {
  3270. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  3271. if(this.placeholder[0].parentNode) {
  3272. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  3273. }
  3274. if(this.options.helper !== "original" && this.helper && this.helper[0].parentNode) {
  3275. this.helper.remove();
  3276. }
  3277. $.extend(this, {
  3278. helper: null,
  3279. dragging: false,
  3280. reverting: false,
  3281. _noFinalSort: null
  3282. });
  3283. if(this.domPosition.prev) {
  3284. $(this.domPosition.prev).after(this.currentItem);
  3285. } else {
  3286. $(this.domPosition.parent).prepend(this.currentItem);
  3287. }
  3288. }
  3289. return this;
  3290. },
  3291. serialize: function(o) {
  3292. var items = this._getItemsAsjQuery(o && o.connected),
  3293. str = [];
  3294. o = o || {};
  3295. $(items).each(function() {
  3296. var res = ($(o.item || this).attr(o.attribute || "id") || "").match(o.expression || (/(.+)[\-=_](.+)/));
  3297. if (res) {
  3298. str.push((o.key || res[1]+"[]")+"="+(o.key && o.expression ? res[1] : res[2]));
  3299. }
  3300. });
  3301. if(!str.length && o.key) {
  3302. str.push(o.key + "=");
  3303. }
  3304. return str.join("&");
  3305. },
  3306. toArray: function(o) {
  3307. var items = this._getItemsAsjQuery(o && o.connected),
  3308. ret = [];
  3309. o = o || {};
  3310. items.each(function() { ret.push($(o.item || this).attr(o.attribute || "id") || ""); });
  3311. return ret;
  3312. },
  3313. /* Be careful with the following core functions */
  3314. _intersectsWith: function(item) {
  3315. var x1 = this.positionAbs.left,
  3316. x2 = x1 + this.helperProportions.width,
  3317. y1 = this.positionAbs.top,
  3318. y2 = y1 + this.helperProportions.height,
  3319. l = item.left,
  3320. r = l + item.width,
  3321. t = item.top,
  3322. b = t + item.height,
  3323. dyClick = this.offset.click.top,
  3324. dxClick = this.offset.click.left,
  3325. isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t && ( y1 + dyClick ) < b ),
  3326. isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l && ( x1 + dxClick ) < r ),
  3327. isOverElement = isOverElementHeight && isOverElementWidth;
  3328. if ( this.options.tolerance === "pointer" ||
  3329. this.options.forcePointerForContainers ||
  3330. (this.options.tolerance !== "pointer" && this.helperProportions[this.floating ? "width" : "height"] > item[this.floating ? "width" : "height"])
  3331. ) {
  3332. return isOverElement;
  3333. } else {
  3334. return (l < x1 + (this.helperProportions.width / 2) && // Right Half
  3335. x2 - (this.helperProportions.width / 2) < r && // Left Half
  3336. t < y1 + (this.helperProportions.height / 2) && // Bottom Half
  3337. y2 - (this.helperProportions.height / 2) < b ); // Top Half
  3338. }
  3339. },
  3340. _intersectsWithPointer: function(item) {
  3341. var isOverElementHeight = (this.options.axis === "x") || isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
  3342. isOverElementWidth = (this.options.axis === "y") || isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
  3343. isOverElement = isOverElementHeight && isOverElementWidth,
  3344. verticalDirection = this._getDragVerticalDirection(),
  3345. horizontalDirection = this._getDragHorizontalDirection();
  3346. if (!isOverElement) {
  3347. return false;
  3348. }
  3349. return this.floating ?
  3350. ( ((horizontalDirection && horizontalDirection === "right") || verticalDirection === "down") ? 2 : 1 )
  3351. : ( verticalDirection && (verticalDirection === "down" ? 2 : 1) );
  3352. },
  3353. _intersectsWithSides: function(item) {
  3354. var isOverBottomHalf = isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height/2), item.height),
  3355. isOverRightHalf = isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width/2), item.width),
  3356. verticalDirection = this._getDragVerticalDirection(),
  3357. horizontalDirection = this._getDragHorizontalDirection();
  3358. if (this.floating && horizontalDirection) {
  3359. return ((horizontalDirection === "right" && isOverRightHalf) || (horizontalDirection === "left" && !isOverRightHalf));
  3360. } else {
  3361. return verticalDirection && ((verticalDirection === "down" && isOverBottomHalf) || (verticalDirection === "up" && !isOverBottomHalf));
  3362. }
  3363. },
  3364. _getDragVerticalDirection: function() {
  3365. var delta = this.positionAbs.top - this.lastPositionAbs.top;
  3366. return delta !== 0 && (delta > 0 ? "down" : "up");
  3367. },
  3368. _getDragHorizontalDirection: function() {
  3369. var delta = this.positionAbs.left - this.lastPositionAbs.left;
  3370. return delta !== 0 && (delta > 0 ? "right" : "left");
  3371. },
  3372. refresh: function(event) {
  3373. this._refreshItems(event);
  3374. this.refreshPositions();
  3375. return this;
  3376. },
  3377. _connectWith: function() {
  3378. var options = this.options;
  3379. return options.connectWith.constructor === String ? [options.connectWith] : options.connectWith;
  3380. },
  3381. _getItemsAsjQuery: function(connected) {
  3382. var i, j, cur, inst,
  3383. items = [],
  3384. queries = [],
  3385. connectWith = this._connectWith();
  3386. if(connectWith && connected) {
  3387. for (i = connectWith.length - 1; i >= 0; i--){
  3388. cur = $(connectWith[i]);
  3389. for ( j = cur.length - 1; j >= 0; j--){
  3390. inst = $.data(cur[j], this.widgetFullName);
  3391. if(inst && inst !== this && !inst.options.disabled) {
  3392. 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]);
  3393. }
  3394. }
  3395. }
  3396. }
  3397. 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]);
  3398. for (i = queries.length - 1; i >= 0; i--){
  3399. queries[i][0].each(function() {
  3400. items.push(this);
  3401. });
  3402. }
  3403. return $(items);
  3404. },
  3405. _removeCurrentsFromItems: function() {
  3406. var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
  3407. this.items = $.grep(this.items, function (item) {
  3408. for (var j=0; j < list.length; j++) {
  3409. if(list[j] === item.item[0]) {
  3410. return false;
  3411. }
  3412. }
  3413. return true;
  3414. });
  3415. },
  3416. _refreshItems: function(event) {
  3417. this.items = [];
  3418. this.containers = [this];
  3419. var i, j, cur, inst, targetData, _queries, item, queriesLength,
  3420. items = this.items,
  3421. queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]],
  3422. connectWith = this._connectWith();
  3423. if(connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
  3424. for (i = connectWith.length - 1; i >= 0; i--){
  3425. cur = $(connectWith[i]);
  3426. for (j = cur.length - 1; j >= 0; j--){
  3427. inst = $.data(cur[j], this.widgetFullName);
  3428. if(inst && inst !== this && !inst.options.disabled) {
  3429. queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
  3430. this.containers.push(inst);
  3431. }
  3432. }
  3433. }
  3434. }
  3435. for (i = queries.length - 1; i >= 0; i--) {
  3436. targetData = queries[i][1];
  3437. _queries = queries[i][0];
  3438. for (j=0, queriesLength = _queries.length; j < queriesLength; j++) {
  3439. item = $(_queries[j]);
  3440. item.data(this.widgetName + "-item", targetData); // Data for target checking (mouse manager)
  3441. items.push({
  3442. item: item,
  3443. instance: targetData,
  3444. width: 0, height: 0,
  3445. left: 0, top: 0
  3446. });
  3447. }
  3448. }
  3449. },
  3450. refreshPositions: function(fast) {
  3451. //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
  3452. if(this.offsetParent && this.helper) {
  3453. this.offset.parent = this._getParentOffset();
  3454. }
  3455. var i, item, t, p;
  3456. for (i = this.items.length - 1; i >= 0; i--){
  3457. item = this.items[i];
  3458. //We ignore calculating positions of all connected containers when we're not over them
  3459. if(item.instance !== this.currentContainer && this.currentContainer && item.item[0] !== this.currentItem[0]) {
  3460. continue;
  3461. }
  3462. t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
  3463. if (!fast) {
  3464. item.width = t.outerWidth();
  3465. item.height = t.outerHeight();
  3466. }
  3467. p = t.offset();
  3468. item.left = p.left;
  3469. item.top = p.top;
  3470. }
  3471. if(this.options.custom && this.options.custom.refreshContainers) {
  3472. this.options.custom.refreshContainers.call(this);
  3473. } else {
  3474. for (i = this.containers.length - 1; i >= 0; i--){
  3475. p = this.containers[i].element.offset();
  3476. this.containers[i].containerCache.left = p.left;
  3477. this.containers[i].containerCache.top = p.top;
  3478. this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
  3479. this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
  3480. }
  3481. }
  3482. return this;
  3483. },
  3484. _createPlaceholder: function(that) {
  3485. that = that || this;
  3486. var className,
  3487. o = that.options;
  3488. if(!o.placeholder || o.placeholder.constructor === String) {
  3489. className = o.placeholder;
  3490. o.placeholder = {
  3491. element: function() {
  3492. var nodeName = that.currentItem[0].nodeName.toLowerCase(),
  3493. element = $( "<" + nodeName + ">", that.document[0] )
  3494. .addClass(className || that.currentItem[0].className+" ui-sortable-placeholder")
  3495. .removeClass("ui-sortable-helper");
  3496. if ( nodeName === "tr" ) {
  3497. that.currentItem.children().each(function() {
  3498. $( "<td>&#160;</td>", that.document[0] )
  3499. .attr( "colspan", $( this ).attr( "colspan" ) || 1 )
  3500. .appendTo( element );
  3501. });
  3502. } else if ( nodeName === "img" ) {
  3503. element.attr( "src", that.currentItem.attr( "src" ) );
  3504. }
  3505. if ( !className ) {
  3506. element.css( "visibility", "hidden" );
  3507. }
  3508. return element;
  3509. },
  3510. update: function(container, p) {
  3511. // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
  3512. // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
  3513. if(className && !o.forcePlaceholderSize) {
  3514. return;
  3515. }
  3516. //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
  3517. if(!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css("paddingTop")||0, 10) - parseInt(that.currentItem.css("paddingBottom")||0, 10)); }
  3518. if(!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css("paddingLeft")||0, 10) - parseInt(that.currentItem.css("paddingRight")||0, 10)); }
  3519. }
  3520. };
  3521. }
  3522. //Create the placeholder
  3523. that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem));
  3524. //Append it after the actual current item
  3525. that.currentItem.after(that.placeholder);
  3526. //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
  3527. o.placeholder.update(that, that.placeholder);
  3528. },
  3529. _contactContainers: function(event) {
  3530. var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, base, cur, nearBottom, floating,
  3531. innermostContainer = null,
  3532. innermostIndex = null;
  3533. // get innermost container that intersects with item
  3534. for (i = this.containers.length - 1; i >= 0; i--) {
  3535. // never consider a container that's located within the item itself
  3536. if($.contains(this.currentItem[0], this.containers[i].element[0])) {
  3537. continue;
  3538. }
  3539. if(this._intersectsWith(this.containers[i].containerCache)) {
  3540. // if we've already found a container and it's more "inner" than this, then continue
  3541. if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0])) {
  3542. continue;
  3543. }
  3544. innermostContainer = this.containers[i];
  3545. innermostIndex = i;
  3546. } else {
  3547. // container doesn't intersect. trigger "out" event if necessary
  3548. if(this.containers[i].containerCache.over) {
  3549. this.containers[i]._trigger("out", event, this._uiHash(this));
  3550. this.containers[i].containerCache.over = 0;
  3551. }
  3552. }
  3553. }
  3554. // if no intersecting containers found, return
  3555. if(!innermostContainer) {
  3556. return;
  3557. }
  3558. // move the item into the container if it's not there already
  3559. if(this.containers.length === 1) {
  3560. if (!this.containers[innermostIndex].containerCache.over) {
  3561. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  3562. this.containers[innermostIndex].containerCache.over = 1;
  3563. }
  3564. } else {
  3565. //When entering a new container, we will find the item with the least distance and append our item near it
  3566. dist = 10000;
  3567. itemWithLeastDistance = null;
  3568. floating = innermostContainer.floating || isFloating(this.currentItem);
  3569. posProperty = floating ? "left" : "top";
  3570. sizeProperty = floating ? "width" : "height";
  3571. base = this.positionAbs[posProperty] + this.offset.click[posProperty];
  3572. for (j = this.items.length - 1; j >= 0; j--) {
  3573. if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) {
  3574. continue;
  3575. }
  3576. if(this.items[j].item[0] === this.currentItem[0]) {
  3577. continue;
  3578. }
  3579. if (floating && !isOverAxis(this.positionAbs.top + this.offset.click.top, this.items[j].top, this.items[j].height)) {
  3580. continue;
  3581. }
  3582. cur = this.items[j].item.offset()[posProperty];
  3583. nearBottom = false;
  3584. if(Math.abs(cur - base) > Math.abs(cur + this.items[j][sizeProperty] - base)){
  3585. nearBottom = true;
  3586. cur += this.items[j][sizeProperty];
  3587. }
  3588. if(Math.abs(cur - base) < dist) {
  3589. dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
  3590. this.direction = nearBottom ? "up": "down";
  3591. }
  3592. }
  3593. //Check if dropOnEmpty is enabled
  3594. if(!itemWithLeastDistance && !this.options.dropOnEmpty) {
  3595. return;
  3596. }
  3597. if(this.currentContainer === this.containers[innermostIndex]) {
  3598. return;
  3599. }
  3600. itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
  3601. this._trigger("change", event, this._uiHash());
  3602. this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
  3603. this.currentContainer = this.containers[innermostIndex];
  3604. //Update the placeholder
  3605. this.options.placeholder.update(this.currentContainer, this.placeholder);
  3606. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  3607. this.containers[innermostIndex].containerCache.over = 1;
  3608. }
  3609. },
  3610. _createHelper: function(event) {
  3611. var o = this.options,
  3612. helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper === "clone" ? this.currentItem.clone() : this.currentItem);
  3613. //Add the helper to the DOM if that didn't happen already
  3614. if(!helper.parents("body").length) {
  3615. $(o.appendTo !== "parent" ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
  3616. }
  3617. if(helper[0] === this.currentItem[0]) {
  3618. 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") };
  3619. }
  3620. if(!helper[0].style.width || o.forceHelperSize) {
  3621. helper.width(this.currentItem.width());
  3622. }
  3623. if(!helper[0].style.height || o.forceHelperSize) {
  3624. helper.height(this.currentItem.height());
  3625. }
  3626. return helper;
  3627. },
  3628. _adjustOffsetFromHelper: function(obj) {
  3629. if (typeof obj === "string") {
  3630. obj = obj.split(" ");
  3631. }
  3632. if ($.isArray(obj)) {
  3633. obj = {left: +obj[0], top: +obj[1] || 0};
  3634. }
  3635. if ("left" in obj) {
  3636. this.offset.click.left = obj.left + this.margins.left;
  3637. }
  3638. if ("right" in obj) {
  3639. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  3640. }
  3641. if ("top" in obj) {
  3642. this.offset.click.top = obj.top + this.margins.top;
  3643. }
  3644. if ("bottom" in obj) {
  3645. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  3646. }
  3647. },
  3648. _getParentOffset: function() {
  3649. //Get the offsetParent and cache its position
  3650. this.offsetParent = this.helper.offsetParent();
  3651. var po = this.offsetParent.offset();
  3652. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  3653. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  3654. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  3655. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  3656. if(this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  3657. po.left += this.scrollParent.scrollLeft();
  3658. po.top += this.scrollParent.scrollTop();
  3659. }
  3660. // This needs to be actually done for all browsers, since pageX/pageY includes this information
  3661. // with an ugly IE fix
  3662. if( this.offsetParent[0] === document.body || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
  3663. po = { top: 0, left: 0 };
  3664. }
  3665. return {
  3666. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"),10) || 0),
  3667. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"),10) || 0)
  3668. };
  3669. },
  3670. _getRelativeOffset: function() {
  3671. if(this.cssPosition === "relative") {
  3672. var p = this.currentItem.position();
  3673. return {
  3674. top: p.top - (parseInt(this.helper.css("top"),10) || 0) + this.scrollParent.scrollTop(),
  3675. left: p.left - (parseInt(this.helper.css("left"),10) || 0) + this.scrollParent.scrollLeft()
  3676. };
  3677. } else {
  3678. return { top: 0, left: 0 };
  3679. }
  3680. },
  3681. _cacheMargins: function() {
  3682. this.margins = {
  3683. left: (parseInt(this.currentItem.css("marginLeft"),10) || 0),
  3684. top: (parseInt(this.currentItem.css("marginTop"),10) || 0)
  3685. };
  3686. },
  3687. _cacheHelperProportions: function() {
  3688. this.helperProportions = {
  3689. width: this.helper.outerWidth(),
  3690. height: this.helper.outerHeight()
  3691. };
  3692. },
  3693. _setContainment: function() {
  3694. var ce, co, over,
  3695. o = this.options;
  3696. if(o.containment === "parent") {
  3697. o.containment = this.helper[0].parentNode;
  3698. }
  3699. if(o.containment === "document" || o.containment === "window") {
  3700. this.containment = [
  3701. 0 - this.offset.relative.left - this.offset.parent.left,
  3702. 0 - this.offset.relative.top - this.offset.parent.top,
  3703. $(o.containment === "document" ? document : window).width() - this.helperProportions.width - this.margins.left,
  3704. ($(o.containment === "document" ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
  3705. ];
  3706. }
  3707. if(!(/^(document|window|parent)$/).test(o.containment)) {
  3708. ce = $(o.containment)[0];
  3709. co = $(o.containment).offset();
  3710. over = ($(ce).css("overflow") !== "hidden");
  3711. this.containment = [
  3712. co.left + (parseInt($(ce).css("borderLeftWidth"),10) || 0) + (parseInt($(ce).css("paddingLeft"),10) || 0) - this.margins.left,
  3713. co.top + (parseInt($(ce).css("borderTopWidth"),10) || 0) + (parseInt($(ce).css("paddingTop"),10) || 0) - this.margins.top,
  3714. 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,
  3715. 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
  3716. ];
  3717. }
  3718. },
  3719. _convertPositionTo: function(d, pos) {
  3720. if(!pos) {
  3721. pos = this.position;
  3722. }
  3723. var mod = d === "absolute" ? 1 : -1,
  3724. scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
  3725. scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
  3726. return {
  3727. top: (
  3728. pos.top + // The absolute mouse position
  3729. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  3730. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  3731. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod)
  3732. ),
  3733. left: (
  3734. pos.left + // The absolute mouse position
  3735. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  3736. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  3737. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ) * mod)
  3738. )
  3739. };
  3740. },
  3741. _generatePosition: function(event) {
  3742. var top, left,
  3743. o = this.options,
  3744. pageX = event.pageX,
  3745. pageY = event.pageY,
  3746. 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);
  3747. // This is another very weird special case that only happens for relative elements:
  3748. // 1. If the css position is relative
  3749. // 2. and the scroll parent is the document or similar to the offset parent
  3750. // we have to refresh the relative offset during the scroll so there are no jumps
  3751. if(this.cssPosition === "relative" && !(this.scrollParent[0] !== document && this.scrollParent[0] !== this.offsetParent[0])) {
  3752. this.offset.relative = this._getRelativeOffset();
  3753. }
  3754. /*
  3755. * - Position constraining -
  3756. * Constrain the position to a mix of grid, containment.
  3757. */
  3758. if(this.originalPosition) { //If we are not dragging yet, we won't check for options
  3759. if(this.containment) {
  3760. if(event.pageX - this.offset.click.left < this.containment[0]) {
  3761. pageX = this.containment[0] + this.offset.click.left;
  3762. }
  3763. if(event.pageY - this.offset.click.top < this.containment[1]) {
  3764. pageY = this.containment[1] + this.offset.click.top;
  3765. }
  3766. if(event.pageX - this.offset.click.left > this.containment[2]) {
  3767. pageX = this.containment[2] + this.offset.click.left;
  3768. }
  3769. if(event.pageY - this.offset.click.top > this.containment[3]) {
  3770. pageY = this.containment[3] + this.offset.click.top;
  3771. }
  3772. }
  3773. if(o.grid) {
  3774. top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
  3775. 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;
  3776. left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
  3777. 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;
  3778. }
  3779. }
  3780. return {
  3781. top: (
  3782. pageY - // The absolute mouse position
  3783. this.offset.click.top - // Click offset (relative to the element)
  3784. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  3785. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  3786. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ))
  3787. ),
  3788. left: (
  3789. pageX - // The absolute mouse position
  3790. this.offset.click.left - // Click offset (relative to the element)
  3791. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  3792. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  3793. ( ( this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft() ))
  3794. )
  3795. };
  3796. },
  3797. _rearrange: function(event, i, a, hardRefresh) {
  3798. 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));
  3799. //Various things done here to improve the performance:
  3800. // 1. we create a setTimeout, that calls refreshPositions
  3801. // 2. on the instance, we have a counter variable, that get's higher after every append
  3802. // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
  3803. // 4. this lets only the last addition to the timeout stack through
  3804. this.counter = this.counter ? ++this.counter : 1;
  3805. var counter = this.counter;
  3806. this._delay(function() {
  3807. if(counter === this.counter) {
  3808. this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
  3809. }
  3810. });
  3811. },
  3812. _clear: function(event, noPropagation) {
  3813. this.reverting = false;
  3814. // We delay all events that have to be triggered to after the point where the placeholder has been removed and
  3815. // everything else normalized again
  3816. var i,
  3817. delayedTriggers = [];
  3818. // We first have to update the dom position of the actual currentItem
  3819. // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
  3820. if(!this._noFinalSort && this.currentItem.parent().length) {
  3821. this.placeholder.before(this.currentItem);
  3822. }
  3823. this._noFinalSort = null;
  3824. if(this.helper[0] === this.currentItem[0]) {
  3825. for(i in this._storedCSS) {
  3826. if(this._storedCSS[i] === "auto" || this._storedCSS[i] === "static") {
  3827. this._storedCSS[i] = "";
  3828. }
  3829. }
  3830. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  3831. } else {
  3832. this.currentItem.show();
  3833. }
  3834. if(this.fromOutside && !noPropagation) {
  3835. delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
  3836. }
  3837. if((this.fromOutside || this.domPosition.prev !== this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent !== this.currentItem.parent()[0]) && !noPropagation) {
  3838. delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
  3839. }
  3840. // Check if the items Container has Changed and trigger appropriate
  3841. // events.
  3842. if (this !== this.currentContainer) {
  3843. if(!noPropagation) {
  3844. delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
  3845. delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  3846. delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  3847. }
  3848. }
  3849. //Post events to containers
  3850. for (i = this.containers.length - 1; i >= 0; i--){
  3851. if(!noPropagation) {
  3852. delayedTriggers.push((function(c) { return function(event) { c._trigger("deactivate", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
  3853. }
  3854. if(this.containers[i].containerCache.over) {
  3855. delayedTriggers.push((function(c) { return function(event) { c._trigger("out", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
  3856. this.containers[i].containerCache.over = 0;
  3857. }
  3858. }
  3859. //Do what was originally in plugins
  3860. if ( this.storedCursor ) {
  3861. this.document.find( "body" ).css( "cursor", this.storedCursor );
  3862. this.storedStylesheet.remove();
  3863. }
  3864. if(this._storedOpacity) {
  3865. this.helper.css("opacity", this._storedOpacity);
  3866. }
  3867. if(this._storedZIndex) {
  3868. this.helper.css("zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex);
  3869. }
  3870. this.dragging = false;
  3871. if(this.cancelHelperRemoval) {
  3872. if(!noPropagation) {
  3873. this._trigger("beforeStop", event, this._uiHash());
  3874. for (i=0; i < delayedTriggers.length; i++) {
  3875. delayedTriggers[i].call(this, event);
  3876. } //Trigger all delayed events
  3877. this._trigger("stop", event, this._uiHash());
  3878. }
  3879. this.fromOutside = false;
  3880. return false;
  3881. }
  3882. if(!noPropagation) {
  3883. this._trigger("beforeStop", event, this._uiHash());
  3884. }
  3885. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  3886. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  3887. if(this.helper[0] !== this.currentItem[0]) {
  3888. this.helper.remove();
  3889. }
  3890. this.helper = null;
  3891. if(!noPropagation) {
  3892. for (i=0; i < delayedTriggers.length; i++) {
  3893. delayedTriggers[i].call(this, event);
  3894. } //Trigger all delayed events
  3895. this._trigger("stop", event, this._uiHash());
  3896. }
  3897. this.fromOutside = false;
  3898. return true;
  3899. },
  3900. _trigger: function() {
  3901. if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
  3902. this.cancel();
  3903. }
  3904. },
  3905. _uiHash: function(_inst) {
  3906. var inst = _inst || this;
  3907. return {
  3908. helper: inst.helper,
  3909. placeholder: inst.placeholder || $([]),
  3910. position: inst.position,
  3911. originalPosition: inst.originalPosition,
  3912. offset: inst.positionAbs,
  3913. item: inst.currentItem,
  3914. sender: _inst ? _inst.element : null
  3915. };
  3916. }
  3917. });
  3918. })(jQuery);
  3919. (function($, undefined) {
  3920. var dataSpace = "ui-effects-";
  3921. $.effects = {
  3922. effect: {}
  3923. };
  3924. /*!
  3925. * jQuery Color Animations v2.1.2
  3926. * https://github.com/jquery/jquery-color
  3927. *
  3928. * Copyright 2013 jQuery Foundation and other contributors
  3929. * Released under the MIT license.
  3930. * http://jquery.org/license
  3931. *
  3932. * Date: Wed Jan 16 08:47:09 2013 -0600
  3933. */
  3934. (function( jQuery, undefined ) {
  3935. var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
  3936. // plusequals test for += 100 -= 100
  3937. rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
  3938. // a set of RE's that can match strings and generate color tuples.
  3939. stringParsers = [{
  3940. re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  3941. parse: function( execResult ) {
  3942. return [
  3943. execResult[ 1 ],
  3944. execResult[ 2 ],
  3945. execResult[ 3 ],
  3946. execResult[ 4 ]
  3947. ];
  3948. }
  3949. }, {
  3950. re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  3951. parse: function( execResult ) {
  3952. return [
  3953. execResult[ 1 ] * 2.55,
  3954. execResult[ 2 ] * 2.55,
  3955. execResult[ 3 ] * 2.55,
  3956. execResult[ 4 ]
  3957. ];
  3958. }
  3959. }, {
  3960. // this regex ignores A-F because it's compared against an already lowercased string
  3961. re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
  3962. parse: function( execResult ) {
  3963. return [
  3964. parseInt( execResult[ 1 ], 16 ),
  3965. parseInt( execResult[ 2 ], 16 ),
  3966. parseInt( execResult[ 3 ], 16 )
  3967. ];
  3968. }
  3969. }, {
  3970. // this regex ignores A-F because it's compared against an already lowercased string
  3971. re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
  3972. parse: function( execResult ) {
  3973. return [
  3974. parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
  3975. parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
  3976. parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
  3977. ];
  3978. }
  3979. }, {
  3980. re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  3981. space: "hsla",
  3982. parse: function( execResult ) {
  3983. return [
  3984. execResult[ 1 ],
  3985. execResult[ 2 ] / 100,
  3986. execResult[ 3 ] / 100,
  3987. execResult[ 4 ]
  3988. ];
  3989. }
  3990. }],
  3991. // jQuery.Color( )
  3992. color = jQuery.Color = function( color, green, blue, alpha ) {
  3993. return new jQuery.Color.fn.parse( color, green, blue, alpha );
  3994. },
  3995. spaces = {
  3996. rgba: {
  3997. props: {
  3998. red: {
  3999. idx: 0,
  4000. type: "byte"
  4001. },
  4002. green: {
  4003. idx: 1,
  4004. type: "byte"
  4005. },
  4006. blue: {
  4007. idx: 2,
  4008. type: "byte"
  4009. }
  4010. }
  4011. },
  4012. hsla: {
  4013. props: {
  4014. hue: {
  4015. idx: 0,
  4016. type: "degrees"
  4017. },
  4018. saturation: {
  4019. idx: 1,
  4020. type: "percent"
  4021. },
  4022. lightness: {
  4023. idx: 2,
  4024. type: "percent"
  4025. }
  4026. }
  4027. }
  4028. },
  4029. propTypes = {
  4030. "byte": {
  4031. floor: true,
  4032. max: 255
  4033. },
  4034. "percent": {
  4035. max: 1
  4036. },
  4037. "degrees": {
  4038. mod: 360,
  4039. floor: true
  4040. }
  4041. },
  4042. support = color.support = {},
  4043. // element for support tests
  4044. supportElem = jQuery( "<p>" )[ 0 ],
  4045. // colors = jQuery.Color.names
  4046. colors,
  4047. // local aliases of functions called often
  4048. each = jQuery.each;
  4049. // determine rgba support immediately
  4050. supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
  4051. support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
  4052. // define cache name and alpha properties
  4053. // for rgba and hsla spaces
  4054. each( spaces, function( spaceName, space ) {
  4055. space.cache = "_" + spaceName;
  4056. space.props.alpha = {
  4057. idx: 3,
  4058. type: "percent",
  4059. def: 1
  4060. };
  4061. });
  4062. function clamp( value, prop, allowEmpty ) {
  4063. var type = propTypes[ prop.type ] || {};
  4064. if ( value == null ) {
  4065. return (allowEmpty || !prop.def) ? null : prop.def;
  4066. }
  4067. // ~~ is an short way of doing floor for positive numbers
  4068. value = type.floor ? ~~value : parseFloat( value );
  4069. // IE will pass in empty strings as value for alpha,
  4070. // which will hit this case
  4071. if ( isNaN( value ) ) {
  4072. return prop.def;
  4073. }
  4074. if ( type.mod ) {
  4075. // we add mod before modding to make sure that negatives values
  4076. // get converted properly: -10 -> 350
  4077. return (value + type.mod) % type.mod;
  4078. }
  4079. // for now all property types without mod have min and max
  4080. return 0 > value ? 0 : type.max < value ? type.max : value;
  4081. }
  4082. function stringParse( string ) {
  4083. var inst = color(),
  4084. rgba = inst._rgba = [];
  4085. string = string.toLowerCase();
  4086. each( stringParsers, function( i, parser ) {
  4087. var parsed,
  4088. match = parser.re.exec( string ),
  4089. values = match && parser.parse( match ),
  4090. spaceName = parser.space || "rgba";
  4091. if ( values ) {
  4092. parsed = inst[ spaceName ]( values );
  4093. // if this was an rgba parse the assignment might happen twice
  4094. // oh well....
  4095. inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
  4096. rgba = inst._rgba = parsed._rgba;
  4097. // exit each( stringParsers ) here because we matched
  4098. return false;
  4099. }
  4100. });
  4101. // Found a stringParser that handled it
  4102. if ( rgba.length ) {
  4103. // if this came from a parsed string, force "transparent" when alpha is 0
  4104. // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
  4105. if ( rgba.join() === "0,0,0,0" ) {
  4106. jQuery.extend( rgba, colors.transparent );
  4107. }
  4108. return inst;
  4109. }
  4110. // named colors
  4111. return colors[ string ];
  4112. }
  4113. color.fn = jQuery.extend( color.prototype, {
  4114. parse: function( red, green, blue, alpha ) {
  4115. if ( red === undefined ) {
  4116. this._rgba = [ null, null, null, null ];
  4117. return this;
  4118. }
  4119. if ( red.jquery || red.nodeType ) {
  4120. red = jQuery( red ).css( green );
  4121. green = undefined;
  4122. }
  4123. var inst = this,
  4124. type = jQuery.type( red ),
  4125. rgba = this._rgba = [];
  4126. // more than 1 argument specified - assume ( red, green, blue, alpha )
  4127. if ( green !== undefined ) {
  4128. red = [ red, green, blue, alpha ];
  4129. type = "array";
  4130. }
  4131. if ( type === "string" ) {
  4132. return this.parse( stringParse( red ) || colors._default );
  4133. }
  4134. if ( type === "array" ) {
  4135. each( spaces.rgba.props, function( key, prop ) {
  4136. rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
  4137. });
  4138. return this;
  4139. }
  4140. if ( type === "object" ) {
  4141. if ( red instanceof color ) {
  4142. each( spaces, function( spaceName, space ) {
  4143. if ( red[ space.cache ] ) {
  4144. inst[ space.cache ] = red[ space.cache ].slice();
  4145. }
  4146. });
  4147. } else {
  4148. each( spaces, function( spaceName, space ) {
  4149. var cache = space.cache;
  4150. each( space.props, function( key, prop ) {
  4151. // if the cache doesn't exist, and we know how to convert
  4152. if ( !inst[ cache ] && space.to ) {
  4153. // if the value was null, we don't need to copy it
  4154. // if the key was alpha, we don't need to copy it either
  4155. if ( key === "alpha" || red[ key ] == null ) {
  4156. return;
  4157. }
  4158. inst[ cache ] = space.to( inst._rgba );
  4159. }
  4160. // this is the only case where we allow nulls for ALL properties.
  4161. // call clamp with alwaysAllowEmpty
  4162. inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
  4163. });
  4164. // everything defined but alpha?
  4165. if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
  4166. // use the default of 1
  4167. inst[ cache ][ 3 ] = 1;
  4168. if ( space.from ) {
  4169. inst._rgba = space.from( inst[ cache ] );
  4170. }
  4171. }
  4172. });
  4173. }
  4174. return this;
  4175. }
  4176. },
  4177. is: function( compare ) {
  4178. var is = color( compare ),
  4179. same = true,
  4180. inst = this;
  4181. each( spaces, function( _, space ) {
  4182. var localCache,
  4183. isCache = is[ space.cache ];
  4184. if (isCache) {
  4185. localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
  4186. each( space.props, function( _, prop ) {
  4187. if ( isCache[ prop.idx ] != null ) {
  4188. same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
  4189. return same;
  4190. }
  4191. });
  4192. }
  4193. return same;
  4194. });
  4195. return same;
  4196. },
  4197. _space: function() {
  4198. var used = [],
  4199. inst = this;
  4200. each( spaces, function( spaceName, space ) {
  4201. if ( inst[ space.cache ] ) {
  4202. used.push( spaceName );
  4203. }
  4204. });
  4205. return used.pop();
  4206. },
  4207. transition: function( other, distance ) {
  4208. var end = color( other ),
  4209. spaceName = end._space(),
  4210. space = spaces[ spaceName ],
  4211. startColor = this.alpha() === 0 ? color( "transparent" ) : this,
  4212. start = startColor[ space.cache ] || space.to( startColor._rgba ),
  4213. result = start.slice();
  4214. end = end[ space.cache ];
  4215. each( space.props, function( key, prop ) {
  4216. var index = prop.idx,
  4217. startValue = start[ index ],
  4218. endValue = end[ index ],
  4219. type = propTypes[ prop.type ] || {};
  4220. // if null, don't override start value
  4221. if ( endValue === null ) {
  4222. return;
  4223. }
  4224. // if null - use end
  4225. if ( startValue === null ) {
  4226. result[ index ] = endValue;
  4227. } else {
  4228. if ( type.mod ) {
  4229. if ( endValue - startValue > type.mod / 2 ) {
  4230. startValue += type.mod;
  4231. } else if ( startValue - endValue > type.mod / 2 ) {
  4232. startValue -= type.mod;
  4233. }
  4234. }
  4235. result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
  4236. }
  4237. });
  4238. return this[ spaceName ]( result );
  4239. },
  4240. blend: function( opaque ) {
  4241. // if we are already opaque - return ourself
  4242. if ( this._rgba[ 3 ] === 1 ) {
  4243. return this;
  4244. }
  4245. var rgb = this._rgba.slice(),
  4246. a = rgb.pop(),
  4247. blend = color( opaque )._rgba;
  4248. return color( jQuery.map( rgb, function( v, i ) {
  4249. return ( 1 - a ) * blend[ i ] + a * v;
  4250. }));
  4251. },
  4252. toRgbaString: function() {
  4253. var prefix = "rgba(",
  4254. rgba = jQuery.map( this._rgba, function( v, i ) {
  4255. return v == null ? ( i > 2 ? 1 : 0 ) : v;
  4256. });
  4257. if ( rgba[ 3 ] === 1 ) {
  4258. rgba.pop();
  4259. prefix = "rgb(";
  4260. }
  4261. return prefix + rgba.join() + ")";
  4262. },
  4263. toHslaString: function() {
  4264. var prefix = "hsla(",
  4265. hsla = jQuery.map( this.hsla(), function( v, i ) {
  4266. if ( v == null ) {
  4267. v = i > 2 ? 1 : 0;
  4268. }
  4269. // catch 1 and 2
  4270. if ( i && i < 3 ) {
  4271. v = Math.round( v * 100 ) + "%";
  4272. }
  4273. return v;
  4274. });
  4275. if ( hsla[ 3 ] === 1 ) {
  4276. hsla.pop();
  4277. prefix = "hsl(";
  4278. }
  4279. return prefix + hsla.join() + ")";
  4280. },
  4281. toHexString: function( includeAlpha ) {
  4282. var rgba = this._rgba.slice(),
  4283. alpha = rgba.pop();
  4284. if ( includeAlpha ) {
  4285. rgba.push( ~~( alpha * 255 ) );
  4286. }
  4287. return "#" + jQuery.map( rgba, function( v ) {
  4288. // default to 0 when nulls exist
  4289. v = ( v || 0 ).toString( 16 );
  4290. return v.length === 1 ? "0" + v : v;
  4291. }).join("");
  4292. },
  4293. toString: function() {
  4294. return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
  4295. }
  4296. });
  4297. color.fn.parse.prototype = color.fn;
  4298. // hsla conversions adapted from:
  4299. // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
  4300. function hue2rgb( p, q, h ) {
  4301. h = ( h + 1 ) % 1;
  4302. if ( h * 6 < 1 ) {
  4303. return p + (q - p) * h * 6;
  4304. }
  4305. if ( h * 2 < 1) {
  4306. return q;
  4307. }
  4308. if ( h * 3 < 2 ) {
  4309. return p + (q - p) * ((2/3) - h) * 6;
  4310. }
  4311. return p;
  4312. }
  4313. spaces.hsla.to = function ( rgba ) {
  4314. if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
  4315. return [ null, null, null, rgba[ 3 ] ];
  4316. }
  4317. var r = rgba[ 0 ] / 255,
  4318. g = rgba[ 1 ] / 255,
  4319. b = rgba[ 2 ] / 255,
  4320. a = rgba[ 3 ],
  4321. max = Math.max( r, g, b ),
  4322. min = Math.min( r, g, b ),
  4323. diff = max - min,
  4324. add = max + min,
  4325. l = add * 0.5,
  4326. h, s;
  4327. if ( min === max ) {
  4328. h = 0;
  4329. } else if ( r === max ) {
  4330. h = ( 60 * ( g - b ) / diff ) + 360;
  4331. } else if ( g === max ) {
  4332. h = ( 60 * ( b - r ) / diff ) + 120;
  4333. } else {
  4334. h = ( 60 * ( r - g ) / diff ) + 240;
  4335. }
  4336. // chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
  4337. // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
  4338. if ( diff === 0 ) {
  4339. s = 0;
  4340. } else if ( l <= 0.5 ) {
  4341. s = diff / add;
  4342. } else {
  4343. s = diff / ( 2 - add );
  4344. }
  4345. return [ Math.round(h) % 360, s, l, a == null ? 1 : a ];
  4346. };
  4347. spaces.hsla.from = function ( hsla ) {
  4348. if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
  4349. return [ null, null, null, hsla[ 3 ] ];
  4350. }
  4351. var h = hsla[ 0 ] / 360,
  4352. s = hsla[ 1 ],
  4353. l = hsla[ 2 ],
  4354. a = hsla[ 3 ],
  4355. q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
  4356. p = 2 * l - q;
  4357. return [
  4358. Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
  4359. Math.round( hue2rgb( p, q, h ) * 255 ),
  4360. Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
  4361. a
  4362. ];
  4363. };
  4364. each( spaces, function( spaceName, space ) {
  4365. var props = space.props,
  4366. cache = space.cache,
  4367. to = space.to,
  4368. from = space.from;
  4369. // makes rgba() and hsla()
  4370. color.fn[ spaceName ] = function( value ) {
  4371. // generate a cache for this space if it doesn't exist
  4372. if ( to && !this[ cache ] ) {
  4373. this[ cache ] = to( this._rgba );
  4374. }
  4375. if ( value === undefined ) {
  4376. return this[ cache ].slice();
  4377. }
  4378. var ret,
  4379. type = jQuery.type( value ),
  4380. arr = ( type === "array" || type === "object" ) ? value : arguments,
  4381. local = this[ cache ].slice();
  4382. each( props, function( key, prop ) {
  4383. var val = arr[ type === "object" ? key : prop.idx ];
  4384. if ( val == null ) {
  4385. val = local[ prop.idx ];
  4386. }
  4387. local[ prop.idx ] = clamp( val, prop );
  4388. });
  4389. if ( from ) {
  4390. ret = color( from( local ) );
  4391. ret[ cache ] = local;
  4392. return ret;
  4393. } else {
  4394. return color( local );
  4395. }
  4396. };
  4397. // makes red() green() blue() alpha() hue() saturation() lightness()
  4398. each( props, function( key, prop ) {
  4399. // alpha is included in more than one space
  4400. if ( color.fn[ key ] ) {
  4401. return;
  4402. }
  4403. color.fn[ key ] = function( value ) {
  4404. var vtype = jQuery.type( value ),
  4405. fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
  4406. local = this[ fn ](),
  4407. cur = local[ prop.idx ],
  4408. match;
  4409. if ( vtype === "undefined" ) {
  4410. return cur;
  4411. }
  4412. if ( vtype === "function" ) {
  4413. value = value.call( this, cur );
  4414. vtype = jQuery.type( value );
  4415. }
  4416. if ( value == null && prop.empty ) {
  4417. return this;
  4418. }
  4419. if ( vtype === "string" ) {
  4420. match = rplusequals.exec( value );
  4421. if ( match ) {
  4422. value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
  4423. }
  4424. }
  4425. local[ prop.idx ] = value;
  4426. return this[ fn ]( local );
  4427. };
  4428. });
  4429. });
  4430. // add cssHook and .fx.step function for each named hook.
  4431. // accept a space separated string of properties
  4432. color.hook = function( hook ) {
  4433. var hooks = hook.split( " " );
  4434. each( hooks, function( i, hook ) {
  4435. jQuery.cssHooks[ hook ] = {
  4436. set: function( elem, value ) {
  4437. var parsed, curElem,
  4438. backgroundColor = "";
  4439. if ( value !== "transparent" && ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) ) {
  4440. value = color( parsed || value );
  4441. if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
  4442. curElem = hook === "backgroundColor" ? elem.parentNode : elem;
  4443. while (
  4444. (backgroundColor === "" || backgroundColor === "transparent") &&
  4445. curElem && curElem.style
  4446. ) {
  4447. try {
  4448. backgroundColor = jQuery.css( curElem, "backgroundColor" );
  4449. curElem = curElem.parentNode;
  4450. } catch ( e ) {
  4451. }
  4452. }
  4453. value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
  4454. backgroundColor :
  4455. "_default" );
  4456. }
  4457. value = value.toRgbaString();
  4458. }
  4459. try {
  4460. elem.style[ hook ] = value;
  4461. } catch( e ) {
  4462. // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
  4463. }
  4464. }
  4465. };
  4466. jQuery.fx.step[ hook ] = function( fx ) {
  4467. if ( !fx.colorInit ) {
  4468. fx.start = color( fx.elem, hook );
  4469. fx.end = color( fx.end );
  4470. fx.colorInit = true;
  4471. }
  4472. jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
  4473. };
  4474. });
  4475. };
  4476. color.hook( stepHooks );
  4477. jQuery.cssHooks.borderColor = {
  4478. expand: function( value ) {
  4479. var expanded = {};
  4480. each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
  4481. expanded[ "border" + part + "Color" ] = value;
  4482. });
  4483. return expanded;
  4484. }
  4485. };
  4486. // Basic color names only.
  4487. // Usage of any of the other color names requires adding yourself or including
  4488. // jquery.color.svg-names.js.
  4489. colors = jQuery.Color.names = {
  4490. // 4.1. Basic color keywords
  4491. aqua: "#00ffff",
  4492. black: "#000000",
  4493. blue: "#0000ff",
  4494. fuchsia: "#ff00ff",
  4495. gray: "#808080",
  4496. green: "#008000",
  4497. lime: "#00ff00",
  4498. maroon: "#800000",
  4499. navy: "#000080",
  4500. olive: "#808000",
  4501. purple: "#800080",
  4502. red: "#ff0000",
  4503. silver: "#c0c0c0",
  4504. teal: "#008080",
  4505. white: "#ffffff",
  4506. yellow: "#ffff00",
  4507. // 4.2.3. "transparent" color keyword
  4508. transparent: [ null, null, null, 0 ],
  4509. _default: "#ffffff"
  4510. };
  4511. })( jQuery );
  4512. /******************************************************************************/
  4513. /****************************** CLASS ANIMATIONS ******************************/
  4514. /******************************************************************************/
  4515. (function() {
  4516. var classAnimationActions = [ "add", "remove", "toggle" ],
  4517. shorthandStyles = {
  4518. border: 1,
  4519. borderBottom: 1,
  4520. borderColor: 1,
  4521. borderLeft: 1,
  4522. borderRight: 1,
  4523. borderTop: 1,
  4524. borderWidth: 1,
  4525. margin: 1,
  4526. padding: 1
  4527. };
  4528. $.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) {
  4529. $.fx.step[ prop ] = function( fx ) {
  4530. if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
  4531. jQuery.style( fx.elem, prop, fx.end );
  4532. fx.setAttr = true;
  4533. }
  4534. };
  4535. });
  4536. function getElementStyles( elem ) {
  4537. var key, len,
  4538. style = elem.ownerDocument.defaultView ?
  4539. elem.ownerDocument.defaultView.getComputedStyle( elem, null ) :
  4540. elem.currentStyle,
  4541. styles = {};
  4542. if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
  4543. len = style.length;
  4544. while ( len-- ) {
  4545. key = style[ len ];
  4546. if ( typeof style[ key ] === "string" ) {
  4547. styles[ $.camelCase( key ) ] = style[ key ];
  4548. }
  4549. }
  4550. // support: Opera, IE <9
  4551. } else {
  4552. for ( key in style ) {
  4553. if ( typeof style[ key ] === "string" ) {
  4554. styles[ key ] = style[ key ];
  4555. }
  4556. }
  4557. }
  4558. return styles;
  4559. }
  4560. function styleDifference( oldStyle, newStyle ) {
  4561. var diff = {},
  4562. name, value;
  4563. for ( name in newStyle ) {
  4564. value = newStyle[ name ];
  4565. if ( oldStyle[ name ] !== value ) {
  4566. if ( !shorthandStyles[ name ] ) {
  4567. if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
  4568. diff[ name ] = value;
  4569. }
  4570. }
  4571. }
  4572. }
  4573. return diff;
  4574. }
  4575. // support: jQuery <1.8
  4576. if ( !$.fn.addBack ) {
  4577. $.fn.addBack = function( selector ) {
  4578. return this.add( selector == null ?
  4579. this.prevObject : this.prevObject.filter( selector )
  4580. );
  4581. };
  4582. }
  4583. $.effects.animateClass = function( value, duration, easing, callback ) {
  4584. var o = $.speed( duration, easing, callback );
  4585. return this.queue( function() {
  4586. var animated = $( this ),
  4587. baseClass = animated.attr( "class" ) || "",
  4588. applyClassChange,
  4589. allAnimations = o.children ? animated.find( "*" ).addBack() : animated;
  4590. // map the animated objects to store the original styles.
  4591. allAnimations = allAnimations.map(function() {
  4592. var el = $( this );
  4593. return {
  4594. el: el,
  4595. start: getElementStyles( this )
  4596. };
  4597. });
  4598. // apply class change
  4599. applyClassChange = function() {
  4600. $.each( classAnimationActions, function(i, action) {
  4601. if ( value[ action ] ) {
  4602. animated[ action + "Class" ]( value[ action ] );
  4603. }
  4604. });
  4605. };
  4606. applyClassChange();
  4607. // map all animated objects again - calculate new styles and diff
  4608. allAnimations = allAnimations.map(function() {
  4609. this.end = getElementStyles( this.el[ 0 ] );
  4610. this.diff = styleDifference( this.start, this.end );
  4611. return this;
  4612. });
  4613. // apply original class
  4614. animated.attr( "class", baseClass );
  4615. // map all animated objects again - this time collecting a promise
  4616. allAnimations = allAnimations.map(function() {
  4617. var styleInfo = this,
  4618. dfd = $.Deferred(),
  4619. opts = $.extend({}, o, {
  4620. queue: false,
  4621. complete: function() {
  4622. dfd.resolve( styleInfo );
  4623. }
  4624. });
  4625. this.el.animate( this.diff, opts );
  4626. return dfd.promise();
  4627. });
  4628. // once all animations have completed:
  4629. $.when.apply( $, allAnimations.get() ).done(function() {
  4630. // set the final class
  4631. applyClassChange();
  4632. // for each animated element,
  4633. // clear all css properties that were animated
  4634. $.each( arguments, function() {
  4635. var el = this.el;
  4636. $.each( this.diff, function(key) {
  4637. el.css( key, "" );
  4638. });
  4639. });
  4640. // this is guarnteed to be there if you use jQuery.speed()
  4641. // it also handles dequeuing the next anim...
  4642. o.complete.call( animated[ 0 ] );
  4643. });
  4644. });
  4645. };
  4646. $.fn.extend({
  4647. addClass: (function( orig ) {
  4648. return function( classNames, speed, easing, callback ) {
  4649. return speed ?
  4650. $.effects.animateClass.call( this,
  4651. { add: classNames }, speed, easing, callback ) :
  4652. orig.apply( this, arguments );
  4653. };
  4654. })( $.fn.addClass ),
  4655. removeClass: (function( orig ) {
  4656. return function( classNames, speed, easing, callback ) {
  4657. return arguments.length > 1 ?
  4658. $.effects.animateClass.call( this,
  4659. { remove: classNames }, speed, easing, callback ) :
  4660. orig.apply( this, arguments );
  4661. };
  4662. })( $.fn.removeClass ),
  4663. toggleClass: (function( orig ) {
  4664. return function( classNames, force, speed, easing, callback ) {
  4665. if ( typeof force === "boolean" || force === undefined ) {
  4666. if ( !speed ) {
  4667. // without speed parameter
  4668. return orig.apply( this, arguments );
  4669. } else {
  4670. return $.effects.animateClass.call( this,
  4671. (force ? { add: classNames } : { remove: classNames }),
  4672. speed, easing, callback );
  4673. }
  4674. } else {
  4675. // without force parameter
  4676. return $.effects.animateClass.call( this,
  4677. { toggle: classNames }, force, speed, easing );
  4678. }
  4679. };
  4680. })( $.fn.toggleClass ),
  4681. switchClass: function( remove, add, speed, easing, callback) {
  4682. return $.effects.animateClass.call( this, {
  4683. add: add,
  4684. remove: remove
  4685. }, speed, easing, callback );
  4686. }
  4687. });
  4688. })();
  4689. /******************************************************************************/
  4690. /*********************************** EFFECTS **********************************/
  4691. /******************************************************************************/
  4692. (function() {
  4693. $.extend( $.effects, {
  4694. version: "1.10.3",
  4695. // Saves a set of properties in a data storage
  4696. save: function( element, set ) {
  4697. for( var i=0; i < set.length; i++ ) {
  4698. if ( set[ i ] !== null ) {
  4699. element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
  4700. }
  4701. }
  4702. },
  4703. // Restores a set of previously saved properties from a data storage
  4704. restore: function( element, set ) {
  4705. var val, i;
  4706. for( i=0; i < set.length; i++ ) {
  4707. if ( set[ i ] !== null ) {
  4708. val = element.data( dataSpace + set[ i ] );
  4709. // support: jQuery 1.6.2
  4710. // http://bugs.jquery.com/ticket/9917
  4711. // jQuery 1.6.2 incorrectly returns undefined for any falsy value.
  4712. // We can't differentiate between "" and 0 here, so we just assume
  4713. // empty string since it's likely to be a more common value...
  4714. if ( val === undefined ) {
  4715. val = "";
  4716. }
  4717. element.css( set[ i ], val );
  4718. }
  4719. }
  4720. },
  4721. setMode: function( el, mode ) {
  4722. if (mode === "toggle") {
  4723. mode = el.is( ":hidden" ) ? "show" : "hide";
  4724. }
  4725. return mode;
  4726. },
  4727. // Translates a [top,left] array into a baseline value
  4728. // this should be a little more flexible in the future to handle a string & hash
  4729. getBaseline: function( origin, original ) {
  4730. var y, x;
  4731. switch ( origin[ 0 ] ) {
  4732. case "top": y = 0; break;
  4733. case "middle": y = 0.5; break;
  4734. case "bottom": y = 1; break;
  4735. default: y = origin[ 0 ] / original.height;
  4736. }
  4737. switch ( origin[ 1 ] ) {
  4738. case "left": x = 0; break;
  4739. case "center": x = 0.5; break;
  4740. case "right": x = 1; break;
  4741. default: x = origin[ 1 ] / original.width;
  4742. }
  4743. return {
  4744. x: x,
  4745. y: y
  4746. };
  4747. },
  4748. // Wraps the element around a wrapper that copies position properties
  4749. createWrapper: function( element ) {
  4750. // if the element is already wrapped, return it
  4751. if ( element.parent().is( ".ui-effects-wrapper" )) {
  4752. return element.parent();
  4753. }
  4754. // wrap the element
  4755. var props = {
  4756. width: element.outerWidth(true),
  4757. height: element.outerHeight(true),
  4758. "float": element.css( "float" )
  4759. },
  4760. wrapper = $( "<div></div>" )
  4761. .addClass( "ui-effects-wrapper" )
  4762. .css({
  4763. fontSize: "100%",
  4764. background: "transparent",
  4765. border: "none",
  4766. margin: 0,
  4767. padding: 0
  4768. }),
  4769. // Store the size in case width/height are defined in % - Fixes #5245
  4770. size = {
  4771. width: element.width(),
  4772. height: element.height()
  4773. },
  4774. active = document.activeElement;
  4775. // support: Firefox
  4776. // Firefox incorrectly exposes anonymous content
  4777. // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
  4778. try {
  4779. active.id;
  4780. } catch( e ) {
  4781. active = document.body;
  4782. }
  4783. element.wrap( wrapper );
  4784. // Fixes #7595 - Elements lose focus when wrapped.
  4785. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  4786. $( active ).focus();
  4787. }
  4788. wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element
  4789. // transfer positioning properties to the wrapper
  4790. if ( element.css( "position" ) === "static" ) {
  4791. wrapper.css({ position: "relative" });
  4792. element.css({ position: "relative" });
  4793. } else {
  4794. $.extend( props, {
  4795. position: element.css( "position" ),
  4796. zIndex: element.css( "z-index" )
  4797. });
  4798. $.each([ "top", "left", "bottom", "right" ], function(i, pos) {
  4799. props[ pos ] = element.css( pos );
  4800. if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
  4801. props[ pos ] = "auto";
  4802. }
  4803. });
  4804. element.css({
  4805. position: "relative",
  4806. top: 0,
  4807. left: 0,
  4808. right: "auto",
  4809. bottom: "auto"
  4810. });
  4811. }
  4812. element.css(size);
  4813. return wrapper.css( props ).show();
  4814. },
  4815. removeWrapper: function( element ) {
  4816. var active = document.activeElement;
  4817. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  4818. element.parent().replaceWith( element );
  4819. // Fixes #7595 - Elements lose focus when wrapped.
  4820. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  4821. $( active ).focus();
  4822. }
  4823. }
  4824. return element;
  4825. },
  4826. setTransition: function( element, list, factor, value ) {
  4827. value = value || {};
  4828. $.each( list, function( i, x ) {
  4829. var unit = element.cssUnit( x );
  4830. if ( unit[ 0 ] > 0 ) {
  4831. value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
  4832. }
  4833. });
  4834. return value;
  4835. }
  4836. });
  4837. // return an effect options object for the given parameters:
  4838. function _normalizeArguments( effect, options, speed, callback ) {
  4839. // allow passing all options as the first parameter
  4840. if ( $.isPlainObject( effect ) ) {
  4841. options = effect;
  4842. effect = effect.effect;
  4843. }
  4844. // convert to an object
  4845. effect = { effect: effect };
  4846. // catch (effect, null, ...)
  4847. if ( options == null ) {
  4848. options = {};
  4849. }
  4850. // catch (effect, callback)
  4851. if ( $.isFunction( options ) ) {
  4852. callback = options;
  4853. speed = null;
  4854. options = {};
  4855. }
  4856. // catch (effect, speed, ?)
  4857. if ( typeof options === "number" || $.fx.speeds[ options ] ) {
  4858. callback = speed;
  4859. speed = options;
  4860. options = {};
  4861. }
  4862. // catch (effect, options, callback)
  4863. if ( $.isFunction( speed ) ) {
  4864. callback = speed;
  4865. speed = null;
  4866. }
  4867. // add options to effect
  4868. if ( options ) {
  4869. $.extend( effect, options );
  4870. }
  4871. speed = speed || options.duration;
  4872. effect.duration = $.fx.off ? 0 :
  4873. typeof speed === "number" ? speed :
  4874. speed in $.fx.speeds ? $.fx.speeds[ speed ] :
  4875. $.fx.speeds._default;
  4876. effect.complete = callback || options.complete;
  4877. return effect;
  4878. }
  4879. function standardAnimationOption( option ) {
  4880. // Valid standard speeds (nothing, number, named speed)
  4881. if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) {
  4882. return true;
  4883. }
  4884. // Invalid strings - treat as "normal" speed
  4885. if ( typeof option === "string" && !$.effects.effect[ option ] ) {
  4886. return true;
  4887. }
  4888. // Complete callback
  4889. if ( $.isFunction( option ) ) {
  4890. return true;
  4891. }
  4892. // Options hash (but not naming an effect)
  4893. if ( typeof option === "object" && !option.effect ) {
  4894. return true;
  4895. }
  4896. // Didn't match any standard API
  4897. return false;
  4898. }
  4899. $.fn.extend({
  4900. effect: function( /* effect, options, speed, callback */ ) {
  4901. var args = _normalizeArguments.apply( this, arguments ),
  4902. mode = args.mode,
  4903. queue = args.queue,
  4904. effectMethod = $.effects.effect[ args.effect ];
  4905. if ( $.fx.off || !effectMethod ) {
  4906. // delegate to the original method (e.g., .show()) if possible
  4907. if ( mode ) {
  4908. return this[ mode ]( args.duration, args.complete );
  4909. } else {
  4910. return this.each( function() {
  4911. if ( args.complete ) {
  4912. args.complete.call( this );
  4913. }
  4914. });
  4915. }
  4916. }
  4917. function run( next ) {
  4918. var elem = $( this ),
  4919. complete = args.complete,
  4920. mode = args.mode;
  4921. function done() {
  4922. if ( $.isFunction( complete ) ) {
  4923. complete.call( elem[0] );
  4924. }
  4925. if ( $.isFunction( next ) ) {
  4926. next();
  4927. }
  4928. }
  4929. // If the element already has the correct final state, delegate to
  4930. // the core methods so the internal tracking of "olddisplay" works.
  4931. if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
  4932. elem[ mode ]();
  4933. done();
  4934. } else {
  4935. effectMethod.call( elem[0], args, done );
  4936. }
  4937. }
  4938. return queue === false ? this.each( run ) : this.queue( queue || "fx", run );
  4939. },
  4940. show: (function( orig ) {
  4941. return function( option ) {
  4942. if ( standardAnimationOption( option ) ) {
  4943. return orig.apply( this, arguments );
  4944. } else {
  4945. var args = _normalizeArguments.apply( this, arguments );
  4946. args.mode = "show";
  4947. return this.effect.call( this, args );
  4948. }
  4949. };
  4950. })( $.fn.show ),
  4951. hide: (function( orig ) {
  4952. return function( option ) {
  4953. if ( standardAnimationOption( option ) ) {
  4954. return orig.apply( this, arguments );
  4955. } else {
  4956. var args = _normalizeArguments.apply( this, arguments );
  4957. args.mode = "hide";
  4958. return this.effect.call( this, args );
  4959. }
  4960. };
  4961. })( $.fn.hide ),
  4962. toggle: (function( orig ) {
  4963. return function( option ) {
  4964. if ( standardAnimationOption( option ) || typeof option === "boolean" ) {
  4965. return orig.apply( this, arguments );
  4966. } else {
  4967. var args = _normalizeArguments.apply( this, arguments );
  4968. args.mode = "toggle";
  4969. return this.effect.call( this, args );
  4970. }
  4971. };
  4972. })( $.fn.toggle ),
  4973. // helper functions
  4974. cssUnit: function(key) {
  4975. var style = this.css( key ),
  4976. val = [];
  4977. $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
  4978. if ( style.indexOf( unit ) > 0 ) {
  4979. val = [ parseFloat( style ), unit ];
  4980. }
  4981. });
  4982. return val;
  4983. }
  4984. });
  4985. })();
  4986. /******************************************************************************/
  4987. /*********************************** EASING ***********************************/
  4988. /******************************************************************************/
  4989. (function() {
  4990. // based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
  4991. var baseEasings = {};
  4992. $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
  4993. baseEasings[ name ] = function( p ) {
  4994. return Math.pow( p, i + 2 );
  4995. };
  4996. });
  4997. $.extend( baseEasings, {
  4998. Sine: function ( p ) {
  4999. return 1 - Math.cos( p * Math.PI / 2 );
  5000. },
  5001. Circ: function ( p ) {
  5002. return 1 - Math.sqrt( 1 - p * p );
  5003. },
  5004. Elastic: function( p ) {
  5005. return p === 0 || p === 1 ? p :
  5006. -Math.pow( 2, 8 * (p - 1) ) * Math.sin( ( (p - 1) * 80 - 7.5 ) * Math.PI / 15 );
  5007. },
  5008. Back: function( p ) {
  5009. return p * p * ( 3 * p - 2 );
  5010. },
  5011. Bounce: function ( p ) {
  5012. var pow2,
  5013. bounce = 4;
  5014. while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
  5015. return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
  5016. }
  5017. });
  5018. $.each( baseEasings, function( name, easeIn ) {
  5019. $.easing[ "easeIn" + name ] = easeIn;
  5020. $.easing[ "easeOut" + name ] = function( p ) {
  5021. return 1 - easeIn( 1 - p );
  5022. };
  5023. $.easing[ "easeInOut" + name ] = function( p ) {
  5024. return p < 0.5 ?
  5025. easeIn( p * 2 ) / 2 :
  5026. 1 - easeIn( p * -2 + 2 ) / 2;
  5027. };
  5028. });
  5029. })();
  5030. })(jQuery);
  5031. (function( $, undefined ) {
  5032. var uid = 0,
  5033. hideProps = {},
  5034. showProps = {};
  5035. hideProps.height = hideProps.paddingTop = hideProps.paddingBottom =
  5036. hideProps.borderTopWidth = hideProps.borderBottomWidth = "hide";
  5037. showProps.height = showProps.paddingTop = showProps.paddingBottom =
  5038. showProps.borderTopWidth = showProps.borderBottomWidth = "show";
  5039. $.widget( "ui.accordion", {
  5040. version: "1.10.3",
  5041. options: {
  5042. active: 0,
  5043. animate: {},
  5044. collapsible: false,
  5045. event: "click",
  5046. header: "> li > :first-child,> :not(li):even",
  5047. heightStyle: "auto",
  5048. icons: {
  5049. activeHeader: "ui-icon-triangle-1-s",
  5050. header: "ui-icon-triangle-1-e"
  5051. },
  5052. // callbacks
  5053. activate: null,
  5054. beforeActivate: null
  5055. },
  5056. _create: function() {
  5057. var options = this.options;
  5058. this.prevShow = this.prevHide = $();
  5059. this.element.addClass( "ui-accordion ui-widget ui-helper-reset" )
  5060. // ARIA
  5061. .attr( "role", "tablist" );
  5062. // don't allow collapsible: false and active: false / null
  5063. if ( !options.collapsible && (options.active === false || options.active == null) ) {
  5064. options.active = 0;
  5065. }
  5066. this._processPanels();
  5067. // handle negative values
  5068. if ( options.active < 0 ) {
  5069. options.active += this.headers.length;
  5070. }
  5071. this._refresh();
  5072. },
  5073. _getCreateEventData: function() {
  5074. return {
  5075. header: this.active,
  5076. panel: !this.active.length ? $() : this.active.next(),
  5077. content: !this.active.length ? $() : this.active.next()
  5078. };
  5079. },
  5080. _createIcons: function() {
  5081. var icons = this.options.icons;
  5082. if ( icons ) {
  5083. $( "<span>" )
  5084. .addClass( "ui-accordion-header-icon ui-icon " + icons.header )
  5085. .prependTo( this.headers );
  5086. this.active.children( ".ui-accordion-header-icon" )
  5087. .removeClass( icons.header )
  5088. .addClass( icons.activeHeader );
  5089. this.headers.addClass( "ui-accordion-icons" );
  5090. }
  5091. },
  5092. _destroyIcons: function() {
  5093. this.headers
  5094. .removeClass( "ui-accordion-icons" )
  5095. .children( ".ui-accordion-header-icon" )
  5096. .remove();
  5097. },
  5098. _destroy: function() {
  5099. var contents;
  5100. // clean up main element
  5101. this.element
  5102. .removeClass( "ui-accordion ui-widget ui-helper-reset" )
  5103. .removeAttr( "role" );
  5104. // clean up headers
  5105. this.headers
  5106. .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" )
  5107. .removeAttr( "role" )
  5108. .removeAttr( "aria-selected" )
  5109. .removeAttr( "aria-controls" )
  5110. .removeAttr( "tabIndex" )
  5111. .each(function() {
  5112. if ( /^ui-accordion/.test( this.id ) ) {
  5113. this.removeAttribute( "id" );
  5114. }
  5115. });
  5116. this._destroyIcons();
  5117. // clean up content panels
  5118. contents = this.headers.next()
  5119. .css( "display", "" )
  5120. .removeAttr( "role" )
  5121. .removeAttr( "aria-expanded" )
  5122. .removeAttr( "aria-hidden" )
  5123. .removeAttr( "aria-labelledby" )
  5124. .removeClass( "ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-state-disabled" )
  5125. .each(function() {
  5126. if ( /^ui-accordion/.test( this.id ) ) {
  5127. this.removeAttribute( "id" );
  5128. }
  5129. });
  5130. if ( this.options.heightStyle !== "content" ) {
  5131. contents.css( "height", "" );
  5132. }
  5133. },
  5134. _setOption: function( key, value ) {
  5135. if ( key === "active" ) {
  5136. // _activate() will handle invalid values and update this.options
  5137. this._activate( value );
  5138. return;
  5139. }
  5140. if ( key === "event" ) {
  5141. if ( this.options.event ) {
  5142. this._off( this.headers, this.options.event );
  5143. }
  5144. this._setupEvents( value );
  5145. }
  5146. this._super( key, value );
  5147. // setting collapsible: false while collapsed; open first panel
  5148. if ( key === "collapsible" && !value && this.options.active === false ) {
  5149. this._activate( 0 );
  5150. }
  5151. if ( key === "icons" ) {
  5152. this._destroyIcons();
  5153. if ( value ) {
  5154. this._createIcons();
  5155. }
  5156. }
  5157. // #5332 - opacity doesn't cascade to positioned elements in IE
  5158. // so we need to add the disabled class to the headers and panels
  5159. if ( key === "disabled" ) {
  5160. this.headers.add( this.headers.next() )
  5161. .toggleClass( "ui-state-disabled", !!value );
  5162. }
  5163. },
  5164. _keydown: function( event ) {
  5165. /*jshint maxcomplexity:15*/
  5166. if ( event.altKey || event.ctrlKey ) {
  5167. return;
  5168. }
  5169. var keyCode = $.ui.keyCode,
  5170. length = this.headers.length,
  5171. currentIndex = this.headers.index( event.target ),
  5172. toFocus = false;
  5173. switch ( event.keyCode ) {
  5174. case keyCode.RIGHT:
  5175. case keyCode.DOWN:
  5176. toFocus = this.headers[ ( currentIndex + 1 ) % length ];
  5177. break;
  5178. case keyCode.LEFT:
  5179. case keyCode.UP:
  5180. toFocus = this.headers[ ( currentIndex - 1 + length ) % length ];
  5181. break;
  5182. case keyCode.SPACE:
  5183. case keyCode.ENTER:
  5184. this._eventHandler( event );
  5185. break;
  5186. case keyCode.HOME:
  5187. toFocus = this.headers[ 0 ];
  5188. break;
  5189. case keyCode.END:
  5190. toFocus = this.headers[ length - 1 ];
  5191. break;
  5192. }
  5193. if ( toFocus ) {
  5194. $( event.target ).attr( "tabIndex", -1 );
  5195. $( toFocus ).attr( "tabIndex", 0 );
  5196. toFocus.focus();
  5197. event.preventDefault();
  5198. }
  5199. },
  5200. _panelKeyDown : function( event ) {
  5201. if ( event.keyCode === $.ui.keyCode.UP && event.ctrlKey ) {
  5202. $( event.currentTarget ).prev().focus();
  5203. }
  5204. },
  5205. refresh: function() {
  5206. var options = this.options;
  5207. this._processPanels();
  5208. // was collapsed or no panel
  5209. if ( ( options.active === false && options.collapsible === true ) || !this.headers.length ) {
  5210. options.active = false;
  5211. this.active = $();
  5212. // active false only when collapsible is true
  5213. } else if ( options.active === false ) {
  5214. this._activate( 0 );
  5215. // was active, but active panel is gone
  5216. } else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  5217. // all remaining panel are disabled
  5218. if ( this.headers.length === this.headers.find(".ui-state-disabled").length ) {
  5219. options.active = false;
  5220. this.active = $();
  5221. // activate previous panel
  5222. } else {
  5223. this._activate( Math.max( 0, options.active - 1 ) );
  5224. }
  5225. // was active, active panel still exists
  5226. } else {
  5227. // make sure active index is correct
  5228. options.active = this.headers.index( this.active );
  5229. }
  5230. this._destroyIcons();
  5231. this._refresh();
  5232. },
  5233. _processPanels: function() {
  5234. this.headers = this.element.find( this.options.header )
  5235. .addClass( "ui-accordion-header ui-helper-reset ui-state-default ui-corner-all" );
  5236. this.headers.next()
  5237. .addClass( "ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom" )
  5238. .filter(":not(.ui-accordion-content-active)")
  5239. .hide();
  5240. },
  5241. _refresh: function() {
  5242. var maxHeight,
  5243. options = this.options,
  5244. heightStyle = options.heightStyle,
  5245. parent = this.element.parent(),
  5246. accordionId = this.accordionId = "ui-accordion-" +
  5247. (this.element.attr( "id" ) || ++uid);
  5248. this.active = this._findActive( options.active )
  5249. .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" )
  5250. .removeClass( "ui-corner-all" );
  5251. this.active.next()
  5252. .addClass( "ui-accordion-content-active" )
  5253. .show();
  5254. this.headers
  5255. .attr( "role", "tab" )
  5256. .each(function( i ) {
  5257. var header = $( this ),
  5258. headerId = header.attr( "id" ),
  5259. panel = header.next(),
  5260. panelId = panel.attr( "id" );
  5261. if ( !headerId ) {
  5262. headerId = accordionId + "-header-" + i;
  5263. header.attr( "id", headerId );
  5264. }
  5265. if ( !panelId ) {
  5266. panelId = accordionId + "-panel-" + i;
  5267. panel.attr( "id", panelId );
  5268. }
  5269. header.attr( "aria-controls", panelId );
  5270. panel.attr( "aria-labelledby", headerId );
  5271. })
  5272. .next()
  5273. .attr( "role", "tabpanel" );
  5274. this.headers
  5275. .not( this.active )
  5276. .attr({
  5277. "aria-selected": "false",
  5278. tabIndex: -1
  5279. })
  5280. .next()
  5281. .attr({
  5282. "aria-expanded": "false",
  5283. "aria-hidden": "true"
  5284. })
  5285. .hide();
  5286. // make sure at least one header is in the tab order
  5287. if ( !this.active.length ) {
  5288. this.headers.eq( 0 ).attr( "tabIndex", 0 );
  5289. } else {
  5290. this.active.attr({
  5291. "aria-selected": "true",
  5292. tabIndex: 0
  5293. })
  5294. .next()
  5295. .attr({
  5296. "aria-expanded": "true",
  5297. "aria-hidden": "false"
  5298. });
  5299. }
  5300. this._createIcons();
  5301. this._setupEvents( options.event );
  5302. if ( heightStyle === "fill" ) {
  5303. maxHeight = parent.height();
  5304. this.element.siblings( ":visible" ).each(function() {
  5305. var elem = $( this ),
  5306. position = elem.css( "position" );
  5307. if ( position === "absolute" || position === "fixed" ) {
  5308. return;
  5309. }
  5310. maxHeight -= elem.outerHeight( true );
  5311. });
  5312. this.headers.each(function() {
  5313. maxHeight -= $( this ).outerHeight( true );
  5314. });
  5315. this.headers.next()
  5316. .each(function() {
  5317. $( this ).height( Math.max( 0, maxHeight -
  5318. $( this ).innerHeight() + $( this ).height() ) );
  5319. })
  5320. .css( "overflow", "auto" );
  5321. } else if ( heightStyle === "auto" ) {
  5322. maxHeight = 0;
  5323. this.headers.next()
  5324. .each(function() {
  5325. maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() );
  5326. })
  5327. .height( maxHeight );
  5328. }
  5329. },
  5330. _activate: function( index ) {
  5331. var active = this._findActive( index )[ 0 ];
  5332. // trying to activate the already active panel
  5333. if ( active === this.active[ 0 ] ) {
  5334. return;
  5335. }
  5336. // trying to collapse, simulate a click on the currently active header
  5337. active = active || this.active[ 0 ];
  5338. this._eventHandler({
  5339. target: active,
  5340. currentTarget: active,
  5341. preventDefault: $.noop
  5342. });
  5343. },
  5344. _findActive: function( selector ) {
  5345. return typeof selector === "number" ? this.headers.eq( selector ) : $();
  5346. },
  5347. _setupEvents: function( event ) {
  5348. var events = {
  5349. keydown: "_keydown"
  5350. };
  5351. if ( event ) {
  5352. $.each( event.split(" "), function( index, eventName ) {
  5353. events[ eventName ] = "_eventHandler";
  5354. });
  5355. }
  5356. this._off( this.headers.add( this.headers.next() ) );
  5357. this._on( this.headers, events );
  5358. this._on( this.headers.next(), { keydown: "_panelKeyDown" });
  5359. this._hoverable( this.headers );
  5360. this._focusable( this.headers );
  5361. },
  5362. _eventHandler: function( event ) {
  5363. var options = this.options,
  5364. active = this.active,
  5365. clicked = $( event.currentTarget ),
  5366. clickedIsActive = clicked[ 0 ] === active[ 0 ],
  5367. collapsing = clickedIsActive && options.collapsible,
  5368. toShow = collapsing ? $() : clicked.next(),
  5369. toHide = active.next(),
  5370. eventData = {
  5371. oldHeader: active,
  5372. oldPanel: toHide,
  5373. newHeader: collapsing ? $() : clicked,
  5374. newPanel: toShow
  5375. };
  5376. event.preventDefault();
  5377. if (
  5378. // click on active header, but not collapsible
  5379. ( clickedIsActive && !options.collapsible ) ||
  5380. // allow canceling activation
  5381. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  5382. return;
  5383. }
  5384. options.active = collapsing ? false : this.headers.index( clicked );
  5385. // when the call to ._toggle() comes after the class changes
  5386. // it causes a very odd bug in IE 8 (see #6720)
  5387. this.active = clickedIsActive ? $() : clicked;
  5388. this._toggle( eventData );
  5389. // switch classes
  5390. // corner classes on the previously active header stay after the animation
  5391. active.removeClass( "ui-accordion-header-active ui-state-active" );
  5392. if ( options.icons ) {
  5393. active.children( ".ui-accordion-header-icon" )
  5394. .removeClass( options.icons.activeHeader )
  5395. .addClass( options.icons.header );
  5396. }
  5397. if ( !clickedIsActive ) {
  5398. clicked
  5399. .removeClass( "ui-corner-all" )
  5400. .addClass( "ui-accordion-header-active ui-state-active ui-corner-top" );
  5401. if ( options.icons ) {
  5402. clicked.children( ".ui-accordion-header-icon" )
  5403. .removeClass( options.icons.header )
  5404. .addClass( options.icons.activeHeader );
  5405. }
  5406. clicked
  5407. .next()
  5408. .addClass( "ui-accordion-content-active" );
  5409. }
  5410. },
  5411. _toggle: function( data ) {
  5412. var toShow = data.newPanel,
  5413. toHide = this.prevShow.length ? this.prevShow : data.oldPanel;
  5414. // handle activating a panel during the animation for another activation
  5415. this.prevShow.add( this.prevHide ).stop( true, true );
  5416. this.prevShow = toShow;
  5417. this.prevHide = toHide;
  5418. if ( this.options.animate ) {
  5419. this._animate( toShow, toHide, data );
  5420. } else {
  5421. toHide.hide();
  5422. toShow.show();
  5423. this._toggleComplete( data );
  5424. }
  5425. toHide.attr({
  5426. "aria-expanded": "false",
  5427. "aria-hidden": "true"
  5428. });
  5429. toHide.prev().attr( "aria-selected", "false" );
  5430. // if we're switching panels, remove the old header from the tab order
  5431. // if we're opening from collapsed state, remove the previous header from the tab order
  5432. // if we're collapsing, then keep the collapsing header in the tab order
  5433. if ( toShow.length && toHide.length ) {
  5434. toHide.prev().attr( "tabIndex", -1 );
  5435. } else if ( toShow.length ) {
  5436. this.headers.filter(function() {
  5437. return $( this ).attr( "tabIndex" ) === 0;
  5438. })
  5439. .attr( "tabIndex", -1 );
  5440. }
  5441. toShow
  5442. .attr({
  5443. "aria-expanded": "true",
  5444. "aria-hidden": "false"
  5445. })
  5446. .prev()
  5447. .attr({
  5448. "aria-selected": "true",
  5449. tabIndex: 0
  5450. });
  5451. },
  5452. _animate: function( toShow, toHide, data ) {
  5453. var total, easing, duration,
  5454. that = this,
  5455. adjust = 0,
  5456. down = toShow.length &&
  5457. ( !toHide.length || ( toShow.index() < toHide.index() ) ),
  5458. animate = this.options.animate || {},
  5459. options = down && animate.down || animate,
  5460. complete = function() {
  5461. that._toggleComplete( data );
  5462. };
  5463. if ( typeof options === "number" ) {
  5464. duration = options;
  5465. }
  5466. if ( typeof options === "string" ) {
  5467. easing = options;
  5468. }
  5469. // fall back from options to animation in case of partial down settings
  5470. easing = easing || options.easing || animate.easing;
  5471. duration = duration || options.duration || animate.duration;
  5472. if ( !toHide.length ) {
  5473. return toShow.animate( showProps, duration, easing, complete );
  5474. }
  5475. if ( !toShow.length ) {
  5476. return toHide.animate( hideProps, duration, easing, complete );
  5477. }
  5478. total = toShow.show().outerHeight();
  5479. toHide.animate( hideProps, {
  5480. duration: duration,
  5481. easing: easing,
  5482. step: function( now, fx ) {
  5483. fx.now = Math.round( now );
  5484. }
  5485. });
  5486. toShow
  5487. .hide()
  5488. .animate( showProps, {
  5489. duration: duration,
  5490. easing: easing,
  5491. complete: complete,
  5492. step: function( now, fx ) {
  5493. fx.now = Math.round( now );
  5494. if ( fx.prop !== "height" ) {
  5495. adjust += fx.now;
  5496. } else if ( that.options.heightStyle !== "content" ) {
  5497. fx.now = Math.round( total - toHide.outerHeight() - adjust );
  5498. adjust = 0;
  5499. }
  5500. }
  5501. });
  5502. },
  5503. _toggleComplete: function( data ) {
  5504. var toHide = data.oldPanel;
  5505. toHide
  5506. .removeClass( "ui-accordion-content-active" )
  5507. .prev()
  5508. .removeClass( "ui-corner-top" )
  5509. .addClass( "ui-corner-all" );
  5510. // Work around for rendering bug in IE (#5421)
  5511. if ( toHide.length ) {
  5512. toHide.parent()[0].className = toHide.parent()[0].className;
  5513. }
  5514. this._trigger( "activate", null, data );
  5515. }
  5516. });
  5517. })( jQuery );
  5518. (function( $, undefined ) {
  5519. // used to prevent race conditions with remote data sources
  5520. var requestIndex = 0;
  5521. $.widget( "ui.autocomplete", {
  5522. version: "1.10.3",
  5523. defaultElement: "<input>",
  5524. options: {
  5525. appendTo: null,
  5526. autoFocus: false,
  5527. delay: 300,
  5528. minLength: 1,
  5529. position: {
  5530. my: "left top",
  5531. at: "left bottom",
  5532. collision: "none"
  5533. },
  5534. source: null,
  5535. // callbacks
  5536. change: null,
  5537. close: null,
  5538. focus: null,
  5539. open: null,
  5540. response: null,
  5541. search: null,
  5542. select: null
  5543. },
  5544. pending: 0,
  5545. _create: function() {
  5546. // Some browsers only repeat keydown events, not keypress events,
  5547. // so we use the suppressKeyPress flag to determine if we've already
  5548. // handled the keydown event. #7269
  5549. // Unfortunately the code for & in keypress is the same as the up arrow,
  5550. // so we use the suppressKeyPressRepeat flag to avoid handling keypress
  5551. // events when we know the keydown event was used to modify the
  5552. // search term. #7799
  5553. var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
  5554. nodeName = this.element[0].nodeName.toLowerCase(),
  5555. isTextarea = nodeName === "textarea",
  5556. isInput = nodeName === "input";
  5557. this.isMultiLine =
  5558. // Textareas are always multi-line
  5559. isTextarea ? true :
  5560. // Inputs are always single-line, even if inside a contentEditable element
  5561. // IE also treats inputs as contentEditable
  5562. isInput ? false :
  5563. // All other element types are determined by whether or not they're contentEditable
  5564. this.element.prop( "isContentEditable" );
  5565. this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
  5566. this.isNewMenu = true;
  5567. this.element
  5568. .addClass( "ui-autocomplete-input" )
  5569. .attr( "autocomplete", "off" );
  5570. this._on( this.element, {
  5571. keydown: function( event ) {
  5572. /*jshint maxcomplexity:15*/
  5573. if ( this.element.prop( "readOnly" ) ) {
  5574. suppressKeyPress = true;
  5575. suppressInput = true;
  5576. suppressKeyPressRepeat = true;
  5577. return;
  5578. }
  5579. suppressKeyPress = false;
  5580. suppressInput = false;
  5581. suppressKeyPressRepeat = false;
  5582. var keyCode = $.ui.keyCode;
  5583. switch( event.keyCode ) {
  5584. case keyCode.PAGE_UP:
  5585. suppressKeyPress = true;
  5586. this._move( "previousPage", event );
  5587. break;
  5588. case keyCode.PAGE_DOWN:
  5589. suppressKeyPress = true;
  5590. this._move( "nextPage", event );
  5591. break;
  5592. case keyCode.UP:
  5593. suppressKeyPress = true;
  5594. this._keyEvent( "previous", event );
  5595. break;
  5596. case keyCode.DOWN:
  5597. suppressKeyPress = true;
  5598. this._keyEvent( "next", event );
  5599. break;
  5600. case keyCode.ENTER:
  5601. case keyCode.NUMPAD_ENTER:
  5602. // when menu is open and has focus
  5603. if ( this.menu.active ) {
  5604. // #6055 - Opera still allows the keypress to occur
  5605. // which causes forms to submit
  5606. suppressKeyPress = true;
  5607. event.preventDefault();
  5608. this.menu.select( event );
  5609. }
  5610. break;
  5611. case keyCode.TAB:
  5612. if ( this.menu.active ) {
  5613. this.menu.select( event );
  5614. }
  5615. break;
  5616. case keyCode.ESCAPE:
  5617. if ( this.menu.element.is( ":visible" ) ) {
  5618. this._value( this.term );
  5619. this.close( event );
  5620. // Different browsers have different default behavior for escape
  5621. // Single press can mean undo or clear
  5622. // Double press in IE means clear the whole form
  5623. event.preventDefault();
  5624. }
  5625. break;
  5626. default:
  5627. suppressKeyPressRepeat = true;
  5628. // search timeout should be triggered before the input value is changed
  5629. this._searchTimeout( event );
  5630. break;
  5631. }
  5632. },
  5633. keypress: function( event ) {
  5634. if ( suppressKeyPress ) {
  5635. suppressKeyPress = false;
  5636. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  5637. event.preventDefault();
  5638. }
  5639. return;
  5640. }
  5641. if ( suppressKeyPressRepeat ) {
  5642. return;
  5643. }
  5644. // replicate some key handlers to allow them to repeat in Firefox and Opera
  5645. var keyCode = $.ui.keyCode;
  5646. switch( event.keyCode ) {
  5647. case keyCode.PAGE_UP:
  5648. this._move( "previousPage", event );
  5649. break;
  5650. case keyCode.PAGE_DOWN:
  5651. this._move( "nextPage", event );
  5652. break;
  5653. case keyCode.UP:
  5654. this._keyEvent( "previous", event );
  5655. break;
  5656. case keyCode.DOWN:
  5657. this._keyEvent( "next", event );
  5658. break;
  5659. }
  5660. },
  5661. input: function( event ) {
  5662. if ( suppressInput ) {
  5663. suppressInput = false;
  5664. event.preventDefault();
  5665. return;
  5666. }
  5667. this._searchTimeout( event );
  5668. },
  5669. focus: function() {
  5670. this.selectedItem = null;
  5671. this.previous = this._value();
  5672. },
  5673. blur: function( event ) {
  5674. if ( this.cancelBlur ) {
  5675. delete this.cancelBlur;
  5676. return;
  5677. }
  5678. clearTimeout( this.searching );
  5679. this.close( event );
  5680. this._change( event );
  5681. }
  5682. });
  5683. this._initSource();
  5684. this.menu = $( "<ul>" )
  5685. .addClass( "ui-autocomplete ui-front" )
  5686. .appendTo( this._appendTo() )
  5687. .menu({
  5688. // disable ARIA support, the live region takes care of that
  5689. role: null
  5690. })
  5691. .hide()
  5692. .data( "ui-menu" );
  5693. this._on( this.menu.element, {
  5694. mousedown: function( event ) {
  5695. // prevent moving focus out of the text field
  5696. event.preventDefault();
  5697. // IE doesn't prevent moving focus even with event.preventDefault()
  5698. // so we set a flag to know when we should ignore the blur event
  5699. this.cancelBlur = true;
  5700. this._delay(function() {
  5701. delete this.cancelBlur;
  5702. });
  5703. // clicking on the scrollbar causes focus to shift to the body
  5704. // but we can't detect a mouseup or a click immediately afterward
  5705. // so we have to track the next mousedown and close the menu if
  5706. // the user clicks somewhere outside of the autocomplete
  5707. var menuElement = this.menu.element[ 0 ];
  5708. if ( !$( event.target ).closest( ".ui-menu-item" ).length ) {
  5709. this._delay(function() {
  5710. var that = this;
  5711. this.document.one( "mousedown", function( event ) {
  5712. if ( event.target !== that.element[ 0 ] &&
  5713. event.target !== menuElement &&
  5714. !$.contains( menuElement, event.target ) ) {
  5715. that.close();
  5716. }
  5717. });
  5718. });
  5719. }
  5720. },
  5721. menufocus: function( event, ui ) {
  5722. // support: Firefox
  5723. // Prevent accidental activation of menu items in Firefox (#7024 #9118)
  5724. if ( this.isNewMenu ) {
  5725. this.isNewMenu = false;
  5726. if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
  5727. this.menu.blur();
  5728. this.document.one( "mousemove", function() {
  5729. $( event.target ).trigger( event.originalEvent );
  5730. });
  5731. return;
  5732. }
  5733. }
  5734. var item = ui.item.data( "ui-autocomplete-item" );
  5735. if ( false !== this._trigger( "focus", event, { item: item } ) ) {
  5736. // use value to match what will end up in the input, if it was a key event
  5737. if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
  5738. this._value( item.value );
  5739. }
  5740. } else {
  5741. // Normally the input is populated with the item's value as the
  5742. // menu is navigated, causing screen readers to notice a change and
  5743. // announce the item. Since the focus event was canceled, this doesn't
  5744. // happen, so we update the live region so that screen readers can
  5745. // still notice the change and announce it.
  5746. this.liveRegion.text( item.value );
  5747. }
  5748. },
  5749. menuselect: function( event, ui ) {
  5750. var item = ui.item.data( "ui-autocomplete-item" ),
  5751. previous = this.previous;
  5752. // only trigger when focus was lost (click on menu)
  5753. if ( this.element[0] !== this.document[0].activeElement ) {
  5754. this.element.focus();
  5755. this.previous = previous;
  5756. // #6109 - IE triggers two focus events and the second
  5757. // is asynchronous, so we need to reset the previous
  5758. // term synchronously and asynchronously :-(
  5759. this._delay(function() {
  5760. this.previous = previous;
  5761. this.selectedItem = item;
  5762. });
  5763. }
  5764. if ( false !== this._trigger( "select", event, { item: item } ) ) {
  5765. this._value( item.value );
  5766. }
  5767. // reset the term after the select event
  5768. // this allows custom select handling to work properly
  5769. this.term = this._value();
  5770. this.close( event );
  5771. this.selectedItem = item;
  5772. }
  5773. });
  5774. this.liveRegion = $( "<span>", {
  5775. role: "status",
  5776. "aria-live": "polite"
  5777. })
  5778. .addClass( "ui-helper-hidden-accessible" )
  5779. .insertBefore( this.element );
  5780. // turning off autocomplete prevents the browser from remembering the
  5781. // value when navigating through history, so we re-enable autocomplete
  5782. // if the page is unloaded before the widget is destroyed. #7790
  5783. this._on( this.window, {
  5784. beforeunload: function() {
  5785. this.element.removeAttr( "autocomplete" );
  5786. }
  5787. });
  5788. },
  5789. _destroy: function() {
  5790. clearTimeout( this.searching );
  5791. this.element
  5792. .removeClass( "ui-autocomplete-input" )
  5793. .removeAttr( "autocomplete" );
  5794. this.menu.element.remove();
  5795. this.liveRegion.remove();
  5796. },
  5797. _setOption: function( key, value ) {
  5798. this._super( key, value );
  5799. if ( key === "source" ) {
  5800. this._initSource();
  5801. }
  5802. if ( key === "appendTo" ) {
  5803. this.menu.element.appendTo( this._appendTo() );
  5804. }
  5805. if ( key === "disabled" && value && this.xhr ) {
  5806. this.xhr.abort();
  5807. }
  5808. },
  5809. _appendTo: function() {
  5810. var element = this.options.appendTo;
  5811. if ( element ) {
  5812. element = element.jquery || element.nodeType ?
  5813. $( element ) :
  5814. this.document.find( element ).eq( 0 );
  5815. }
  5816. if ( !element ) {
  5817. element = this.element.closest( ".ui-front" );
  5818. }
  5819. if ( !element.length ) {
  5820. element = this.document[0].body;
  5821. }
  5822. return element;
  5823. },
  5824. _initSource: function() {
  5825. var array, url,
  5826. that = this;
  5827. if ( $.isArray(this.options.source) ) {
  5828. array = this.options.source;
  5829. this.source = function( request, response ) {
  5830. response( $.ui.autocomplete.filter( array, request.term ) );
  5831. };
  5832. } else if ( typeof this.options.source === "string" ) {
  5833. url = this.options.source;
  5834. this.source = function( request, response ) {
  5835. if ( that.xhr ) {
  5836. that.xhr.abort();
  5837. }
  5838. that.xhr = $.ajax({
  5839. url: url,
  5840. data: request,
  5841. dataType: "json",
  5842. success: function( data ) {
  5843. response( data );
  5844. },
  5845. error: function() {
  5846. response( [] );
  5847. }
  5848. });
  5849. };
  5850. } else {
  5851. this.source = this.options.source;
  5852. }
  5853. },
  5854. _searchTimeout: function( event ) {
  5855. clearTimeout( this.searching );
  5856. this.searching = this._delay(function() {
  5857. // only search if the value has changed
  5858. if ( this.term !== this._value() ) {
  5859. this.selectedItem = null;
  5860. this.search( null, event );
  5861. }
  5862. }, this.options.delay );
  5863. },
  5864. search: function( value, event ) {
  5865. value = value != null ? value : this._value();
  5866. // always save the actual value, not the one passed as an argument
  5867. this.term = this._value();
  5868. if ( value.length < this.options.minLength ) {
  5869. return this.close( event );
  5870. }
  5871. if ( this._trigger( "search", event ) === false ) {
  5872. return;
  5873. }
  5874. return this._search( value );
  5875. },
  5876. _search: function( value ) {
  5877. this.pending++;
  5878. this.element.addClass( "ui-autocomplete-loading" );
  5879. this.cancelSearch = false;
  5880. this.source( { term: value }, this._response() );
  5881. },
  5882. _response: function() {
  5883. var that = this,
  5884. index = ++requestIndex;
  5885. return function( content ) {
  5886. if ( index === requestIndex ) {
  5887. that.__response( content );
  5888. }
  5889. that.pending--;
  5890. if ( !that.pending ) {
  5891. that.element.removeClass( "ui-autocomplete-loading" );
  5892. }
  5893. };
  5894. },
  5895. __response: function( content ) {
  5896. if ( content ) {
  5897. content = this._normalize( content );
  5898. }
  5899. this._trigger( "response", null, { content: content } );
  5900. if ( !this.options.disabled && content && content.length && !this.cancelSearch ) {
  5901. this._suggest( content );
  5902. this._trigger( "open" );
  5903. } else {
  5904. // use ._close() instead of .close() so we don't cancel future searches
  5905. this._close();
  5906. }
  5907. },
  5908. close: function( event ) {
  5909. this.cancelSearch = true;
  5910. this._close( event );
  5911. },
  5912. _close: function( event ) {
  5913. if ( this.menu.element.is( ":visible" ) ) {
  5914. this.menu.element.hide();
  5915. this.menu.blur();
  5916. this.isNewMenu = true;
  5917. this._trigger( "close", event );
  5918. }
  5919. },
  5920. _change: function( event ) {
  5921. if ( this.previous !== this._value() ) {
  5922. this._trigger( "change", event, { item: this.selectedItem } );
  5923. }
  5924. },
  5925. _normalize: function( items ) {
  5926. // assume all items have the right format when the first item is complete
  5927. if ( items.length && items[0].label && items[0].value ) {
  5928. return items;
  5929. }
  5930. return $.map( items, function( item ) {
  5931. if ( typeof item === "string" ) {
  5932. return {
  5933. label: item,
  5934. value: item
  5935. };
  5936. }
  5937. return $.extend({
  5938. label: item.label || item.value,
  5939. value: item.value || item.label
  5940. }, item );
  5941. });
  5942. },
  5943. _suggest: function( items ) {
  5944. var ul = this.menu.element.empty();
  5945. this._renderMenu( ul, items );
  5946. this.isNewMenu = true;
  5947. this.menu.refresh();
  5948. // size and position menu
  5949. ul.show();
  5950. this._resizeMenu();
  5951. ul.position( $.extend({
  5952. of: this.element
  5953. }, this.options.position ));
  5954. if ( this.options.autoFocus ) {
  5955. this.menu.next();
  5956. }
  5957. },
  5958. _resizeMenu: function() {
  5959. var ul = this.menu.element;
  5960. ul.outerWidth( Math.max(
  5961. // Firefox wraps long text (possibly a rounding bug)
  5962. // so we add 1px to avoid the wrapping (#7513)
  5963. ul.width( "" ).outerWidth() + 1,
  5964. this.element.outerWidth()
  5965. ) );
  5966. },
  5967. _renderMenu: function( ul, items ) {
  5968. var that = this;
  5969. $.each( items, function( index, item ) {
  5970. that._renderItemData( ul, item );
  5971. });
  5972. },
  5973. _renderItemData: function( ul, item ) {
  5974. return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
  5975. },
  5976. _renderItem: function( ul, item ) {
  5977. return $( "<li>" )
  5978. .append( $( "<a>" ).text( item.label ) )
  5979. .appendTo( ul );
  5980. },
  5981. _move: function( direction, event ) {
  5982. if ( !this.menu.element.is( ":visible" ) ) {
  5983. this.search( null, event );
  5984. return;
  5985. }
  5986. if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
  5987. this.menu.isLastItem() && /^next/.test( direction ) ) {
  5988. this._value( this.term );
  5989. this.menu.blur();
  5990. return;
  5991. }
  5992. this.menu[ direction ]( event );
  5993. },
  5994. widget: function() {
  5995. return this.menu.element;
  5996. },
  5997. _value: function() {
  5998. return this.valueMethod.apply( this.element, arguments );
  5999. },
  6000. _keyEvent: function( keyEvent, event ) {
  6001. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  6002. this._move( keyEvent, event );
  6003. // prevents moving cursor to beginning/end of the text field in some browsers
  6004. event.preventDefault();
  6005. }
  6006. }
  6007. });
  6008. $.extend( $.ui.autocomplete, {
  6009. escapeRegex: function( value ) {
  6010. return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
  6011. },
  6012. filter: function(array, term) {
  6013. var matcher = new RegExp( $.ui.autocomplete.escapeRegex(term), "i" );
  6014. return $.grep( array, function(value) {
  6015. return matcher.test( value.label || value.value || value );
  6016. });
  6017. }
  6018. });
  6019. // live region extension, adding a `messages` option
  6020. // NOTE: This is an experimental API. We are still investigating
  6021. // a full solution for string manipulation and internationalization.
  6022. $.widget( "ui.autocomplete", $.ui.autocomplete, {
  6023. options: {
  6024. messages: {
  6025. noResults: "No search results.",
  6026. results: function( amount ) {
  6027. return amount + ( amount > 1 ? " results are" : " result is" ) +
  6028. " available, use up and down arrow keys to navigate.";
  6029. }
  6030. }
  6031. },
  6032. __response: function( content ) {
  6033. var message;
  6034. this._superApply( arguments );
  6035. if ( this.options.disabled || this.cancelSearch ) {
  6036. return;
  6037. }
  6038. if ( content && content.length ) {
  6039. message = this.options.messages.results( content.length );
  6040. } else {
  6041. message = this.options.messages.noResults;
  6042. }
  6043. this.liveRegion.text( message );
  6044. }
  6045. });
  6046. }( jQuery ));
  6047. (function( $, undefined ) {
  6048. var lastActive, startXPos, startYPos, clickDragged,
  6049. baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
  6050. stateClasses = "ui-state-hover ui-state-active ",
  6051. 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",
  6052. formResetHandler = function() {
  6053. var form = $( this );
  6054. setTimeout(function() {
  6055. form.find( ":ui-button" ).button( "refresh" );
  6056. }, 1 );
  6057. },
  6058. radioGroup = function( radio ) {
  6059. var name = radio.name,
  6060. form = radio.form,
  6061. radios = $( [] );
  6062. if ( name ) {
  6063. name = name.replace( /'/g, "\\'" );
  6064. if ( form ) {
  6065. radios = $( form ).find( "[name='" + name + "']" );
  6066. } else {
  6067. radios = $( "[name='" + name + "']", radio.ownerDocument )
  6068. .filter(function() {
  6069. return !this.form;
  6070. });
  6071. }
  6072. }
  6073. return radios;
  6074. };
  6075. $.widget( "ui.button", {
  6076. version: "1.10.3",
  6077. defaultElement: "<button>",
  6078. options: {
  6079. disabled: null,
  6080. text: true,
  6081. label: null,
  6082. icons: {
  6083. primary: null,
  6084. secondary: null
  6085. }
  6086. },
  6087. _create: function() {
  6088. this.element.closest( "form" )
  6089. .unbind( "reset" + this.eventNamespace )
  6090. .bind( "reset" + this.eventNamespace, formResetHandler );
  6091. if ( typeof this.options.disabled !== "boolean" ) {
  6092. this.options.disabled = !!this.element.prop( "disabled" );
  6093. } else {
  6094. this.element.prop( "disabled", this.options.disabled );
  6095. }
  6096. this._determineButtonType();
  6097. this.hasTitle = !!this.buttonElement.attr( "title" );
  6098. var that = this,
  6099. options = this.options,
  6100. toggleButton = this.type === "checkbox" || this.type === "radio",
  6101. activeClass = !toggleButton ? "ui-state-active" : "",
  6102. focusClass = "ui-state-focus";
  6103. if ( options.label === null ) {
  6104. options.label = (this.type === "input" ? this.buttonElement.val() : this.buttonElement.html());
  6105. }
  6106. this._hoverable( this.buttonElement );
  6107. this.buttonElement
  6108. .addClass( baseClasses )
  6109. .attr( "role", "button" )
  6110. .bind( "mouseenter" + this.eventNamespace, function() {
  6111. if ( options.disabled ) {
  6112. return;
  6113. }
  6114. if ( this === lastActive ) {
  6115. $( this ).addClass( "ui-state-active" );
  6116. }
  6117. })
  6118. .bind( "mouseleave" + this.eventNamespace, function() {
  6119. if ( options.disabled ) {
  6120. return;
  6121. }
  6122. $( this ).removeClass( activeClass );
  6123. })
  6124. .bind( "click" + this.eventNamespace, function( event ) {
  6125. if ( options.disabled ) {
  6126. event.preventDefault();
  6127. event.stopImmediatePropagation();
  6128. }
  6129. });
  6130. this.element
  6131. .bind( "focus" + this.eventNamespace, function() {
  6132. // no need to check disabled, focus won't be triggered anyway
  6133. that.buttonElement.addClass( focusClass );
  6134. })
  6135. .bind( "blur" + this.eventNamespace, function() {
  6136. that.buttonElement.removeClass( focusClass );
  6137. });
  6138. if ( toggleButton ) {
  6139. this.element.bind( "change" + this.eventNamespace, function() {
  6140. if ( clickDragged ) {
  6141. return;
  6142. }
  6143. that.refresh();
  6144. });
  6145. // if mouse moves between mousedown and mouseup (drag) set clickDragged flag
  6146. // prevents issue where button state changes but checkbox/radio checked state
  6147. // does not in Firefox (see ticket #6970)
  6148. this.buttonElement
  6149. .bind( "mousedown" + this.eventNamespace, function( event ) {
  6150. if ( options.disabled ) {
  6151. return;
  6152. }
  6153. clickDragged = false;
  6154. startXPos = event.pageX;
  6155. startYPos = event.pageY;
  6156. })
  6157. .bind( "mouseup" + this.eventNamespace, function( event ) {
  6158. if ( options.disabled ) {
  6159. return;
  6160. }
  6161. if ( startXPos !== event.pageX || startYPos !== event.pageY ) {
  6162. clickDragged = true;
  6163. }
  6164. });
  6165. }
  6166. if ( this.type === "checkbox" ) {
  6167. this.buttonElement.bind( "click" + this.eventNamespace, function() {
  6168. if ( options.disabled || clickDragged ) {
  6169. return false;
  6170. }
  6171. });
  6172. } else if ( this.type === "radio" ) {
  6173. this.buttonElement.bind( "click" + this.eventNamespace, function() {
  6174. if ( options.disabled || clickDragged ) {
  6175. return false;
  6176. }
  6177. $( this ).addClass( "ui-state-active" );
  6178. that.buttonElement.attr( "aria-pressed", "true" );
  6179. var radio = that.element[ 0 ];
  6180. radioGroup( radio )
  6181. .not( radio )
  6182. .map(function() {
  6183. return $( this ).button( "widget" )[ 0 ];
  6184. })
  6185. .removeClass( "ui-state-active" )
  6186. .attr( "aria-pressed", "false" );
  6187. });
  6188. } else {
  6189. this.buttonElement
  6190. .bind( "mousedown" + this.eventNamespace, function() {
  6191. if ( options.disabled ) {
  6192. return false;
  6193. }
  6194. $( this ).addClass( "ui-state-active" );
  6195. lastActive = this;
  6196. that.document.one( "mouseup", function() {
  6197. lastActive = null;
  6198. });
  6199. })
  6200. .bind( "mouseup" + this.eventNamespace, function() {
  6201. if ( options.disabled ) {
  6202. return false;
  6203. }
  6204. $( this ).removeClass( "ui-state-active" );
  6205. })
  6206. .bind( "keydown" + this.eventNamespace, function(event) {
  6207. if ( options.disabled ) {
  6208. return false;
  6209. }
  6210. if ( event.keyCode === $.ui.keyCode.SPACE || event.keyCode === $.ui.keyCode.ENTER ) {
  6211. $( this ).addClass( "ui-state-active" );
  6212. }
  6213. })
  6214. // see #8559, we bind to blur here in case the button element loses
  6215. // focus between keydown and keyup, it would be left in an "active" state
  6216. .bind( "keyup" + this.eventNamespace + " blur" + this.eventNamespace, function() {
  6217. $( this ).removeClass( "ui-state-active" );
  6218. });
  6219. if ( this.buttonElement.is("a") ) {
  6220. this.buttonElement.keyup(function(event) {
  6221. if ( event.keyCode === $.ui.keyCode.SPACE ) {
  6222. // TODO pass through original event correctly (just as 2nd argument doesn't work)
  6223. $( this ).click();
  6224. }
  6225. });
  6226. }
  6227. }
  6228. // TODO: pull out $.Widget's handling for the disabled option into
  6229. // $.Widget.prototype._setOptionDisabled so it's easy to proxy and can
  6230. // be overridden by individual plugins
  6231. this._setOption( "disabled", options.disabled );
  6232. this._resetButton();
  6233. },
  6234. _determineButtonType: function() {
  6235. var ancestor, labelSelector, checked;
  6236. if ( this.element.is("[type=checkbox]") ) {
  6237. this.type = "checkbox";
  6238. } else if ( this.element.is("[type=radio]") ) {
  6239. this.type = "radio";
  6240. } else if ( this.element.is("input") ) {
  6241. this.type = "input";
  6242. } else {
  6243. this.type = "button";
  6244. }
  6245. if ( this.type === "checkbox" || this.type === "radio" ) {
  6246. // we don't search against the document in case the element
  6247. // is disconnected from the DOM
  6248. ancestor = this.element.parents().last();
  6249. labelSelector = "label[for='" + this.element.attr("id") + "']";
  6250. this.buttonElement = ancestor.find( labelSelector );
  6251. if ( !this.buttonElement.length ) {
  6252. ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
  6253. this.buttonElement = ancestor.filter( labelSelector );
  6254. if ( !this.buttonElement.length ) {
  6255. this.buttonElement = ancestor.find( labelSelector );
  6256. }
  6257. }
  6258. this.element.addClass( "ui-helper-hidden-accessible" );
  6259. checked = this.element.is( ":checked" );
  6260. if ( checked ) {
  6261. this.buttonElement.addClass( "ui-state-active" );
  6262. }
  6263. this.buttonElement.prop( "aria-pressed", checked );
  6264. } else {
  6265. this.buttonElement = this.element;
  6266. }
  6267. },
  6268. widget: function() {
  6269. return this.buttonElement;
  6270. },
  6271. _destroy: function() {
  6272. this.element
  6273. .removeClass( "ui-helper-hidden-accessible" );
  6274. this.buttonElement
  6275. .removeClass( baseClasses + " " + stateClasses + " " + typeClasses )
  6276. .removeAttr( "role" )
  6277. .removeAttr( "aria-pressed" )
  6278. .html( this.buttonElement.find(".ui-button-text").html() );
  6279. if ( !this.hasTitle ) {
  6280. this.buttonElement.removeAttr( "title" );
  6281. }
  6282. },
  6283. _setOption: function( key, value ) {
  6284. this._super( key, value );
  6285. if ( key === "disabled" ) {
  6286. if ( value ) {
  6287. this.element.prop( "disabled", true );
  6288. } else {
  6289. this.element.prop( "disabled", false );
  6290. }
  6291. return;
  6292. }
  6293. this._resetButton();
  6294. },
  6295. refresh: function() {
  6296. //See #8237 & #8828
  6297. var isDisabled = this.element.is( "input, button" ) ? this.element.is( ":disabled" ) : this.element.hasClass( "ui-button-disabled" );
  6298. if ( isDisabled !== this.options.disabled ) {
  6299. this._setOption( "disabled", isDisabled );
  6300. }
  6301. if ( this.type === "radio" ) {
  6302. radioGroup( this.element[0] ).each(function() {
  6303. if ( $( this ).is( ":checked" ) ) {
  6304. $( this ).button( "widget" )
  6305. .addClass( "ui-state-active" )
  6306. .attr( "aria-pressed", "true" );
  6307. } else {
  6308. $( this ).button( "widget" )
  6309. .removeClass( "ui-state-active" )
  6310. .attr( "aria-pressed", "false" );
  6311. }
  6312. });
  6313. } else if ( this.type === "checkbox" ) {
  6314. if ( this.element.is( ":checked" ) ) {
  6315. this.buttonElement
  6316. .addClass( "ui-state-active" )
  6317. .attr( "aria-pressed", "true" );
  6318. } else {
  6319. this.buttonElement
  6320. .removeClass( "ui-state-active" )
  6321. .attr( "aria-pressed", "false" );
  6322. }
  6323. }
  6324. },
  6325. _resetButton: function() {
  6326. if ( this.type === "input" ) {
  6327. if ( this.options.label ) {
  6328. this.element.val( this.options.label );
  6329. }
  6330. return;
  6331. }
  6332. var buttonElement = this.buttonElement.removeClass( typeClasses ),
  6333. buttonText = $( "<span></span>", this.document[0] )
  6334. .addClass( "ui-button-text" )
  6335. .html( this.options.label )
  6336. .appendTo( buttonElement.empty() )
  6337. .text(),
  6338. icons = this.options.icons,
  6339. multipleIcons = icons.primary && icons.secondary,
  6340. buttonClasses = [];
  6341. if ( icons.primary || icons.secondary ) {
  6342. if ( this.options.text ) {
  6343. buttonClasses.push( "ui-button-text-icon" + ( multipleIcons ? "s" : ( icons.primary ? "-primary" : "-secondary" ) ) );
  6344. }
  6345. if ( icons.primary ) {
  6346. buttonElement.prepend( "<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>" );
  6347. }
  6348. if ( icons.secondary ) {
  6349. buttonElement.append( "<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>" );
  6350. }
  6351. if ( !this.options.text ) {
  6352. buttonClasses.push( multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only" );
  6353. if ( !this.hasTitle ) {
  6354. buttonElement.attr( "title", $.trim( buttonText ) );
  6355. }
  6356. }
  6357. } else {
  6358. buttonClasses.push( "ui-button-text-only" );
  6359. }
  6360. buttonElement.addClass( buttonClasses.join( " " ) );
  6361. }
  6362. });
  6363. $.widget( "ui.buttonset", {
  6364. version: "1.10.3",
  6365. options: {
  6366. items: "button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(ui-button)"
  6367. },
  6368. _create: function() {
  6369. this.element.addClass( "ui-buttonset" );
  6370. },
  6371. _init: function() {
  6372. this.refresh();
  6373. },
  6374. _setOption: function( key, value ) {
  6375. if ( key === "disabled" ) {
  6376. this.buttons.button( "option", key, value );
  6377. }
  6378. this._super( key, value );
  6379. },
  6380. refresh: function() {
  6381. var rtl = this.element.css( "direction" ) === "rtl";
  6382. this.buttons = this.element.find( this.options.items )
  6383. .filter( ":ui-button" )
  6384. .button( "refresh" )
  6385. .end()
  6386. .not( ":ui-button" )
  6387. .button()
  6388. .end()
  6389. .map(function() {
  6390. return $( this ).button( "widget" )[ 0 ];
  6391. })
  6392. .removeClass( "ui-corner-all ui-corner-left ui-corner-right" )
  6393. .filter( ":first" )
  6394. .addClass( rtl ? "ui-corner-right" : "ui-corner-left" )
  6395. .end()
  6396. .filter( ":last" )
  6397. .addClass( rtl ? "ui-corner-left" : "ui-corner-right" )
  6398. .end()
  6399. .end();
  6400. },
  6401. _destroy: function() {
  6402. this.element.removeClass( "ui-buttonset" );
  6403. this.buttons
  6404. .map(function() {
  6405. return $( this ).button( "widget" )[ 0 ];
  6406. })
  6407. .removeClass( "ui-corner-left ui-corner-right" )
  6408. .end()
  6409. .button( "destroy" );
  6410. }
  6411. });
  6412. }( jQuery ) );
  6413. (function( $, undefined ) {
  6414. $.extend($.ui, { datepicker: { version: "1.10.3" } });
  6415. var PROP_NAME = "datepicker",
  6416. instActive;
  6417. /* Date picker manager.
  6418. Use the singleton instance of this class, $.datepicker, to interact with the date picker.
  6419. Settings for (groups of) date pickers are maintained in an instance object,
  6420. allowing multiple different settings on the same page. */
  6421. function Datepicker() {
  6422. this._curInst = null; // The current instance in use
  6423. this._keyEvent = false; // If the last event was a key event
  6424. this._disabledInputs = []; // List of date picker inputs that have been disabled
  6425. this._datepickerShowing = false; // True if the popup picker is showing , false if not
  6426. this._inDialog = false; // True if showing within a "dialog", false if not
  6427. this._mainDivId = "ui-datepicker-div"; // The ID of the main datepicker division
  6428. this._inlineClass = "ui-datepicker-inline"; // The name of the inline marker class
  6429. this._appendClass = "ui-datepicker-append"; // The name of the append marker class
  6430. this._triggerClass = "ui-datepicker-trigger"; // The name of the trigger marker class
  6431. this._dialogClass = "ui-datepicker-dialog"; // The name of the dialog marker class
  6432. this._disableClass = "ui-datepicker-disabled"; // The name of the disabled covering marker class
  6433. this._unselectableClass = "ui-datepicker-unselectable"; // The name of the unselectable cell marker class
  6434. this._currentClass = "ui-datepicker-current-day"; // The name of the current day marker class
  6435. this._dayOverClass = "ui-datepicker-days-cell-over"; // The name of the day hover marker class
  6436. this.regional = []; // Available regional settings, indexed by language code
  6437. this.regional[""] = { // Default regional settings
  6438. closeText: "Done", // Display text for close link
  6439. prevText: "Prev", // Display text for previous month link
  6440. nextText: "Next", // Display text for next month link
  6441. currentText: "Today", // Display text for current month link
  6442. monthNames: ["January","February","March","April","May","June",
  6443. "July","August","September","October","November","December"], // Names of months for drop-down and formatting
  6444. monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], // For formatting
  6445. dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], // For formatting
  6446. dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], // For formatting
  6447. dayNamesMin: ["Su","Mo","Tu","We","Th","Fr","Sa"], // Column headings for days starting at Sunday
  6448. weekHeader: "Wk", // Column header for week of the year
  6449. dateFormat: "mm/dd/yy", // See format options on parseDate
  6450. firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
  6451. isRTL: false, // True if right-to-left language, false if left-to-right
  6452. showMonthAfterYear: false, // True if the year select precedes month, false for month then year
  6453. yearSuffix: "" // Additional text to append to the year in the month headers
  6454. };
  6455. this._defaults = { // Global defaults for all the date picker instances
  6456. showOn: "focus", // "focus" for popup on focus,
  6457. // "button" for trigger button, or "both" for either
  6458. showAnim: "fadeIn", // Name of jQuery animation for popup
  6459. showOptions: {}, // Options for enhanced animations
  6460. defaultDate: null, // Used when field is blank: actual date,
  6461. // +/-number for offset from today, null for today
  6462. appendText: "", // Display text following the input box, e.g. showing the format
  6463. buttonText: "...", // Text for trigger button
  6464. buttonImage: "", // URL for trigger button image
  6465. buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
  6466. hideIfNoPrevNext: false, // True to hide next/previous month links
  6467. // if not applicable, false to just disable them
  6468. navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
  6469. gotoCurrent: false, // True if today link goes back to current selection instead
  6470. changeMonth: false, // True if month can be selected directly, false if only prev/next
  6471. changeYear: false, // True if year can be selected directly, false if only prev/next
  6472. yearRange: "c-10:c+10", // Range of years to display in drop-down,
  6473. // either relative to today's year (-nn:+nn), relative to currently displayed year
  6474. // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
  6475. showOtherMonths: false, // True to show dates in other months, false to leave blank
  6476. selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
  6477. showWeek: false, // True to show week of the year, false to not show it
  6478. calculateWeek: this.iso8601Week, // How to calculate the week of the year,
  6479. // takes a Date and returns the number of the week for it
  6480. shortYearCutoff: "+10", // Short year values < this are in the current century,
  6481. // > this are in the previous century,
  6482. // string value starting with "+" for current year + value
  6483. minDate: null, // The earliest selectable date, or null for no limit
  6484. maxDate: null, // The latest selectable date, or null for no limit
  6485. duration: "fast", // Duration of display/closure
  6486. beforeShowDay: null, // Function that takes a date and returns an array with
  6487. // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "",
  6488. // [2] = cell title (optional), e.g. $.datepicker.noWeekends
  6489. beforeShow: null, // Function that takes an input field and
  6490. // returns a set of custom settings for the date picker
  6491. onSelect: null, // Define a callback function when a date is selected
  6492. onChangeMonthYear: null, // Define a callback function when the month or year is changed
  6493. onClose: null, // Define a callback function when the datepicker is closed
  6494. numberOfMonths: 1, // Number of months to show at a time
  6495. showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
  6496. stepMonths: 1, // Number of months to step back/forward
  6497. stepBigMonths: 12, // Number of months to step back/forward for the big links
  6498. altField: "", // Selector for an alternate field to store selected dates into
  6499. altFormat: "", // The date format to use for the alternate field
  6500. constrainInput: true, // The input is constrained by the current date format
  6501. showButtonPanel: false, // True to show button panel, false to not show it
  6502. autoSize: false, // True to size the input for the date format, false to leave as is
  6503. disabled: false // The initial disabled state
  6504. };
  6505. $.extend(this._defaults, this.regional[""]);
  6506. this.dpDiv = bindHover($("<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>"));
  6507. }
  6508. $.extend(Datepicker.prototype, {
  6509. /* Class name added to elements to indicate already configured with a date picker. */
  6510. markerClassName: "hasDatepicker",
  6511. //Keep track of the maximum number of rows displayed (see #7043)
  6512. maxRows: 4,
  6513. // TODO rename to "widget" when switching to widget factory
  6514. _widgetDatepicker: function() {
  6515. return this.dpDiv;
  6516. },
  6517. /* Override the default settings for all instances of the date picker.
  6518. * @param settings object - the new settings to use as defaults (anonymous object)
  6519. * @return the manager object
  6520. */
  6521. setDefaults: function(settings) {
  6522. extendRemove(this._defaults, settings || {});
  6523. return this;
  6524. },
  6525. /* Attach the date picker to a jQuery selection.
  6526. * @param target element - the target input field or division or span
  6527. * @param settings object - the new settings to use for this date picker instance (anonymous)
  6528. */
  6529. _attachDatepicker: function(target, settings) {
  6530. var nodeName, inline, inst;
  6531. nodeName = target.nodeName.toLowerCase();
  6532. inline = (nodeName === "div" || nodeName === "span");
  6533. if (!target.id) {
  6534. this.uuid += 1;
  6535. target.id = "dp" + this.uuid;
  6536. }
  6537. inst = this._newInst($(target), inline);
  6538. inst.settings = $.extend({}, settings || {});
  6539. if (nodeName === "input") {
  6540. this._connectDatepicker(target, inst);
  6541. } else if (inline) {
  6542. this._inlineDatepicker(target, inst);
  6543. }
  6544. },
  6545. /* Create a new instance object. */
  6546. _newInst: function(target, inline) {
  6547. var id = target[0].id.replace(/([^A-Za-z0-9_\-])/g, "\\\\$1"); // escape jQuery meta chars
  6548. return {id: id, input: target, // associated target
  6549. selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
  6550. drawMonth: 0, drawYear: 0, // month being drawn
  6551. inline: inline, // is datepicker inline or not
  6552. dpDiv: (!inline ? this.dpDiv : // presentation div
  6553. bindHover($("<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>")))};
  6554. },
  6555. /* Attach the date picker to an input field. */
  6556. _connectDatepicker: function(target, inst) {
  6557. var input = $(target);
  6558. inst.append = $([]);
  6559. inst.trigger = $([]);
  6560. if (input.hasClass(this.markerClassName)) {
  6561. return;
  6562. }
  6563. this._attachments(input, inst);
  6564. input.addClass(this.markerClassName).keydown(this._doKeyDown).
  6565. keypress(this._doKeyPress).keyup(this._doKeyUp);
  6566. this._autoSize(inst);
  6567. $.data(target, PROP_NAME, inst);
  6568. //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
  6569. if( inst.settings.disabled ) {
  6570. this._disableDatepicker( target );
  6571. }
  6572. },
  6573. /* Make attachments based on settings. */
  6574. _attachments: function(input, inst) {
  6575. var showOn, buttonText, buttonImage,
  6576. appendText = this._get(inst, "appendText"),
  6577. isRTL = this._get(inst, "isRTL");
  6578. if (inst.append) {
  6579. inst.append.remove();
  6580. }
  6581. if (appendText) {
  6582. inst.append = $("<span class='" + this._appendClass + "'>" + appendText + "</span>");
  6583. input[isRTL ? "before" : "after"](inst.append);
  6584. }
  6585. input.unbind("focus", this._showDatepicker);
  6586. if (inst.trigger) {
  6587. inst.trigger.remove();
  6588. }
  6589. showOn = this._get(inst, "showOn");
  6590. if (showOn === "focus" || showOn === "both") { // pop-up date picker when in the marked field
  6591. input.focus(this._showDatepicker);
  6592. }
  6593. if (showOn === "button" || showOn === "both") { // pop-up date picker when button clicked
  6594. buttonText = this._get(inst, "buttonText");
  6595. buttonImage = this._get(inst, "buttonImage");
  6596. inst.trigger = $(this._get(inst, "buttonImageOnly") ?
  6597. $("<img/>").addClass(this._triggerClass).
  6598. attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
  6599. $("<button type='button'></button>").addClass(this._triggerClass).
  6600. html(!buttonImage ? buttonText : $("<img/>").attr(
  6601. { src:buttonImage, alt:buttonText, title:buttonText })));
  6602. input[isRTL ? "before" : "after"](inst.trigger);
  6603. inst.trigger.click(function() {
  6604. if ($.datepicker._datepickerShowing && $.datepicker._lastInput === input[0]) {
  6605. $.datepicker._hideDatepicker();
  6606. } else if ($.datepicker._datepickerShowing && $.datepicker._lastInput !== input[0]) {
  6607. $.datepicker._hideDatepicker();
  6608. $.datepicker._showDatepicker(input[0]);
  6609. } else {
  6610. $.datepicker._showDatepicker(input[0]);
  6611. }
  6612. return false;
  6613. });
  6614. }
  6615. },
  6616. /* Apply the maximum length for the date format. */
  6617. _autoSize: function(inst) {
  6618. if (this._get(inst, "autoSize") && !inst.inline) {
  6619. var findMax, max, maxI, i,
  6620. date = new Date(2009, 12 - 1, 20), // Ensure double digits
  6621. dateFormat = this._get(inst, "dateFormat");
  6622. if (dateFormat.match(/[DM]/)) {
  6623. findMax = function(names) {
  6624. max = 0;
  6625. maxI = 0;
  6626. for (i = 0; i < names.length; i++) {
  6627. if (names[i].length > max) {
  6628. max = names[i].length;
  6629. maxI = i;
  6630. }
  6631. }
  6632. return maxI;
  6633. };
  6634. date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ?
  6635. "monthNames" : "monthNamesShort"))));
  6636. date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ?
  6637. "dayNames" : "dayNamesShort"))) + 20 - date.getDay());
  6638. }
  6639. inst.input.attr("size", this._formatDate(inst, date).length);
  6640. }
  6641. },
  6642. /* Attach an inline date picker to a div. */
  6643. _inlineDatepicker: function(target, inst) {
  6644. var divSpan = $(target);
  6645. if (divSpan.hasClass(this.markerClassName)) {
  6646. return;
  6647. }
  6648. divSpan.addClass(this.markerClassName).append(inst.dpDiv);
  6649. $.data(target, PROP_NAME, inst);
  6650. this._setDate(inst, this._getDefaultDate(inst), true);
  6651. this._updateDatepicker(inst);
  6652. this._updateAlternate(inst);
  6653. //If disabled option is true, disable the datepicker before showing it (see ticket #5665)
  6654. if( inst.settings.disabled ) {
  6655. this._disableDatepicker( target );
  6656. }
  6657. // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
  6658. // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
  6659. inst.dpDiv.css( "display", "block" );
  6660. },
  6661. /* Pop-up the date picker in a "dialog" box.
  6662. * @param input element - ignored
  6663. * @param date string or Date - the initial date to display
  6664. * @param onSelect function - the function to call when a date is selected
  6665. * @param settings object - update the dialog date picker instance's settings (anonymous object)
  6666. * @param pos int[2] - coordinates for the dialog's position within the screen or
  6667. * event - with x/y coordinates or
  6668. * leave empty for default (screen centre)
  6669. * @return the manager object
  6670. */
  6671. _dialogDatepicker: function(input, date, onSelect, settings, pos) {
  6672. var id, browserWidth, browserHeight, scrollX, scrollY,
  6673. inst = this._dialogInst; // internal instance
  6674. if (!inst) {
  6675. this.uuid += 1;
  6676. id = "dp" + this.uuid;
  6677. this._dialogInput = $("<input type='text' id='" + id +
  6678. "' style='position: absolute; top: -100px; width: 0px;'/>");
  6679. this._dialogInput.keydown(this._doKeyDown);
  6680. $("body").append(this._dialogInput);
  6681. inst = this._dialogInst = this._newInst(this._dialogInput, false);
  6682. inst.settings = {};
  6683. $.data(this._dialogInput[0], PROP_NAME, inst);
  6684. }
  6685. extendRemove(inst.settings, settings || {});
  6686. date = (date && date.constructor === Date ? this._formatDate(inst, date) : date);
  6687. this._dialogInput.val(date);
  6688. this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
  6689. if (!this._pos) {
  6690. browserWidth = document.documentElement.clientWidth;
  6691. browserHeight = document.documentElement.clientHeight;
  6692. scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
  6693. scrollY = document.documentElement.scrollTop || document.body.scrollTop;
  6694. this._pos = // should use actual width/height below
  6695. [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
  6696. }
  6697. // move input on screen for focus, but hidden behind dialog
  6698. this._dialogInput.css("left", (this._pos[0] + 20) + "px").css("top", this._pos[1] + "px");
  6699. inst.settings.onSelect = onSelect;
  6700. this._inDialog = true;
  6701. this.dpDiv.addClass(this._dialogClass);
  6702. this._showDatepicker(this._dialogInput[0]);
  6703. if ($.blockUI) {
  6704. $.blockUI(this.dpDiv);
  6705. }
  6706. $.data(this._dialogInput[0], PROP_NAME, inst);
  6707. return this;
  6708. },
  6709. /* Detach a datepicker from its control.
  6710. * @param target element - the target input field or division or span
  6711. */
  6712. _destroyDatepicker: function(target) {
  6713. var nodeName,
  6714. $target = $(target),
  6715. inst = $.data(target, PROP_NAME);
  6716. if (!$target.hasClass(this.markerClassName)) {
  6717. return;
  6718. }
  6719. nodeName = target.nodeName.toLowerCase();
  6720. $.removeData(target, PROP_NAME);
  6721. if (nodeName === "input") {
  6722. inst.append.remove();
  6723. inst.trigger.remove();
  6724. $target.removeClass(this.markerClassName).
  6725. unbind("focus", this._showDatepicker).
  6726. unbind("keydown", this._doKeyDown).
  6727. unbind("keypress", this._doKeyPress).
  6728. unbind("keyup", this._doKeyUp);
  6729. } else if (nodeName === "div" || nodeName === "span") {
  6730. $target.removeClass(this.markerClassName).empty();
  6731. }
  6732. },
  6733. /* Enable the date picker to a jQuery selection.
  6734. * @param target element - the target input field or division or span
  6735. */
  6736. _enableDatepicker: function(target) {
  6737. var nodeName, inline,
  6738. $target = $(target),
  6739. inst = $.data(target, PROP_NAME);
  6740. if (!$target.hasClass(this.markerClassName)) {
  6741. return;
  6742. }
  6743. nodeName = target.nodeName.toLowerCase();
  6744. if (nodeName === "input") {
  6745. target.disabled = false;
  6746. inst.trigger.filter("button").
  6747. each(function() { this.disabled = false; }).end().
  6748. filter("img").css({opacity: "1.0", cursor: ""});
  6749. } else if (nodeName === "div" || nodeName === "span") {
  6750. inline = $target.children("." + this._inlineClass);
  6751. inline.children().removeClass("ui-state-disabled");
  6752. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  6753. prop("disabled", false);
  6754. }
  6755. this._disabledInputs = $.map(this._disabledInputs,
  6756. function(value) { return (value === target ? null : value); }); // delete entry
  6757. },
  6758. /* Disable the date picker to a jQuery selection.
  6759. * @param target element - the target input field or division or span
  6760. */
  6761. _disableDatepicker: function(target) {
  6762. var nodeName, inline,
  6763. $target = $(target),
  6764. inst = $.data(target, PROP_NAME);
  6765. if (!$target.hasClass(this.markerClassName)) {
  6766. return;
  6767. }
  6768. nodeName = target.nodeName.toLowerCase();
  6769. if (nodeName === "input") {
  6770. target.disabled = true;
  6771. inst.trigger.filter("button").
  6772. each(function() { this.disabled = true; }).end().
  6773. filter("img").css({opacity: "0.5", cursor: "default"});
  6774. } else if (nodeName === "div" || nodeName === "span") {
  6775. inline = $target.children("." + this._inlineClass);
  6776. inline.children().addClass("ui-state-disabled");
  6777. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  6778. prop("disabled", true);
  6779. }
  6780. this._disabledInputs = $.map(this._disabledInputs,
  6781. function(value) { return (value === target ? null : value); }); // delete entry
  6782. this._disabledInputs[this._disabledInputs.length] = target;
  6783. },
  6784. /* Is the first field in a jQuery collection disabled as a datepicker?
  6785. * @param target element - the target input field or division or span
  6786. * @return boolean - true if disabled, false if enabled
  6787. */
  6788. _isDisabledDatepicker: function(target) {
  6789. if (!target) {
  6790. return false;
  6791. }
  6792. for (var i = 0; i < this._disabledInputs.length; i++) {
  6793. if (this._disabledInputs[i] === target) {
  6794. return true;
  6795. }
  6796. }
  6797. return false;
  6798. },
  6799. /* Retrieve the instance data for the target control.
  6800. * @param target element - the target input field or division or span
  6801. * @return object - the associated instance data
  6802. * @throws error if a jQuery problem getting data
  6803. */
  6804. _getInst: function(target) {
  6805. try {
  6806. return $.data(target, PROP_NAME);
  6807. }
  6808. catch (err) {
  6809. throw "Missing instance data for this datepicker";
  6810. }
  6811. },
  6812. /* Update or retrieve the settings for a date picker attached to an input field or division.
  6813. * @param target element - the target input field or division or span
  6814. * @param name object - the new settings to update or
  6815. * string - the name of the setting to change or retrieve,
  6816. * when retrieving also "all" for all instance settings or
  6817. * "defaults" for all global defaults
  6818. * @param value any - the new value for the setting
  6819. * (omit if above is an object or to retrieve a value)
  6820. */
  6821. _optionDatepicker: function(target, name, value) {
  6822. var settings, date, minDate, maxDate,
  6823. inst = this._getInst(target);
  6824. if (arguments.length === 2 && typeof name === "string") {
  6825. return (name === "defaults" ? $.extend({}, $.datepicker._defaults) :
  6826. (inst ? (name === "all" ? $.extend({}, inst.settings) :
  6827. this._get(inst, name)) : null));
  6828. }
  6829. settings = name || {};
  6830. if (typeof name === "string") {
  6831. settings = {};
  6832. settings[name] = value;
  6833. }
  6834. if (inst) {
  6835. if (this._curInst === inst) {
  6836. this._hideDatepicker();
  6837. }
  6838. date = this._getDateDatepicker(target, true);
  6839. minDate = this._getMinMaxDate(inst, "min");
  6840. maxDate = this._getMinMaxDate(inst, "max");
  6841. extendRemove(inst.settings, settings);
  6842. // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
  6843. if (minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined) {
  6844. inst.settings.minDate = this._formatDate(inst, minDate);
  6845. }
  6846. if (maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined) {
  6847. inst.settings.maxDate = this._formatDate(inst, maxDate);
  6848. }
  6849. if ( "disabled" in settings ) {
  6850. if ( settings.disabled ) {
  6851. this._disableDatepicker(target);
  6852. } else {
  6853. this._enableDatepicker(target);
  6854. }
  6855. }
  6856. this._attachments($(target), inst);
  6857. this._autoSize(inst);
  6858. this._setDate(inst, date);
  6859. this._updateAlternate(inst);
  6860. this._updateDatepicker(inst);
  6861. }
  6862. },
  6863. // change method deprecated
  6864. _changeDatepicker: function(target, name, value) {
  6865. this._optionDatepicker(target, name, value);
  6866. },
  6867. /* Redraw the date picker attached to an input field or division.
  6868. * @param target element - the target input field or division or span
  6869. */
  6870. _refreshDatepicker: function(target) {
  6871. var inst = this._getInst(target);
  6872. if (inst) {
  6873. this._updateDatepicker(inst);
  6874. }
  6875. },
  6876. /* Set the dates for a jQuery selection.
  6877. * @param target element - the target input field or division or span
  6878. * @param date Date - the new date
  6879. */
  6880. _setDateDatepicker: function(target, date) {
  6881. var inst = this._getInst(target);
  6882. if (inst) {
  6883. this._setDate(inst, date);
  6884. this._updateDatepicker(inst);
  6885. this._updateAlternate(inst);
  6886. }
  6887. },
  6888. /* Get the date(s) for the first entry in a jQuery selection.
  6889. * @param target element - the target input field or division or span
  6890. * @param noDefault boolean - true if no default date is to be used
  6891. * @return Date - the current date
  6892. */
  6893. _getDateDatepicker: function(target, noDefault) {
  6894. var inst = this._getInst(target);
  6895. if (inst && !inst.inline) {
  6896. this._setDateFromField(inst, noDefault);
  6897. }
  6898. return (inst ? this._getDate(inst) : null);
  6899. },
  6900. /* Handle keystrokes. */
  6901. _doKeyDown: function(event) {
  6902. var onSelect, dateStr, sel,
  6903. inst = $.datepicker._getInst(event.target),
  6904. handled = true,
  6905. isRTL = inst.dpDiv.is(".ui-datepicker-rtl");
  6906. inst._keyEvent = true;
  6907. if ($.datepicker._datepickerShowing) {
  6908. switch (event.keyCode) {
  6909. case 9: $.datepicker._hideDatepicker();
  6910. handled = false;
  6911. break; // hide on tab out
  6912. case 13: sel = $("td." + $.datepicker._dayOverClass + ":not(." +
  6913. $.datepicker._currentClass + ")", inst.dpDiv);
  6914. if (sel[0]) {
  6915. $.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
  6916. }
  6917. onSelect = $.datepicker._get(inst, "onSelect");
  6918. if (onSelect) {
  6919. dateStr = $.datepicker._formatDate(inst);
  6920. // trigger custom callback
  6921. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);
  6922. } else {
  6923. $.datepicker._hideDatepicker();
  6924. }
  6925. return false; // don't submit the form
  6926. case 27: $.datepicker._hideDatepicker();
  6927. break; // hide on escape
  6928. case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6929. -$.datepicker._get(inst, "stepBigMonths") :
  6930. -$.datepicker._get(inst, "stepMonths")), "M");
  6931. break; // previous month/year on page up/+ ctrl
  6932. case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6933. +$.datepicker._get(inst, "stepBigMonths") :
  6934. +$.datepicker._get(inst, "stepMonths")), "M");
  6935. break; // next month/year on page down/+ ctrl
  6936. case 35: if (event.ctrlKey || event.metaKey) {
  6937. $.datepicker._clearDate(event.target);
  6938. }
  6939. handled = event.ctrlKey || event.metaKey;
  6940. break; // clear on ctrl or command +end
  6941. case 36: if (event.ctrlKey || event.metaKey) {
  6942. $.datepicker._gotoToday(event.target);
  6943. }
  6944. handled = event.ctrlKey || event.metaKey;
  6945. break; // current on ctrl or command +home
  6946. case 37: if (event.ctrlKey || event.metaKey) {
  6947. $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), "D");
  6948. }
  6949. handled = event.ctrlKey || event.metaKey;
  6950. // -1 day on ctrl or command +left
  6951. if (event.originalEvent.altKey) {
  6952. $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6953. -$.datepicker._get(inst, "stepBigMonths") :
  6954. -$.datepicker._get(inst, "stepMonths")), "M");
  6955. }
  6956. // next month/year on alt +left on Mac
  6957. break;
  6958. case 38: if (event.ctrlKey || event.metaKey) {
  6959. $.datepicker._adjustDate(event.target, -7, "D");
  6960. }
  6961. handled = event.ctrlKey || event.metaKey;
  6962. break; // -1 week on ctrl or command +up
  6963. case 39: if (event.ctrlKey || event.metaKey) {
  6964. $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), "D");
  6965. }
  6966. handled = event.ctrlKey || event.metaKey;
  6967. // +1 day on ctrl or command +right
  6968. if (event.originalEvent.altKey) {
  6969. $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  6970. +$.datepicker._get(inst, "stepBigMonths") :
  6971. +$.datepicker._get(inst, "stepMonths")), "M");
  6972. }
  6973. // next month/year on alt +right
  6974. break;
  6975. case 40: if (event.ctrlKey || event.metaKey) {
  6976. $.datepicker._adjustDate(event.target, +7, "D");
  6977. }
  6978. handled = event.ctrlKey || event.metaKey;
  6979. break; // +1 week on ctrl or command +down
  6980. default: handled = false;
  6981. }
  6982. } else if (event.keyCode === 36 && event.ctrlKey) { // display the date picker on ctrl+home
  6983. $.datepicker._showDatepicker(this);
  6984. } else {
  6985. handled = false;
  6986. }
  6987. if (handled) {
  6988. event.preventDefault();
  6989. event.stopPropagation();
  6990. }
  6991. },
  6992. /* Filter entered characters - based on date format. */
  6993. _doKeyPress: function(event) {
  6994. var chars, chr,
  6995. inst = $.datepicker._getInst(event.target);
  6996. if ($.datepicker._get(inst, "constrainInput")) {
  6997. chars = $.datepicker._possibleChars($.datepicker._get(inst, "dateFormat"));
  6998. chr = String.fromCharCode(event.charCode == null ? event.keyCode : event.charCode);
  6999. return event.ctrlKey || event.metaKey || (chr < " " || !chars || chars.indexOf(chr) > -1);
  7000. }
  7001. },
  7002. /* Synchronise manual entry and field/alternate field. */
  7003. _doKeyUp: function(event) {
  7004. var date,
  7005. inst = $.datepicker._getInst(event.target);
  7006. if (inst.input.val() !== inst.lastVal) {
  7007. try {
  7008. date = $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
  7009. (inst.input ? inst.input.val() : null),
  7010. $.datepicker._getFormatConfig(inst));
  7011. if (date) { // only if valid
  7012. $.datepicker._setDateFromField(inst);
  7013. $.datepicker._updateAlternate(inst);
  7014. $.datepicker._updateDatepicker(inst);
  7015. }
  7016. }
  7017. catch (err) {
  7018. }
  7019. }
  7020. return true;
  7021. },
  7022. /* Pop-up the date picker for a given input field.
  7023. * If false returned from beforeShow event handler do not show.
  7024. * @param input element - the input field attached to the date picker or
  7025. * event - if triggered by focus
  7026. */
  7027. _showDatepicker: function(input) {
  7028. input = input.target || input;
  7029. if (input.nodeName.toLowerCase() !== "input") { // find from button/image trigger
  7030. input = $("input", input.parentNode)[0];
  7031. }
  7032. if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput === input) { // already here
  7033. return;
  7034. }
  7035. var inst, beforeShow, beforeShowSettings, isFixed,
  7036. offset, showAnim, duration;
  7037. inst = $.datepicker._getInst(input);
  7038. if ($.datepicker._curInst && $.datepicker._curInst !== inst) {
  7039. $.datepicker._curInst.dpDiv.stop(true, true);
  7040. if ( inst && $.datepicker._datepickerShowing ) {
  7041. $.datepicker._hideDatepicker( $.datepicker._curInst.input[0] );
  7042. }
  7043. }
  7044. beforeShow = $.datepicker._get(inst, "beforeShow");
  7045. beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {};
  7046. if(beforeShowSettings === false){
  7047. return;
  7048. }
  7049. extendRemove(inst.settings, beforeShowSettings);
  7050. inst.lastVal = null;
  7051. $.datepicker._lastInput = input;
  7052. $.datepicker._setDateFromField(inst);
  7053. if ($.datepicker._inDialog) { // hide cursor
  7054. input.value = "";
  7055. }
  7056. if (!$.datepicker._pos) { // position below input
  7057. $.datepicker._pos = $.datepicker._findPos(input);
  7058. $.datepicker._pos[1] += input.offsetHeight; // add the height
  7059. }
  7060. isFixed = false;
  7061. $(input).parents().each(function() {
  7062. isFixed |= $(this).css("position") === "fixed";
  7063. return !isFixed;
  7064. });
  7065. offset = {left: $.datepicker._pos[0], top: $.datepicker._pos[1]};
  7066. $.datepicker._pos = null;
  7067. //to avoid flashes on Firefox
  7068. inst.dpDiv.empty();
  7069. // determine sizing offscreen
  7070. inst.dpDiv.css({position: "absolute", display: "block", top: "-1000px"});
  7071. $.datepicker._updateDatepicker(inst);
  7072. // fix width for dynamic number of date pickers
  7073. // and adjust position before showing
  7074. offset = $.datepicker._checkOffset(inst, offset, isFixed);
  7075. inst.dpDiv.css({position: ($.datepicker._inDialog && $.blockUI ?
  7076. "static" : (isFixed ? "fixed" : "absolute")), display: "none",
  7077. left: offset.left + "px", top: offset.top + "px"});
  7078. if (!inst.inline) {
  7079. showAnim = $.datepicker._get(inst, "showAnim");
  7080. duration = $.datepicker._get(inst, "duration");
  7081. inst.dpDiv.zIndex($(input).zIndex()+1);
  7082. $.datepicker._datepickerShowing = true;
  7083. if ( $.effects && $.effects.effect[ showAnim ] ) {
  7084. inst.dpDiv.show(showAnim, $.datepicker._get(inst, "showOptions"), duration);
  7085. } else {
  7086. inst.dpDiv[showAnim || "show"](showAnim ? duration : null);
  7087. }
  7088. if ( $.datepicker._shouldFocusInput( inst ) ) {
  7089. inst.input.focus();
  7090. }
  7091. $.datepicker._curInst = inst;
  7092. }
  7093. },
  7094. /* Generate the date picker content. */
  7095. _updateDatepicker: function(inst) {
  7096. this.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
  7097. instActive = inst; // for delegate hover events
  7098. inst.dpDiv.empty().append(this._generateHTML(inst));
  7099. this._attachHandlers(inst);
  7100. inst.dpDiv.find("." + this._dayOverClass + " a").mouseover();
  7101. var origyearshtml,
  7102. numMonths = this._getNumberOfMonths(inst),
  7103. cols = numMonths[1],
  7104. width = 17;
  7105. inst.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width("");
  7106. if (cols > 1) {
  7107. inst.dpDiv.addClass("ui-datepicker-multi-" + cols).css("width", (width * cols) + "em");
  7108. }
  7109. inst.dpDiv[(numMonths[0] !== 1 || numMonths[1] !== 1 ? "add" : "remove") +
  7110. "Class"]("ui-datepicker-multi");
  7111. inst.dpDiv[(this._get(inst, "isRTL") ? "add" : "remove") +
  7112. "Class"]("ui-datepicker-rtl");
  7113. if (inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) {
  7114. inst.input.focus();
  7115. }
  7116. // deffered render of the years select (to avoid flashes on Firefox)
  7117. if( inst.yearshtml ){
  7118. origyearshtml = inst.yearshtml;
  7119. setTimeout(function(){
  7120. //assure that inst.yearshtml didn't change.
  7121. if( origyearshtml === inst.yearshtml && inst.yearshtml ){
  7122. inst.dpDiv.find("select.ui-datepicker-year:first").replaceWith(inst.yearshtml);
  7123. }
  7124. origyearshtml = inst.yearshtml = null;
  7125. }, 0);
  7126. }
  7127. },
  7128. // #6694 - don't focus the input if it's already focused
  7129. // this breaks the change event in IE
  7130. // Support: IE and jQuery <1.9
  7131. _shouldFocusInput: function( inst ) {
  7132. return inst.input && inst.input.is( ":visible" ) && !inst.input.is( ":disabled" ) && !inst.input.is( ":focus" );
  7133. },
  7134. /* Check positioning to remain on screen. */
  7135. _checkOffset: function(inst, offset, isFixed) {
  7136. var dpWidth = inst.dpDiv.outerWidth(),
  7137. dpHeight = inst.dpDiv.outerHeight(),
  7138. inputWidth = inst.input ? inst.input.outerWidth() : 0,
  7139. inputHeight = inst.input ? inst.input.outerHeight() : 0,
  7140. viewWidth = document.documentElement.clientWidth + (isFixed ? 0 : $(document).scrollLeft()),
  7141. viewHeight = document.documentElement.clientHeight + (isFixed ? 0 : $(document).scrollTop());
  7142. offset.left -= (this._get(inst, "isRTL") ? (dpWidth - inputWidth) : 0);
  7143. offset.left -= (isFixed && offset.left === inst.input.offset().left) ? $(document).scrollLeft() : 0;
  7144. offset.top -= (isFixed && offset.top === (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
  7145. // now check if datepicker is showing outside window viewport - move to a better place if so.
  7146. offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
  7147. Math.abs(offset.left + dpWidth - viewWidth) : 0);
  7148. offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
  7149. Math.abs(dpHeight + inputHeight) : 0);
  7150. return offset;
  7151. },
  7152. /* Find an object's position on the screen. */
  7153. _findPos: function(obj) {
  7154. var position,
  7155. inst = this._getInst(obj),
  7156. isRTL = this._get(inst, "isRTL");
  7157. while (obj && (obj.type === "hidden" || obj.nodeType !== 1 || $.expr.filters.hidden(obj))) {
  7158. obj = obj[isRTL ? "previousSibling" : "nextSibling"];
  7159. }
  7160. position = $(obj).offset();
  7161. return [position.left, position.top];
  7162. },
  7163. /* Hide the date picker from view.
  7164. * @param input element - the input field attached to the date picker
  7165. */
  7166. _hideDatepicker: function(input) {
  7167. var showAnim, duration, postProcess, onClose,
  7168. inst = this._curInst;
  7169. if (!inst || (input && inst !== $.data(input, PROP_NAME))) {
  7170. return;
  7171. }
  7172. if (this._datepickerShowing) {
  7173. showAnim = this._get(inst, "showAnim");
  7174. duration = this._get(inst, "duration");
  7175. postProcess = function() {
  7176. $.datepicker._tidyDialog(inst);
  7177. };
  7178. // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
  7179. if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) {
  7180. inst.dpDiv.hide(showAnim, $.datepicker._get(inst, "showOptions"), duration, postProcess);
  7181. } else {
  7182. inst.dpDiv[(showAnim === "slideDown" ? "slideUp" :
  7183. (showAnim === "fadeIn" ? "fadeOut" : "hide"))]((showAnim ? duration : null), postProcess);
  7184. }
  7185. if (!showAnim) {
  7186. postProcess();
  7187. }
  7188. this._datepickerShowing = false;
  7189. onClose = this._get(inst, "onClose");
  7190. if (onClose) {
  7191. onClose.apply((inst.input ? inst.input[0] : null), [(inst.input ? inst.input.val() : ""), inst]);
  7192. }
  7193. this._lastInput = null;
  7194. if (this._inDialog) {
  7195. this._dialogInput.css({ position: "absolute", left: "0", top: "-100px" });
  7196. if ($.blockUI) {
  7197. $.unblockUI();
  7198. $("body").append(this.dpDiv);
  7199. }
  7200. }
  7201. this._inDialog = false;
  7202. }
  7203. },
  7204. /* Tidy up after a dialog display. */
  7205. _tidyDialog: function(inst) {
  7206. inst.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar");
  7207. },
  7208. /* Close date picker if clicked elsewhere. */
  7209. _checkExternalClick: function(event) {
  7210. if (!$.datepicker._curInst) {
  7211. return;
  7212. }
  7213. var $target = $(event.target),
  7214. inst = $.datepicker._getInst($target[0]);
  7215. if ( ( ( $target[0].id !== $.datepicker._mainDivId &&
  7216. $target.parents("#" + $.datepicker._mainDivId).length === 0 &&
  7217. !$target.hasClass($.datepicker.markerClassName) &&
  7218. !$target.closest("." + $.datepicker._triggerClass).length &&
  7219. $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI) ) ) ||
  7220. ( $target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst !== inst ) ) {
  7221. $.datepicker._hideDatepicker();
  7222. }
  7223. },
  7224. /* Adjust one of the date sub-fields. */
  7225. _adjustDate: function(id, offset, period) {
  7226. var target = $(id),
  7227. inst = this._getInst(target[0]);
  7228. if (this._isDisabledDatepicker(target[0])) {
  7229. return;
  7230. }
  7231. this._adjustInstDate(inst, offset +
  7232. (period === "M" ? this._get(inst, "showCurrentAtPos") : 0), // undo positioning
  7233. period);
  7234. this._updateDatepicker(inst);
  7235. },
  7236. /* Action for current link. */
  7237. _gotoToday: function(id) {
  7238. var date,
  7239. target = $(id),
  7240. inst = this._getInst(target[0]);
  7241. if (this._get(inst, "gotoCurrent") && inst.currentDay) {
  7242. inst.selectedDay = inst.currentDay;
  7243. inst.drawMonth = inst.selectedMonth = inst.currentMonth;
  7244. inst.drawYear = inst.selectedYear = inst.currentYear;
  7245. } else {
  7246. date = new Date();
  7247. inst.selectedDay = date.getDate();
  7248. inst.drawMonth = inst.selectedMonth = date.getMonth();
  7249. inst.drawYear = inst.selectedYear = date.getFullYear();
  7250. }
  7251. this._notifyChange(inst);
  7252. this._adjustDate(target);
  7253. },
  7254. /* Action for selecting a new month/year. */
  7255. _selectMonthYear: function(id, select, period) {
  7256. var target = $(id),
  7257. inst = this._getInst(target[0]);
  7258. inst["selected" + (period === "M" ? "Month" : "Year")] =
  7259. inst["draw" + (period === "M" ? "Month" : "Year")] =
  7260. parseInt(select.options[select.selectedIndex].value,10);
  7261. this._notifyChange(inst);
  7262. this._adjustDate(target);
  7263. },
  7264. /* Action for selecting a day. */
  7265. _selectDay: function(id, month, year, td) {
  7266. var inst,
  7267. target = $(id);
  7268. if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) {
  7269. return;
  7270. }
  7271. inst = this._getInst(target[0]);
  7272. inst.selectedDay = inst.currentDay = $("a", td).html();
  7273. inst.selectedMonth = inst.currentMonth = month;
  7274. inst.selectedYear = inst.currentYear = year;
  7275. this._selectDate(id, this._formatDate(inst,
  7276. inst.currentDay, inst.currentMonth, inst.currentYear));
  7277. },
  7278. /* Erase the input field and hide the date picker. */
  7279. _clearDate: function(id) {
  7280. var target = $(id);
  7281. this._selectDate(target, "");
  7282. },
  7283. /* Update the input field with the selected date. */
  7284. _selectDate: function(id, dateStr) {
  7285. var onSelect,
  7286. target = $(id),
  7287. inst = this._getInst(target[0]);
  7288. dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
  7289. if (inst.input) {
  7290. inst.input.val(dateStr);
  7291. }
  7292. this._updateAlternate(inst);
  7293. onSelect = this._get(inst, "onSelect");
  7294. if (onSelect) {
  7295. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback
  7296. } else if (inst.input) {
  7297. inst.input.trigger("change"); // fire the change event
  7298. }
  7299. if (inst.inline){
  7300. this._updateDatepicker(inst);
  7301. } else {
  7302. this._hideDatepicker();
  7303. this._lastInput = inst.input[0];
  7304. if (typeof(inst.input[0]) !== "object") {
  7305. inst.input.focus(); // restore focus
  7306. }
  7307. this._lastInput = null;
  7308. }
  7309. },
  7310. /* Update any alternate field to synchronise with the main field. */
  7311. _updateAlternate: function(inst) {
  7312. var altFormat, date, dateStr,
  7313. altField = this._get(inst, "altField");
  7314. if (altField) { // update alternate field too
  7315. altFormat = this._get(inst, "altFormat") || this._get(inst, "dateFormat");
  7316. date = this._getDate(inst);
  7317. dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
  7318. $(altField).each(function() { $(this).val(dateStr); });
  7319. }
  7320. },
  7321. /* Set as beforeShowDay function to prevent selection of weekends.
  7322. * @param date Date - the date to customise
  7323. * @return [boolean, string] - is this date selectable?, what is its CSS class?
  7324. */
  7325. noWeekends: function(date) {
  7326. var day = date.getDay();
  7327. return [(day > 0 && day < 6), ""];
  7328. },
  7329. /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
  7330. * @param date Date - the date to get the week for
  7331. * @return number - the number of the week within the year that contains this date
  7332. */
  7333. iso8601Week: function(date) {
  7334. var time,
  7335. checkDate = new Date(date.getTime());
  7336. // Find Thursday of this week starting on Monday
  7337. checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
  7338. time = checkDate.getTime();
  7339. checkDate.setMonth(0); // Compare with Jan 1
  7340. checkDate.setDate(1);
  7341. return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
  7342. },
  7343. /* Parse a string value into a date object.
  7344. * See formatDate below for the possible formats.
  7345. *
  7346. * @param format string - the expected format of the date
  7347. * @param value string - the date in the above format
  7348. * @param settings Object - attributes include:
  7349. * shortYearCutoff number - the cutoff year for determining the century (optional)
  7350. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  7351. * dayNames string[7] - names of the days from Sunday (optional)
  7352. * monthNamesShort string[12] - abbreviated names of the months (optional)
  7353. * monthNames string[12] - names of the months (optional)
  7354. * @return Date - the extracted date value or null if value is blank
  7355. */
  7356. parseDate: function (format, value, settings) {
  7357. if (format == null || value == null) {
  7358. throw "Invalid arguments";
  7359. }
  7360. value = (typeof value === "object" ? value.toString() : value + "");
  7361. if (value === "") {
  7362. return null;
  7363. }
  7364. var iFormat, dim, extra,
  7365. iValue = 0,
  7366. shortYearCutoffTemp = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff,
  7367. shortYearCutoff = (typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp :
  7368. new Date().getFullYear() % 100 + parseInt(shortYearCutoffTemp, 10)),
  7369. dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
  7370. dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
  7371. monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
  7372. monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
  7373. year = -1,
  7374. month = -1,
  7375. day = -1,
  7376. doy = -1,
  7377. literal = false,
  7378. date,
  7379. // Check whether a format character is doubled
  7380. lookAhead = function(match) {
  7381. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  7382. if (matches) {
  7383. iFormat++;
  7384. }
  7385. return matches;
  7386. },
  7387. // Extract a number from the string value
  7388. getNumber = function(match) {
  7389. var isDoubled = lookAhead(match),
  7390. size = (match === "@" ? 14 : (match === "!" ? 20 :
  7391. (match === "y" && isDoubled ? 4 : (match === "o" ? 3 : 2)))),
  7392. digits = new RegExp("^\\d{1," + size + "}"),
  7393. num = value.substring(iValue).match(digits);
  7394. if (!num) {
  7395. throw "Missing number at position " + iValue;
  7396. }
  7397. iValue += num[0].length;
  7398. return parseInt(num[0], 10);
  7399. },
  7400. // Extract a name from the string value and convert to an index
  7401. getName = function(match, shortNames, longNames) {
  7402. var index = -1,
  7403. names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) {
  7404. return [ [k, v] ];
  7405. }).sort(function (a, b) {
  7406. return -(a[1].length - b[1].length);
  7407. });
  7408. $.each(names, function (i, pair) {
  7409. var name = pair[1];
  7410. if (value.substr(iValue, name.length).toLowerCase() === name.toLowerCase()) {
  7411. index = pair[0];
  7412. iValue += name.length;
  7413. return false;
  7414. }
  7415. });
  7416. if (index !== -1) {
  7417. return index + 1;
  7418. } else {
  7419. throw "Unknown name at position " + iValue;
  7420. }
  7421. },
  7422. // Confirm that a literal character matches the string value
  7423. checkLiteral = function() {
  7424. if (value.charAt(iValue) !== format.charAt(iFormat)) {
  7425. throw "Unexpected literal at position " + iValue;
  7426. }
  7427. iValue++;
  7428. };
  7429. for (iFormat = 0; iFormat < format.length; iFormat++) {
  7430. if (literal) {
  7431. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  7432. literal = false;
  7433. } else {
  7434. checkLiteral();
  7435. }
  7436. } else {
  7437. switch (format.charAt(iFormat)) {
  7438. case "d":
  7439. day = getNumber("d");
  7440. break;
  7441. case "D":
  7442. getName("D", dayNamesShort, dayNames);
  7443. break;
  7444. case "o":
  7445. doy = getNumber("o");
  7446. break;
  7447. case "m":
  7448. month = getNumber("m");
  7449. break;
  7450. case "M":
  7451. month = getName("M", monthNamesShort, monthNames);
  7452. break;
  7453. case "y":
  7454. year = getNumber("y");
  7455. break;
  7456. case "@":
  7457. date = new Date(getNumber("@"));
  7458. year = date.getFullYear();
  7459. month = date.getMonth() + 1;
  7460. day = date.getDate();
  7461. break;
  7462. case "!":
  7463. date = new Date((getNumber("!") - this._ticksTo1970) / 10000);
  7464. year = date.getFullYear();
  7465. month = date.getMonth() + 1;
  7466. day = date.getDate();
  7467. break;
  7468. case "'":
  7469. if (lookAhead("'")){
  7470. checkLiteral();
  7471. } else {
  7472. literal = true;
  7473. }
  7474. break;
  7475. default:
  7476. checkLiteral();
  7477. }
  7478. }
  7479. }
  7480. if (iValue < value.length){
  7481. extra = value.substr(iValue);
  7482. if (!/^\s+/.test(extra)) {
  7483. throw "Extra/unparsed characters found in date: " + extra;
  7484. }
  7485. }
  7486. if (year === -1) {
  7487. year = new Date().getFullYear();
  7488. } else if (year < 100) {
  7489. year += new Date().getFullYear() - new Date().getFullYear() % 100 +
  7490. (year <= shortYearCutoff ? 0 : -100);
  7491. }
  7492. if (doy > -1) {
  7493. month = 1;
  7494. day = doy;
  7495. do {
  7496. dim = this._getDaysInMonth(year, month - 1);
  7497. if (day <= dim) {
  7498. break;
  7499. }
  7500. month++;
  7501. day -= dim;
  7502. } while (true);
  7503. }
  7504. date = this._daylightSavingAdjust(new Date(year, month - 1, day));
  7505. if (date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day) {
  7506. throw "Invalid date"; // E.g. 31/02/00
  7507. }
  7508. return date;
  7509. },
  7510. /* Standard date formats. */
  7511. ATOM: "yy-mm-dd", // RFC 3339 (ISO 8601)
  7512. COOKIE: "D, dd M yy",
  7513. ISO_8601: "yy-mm-dd",
  7514. RFC_822: "D, d M y",
  7515. RFC_850: "DD, dd-M-y",
  7516. RFC_1036: "D, d M y",
  7517. RFC_1123: "D, d M yy",
  7518. RFC_2822: "D, d M yy",
  7519. RSS: "D, d M y", // RFC 822
  7520. TICKS: "!",
  7521. TIMESTAMP: "@",
  7522. W3C: "yy-mm-dd", // ISO 8601
  7523. _ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) +
  7524. Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000),
  7525. /* Format a date object into a string value.
  7526. * The format can be combinations of the following:
  7527. * d - day of month (no leading zero)
  7528. * dd - day of month (two digit)
  7529. * o - day of year (no leading zeros)
  7530. * oo - day of year (three digit)
  7531. * D - day name short
  7532. * DD - day name long
  7533. * m - month of year (no leading zero)
  7534. * mm - month of year (two digit)
  7535. * M - month name short
  7536. * MM - month name long
  7537. * y - year (two digit)
  7538. * yy - year (four digit)
  7539. * @ - Unix timestamp (ms since 01/01/1970)
  7540. * ! - Windows ticks (100ns since 01/01/0001)
  7541. * "..." - literal text
  7542. * '' - single quote
  7543. *
  7544. * @param format string - the desired format of the date
  7545. * @param date Date - the date value to format
  7546. * @param settings Object - attributes include:
  7547. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  7548. * dayNames string[7] - names of the days from Sunday (optional)
  7549. * monthNamesShort string[12] - abbreviated names of the months (optional)
  7550. * monthNames string[12] - names of the months (optional)
  7551. * @return string - the date in the above format
  7552. */
  7553. formatDate: function (format, date, settings) {
  7554. if (!date) {
  7555. return "";
  7556. }
  7557. var iFormat,
  7558. dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
  7559. dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
  7560. monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
  7561. monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
  7562. // Check whether a format character is doubled
  7563. lookAhead = function(match) {
  7564. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  7565. if (matches) {
  7566. iFormat++;
  7567. }
  7568. return matches;
  7569. },
  7570. // Format a number, with leading zero if necessary
  7571. formatNumber = function(match, value, len) {
  7572. var num = "" + value;
  7573. if (lookAhead(match)) {
  7574. while (num.length < len) {
  7575. num = "0" + num;
  7576. }
  7577. }
  7578. return num;
  7579. },
  7580. // Format a name, short or long as requested
  7581. formatName = function(match, value, shortNames, longNames) {
  7582. return (lookAhead(match) ? longNames[value] : shortNames[value]);
  7583. },
  7584. output = "",
  7585. literal = false;
  7586. if (date) {
  7587. for (iFormat = 0; iFormat < format.length; iFormat++) {
  7588. if (literal) {
  7589. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  7590. literal = false;
  7591. } else {
  7592. output += format.charAt(iFormat);
  7593. }
  7594. } else {
  7595. switch (format.charAt(iFormat)) {
  7596. case "d":
  7597. output += formatNumber("d", date.getDate(), 2);
  7598. break;
  7599. case "D":
  7600. output += formatName("D", date.getDay(), dayNamesShort, dayNames);
  7601. break;
  7602. case "o":
  7603. output += formatNumber("o",
  7604. Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3);
  7605. break;
  7606. case "m":
  7607. output += formatNumber("m", date.getMonth() + 1, 2);
  7608. break;
  7609. case "M":
  7610. output += formatName("M", date.getMonth(), monthNamesShort, monthNames);
  7611. break;
  7612. case "y":
  7613. output += (lookAhead("y") ? date.getFullYear() :
  7614. (date.getYear() % 100 < 10 ? "0" : "") + date.getYear() % 100);
  7615. break;
  7616. case "@":
  7617. output += date.getTime();
  7618. break;
  7619. case "!":
  7620. output += date.getTime() * 10000 + this._ticksTo1970;
  7621. break;
  7622. case "'":
  7623. if (lookAhead("'")) {
  7624. output += "'";
  7625. } else {
  7626. literal = true;
  7627. }
  7628. break;
  7629. default:
  7630. output += format.charAt(iFormat);
  7631. }
  7632. }
  7633. }
  7634. }
  7635. return output;
  7636. },
  7637. /* Extract all possible characters from the date format. */
  7638. _possibleChars: function (format) {
  7639. var iFormat,
  7640. chars = "",
  7641. literal = false,
  7642. // Check whether a format character is doubled
  7643. lookAhead = function(match) {
  7644. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  7645. if (matches) {
  7646. iFormat++;
  7647. }
  7648. return matches;
  7649. };
  7650. for (iFormat = 0; iFormat < format.length; iFormat++) {
  7651. if (literal) {
  7652. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  7653. literal = false;
  7654. } else {
  7655. chars += format.charAt(iFormat);
  7656. }
  7657. } else {
  7658. switch (format.charAt(iFormat)) {
  7659. case "d": case "m": case "y": case "@":
  7660. chars += "0123456789";
  7661. break;
  7662. case "D": case "M":
  7663. return null; // Accept anything
  7664. case "'":
  7665. if (lookAhead("'")) {
  7666. chars += "'";
  7667. } else {
  7668. literal = true;
  7669. }
  7670. break;
  7671. default:
  7672. chars += format.charAt(iFormat);
  7673. }
  7674. }
  7675. }
  7676. return chars;
  7677. },
  7678. /* Get a setting value, defaulting if necessary. */
  7679. _get: function(inst, name) {
  7680. return inst.settings[name] !== undefined ?
  7681. inst.settings[name] : this._defaults[name];
  7682. },
  7683. /* Parse existing date and initialise date picker. */
  7684. _setDateFromField: function(inst, noDefault) {
  7685. if (inst.input.val() === inst.lastVal) {
  7686. return;
  7687. }
  7688. var dateFormat = this._get(inst, "dateFormat"),
  7689. dates = inst.lastVal = inst.input ? inst.input.val() : null,
  7690. defaultDate = this._getDefaultDate(inst),
  7691. date = defaultDate,
  7692. settings = this._getFormatConfig(inst);
  7693. try {
  7694. date = this.parseDate(dateFormat, dates, settings) || defaultDate;
  7695. } catch (event) {
  7696. dates = (noDefault ? "" : dates);
  7697. }
  7698. inst.selectedDay = date.getDate();
  7699. inst.drawMonth = inst.selectedMonth = date.getMonth();
  7700. inst.drawYear = inst.selectedYear = date.getFullYear();
  7701. inst.currentDay = (dates ? date.getDate() : 0);
  7702. inst.currentMonth = (dates ? date.getMonth() : 0);
  7703. inst.currentYear = (dates ? date.getFullYear() : 0);
  7704. this._adjustInstDate(inst);
  7705. },
  7706. /* Retrieve the default date shown on opening. */
  7707. _getDefaultDate: function(inst) {
  7708. return this._restrictMinMax(inst,
  7709. this._determineDate(inst, this._get(inst, "defaultDate"), new Date()));
  7710. },
  7711. /* A date may be specified as an exact value or a relative one. */
  7712. _determineDate: function(inst, date, defaultDate) {
  7713. var offsetNumeric = function(offset) {
  7714. var date = new Date();
  7715. date.setDate(date.getDate() + offset);
  7716. return date;
  7717. },
  7718. offsetString = function(offset) {
  7719. try {
  7720. return $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
  7721. offset, $.datepicker._getFormatConfig(inst));
  7722. }
  7723. catch (e) {
  7724. // Ignore
  7725. }
  7726. var date = (offset.toLowerCase().match(/^c/) ?
  7727. $.datepicker._getDate(inst) : null) || new Date(),
  7728. year = date.getFullYear(),
  7729. month = date.getMonth(),
  7730. day = date.getDate(),
  7731. pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,
  7732. matches = pattern.exec(offset);
  7733. while (matches) {
  7734. switch (matches[2] || "d") {
  7735. case "d" : case "D" :
  7736. day += parseInt(matches[1],10); break;
  7737. case "w" : case "W" :
  7738. day += parseInt(matches[1],10) * 7; break;
  7739. case "m" : case "M" :
  7740. month += parseInt(matches[1],10);
  7741. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  7742. break;
  7743. case "y": case "Y" :
  7744. year += parseInt(matches[1],10);
  7745. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  7746. break;
  7747. }
  7748. matches = pattern.exec(offset);
  7749. }
  7750. return new Date(year, month, day);
  7751. },
  7752. newDate = (date == null || date === "" ? defaultDate : (typeof date === "string" ? offsetString(date) :
  7753. (typeof date === "number" ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime()))));
  7754. newDate = (newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate);
  7755. if (newDate) {
  7756. newDate.setHours(0);
  7757. newDate.setMinutes(0);
  7758. newDate.setSeconds(0);
  7759. newDate.setMilliseconds(0);
  7760. }
  7761. return this._daylightSavingAdjust(newDate);
  7762. },
  7763. /* Handle switch to/from daylight saving.
  7764. * Hours may be non-zero on daylight saving cut-over:
  7765. * > 12 when midnight changeover, but then cannot generate
  7766. * midnight datetime, so jump to 1AM, otherwise reset.
  7767. * @param date (Date) the date to check
  7768. * @return (Date) the corrected date
  7769. */
  7770. _daylightSavingAdjust: function(date) {
  7771. if (!date) {
  7772. return null;
  7773. }
  7774. date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
  7775. return date;
  7776. },
  7777. /* Set the date(s) directly. */
  7778. _setDate: function(inst, date, noChange) {
  7779. var clear = !date,
  7780. origMonth = inst.selectedMonth,
  7781. origYear = inst.selectedYear,
  7782. newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
  7783. inst.selectedDay = inst.currentDay = newDate.getDate();
  7784. inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
  7785. inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
  7786. if ((origMonth !== inst.selectedMonth || origYear !== inst.selectedYear) && !noChange) {
  7787. this._notifyChange(inst);
  7788. }
  7789. this._adjustInstDate(inst);
  7790. if (inst.input) {
  7791. inst.input.val(clear ? "" : this._formatDate(inst));
  7792. }
  7793. },
  7794. /* Retrieve the date(s) directly. */
  7795. _getDate: function(inst) {
  7796. var startDate = (!inst.currentYear || (inst.input && inst.input.val() === "") ? null :
  7797. this._daylightSavingAdjust(new Date(
  7798. inst.currentYear, inst.currentMonth, inst.currentDay)));
  7799. return startDate;
  7800. },
  7801. /* Attach the onxxx handlers. These are declared statically so
  7802. * they work with static code transformers like Caja.
  7803. */
  7804. _attachHandlers: function(inst) {
  7805. var stepMonths = this._get(inst, "stepMonths"),
  7806. id = "#" + inst.id.replace( /\\\\/g, "\\" );
  7807. inst.dpDiv.find("[data-handler]").map(function () {
  7808. var handler = {
  7809. prev: function () {
  7810. $.datepicker._adjustDate(id, -stepMonths, "M");
  7811. },
  7812. next: function () {
  7813. $.datepicker._adjustDate(id, +stepMonths, "M");
  7814. },
  7815. hide: function () {
  7816. $.datepicker._hideDatepicker();
  7817. },
  7818. today: function () {
  7819. $.datepicker._gotoToday(id);
  7820. },
  7821. selectDay: function () {
  7822. $.datepicker._selectDay(id, +this.getAttribute("data-month"), +this.getAttribute("data-year"), this);
  7823. return false;
  7824. },
  7825. selectMonth: function () {
  7826. $.datepicker._selectMonthYear(id, this, "M");
  7827. return false;
  7828. },
  7829. selectYear: function () {
  7830. $.datepicker._selectMonthYear(id, this, "Y");
  7831. return false;
  7832. }
  7833. };
  7834. $(this).bind(this.getAttribute("data-event"), handler[this.getAttribute("data-handler")]);
  7835. });
  7836. },
  7837. /* Generate the HTML for the current state of the date picker. */
  7838. _generateHTML: function(inst) {
  7839. var maxDraw, prevText, prev, nextText, next, currentText, gotoDate,
  7840. controls, buttonPanel, firstDay, showWeek, dayNames, dayNamesMin,
  7841. monthNames, monthNamesShort, beforeShowDay, showOtherMonths,
  7842. selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate,
  7843. cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows,
  7844. printDate, dRow, tbody, daySettings, otherMonth, unselectable,
  7845. tempDate = new Date(),
  7846. today = this._daylightSavingAdjust(
  7847. new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate())), // clear time
  7848. isRTL = this._get(inst, "isRTL"),
  7849. showButtonPanel = this._get(inst, "showButtonPanel"),
  7850. hideIfNoPrevNext = this._get(inst, "hideIfNoPrevNext"),
  7851. navigationAsDateFormat = this._get(inst, "navigationAsDateFormat"),
  7852. numMonths = this._getNumberOfMonths(inst),
  7853. showCurrentAtPos = this._get(inst, "showCurrentAtPos"),
  7854. stepMonths = this._get(inst, "stepMonths"),
  7855. isMultiMonth = (numMonths[0] !== 1 || numMonths[1] !== 1),
  7856. currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
  7857. new Date(inst.currentYear, inst.currentMonth, inst.currentDay))),
  7858. minDate = this._getMinMaxDate(inst, "min"),
  7859. maxDate = this._getMinMaxDate(inst, "max"),
  7860. drawMonth = inst.drawMonth - showCurrentAtPos,
  7861. drawYear = inst.drawYear;
  7862. if (drawMonth < 0) {
  7863. drawMonth += 12;
  7864. drawYear--;
  7865. }
  7866. if (maxDate) {
  7867. maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
  7868. maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate()));
  7869. maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
  7870. while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
  7871. drawMonth--;
  7872. if (drawMonth < 0) {
  7873. drawMonth = 11;
  7874. drawYear--;
  7875. }
  7876. }
  7877. }
  7878. inst.drawMonth = drawMonth;
  7879. inst.drawYear = drawYear;
  7880. prevText = this._get(inst, "prevText");
  7881. prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText,
  7882. this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
  7883. this._getFormatConfig(inst)));
  7884. prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
  7885. "<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click'" +
  7886. " title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w") + "'>" + prevText + "</span></a>" :
  7887. (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>"));
  7888. nextText = this._get(inst, "nextText");
  7889. nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
  7890. this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
  7891. this._getFormatConfig(inst)));
  7892. next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
  7893. "<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click'" +
  7894. " title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e") + "'>" + nextText + "</span></a>" :
  7895. (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>"));
  7896. currentText = this._get(inst, "currentText");
  7897. gotoDate = (this._get(inst, "gotoCurrent") && inst.currentDay ? currentDate : today);
  7898. currentText = (!navigationAsDateFormat ? currentText :
  7899. this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
  7900. 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'>" +
  7901. this._get(inst, "closeText") + "</button>" : "");
  7902. buttonPanel = (showButtonPanel) ? "<div class='ui-datepicker-buttonpane ui-widget-content'>" + (isRTL ? controls : "") +
  7903. (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'" +
  7904. ">" + currentText + "</button>" : "") + (isRTL ? "" : controls) + "</div>" : "";
  7905. firstDay = parseInt(this._get(inst, "firstDay"),10);
  7906. firstDay = (isNaN(firstDay) ? 0 : firstDay);
  7907. showWeek = this._get(inst, "showWeek");
  7908. dayNames = this._get(inst, "dayNames");
  7909. dayNamesMin = this._get(inst, "dayNamesMin");
  7910. monthNames = this._get(inst, "monthNames");
  7911. monthNamesShort = this._get(inst, "monthNamesShort");
  7912. beforeShowDay = this._get(inst, "beforeShowDay");
  7913. showOtherMonths = this._get(inst, "showOtherMonths");
  7914. selectOtherMonths = this._get(inst, "selectOtherMonths");
  7915. defaultDate = this._getDefaultDate(inst);
  7916. html = "";
  7917. dow;
  7918. for (row = 0; row < numMonths[0]; row++) {
  7919. group = "";
  7920. this.maxRows = 4;
  7921. for (col = 0; col < numMonths[1]; col++) {
  7922. selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
  7923. cornerClass = " ui-corner-all";
  7924. calender = "";
  7925. if (isMultiMonth) {
  7926. calender += "<div class='ui-datepicker-group";
  7927. if (numMonths[1] > 1) {
  7928. switch (col) {
  7929. case 0: calender += " ui-datepicker-group-first";
  7930. cornerClass = " ui-corner-" + (isRTL ? "right" : "left"); break;
  7931. case numMonths[1]-1: calender += " ui-datepicker-group-last";
  7932. cornerClass = " ui-corner-" + (isRTL ? "left" : "right"); break;
  7933. default: calender += " ui-datepicker-group-middle"; cornerClass = ""; break;
  7934. }
  7935. }
  7936. calender += "'>";
  7937. }
  7938. calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" +
  7939. (/all|left/.test(cornerClass) && row === 0 ? (isRTL ? next : prev) : "") +
  7940. (/all|right/.test(cornerClass) && row === 0 ? (isRTL ? prev : next) : "") +
  7941. this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
  7942. row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers
  7943. "</div><table class='ui-datepicker-calendar'><thead>" +
  7944. "<tr>";
  7945. thead = (showWeek ? "<th class='ui-datepicker-week-col'>" + this._get(inst, "weekHeader") + "</th>" : "");
  7946. for (dow = 0; dow < 7; dow++) { // days of the week
  7947. day = (dow + firstDay) % 7;
  7948. thead += "<th" + ((dow + firstDay + 6) % 7 >= 5 ? " class='ui-datepicker-week-end'" : "") + ">" +
  7949. "<span title='" + dayNames[day] + "'>" + dayNamesMin[day] + "</span></th>";
  7950. }
  7951. calender += thead + "</tr></thead><tbody>";
  7952. daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
  7953. if (drawYear === inst.selectedYear && drawMonth === inst.selectedMonth) {
  7954. inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
  7955. }
  7956. leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
  7957. curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate
  7958. numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043)
  7959. this.maxRows = numRows;
  7960. printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
  7961. for (dRow = 0; dRow < numRows; dRow++) { // create date picker rows
  7962. calender += "<tr>";
  7963. tbody = (!showWeek ? "" : "<td class='ui-datepicker-week-col'>" +
  7964. this._get(inst, "calculateWeek")(printDate) + "</td>");
  7965. for (dow = 0; dow < 7; dow++) { // create date picker days
  7966. daySettings = (beforeShowDay ?
  7967. beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, ""]);
  7968. otherMonth = (printDate.getMonth() !== drawMonth);
  7969. unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] ||
  7970. (minDate && printDate < minDate) || (maxDate && printDate > maxDate);
  7971. tbody += "<td class='" +
  7972. ((dow + firstDay + 6) % 7 >= 5 ? " ui-datepicker-week-end" : "") + // highlight weekends
  7973. (otherMonth ? " ui-datepicker-other-month" : "") + // highlight days from other months
  7974. ((printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent) || // user pressed key
  7975. (defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime()) ?
  7976. // or defaultDate is current printedDate and defaultDate is selectedDate
  7977. " " + this._dayOverClass : "") + // highlight selected day
  7978. (unselectable ? " " + this._unselectableClass + " ui-state-disabled": "") + // highlight unselectable days
  7979. (otherMonth && !showOtherMonths ? "" : " " + daySettings[1] + // highlight custom dates
  7980. (printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "") + // highlight selected day
  7981. (printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "")) + "'" + // highlight today (if different)
  7982. ((!otherMonth || showOtherMonths) && daySettings[2] ? " title='" + daySettings[2].replace(/'/g, "&#39;") + "'" : "") + // cell title
  7983. (unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'") + ">" + // actions
  7984. (otherMonth && !showOtherMonths ? "&#xa0;" : // display for other months
  7985. (unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" +
  7986. (printDate.getTime() === today.getTime() ? " ui-state-highlight" : "") +
  7987. (printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "") + // highlight selected day
  7988. (otherMonth ? " ui-priority-secondary" : "") + // distinguish dates from other months
  7989. "' href='#'>" + printDate.getDate() + "</a>")) + "</td>"; // display selectable date
  7990. printDate.setDate(printDate.getDate() + 1);
  7991. printDate = this._daylightSavingAdjust(printDate);
  7992. }
  7993. calender += tbody + "</tr>";
  7994. }
  7995. drawMonth++;
  7996. if (drawMonth > 11) {
  7997. drawMonth = 0;
  7998. drawYear++;
  7999. }
  8000. calender += "</tbody></table>" + (isMultiMonth ? "</div>" +
  8001. ((numMonths[0] > 0 && col === numMonths[1]-1) ? "<div class='ui-datepicker-row-break'></div>" : "") : "");
  8002. group += calender;
  8003. }
  8004. html += group;
  8005. }
  8006. html += buttonPanel;
  8007. inst._keyEvent = false;
  8008. return html;
  8009. },
  8010. /* Generate the month and year header. */
  8011. _generateMonthYearHeader: function(inst, drawMonth, drawYear, minDate, maxDate,
  8012. secondary, monthNames, monthNamesShort) {
  8013. var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear,
  8014. changeMonth = this._get(inst, "changeMonth"),
  8015. changeYear = this._get(inst, "changeYear"),
  8016. showMonthAfterYear = this._get(inst, "showMonthAfterYear"),
  8017. html = "<div class='ui-datepicker-title'>",
  8018. monthHtml = "";
  8019. // month selection
  8020. if (secondary || !changeMonth) {
  8021. monthHtml += "<span class='ui-datepicker-month'>" + monthNames[drawMonth] + "</span>";
  8022. } else {
  8023. inMinYear = (minDate && minDate.getFullYear() === drawYear);
  8024. inMaxYear = (maxDate && maxDate.getFullYear() === drawYear);
  8025. monthHtml += "<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>";
  8026. for ( month = 0; month < 12; month++) {
  8027. if ((!inMinYear || month >= minDate.getMonth()) && (!inMaxYear || month <= maxDate.getMonth())) {
  8028. monthHtml += "<option value='" + month + "'" +
  8029. (month === drawMonth ? " selected='selected'" : "") +
  8030. ">" + monthNamesShort[month] + "</option>";
  8031. }
  8032. }
  8033. monthHtml += "</select>";
  8034. }
  8035. if (!showMonthAfterYear) {
  8036. html += monthHtml + (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "");
  8037. }
  8038. // year selection
  8039. if ( !inst.yearshtml ) {
  8040. inst.yearshtml = "";
  8041. if (secondary || !changeYear) {
  8042. html += "<span class='ui-datepicker-year'>" + drawYear + "</span>";
  8043. } else {
  8044. // determine range of years to display
  8045. years = this._get(inst, "yearRange").split(":");
  8046. thisYear = new Date().getFullYear();
  8047. determineYear = function(value) {
  8048. var year = (value.match(/c[+\-].*/) ? drawYear + parseInt(value.substring(1), 10) :
  8049. (value.match(/[+\-].*/) ? thisYear + parseInt(value, 10) :
  8050. parseInt(value, 10)));
  8051. return (isNaN(year) ? thisYear : year);
  8052. };
  8053. year = determineYear(years[0]);
  8054. endYear = Math.max(year, determineYear(years[1] || ""));
  8055. year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
  8056. endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
  8057. inst.yearshtml += "<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>";
  8058. for (; year <= endYear; year++) {
  8059. inst.yearshtml += "<option value='" + year + "'" +
  8060. (year === drawYear ? " selected='selected'" : "") +
  8061. ">" + year + "</option>";
  8062. }
  8063. inst.yearshtml += "</select>";
  8064. html += inst.yearshtml;
  8065. inst.yearshtml = null;
  8066. }
  8067. }
  8068. html += this._get(inst, "yearSuffix");
  8069. if (showMonthAfterYear) {
  8070. html += (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "") + monthHtml;
  8071. }
  8072. html += "</div>"; // Close datepicker_header
  8073. return html;
  8074. },
  8075. /* Adjust one of the date sub-fields. */
  8076. _adjustInstDate: function(inst, offset, period) {
  8077. var year = inst.drawYear + (period === "Y" ? offset : 0),
  8078. month = inst.drawMonth + (period === "M" ? offset : 0),
  8079. day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) + (period === "D" ? offset : 0),
  8080. date = this._restrictMinMax(inst, this._daylightSavingAdjust(new Date(year, month, day)));
  8081. inst.selectedDay = date.getDate();
  8082. inst.drawMonth = inst.selectedMonth = date.getMonth();
  8083. inst.drawYear = inst.selectedYear = date.getFullYear();
  8084. if (period === "M" || period === "Y") {
  8085. this._notifyChange(inst);
  8086. }
  8087. },
  8088. /* Ensure a date is within any min/max bounds. */
  8089. _restrictMinMax: function(inst, date) {
  8090. var minDate = this._getMinMaxDate(inst, "min"),
  8091. maxDate = this._getMinMaxDate(inst, "max"),
  8092. newDate = (minDate && date < minDate ? minDate : date);
  8093. return (maxDate && newDate > maxDate ? maxDate : newDate);
  8094. },
  8095. /* Notify change of month/year. */
  8096. _notifyChange: function(inst) {
  8097. var onChange = this._get(inst, "onChangeMonthYear");
  8098. if (onChange) {
  8099. onChange.apply((inst.input ? inst.input[0] : null),
  8100. [inst.selectedYear, inst.selectedMonth + 1, inst]);
  8101. }
  8102. },
  8103. /* Determine the number of months to show. */
  8104. _getNumberOfMonths: function(inst) {
  8105. var numMonths = this._get(inst, "numberOfMonths");
  8106. return (numMonths == null ? [1, 1] : (typeof numMonths === "number" ? [1, numMonths] : numMonths));
  8107. },
  8108. /* Determine the current maximum date - ensure no time components are set. */
  8109. _getMinMaxDate: function(inst, minMax) {
  8110. return this._determineDate(inst, this._get(inst, minMax + "Date"), null);
  8111. },
  8112. /* Find the number of days in a given month. */
  8113. _getDaysInMonth: function(year, month) {
  8114. return 32 - this._daylightSavingAdjust(new Date(year, month, 32)).getDate();
  8115. },
  8116. /* Find the day of the week of the first of a month. */
  8117. _getFirstDayOfMonth: function(year, month) {
  8118. return new Date(year, month, 1).getDay();
  8119. },
  8120. /* Determines if we should allow a "next/prev" month display change. */
  8121. _canAdjustMonth: function(inst, offset, curYear, curMonth) {
  8122. var numMonths = this._getNumberOfMonths(inst),
  8123. date = this._daylightSavingAdjust(new Date(curYear,
  8124. curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1));
  8125. if (offset < 0) {
  8126. date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
  8127. }
  8128. return this._isInRange(inst, date);
  8129. },
  8130. /* Is the given date in the accepted range? */
  8131. _isInRange: function(inst, date) {
  8132. var yearSplit, currentYear,
  8133. minDate = this._getMinMaxDate(inst, "min"),
  8134. maxDate = this._getMinMaxDate(inst, "max"),
  8135. minYear = null,
  8136. maxYear = null,
  8137. years = this._get(inst, "yearRange");
  8138. if (years){
  8139. yearSplit = years.split(":");
  8140. currentYear = new Date().getFullYear();
  8141. minYear = parseInt(yearSplit[0], 10);
  8142. maxYear = parseInt(yearSplit[1], 10);
  8143. if ( yearSplit[0].match(/[+\-].*/) ) {
  8144. minYear += currentYear;
  8145. }
  8146. if ( yearSplit[1].match(/[+\-].*/) ) {
  8147. maxYear += currentYear;
  8148. }
  8149. }
  8150. return ((!minDate || date.getTime() >= minDate.getTime()) &&
  8151. (!maxDate || date.getTime() <= maxDate.getTime()) &&
  8152. (!minYear || date.getFullYear() >= minYear) &&
  8153. (!maxYear || date.getFullYear() <= maxYear));
  8154. },
  8155. /* Provide the configuration settings for formatting/parsing. */
  8156. _getFormatConfig: function(inst) {
  8157. var shortYearCutoff = this._get(inst, "shortYearCutoff");
  8158. shortYearCutoff = (typeof shortYearCutoff !== "string" ? shortYearCutoff :
  8159. new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
  8160. return {shortYearCutoff: shortYearCutoff,
  8161. dayNamesShort: this._get(inst, "dayNamesShort"), dayNames: this._get(inst, "dayNames"),
  8162. monthNamesShort: this._get(inst, "monthNamesShort"), monthNames: this._get(inst, "monthNames")};
  8163. },
  8164. /* Format the given date for display. */
  8165. _formatDate: function(inst, day, month, year) {
  8166. if (!day) {
  8167. inst.currentDay = inst.selectedDay;
  8168. inst.currentMonth = inst.selectedMonth;
  8169. inst.currentYear = inst.selectedYear;
  8170. }
  8171. var date = (day ? (typeof day === "object" ? day :
  8172. this._daylightSavingAdjust(new Date(year, month, day))) :
  8173. this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
  8174. return this.formatDate(this._get(inst, "dateFormat"), date, this._getFormatConfig(inst));
  8175. }
  8176. });
  8177. /*
  8178. * Bind hover events for datepicker elements.
  8179. * Done via delegate so the binding only occurs once in the lifetime of the parent div.
  8180. * Global instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
  8181. */
  8182. function bindHover(dpDiv) {
  8183. var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";
  8184. return dpDiv.delegate(selector, "mouseout", function() {
  8185. $(this).removeClass("ui-state-hover");
  8186. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  8187. $(this).removeClass("ui-datepicker-prev-hover");
  8188. }
  8189. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  8190. $(this).removeClass("ui-datepicker-next-hover");
  8191. }
  8192. })
  8193. .delegate(selector, "mouseover", function(){
  8194. if (!$.datepicker._isDisabledDatepicker( instActive.inline ? dpDiv.parent()[0] : instActive.input[0])) {
  8195. $(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover");
  8196. $(this).addClass("ui-state-hover");
  8197. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  8198. $(this).addClass("ui-datepicker-prev-hover");
  8199. }
  8200. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  8201. $(this).addClass("ui-datepicker-next-hover");
  8202. }
  8203. }
  8204. });
  8205. }
  8206. /* jQuery extend now ignores nulls! */
  8207. function extendRemove(target, props) {
  8208. $.extend(target, props);
  8209. for (var name in props) {
  8210. if (props[name] == null) {
  8211. target[name] = props[name];
  8212. }
  8213. }
  8214. return target;
  8215. }
  8216. /* Invoke the datepicker functionality.
  8217. @param options string - a command, optionally followed by additional parameters or
  8218. Object - settings for attaching new datepicker functionality
  8219. @return jQuery object */
  8220. $.fn.datepicker = function(options){
  8221. /* Verify an empty collection wasn't passed - Fixes #6976 */
  8222. if ( !this.length ) {
  8223. return this;
  8224. }
  8225. /* Initialise the date picker. */
  8226. if (!$.datepicker.initialized) {
  8227. $(document).mousedown($.datepicker._checkExternalClick);
  8228. $.datepicker.initialized = true;
  8229. }
  8230. /* Append datepicker main container to body if not exist. */
  8231. if ($("#"+$.datepicker._mainDivId).length === 0) {
  8232. $("body").append($.datepicker.dpDiv);
  8233. }
  8234. var otherArgs = Array.prototype.slice.call(arguments, 1);
  8235. if (typeof options === "string" && (options === "isDisabled" || options === "getDate" || options === "widget")) {
  8236. return $.datepicker["_" + options + "Datepicker"].
  8237. apply($.datepicker, [this[0]].concat(otherArgs));
  8238. }
  8239. if (options === "option" && arguments.length === 2 && typeof arguments[1] === "string") {
  8240. return $.datepicker["_" + options + "Datepicker"].
  8241. apply($.datepicker, [this[0]].concat(otherArgs));
  8242. }
  8243. return this.each(function() {
  8244. typeof options === "string" ?
  8245. $.datepicker["_" + options + "Datepicker"].
  8246. apply($.datepicker, [this].concat(otherArgs)) :
  8247. $.datepicker._attachDatepicker(this, options);
  8248. });
  8249. };
  8250. $.datepicker = new Datepicker(); // singleton instance
  8251. $.datepicker.initialized = false;
  8252. $.datepicker.uuid = new Date().getTime();
  8253. $.datepicker.version = "1.10.3";
  8254. })(jQuery);
  8255. (function( $, undefined ) {
  8256. var sizeRelatedOptions = {
  8257. buttons: true,
  8258. height: true,
  8259. maxHeight: true,
  8260. maxWidth: true,
  8261. minHeight: true,
  8262. minWidth: true,
  8263. width: true
  8264. },
  8265. resizableRelatedOptions = {
  8266. maxHeight: true,
  8267. maxWidth: true,
  8268. minHeight: true,
  8269. minWidth: true
  8270. };
  8271. $.widget( "ui.dialog", {
  8272. version: "1.10.3",
  8273. options: {
  8274. appendTo: "body",
  8275. autoOpen: true,
  8276. buttons: [],
  8277. closeOnEscape: true,
  8278. closeText: "close",
  8279. dialogClass: "",
  8280. draggable: true,
  8281. hide: null,
  8282. height: "auto",
  8283. maxHeight: null,
  8284. maxWidth: null,
  8285. minHeight: 150,
  8286. minWidth: 150,
  8287. modal: false,
  8288. position: {
  8289. my: "center",
  8290. at: "center",
  8291. of: window,
  8292. collision: "fit",
  8293. // Ensure the titlebar is always visible
  8294. using: function( pos ) {
  8295. var topOffset = $( this ).css( pos ).offset().top;
  8296. if ( topOffset < 0 ) {
  8297. $( this ).css( "top", pos.top - topOffset );
  8298. }
  8299. }
  8300. },
  8301. resizable: true,
  8302. show: null,
  8303. title: null,
  8304. width: 300,
  8305. // callbacks
  8306. beforeClose: null,
  8307. close: null,
  8308. drag: null,
  8309. dragStart: null,
  8310. dragStop: null,
  8311. focus: null,
  8312. open: null,
  8313. resize: null,
  8314. resizeStart: null,
  8315. resizeStop: null
  8316. },
  8317. _create: function() {
  8318. this.originalCss = {
  8319. display: this.element[0].style.display,
  8320. width: this.element[0].style.width,
  8321. minHeight: this.element[0].style.minHeight,
  8322. maxHeight: this.element[0].style.maxHeight,
  8323. height: this.element[0].style.height
  8324. };
  8325. this.originalPosition = {
  8326. parent: this.element.parent(),
  8327. index: this.element.parent().children().index( this.element )
  8328. };
  8329. this.originalTitle = this.element.attr("title");
  8330. this.options.title = this.options.title || this.originalTitle;
  8331. this._createWrapper();
  8332. this.element
  8333. .show()
  8334. .removeAttr("title")
  8335. .addClass("ui-dialog-content ui-widget-content")
  8336. .appendTo( this.uiDialog );
  8337. this._createTitlebar();
  8338. this._createButtonPane();
  8339. if ( this.options.draggable && $.fn.draggable ) {
  8340. this._makeDraggable();
  8341. }
  8342. if ( this.options.resizable && $.fn.resizable ) {
  8343. this._makeResizable();
  8344. }
  8345. this._isOpen = false;
  8346. },
  8347. _init: function() {
  8348. if ( this.options.autoOpen ) {
  8349. this.open();
  8350. }
  8351. },
  8352. _appendTo: function() {
  8353. var element = this.options.appendTo;
  8354. if ( element && (element.jquery || element.nodeType) ) {
  8355. return $( element );
  8356. }
  8357. return this.document.find( element || "body" ).eq( 0 );
  8358. },
  8359. _destroy: function() {
  8360. var next,
  8361. originalPosition = this.originalPosition;
  8362. this._destroyOverlay();
  8363. this.element
  8364. .removeUniqueId()
  8365. .removeClass("ui-dialog-content ui-widget-content")
  8366. .css( this.originalCss )
  8367. // Without detaching first, the following becomes really slow
  8368. .detach();
  8369. this.uiDialog.stop( true, true ).remove();
  8370. if ( this.originalTitle ) {
  8371. this.element.attr( "title", this.originalTitle );
  8372. }
  8373. next = originalPosition.parent.children().eq( originalPosition.index );
  8374. // Don't try to place the dialog next to itself (#8613)
  8375. if ( next.length && next[0] !== this.element[0] ) {
  8376. next.before( this.element );
  8377. } else {
  8378. originalPosition.parent.append( this.element );
  8379. }
  8380. },
  8381. widget: function() {
  8382. return this.uiDialog;
  8383. },
  8384. disable: $.noop,
  8385. enable: $.noop,
  8386. close: function( event ) {
  8387. var that = this;
  8388. if ( !this._isOpen || this._trigger( "beforeClose", event ) === false ) {
  8389. return;
  8390. }
  8391. this._isOpen = false;
  8392. this._destroyOverlay();
  8393. if ( !this.opener.filter(":focusable").focus().length ) {
  8394. // Hiding a focused element doesn't trigger blur in WebKit
  8395. // so in case we have nothing to focus on, explicitly blur the active element
  8396. // https://bugs.webkit.org/show_bug.cgi?id=47182
  8397. $( this.document[0].activeElement ).blur();
  8398. }
  8399. this._hide( this.uiDialog, this.options.hide, function() {
  8400. that._trigger( "close", event );
  8401. });
  8402. },
  8403. isOpen: function() {
  8404. return this._isOpen;
  8405. },
  8406. moveToTop: function() {
  8407. this._moveToTop();
  8408. },
  8409. _moveToTop: function( event, silent ) {
  8410. var moved = !!this.uiDialog.nextAll(":visible").insertBefore( this.uiDialog ).length;
  8411. if ( moved && !silent ) {
  8412. this._trigger( "focus", event );
  8413. }
  8414. return moved;
  8415. },
  8416. open: function() {
  8417. var that = this;
  8418. if ( this._isOpen ) {
  8419. if ( this._moveToTop() ) {
  8420. this._focusTabbable();
  8421. }
  8422. return;
  8423. }
  8424. this._isOpen = true;
  8425. this.opener = $( this.document[0].activeElement );
  8426. this._size();
  8427. this._position();
  8428. this._createOverlay();
  8429. this._moveToTop( null, true );
  8430. this._show( this.uiDialog, this.options.show, function() {
  8431. that._focusTabbable();
  8432. that._trigger("focus");
  8433. });
  8434. this._trigger("open");
  8435. },
  8436. _focusTabbable: function() {
  8437. // Set focus to the first match:
  8438. // 1. First element inside the dialog matching [autofocus]
  8439. // 2. Tabbable element inside the content element
  8440. // 3. Tabbable element inside the buttonpane
  8441. // 4. The close button
  8442. // 5. The dialog itself
  8443. var hasFocus = this.element.find("[autofocus]");
  8444. if ( !hasFocus.length ) {
  8445. hasFocus = this.element.find(":tabbable");
  8446. }
  8447. if ( !hasFocus.length ) {
  8448. hasFocus = this.uiDialogButtonPane.find(":tabbable");
  8449. }
  8450. if ( !hasFocus.length ) {
  8451. hasFocus = this.uiDialogTitlebarClose.filter(":tabbable");
  8452. }
  8453. if ( !hasFocus.length ) {
  8454. hasFocus = this.uiDialog;
  8455. }
  8456. hasFocus.eq( 0 ).focus();
  8457. },
  8458. _keepFocus: function( event ) {
  8459. function checkFocus() {
  8460. var activeElement = this.document[0].activeElement,
  8461. isActive = this.uiDialog[0] === activeElement ||
  8462. $.contains( this.uiDialog[0], activeElement );
  8463. if ( !isActive ) {
  8464. this._focusTabbable();
  8465. }
  8466. }
  8467. event.preventDefault();
  8468. checkFocus.call( this );
  8469. // support: IE
  8470. // IE <= 8 doesn't prevent moving focus even with event.preventDefault()
  8471. // so we check again later
  8472. this._delay( checkFocus );
  8473. },
  8474. _createWrapper: function() {
  8475. this.uiDialog = $("<div>")
  8476. .addClass( "ui-dialog ui-widget ui-widget-content ui-corner-all ui-front " +
  8477. this.options.dialogClass )
  8478. .hide()
  8479. .attr({
  8480. // Setting tabIndex makes the div focusable
  8481. tabIndex: -1,
  8482. role: "dialog"
  8483. })
  8484. .appendTo( this._appendTo() );
  8485. this._on( this.uiDialog, {
  8486. keydown: function( event ) {
  8487. if ( this.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
  8488. event.keyCode === $.ui.keyCode.ESCAPE ) {
  8489. event.preventDefault();
  8490. this.close( event );
  8491. return;
  8492. }
  8493. // prevent tabbing out of dialogs
  8494. if ( event.keyCode !== $.ui.keyCode.TAB ) {
  8495. return;
  8496. }
  8497. var tabbables = this.uiDialog.find(":tabbable"),
  8498. first = tabbables.filter(":first"),
  8499. last = tabbables.filter(":last");
  8500. if ( ( event.target === last[0] || event.target === this.uiDialog[0] ) && !event.shiftKey ) {
  8501. first.focus( 1 );
  8502. event.preventDefault();
  8503. } else if ( ( event.target === first[0] || event.target === this.uiDialog[0] ) && event.shiftKey ) {
  8504. last.focus( 1 );
  8505. event.preventDefault();
  8506. }
  8507. },
  8508. mousedown: function( event ) {
  8509. if ( this._moveToTop( event ) ) {
  8510. this._focusTabbable();
  8511. }
  8512. }
  8513. });
  8514. // We assume that any existing aria-describedby attribute means
  8515. // that the dialog content is marked up properly
  8516. // otherwise we brute force the content as the description
  8517. if ( !this.element.find("[aria-describedby]").length ) {
  8518. this.uiDialog.attr({
  8519. "aria-describedby": this.element.uniqueId().attr("id")
  8520. });
  8521. }
  8522. },
  8523. _createTitlebar: function() {
  8524. var uiDialogTitle;
  8525. this.uiDialogTitlebar = $("<div>")
  8526. .addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix")
  8527. .prependTo( this.uiDialog );
  8528. this._on( this.uiDialogTitlebar, {
  8529. mousedown: function( event ) {
  8530. // Don't prevent click on close button (#8838)
  8531. // Focusing a dialog that is partially scrolled out of view
  8532. // causes the browser to scroll it into view, preventing the click event
  8533. if ( !$( event.target ).closest(".ui-dialog-titlebar-close") ) {
  8534. // Dialog isn't getting focus when dragging (#8063)
  8535. this.uiDialog.focus();
  8536. }
  8537. }
  8538. });
  8539. this.uiDialogTitlebarClose = $("<button></button>")
  8540. .button({
  8541. label: this.options.closeText,
  8542. icons: {
  8543. primary: "ui-icon-closethick"
  8544. },
  8545. text: false
  8546. })
  8547. .addClass("ui-dialog-titlebar-close")
  8548. .appendTo( this.uiDialogTitlebar );
  8549. this._on( this.uiDialogTitlebarClose, {
  8550. click: function( event ) {
  8551. event.preventDefault();
  8552. this.close( event );
  8553. }
  8554. });
  8555. uiDialogTitle = $("<span>")
  8556. .uniqueId()
  8557. .addClass("ui-dialog-title")
  8558. .prependTo( this.uiDialogTitlebar );
  8559. this._title( uiDialogTitle );
  8560. this.uiDialog.attr({
  8561. "aria-labelledby": uiDialogTitle.attr("id")
  8562. });
  8563. },
  8564. _title: function( title ) {
  8565. if ( !this.options.title ) {
  8566. title.html("&#160;");
  8567. }
  8568. title.text( this.options.title );
  8569. },
  8570. _createButtonPane: function() {
  8571. this.uiDialogButtonPane = $("<div>")
  8572. .addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix");
  8573. this.uiButtonSet = $("<div>")
  8574. .addClass("ui-dialog-buttonset")
  8575. .appendTo( this.uiDialogButtonPane );
  8576. this._createButtons();
  8577. },
  8578. _createButtons: function() {
  8579. var that = this,
  8580. buttons = this.options.buttons;
  8581. // if we already have a button pane, remove it
  8582. this.uiDialogButtonPane.remove();
  8583. this.uiButtonSet.empty();
  8584. if ( $.isEmptyObject( buttons ) || ($.isArray( buttons ) && !buttons.length) ) {
  8585. this.uiDialog.removeClass("ui-dialog-buttons");
  8586. return;
  8587. }
  8588. $.each( buttons, function( name, props ) {
  8589. var click, buttonOptions;
  8590. props = $.isFunction( props ) ?
  8591. { click: props, text: name } :
  8592. props;
  8593. // Default to a non-submitting button
  8594. props = $.extend( { type: "button" }, props );
  8595. // Change the context for the click callback to be the main element
  8596. click = props.click;
  8597. props.click = function() {
  8598. click.apply( that.element[0], arguments );
  8599. };
  8600. buttonOptions = {
  8601. icons: props.icons,
  8602. text: props.showText
  8603. };
  8604. delete props.icons;
  8605. delete props.showText;
  8606. $( "<button></button>", props )
  8607. .button( buttonOptions )
  8608. .appendTo( that.uiButtonSet );
  8609. });
  8610. this.uiDialog.addClass("ui-dialog-buttons");
  8611. this.uiDialogButtonPane.appendTo( this.uiDialog );
  8612. },
  8613. _makeDraggable: function() {
  8614. var that = this,
  8615. options = this.options;
  8616. function filteredUi( ui ) {
  8617. return {
  8618. position: ui.position,
  8619. offset: ui.offset
  8620. };
  8621. }
  8622. this.uiDialog.draggable({
  8623. cancel: ".ui-dialog-content, .ui-dialog-titlebar-close",
  8624. handle: ".ui-dialog-titlebar",
  8625. containment: "document",
  8626. start: function( event, ui ) {
  8627. $( this ).addClass("ui-dialog-dragging");
  8628. that._blockFrames();
  8629. that._trigger( "dragStart", event, filteredUi( ui ) );
  8630. },
  8631. drag: function( event, ui ) {
  8632. that._trigger( "drag", event, filteredUi( ui ) );
  8633. },
  8634. stop: function( event, ui ) {
  8635. options.position = [
  8636. ui.position.left - that.document.scrollLeft(),
  8637. ui.position.top - that.document.scrollTop()
  8638. ];
  8639. $( this ).removeClass("ui-dialog-dragging");
  8640. that._unblockFrames();
  8641. that._trigger( "dragStop", event, filteredUi( ui ) );
  8642. }
  8643. });
  8644. },
  8645. _makeResizable: function() {
  8646. var that = this,
  8647. options = this.options,
  8648. handles = options.resizable,
  8649. // .ui-resizable has position: relative defined in the stylesheet
  8650. // but dialogs have to use absolute or fixed positioning
  8651. position = this.uiDialog.css("position"),
  8652. resizeHandles = typeof handles === "string" ?
  8653. handles :
  8654. "n,e,s,w,se,sw,ne,nw";
  8655. function filteredUi( ui ) {
  8656. return {
  8657. originalPosition: ui.originalPosition,
  8658. originalSize: ui.originalSize,
  8659. position: ui.position,
  8660. size: ui.size
  8661. };
  8662. }
  8663. this.uiDialog.resizable({
  8664. cancel: ".ui-dialog-content",
  8665. containment: "document",
  8666. alsoResize: this.element,
  8667. maxWidth: options.maxWidth,
  8668. maxHeight: options.maxHeight,
  8669. minWidth: options.minWidth,
  8670. minHeight: this._minHeight(),
  8671. handles: resizeHandles,
  8672. start: function( event, ui ) {
  8673. $( this ).addClass("ui-dialog-resizing");
  8674. that._blockFrames();
  8675. that._trigger( "resizeStart", event, filteredUi( ui ) );
  8676. },
  8677. resize: function( event, ui ) {
  8678. that._trigger( "resize", event, filteredUi( ui ) );
  8679. },
  8680. stop: function( event, ui ) {
  8681. options.height = $( this ).height();
  8682. options.width = $( this ).width();
  8683. $( this ).removeClass("ui-dialog-resizing");
  8684. that._unblockFrames();
  8685. that._trigger( "resizeStop", event, filteredUi( ui ) );
  8686. }
  8687. })
  8688. .css( "position", position );
  8689. },
  8690. _minHeight: function() {
  8691. var options = this.options;
  8692. return options.height === "auto" ?
  8693. options.minHeight :
  8694. Math.min( options.minHeight, options.height );
  8695. },
  8696. _position: function() {
  8697. // Need to show the dialog to get the actual offset in the position plugin
  8698. var isVisible = this.uiDialog.is(":visible");
  8699. if ( !isVisible ) {
  8700. this.uiDialog.show();
  8701. }
  8702. this.uiDialog.position( this.options.position );
  8703. if ( !isVisible ) {
  8704. this.uiDialog.hide();
  8705. }
  8706. },
  8707. _setOptions: function( options ) {
  8708. var that = this,
  8709. resize = false,
  8710. resizableOptions = {};
  8711. $.each( options, function( key, value ) {
  8712. that._setOption( key, value );
  8713. if ( key in sizeRelatedOptions ) {
  8714. resize = true;
  8715. }
  8716. if ( key in resizableRelatedOptions ) {
  8717. resizableOptions[ key ] = value;
  8718. }
  8719. });
  8720. if ( resize ) {
  8721. this._size();
  8722. this._position();
  8723. }
  8724. if ( this.uiDialog.is(":data(ui-resizable)") ) {
  8725. this.uiDialog.resizable( "option", resizableOptions );
  8726. }
  8727. },
  8728. _setOption: function( key, value ) {
  8729. /*jshint maxcomplexity:15*/
  8730. var isDraggable, isResizable,
  8731. uiDialog = this.uiDialog;
  8732. if ( key === "dialogClass" ) {
  8733. uiDialog
  8734. .removeClass( this.options.dialogClass )
  8735. .addClass( value );
  8736. }
  8737. if ( key === "disabled" ) {
  8738. return;
  8739. }
  8740. this._super( key, value );
  8741. if ( key === "appendTo" ) {
  8742. this.uiDialog.appendTo( this._appendTo() );
  8743. }
  8744. if ( key === "buttons" ) {
  8745. this._createButtons();
  8746. }
  8747. if ( key === "closeText" ) {
  8748. this.uiDialogTitlebarClose.button({
  8749. // Ensure that we always pass a string
  8750. label: "" + value
  8751. });
  8752. }
  8753. if ( key === "draggable" ) {
  8754. isDraggable = uiDialog.is(":data(ui-draggable)");
  8755. if ( isDraggable && !value ) {
  8756. uiDialog.draggable("destroy");
  8757. }
  8758. if ( !isDraggable && value ) {
  8759. this._makeDraggable();
  8760. }
  8761. }
  8762. if ( key === "position" ) {
  8763. this._position();
  8764. }
  8765. if ( key === "resizable" ) {
  8766. // currently resizable, becoming non-resizable
  8767. isResizable = uiDialog.is(":data(ui-resizable)");
  8768. if ( isResizable && !value ) {
  8769. uiDialog.resizable("destroy");
  8770. }
  8771. // currently resizable, changing handles
  8772. if ( isResizable && typeof value === "string" ) {
  8773. uiDialog.resizable( "option", "handles", value );
  8774. }
  8775. // currently non-resizable, becoming resizable
  8776. if ( !isResizable && value !== false ) {
  8777. this._makeResizable();
  8778. }
  8779. }
  8780. if ( key === "title" ) {
  8781. this._title( this.uiDialogTitlebar.find(".ui-dialog-title") );
  8782. }
  8783. },
  8784. _size: function() {
  8785. // If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
  8786. // divs will both have width and height set, so we need to reset them
  8787. var nonContentHeight, minContentHeight, maxContentHeight,
  8788. options = this.options;
  8789. // Reset content sizing
  8790. this.element.show().css({
  8791. width: "auto",
  8792. minHeight: 0,
  8793. maxHeight: "none",
  8794. height: 0
  8795. });
  8796. if ( options.minWidth > options.width ) {
  8797. options.width = options.minWidth;
  8798. }
  8799. // reset wrapper sizing
  8800. // determine the height of all the non-content elements
  8801. nonContentHeight = this.uiDialog.css({
  8802. height: "auto",
  8803. width: options.width
  8804. })
  8805. .outerHeight();
  8806. minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
  8807. maxContentHeight = typeof options.maxHeight === "number" ?
  8808. Math.max( 0, options.maxHeight - nonContentHeight ) :
  8809. "none";
  8810. if ( options.height === "auto" ) {
  8811. this.element.css({
  8812. minHeight: minContentHeight,
  8813. maxHeight: maxContentHeight,
  8814. height: "auto"
  8815. });
  8816. } else {
  8817. this.element.height( Math.max( 0, options.height - nonContentHeight ) );
  8818. }
  8819. if (this.uiDialog.is(":data(ui-resizable)") ) {
  8820. this.uiDialog.resizable( "option", "minHeight", this._minHeight() );
  8821. }
  8822. },
  8823. _blockFrames: function() {
  8824. this.iframeBlocks = this.document.find( "iframe" ).map(function() {
  8825. var iframe = $( this );
  8826. return $( "<div>" )
  8827. .css({
  8828. position: "absolute",
  8829. width: iframe.outerWidth(),
  8830. height: iframe.outerHeight()
  8831. })
  8832. .appendTo( iframe.parent() )
  8833. .offset( iframe.offset() )[0];
  8834. });
  8835. },
  8836. _unblockFrames: function() {
  8837. if ( this.iframeBlocks ) {
  8838. this.iframeBlocks.remove();
  8839. delete this.iframeBlocks;
  8840. }
  8841. },
  8842. _allowInteraction: function( event ) {
  8843. if ( $( event.target ).closest(".ui-dialog").length ) {
  8844. return true;
  8845. }
  8846. // TODO: Remove hack when datepicker implements
  8847. // the .ui-front logic (#8989)
  8848. return !!$( event.target ).closest(".ui-datepicker").length;
  8849. },
  8850. _createOverlay: function() {
  8851. if ( !this.options.modal ) {
  8852. return;
  8853. }
  8854. var that = this,
  8855. widgetFullName = this.widgetFullName;
  8856. if ( !$.ui.dialog.overlayInstances ) {
  8857. // Prevent use of anchors and inputs.
  8858. // We use a delay in case the overlay is created from an
  8859. // event that we're going to be cancelling. (#2804)
  8860. this._delay(function() {
  8861. // Handle .dialog().dialog("close") (#4065)
  8862. if ( $.ui.dialog.overlayInstances ) {
  8863. this.document.bind( "focusin.dialog", function( event ) {
  8864. if ( !that._allowInteraction( event ) ) {
  8865. event.preventDefault();
  8866. $(".ui-dialog:visible:last .ui-dialog-content")
  8867. .data( widgetFullName )._focusTabbable();
  8868. }
  8869. });
  8870. }
  8871. });
  8872. }
  8873. this.overlay = $("<div>")
  8874. .addClass("ui-widget-overlay ui-front")
  8875. .appendTo( this._appendTo() );
  8876. this._on( this.overlay, {
  8877. mousedown: "_keepFocus"
  8878. });
  8879. $.ui.dialog.overlayInstances++;
  8880. },
  8881. _destroyOverlay: function() {
  8882. if ( !this.options.modal ) {
  8883. return;
  8884. }
  8885. if ( this.overlay ) {
  8886. $.ui.dialog.overlayInstances--;
  8887. if ( !$.ui.dialog.overlayInstances ) {
  8888. this.document.unbind( "focusin.dialog" );
  8889. }
  8890. this.overlay.remove();
  8891. this.overlay = null;
  8892. }
  8893. }
  8894. });
  8895. $.ui.dialog.overlayInstances = 0;
  8896. // DEPRECATED
  8897. if ( $.uiBackCompat !== false ) {
  8898. // position option with array notation
  8899. // just override with old implementation
  8900. $.widget( "ui.dialog", $.ui.dialog, {
  8901. _position: function() {
  8902. var position = this.options.position,
  8903. myAt = [],
  8904. offset = [ 0, 0 ],
  8905. isVisible;
  8906. if ( position ) {
  8907. if ( typeof position === "string" || (typeof position === "object" && "0" in position ) ) {
  8908. myAt = position.split ? position.split(" ") : [ position[0], position[1] ];
  8909. if ( myAt.length === 1 ) {
  8910. myAt[1] = myAt[0];
  8911. }
  8912. $.each( [ "left", "top" ], function( i, offsetPosition ) {
  8913. if ( +myAt[ i ] === myAt[ i ] ) {
  8914. offset[ i ] = myAt[ i ];
  8915. myAt[ i ] = offsetPosition;
  8916. }
  8917. });
  8918. position = {
  8919. my: myAt[0] + (offset[0] < 0 ? offset[0] : "+" + offset[0]) + " " +
  8920. myAt[1] + (offset[1] < 0 ? offset[1] : "+" + offset[1]),
  8921. at: myAt.join(" ")
  8922. };
  8923. }
  8924. position = $.extend( {}, $.ui.dialog.prototype.options.position, position );
  8925. } else {
  8926. position = $.ui.dialog.prototype.options.position;
  8927. }
  8928. // need to show the dialog to get the actual offset in the position plugin
  8929. isVisible = this.uiDialog.is(":visible");
  8930. if ( !isVisible ) {
  8931. this.uiDialog.show();
  8932. }
  8933. this.uiDialog.position( position );
  8934. if ( !isVisible ) {
  8935. this.uiDialog.hide();
  8936. }
  8937. }
  8938. });
  8939. }
  8940. }( jQuery ) );
  8941. (function( $, undefined ) {
  8942. var rvertical = /up|down|vertical/,
  8943. rpositivemotion = /up|left|vertical|horizontal/;
  8944. $.effects.effect.blind = function( o, done ) {
  8945. // Create element
  8946. var el = $( this ),
  8947. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  8948. mode = $.effects.setMode( el, o.mode || "hide" ),
  8949. direction = o.direction || "up",
  8950. vertical = rvertical.test( direction ),
  8951. ref = vertical ? "height" : "width",
  8952. ref2 = vertical ? "top" : "left",
  8953. motion = rpositivemotion.test( direction ),
  8954. animation = {},
  8955. show = mode === "show",
  8956. wrapper, distance, margin;
  8957. // if already wrapped, the wrapper's properties are my property. #6245
  8958. if ( el.parent().is( ".ui-effects-wrapper" ) ) {
  8959. $.effects.save( el.parent(), props );
  8960. } else {
  8961. $.effects.save( el, props );
  8962. }
  8963. el.show();
  8964. wrapper = $.effects.createWrapper( el ).css({
  8965. overflow: "hidden"
  8966. });
  8967. distance = wrapper[ ref ]();
  8968. margin = parseFloat( wrapper.css( ref2 ) ) || 0;
  8969. animation[ ref ] = show ? distance : 0;
  8970. if ( !motion ) {
  8971. el
  8972. .css( vertical ? "bottom" : "right", 0 )
  8973. .css( vertical ? "top" : "left", "auto" )
  8974. .css({ position: "absolute" });
  8975. animation[ ref2 ] = show ? margin : distance + margin;
  8976. }
  8977. // start at 0 if we are showing
  8978. if ( show ) {
  8979. wrapper.css( ref, 0 );
  8980. if ( ! motion ) {
  8981. wrapper.css( ref2, margin + distance );
  8982. }
  8983. }
  8984. // Animate
  8985. wrapper.animate( animation, {
  8986. duration: o.duration,
  8987. easing: o.easing,
  8988. queue: false,
  8989. complete: function() {
  8990. if ( mode === "hide" ) {
  8991. el.hide();
  8992. }
  8993. $.effects.restore( el, props );
  8994. $.effects.removeWrapper( el );
  8995. done();
  8996. }
  8997. });
  8998. };
  8999. })(jQuery);
  9000. (function( $, undefined ) {
  9001. $.effects.effect.bounce = function( o, done ) {
  9002. var el = $( this ),
  9003. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  9004. // defaults:
  9005. mode = $.effects.setMode( el, o.mode || "effect" ),
  9006. hide = mode === "hide",
  9007. show = mode === "show",
  9008. direction = o.direction || "up",
  9009. distance = o.distance,
  9010. times = o.times || 5,
  9011. // number of internal animations
  9012. anims = times * 2 + ( show || hide ? 1 : 0 ),
  9013. speed = o.duration / anims,
  9014. easing = o.easing,
  9015. // utility:
  9016. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  9017. motion = ( direction === "up" || direction === "left" ),
  9018. i,
  9019. upAnim,
  9020. downAnim,
  9021. // we will need to re-assemble the queue to stack our animations in place
  9022. queue = el.queue(),
  9023. queuelen = queue.length;
  9024. // Avoid touching opacity to prevent clearType and PNG issues in IE
  9025. if ( show || hide ) {
  9026. props.push( "opacity" );
  9027. }
  9028. $.effects.save( el, props );
  9029. el.show();
  9030. $.effects.createWrapper( el ); // Create Wrapper
  9031. // default distance for the BIGGEST bounce is the outer Distance / 3
  9032. if ( !distance ) {
  9033. distance = el[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
  9034. }
  9035. if ( show ) {
  9036. downAnim = { opacity: 1 };
  9037. downAnim[ ref ] = 0;
  9038. // if we are showing, force opacity 0 and set the initial position
  9039. // then do the "first" animation
  9040. el.css( "opacity", 0 )
  9041. .css( ref, motion ? -distance * 2 : distance * 2 )
  9042. .animate( downAnim, speed, easing );
  9043. }
  9044. // start at the smallest distance if we are hiding
  9045. if ( hide ) {
  9046. distance = distance / Math.pow( 2, times - 1 );
  9047. }
  9048. downAnim = {};
  9049. downAnim[ ref ] = 0;
  9050. // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
  9051. for ( i = 0; i < times; i++ ) {
  9052. upAnim = {};
  9053. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  9054. el.animate( upAnim, speed, easing )
  9055. .animate( downAnim, speed, easing );
  9056. distance = hide ? distance * 2 : distance / 2;
  9057. }
  9058. // Last Bounce when Hiding
  9059. if ( hide ) {
  9060. upAnim = { opacity: 0 };
  9061. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  9062. el.animate( upAnim, speed, easing );
  9063. }
  9064. el.queue(function() {
  9065. if ( hide ) {
  9066. el.hide();
  9067. }
  9068. $.effects.restore( el, props );
  9069. $.effects.removeWrapper( el );
  9070. done();
  9071. });
  9072. // inject all the animations we just queued to be first in line (after "inprogress")
  9073. if ( queuelen > 1) {
  9074. queue.splice.apply( queue,
  9075. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  9076. }
  9077. el.dequeue();
  9078. };
  9079. })(jQuery);
  9080. (function( $, undefined ) {
  9081. $.effects.effect.clip = function( o, done ) {
  9082. // Create element
  9083. var el = $( this ),
  9084. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  9085. mode = $.effects.setMode( el, o.mode || "hide" ),
  9086. show = mode === "show",
  9087. direction = o.direction || "vertical",
  9088. vert = direction === "vertical",
  9089. size = vert ? "height" : "width",
  9090. position = vert ? "top" : "left",
  9091. animation = {},
  9092. wrapper, animate, distance;
  9093. // Save & Show
  9094. $.effects.save( el, props );
  9095. el.show();
  9096. // Create Wrapper
  9097. wrapper = $.effects.createWrapper( el ).css({
  9098. overflow: "hidden"
  9099. });
  9100. animate = ( el[0].tagName === "IMG" ) ? wrapper : el;
  9101. distance = animate[ size ]();
  9102. // Shift
  9103. if ( show ) {
  9104. animate.css( size, 0 );
  9105. animate.css( position, distance / 2 );
  9106. }
  9107. // Create Animation Object:
  9108. animation[ size ] = show ? distance : 0;
  9109. animation[ position ] = show ? 0 : distance / 2;
  9110. // Animate
  9111. animate.animate( animation, {
  9112. queue: false,
  9113. duration: o.duration,
  9114. easing: o.easing,
  9115. complete: function() {
  9116. if ( !show ) {
  9117. el.hide();
  9118. }
  9119. $.effects.restore( el, props );
  9120. $.effects.removeWrapper( el );
  9121. done();
  9122. }
  9123. });
  9124. };
  9125. })(jQuery);
  9126. (function( $, undefined ) {
  9127. $.effects.effect.drop = function( o, done ) {
  9128. var el = $( this ),
  9129. props = [ "position", "top", "bottom", "left", "right", "opacity", "height", "width" ],
  9130. mode = $.effects.setMode( el, o.mode || "hide" ),
  9131. show = mode === "show",
  9132. direction = o.direction || "left",
  9133. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  9134. motion = ( direction === "up" || direction === "left" ) ? "pos" : "neg",
  9135. animation = {
  9136. opacity: show ? 1 : 0
  9137. },
  9138. distance;
  9139. // Adjust
  9140. $.effects.save( el, props );
  9141. el.show();
  9142. $.effects.createWrapper( el );
  9143. distance = o.distance || el[ ref === "top" ? "outerHeight": "outerWidth" ]( true ) / 2;
  9144. if ( show ) {
  9145. el
  9146. .css( "opacity", 0 )
  9147. .css( ref, motion === "pos" ? -distance : distance );
  9148. }
  9149. // Animation
  9150. animation[ ref ] = ( show ?
  9151. ( motion === "pos" ? "+=" : "-=" ) :
  9152. ( motion === "pos" ? "-=" : "+=" ) ) +
  9153. distance;
  9154. // Animate
  9155. el.animate( animation, {
  9156. queue: false,
  9157. duration: o.duration,
  9158. easing: o.easing,
  9159. complete: function() {
  9160. if ( mode === "hide" ) {
  9161. el.hide();
  9162. }
  9163. $.effects.restore( el, props );
  9164. $.effects.removeWrapper( el );
  9165. done();
  9166. }
  9167. });
  9168. };
  9169. })(jQuery);
  9170. (function( $, undefined ) {
  9171. $.effects.effect.explode = function( o, done ) {
  9172. var rows = o.pieces ? Math.round( Math.sqrt( o.pieces ) ) : 3,
  9173. cells = rows,
  9174. el = $( this ),
  9175. mode = $.effects.setMode( el, o.mode || "hide" ),
  9176. show = mode === "show",
  9177. // show and then visibility:hidden the element before calculating offset
  9178. offset = el.show().css( "visibility", "hidden" ).offset(),
  9179. // width and height of a piece
  9180. width = Math.ceil( el.outerWidth() / cells ),
  9181. height = Math.ceil( el.outerHeight() / rows ),
  9182. pieces = [],
  9183. // loop
  9184. i, j, left, top, mx, my;
  9185. // children animate complete:
  9186. function childComplete() {
  9187. pieces.push( this );
  9188. if ( pieces.length === rows * cells ) {
  9189. animComplete();
  9190. }
  9191. }
  9192. // clone the element for each row and cell.
  9193. for( i = 0; i < rows ; i++ ) { // ===>
  9194. top = offset.top + i * height;
  9195. my = i - ( rows - 1 ) / 2 ;
  9196. for( j = 0; j < cells ; j++ ) { // |||
  9197. left = offset.left + j * width;
  9198. mx = j - ( cells - 1 ) / 2 ;
  9199. // Create a clone of the now hidden main element that will be absolute positioned
  9200. // within a wrapper div off the -left and -top equal to size of our pieces
  9201. el
  9202. .clone()
  9203. .appendTo( "body" )
  9204. .wrap( "<div></div>" )
  9205. .css({
  9206. position: "absolute",
  9207. visibility: "visible",
  9208. left: -j * width,
  9209. top: -i * height
  9210. })
  9211. // select the wrapper - make it overflow: hidden and absolute positioned based on
  9212. // where the original was located +left and +top equal to the size of pieces
  9213. .parent()
  9214. .addClass( "ui-effects-explode" )
  9215. .css({
  9216. position: "absolute",
  9217. overflow: "hidden",
  9218. width: width,
  9219. height: height,
  9220. left: left + ( show ? mx * width : 0 ),
  9221. top: top + ( show ? my * height : 0 ),
  9222. opacity: show ? 0 : 1
  9223. }).animate({
  9224. left: left + ( show ? 0 : mx * width ),
  9225. top: top + ( show ? 0 : my * height ),
  9226. opacity: show ? 1 : 0
  9227. }, o.duration || 500, o.easing, childComplete );
  9228. }
  9229. }
  9230. function animComplete() {
  9231. el.css({
  9232. visibility: "visible"
  9233. });
  9234. $( pieces ).remove();
  9235. if ( !show ) {
  9236. el.hide();
  9237. }
  9238. done();
  9239. }
  9240. };
  9241. })(jQuery);
  9242. (function( $, undefined ) {
  9243. $.effects.effect.fade = function( o, done ) {
  9244. var el = $( this ),
  9245. mode = $.effects.setMode( el, o.mode || "toggle" );
  9246. el.animate({
  9247. opacity: mode
  9248. }, {
  9249. queue: false,
  9250. duration: o.duration,
  9251. easing: o.easing,
  9252. complete: done
  9253. });
  9254. };
  9255. })( jQuery );
  9256. (function( $, undefined ) {
  9257. $.effects.effect.fold = function( o, done ) {
  9258. // Create element
  9259. var el = $( this ),
  9260. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  9261. mode = $.effects.setMode( el, o.mode || "hide" ),
  9262. show = mode === "show",
  9263. hide = mode === "hide",
  9264. size = o.size || 15,
  9265. percent = /([0-9]+)%/.exec( size ),
  9266. horizFirst = !!o.horizFirst,
  9267. widthFirst = show !== horizFirst,
  9268. ref = widthFirst ? [ "width", "height" ] : [ "height", "width" ],
  9269. duration = o.duration / 2,
  9270. wrapper, distance,
  9271. animation1 = {},
  9272. animation2 = {};
  9273. $.effects.save( el, props );
  9274. el.show();
  9275. // Create Wrapper
  9276. wrapper = $.effects.createWrapper( el ).css({
  9277. overflow: "hidden"
  9278. });
  9279. distance = widthFirst ?
  9280. [ wrapper.width(), wrapper.height() ] :
  9281. [ wrapper.height(), wrapper.width() ];
  9282. if ( percent ) {
  9283. size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
  9284. }
  9285. if ( show ) {
  9286. wrapper.css( horizFirst ? {
  9287. height: 0,
  9288. width: size
  9289. } : {
  9290. height: size,
  9291. width: 0
  9292. });
  9293. }
  9294. // Animation
  9295. animation1[ ref[ 0 ] ] = show ? distance[ 0 ] : size;
  9296. animation2[ ref[ 1 ] ] = show ? distance[ 1 ] : 0;
  9297. // Animate
  9298. wrapper
  9299. .animate( animation1, duration, o.easing )
  9300. .animate( animation2, duration, o.easing, function() {
  9301. if ( hide ) {
  9302. el.hide();
  9303. }
  9304. $.effects.restore( el, props );
  9305. $.effects.removeWrapper( el );
  9306. done();
  9307. });
  9308. };
  9309. })(jQuery);
  9310. (function( $, undefined ) {
  9311. $.effects.effect.highlight = function( o, done ) {
  9312. var elem = $( this ),
  9313. props = [ "backgroundImage", "backgroundColor", "opacity" ],
  9314. mode = $.effects.setMode( elem, o.mode || "show" ),
  9315. animation = {
  9316. backgroundColor: elem.css( "backgroundColor" )
  9317. };
  9318. if (mode === "hide") {
  9319. animation.opacity = 0;
  9320. }
  9321. $.effects.save( elem, props );
  9322. elem
  9323. .show()
  9324. .css({
  9325. backgroundImage: "none",
  9326. backgroundColor: o.color || "#ffff99"
  9327. })
  9328. .animate( animation, {
  9329. queue: false,
  9330. duration: o.duration,
  9331. easing: o.easing,
  9332. complete: function() {
  9333. if ( mode === "hide" ) {
  9334. elem.hide();
  9335. }
  9336. $.effects.restore( elem, props );
  9337. done();
  9338. }
  9339. });
  9340. };
  9341. })(jQuery);
  9342. (function( $, undefined ) {
  9343. $.effects.effect.pulsate = function( o, done ) {
  9344. var elem = $( this ),
  9345. mode = $.effects.setMode( elem, o.mode || "show" ),
  9346. show = mode === "show",
  9347. hide = mode === "hide",
  9348. showhide = ( show || mode === "hide" ),
  9349. // showing or hiding leaves of the "last" animation
  9350. anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
  9351. duration = o.duration / anims,
  9352. animateTo = 0,
  9353. queue = elem.queue(),
  9354. queuelen = queue.length,
  9355. i;
  9356. if ( show || !elem.is(":visible")) {
  9357. elem.css( "opacity", 0 ).show();
  9358. animateTo = 1;
  9359. }
  9360. // anims - 1 opacity "toggles"
  9361. for ( i = 1; i < anims; i++ ) {
  9362. elem.animate({
  9363. opacity: animateTo
  9364. }, duration, o.easing );
  9365. animateTo = 1 - animateTo;
  9366. }
  9367. elem.animate({
  9368. opacity: animateTo
  9369. }, duration, o.easing);
  9370. elem.queue(function() {
  9371. if ( hide ) {
  9372. elem.hide();
  9373. }
  9374. done();
  9375. });
  9376. // We just queued up "anims" animations, we need to put them next in the queue
  9377. if ( queuelen > 1 ) {
  9378. queue.splice.apply( queue,
  9379. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  9380. }
  9381. elem.dequeue();
  9382. };
  9383. })(jQuery);
  9384. (function( $, undefined ) {
  9385. $.effects.effect.puff = function( o, done ) {
  9386. var elem = $( this ),
  9387. mode = $.effects.setMode( elem, o.mode || "hide" ),
  9388. hide = mode === "hide",
  9389. percent = parseInt( o.percent, 10 ) || 150,
  9390. factor = percent / 100,
  9391. original = {
  9392. height: elem.height(),
  9393. width: elem.width(),
  9394. outerHeight: elem.outerHeight(),
  9395. outerWidth: elem.outerWidth()
  9396. };
  9397. $.extend( o, {
  9398. effect: "scale",
  9399. queue: false,
  9400. fade: true,
  9401. mode: mode,
  9402. complete: done,
  9403. percent: hide ? percent : 100,
  9404. from: hide ?
  9405. original :
  9406. {
  9407. height: original.height * factor,
  9408. width: original.width * factor,
  9409. outerHeight: original.outerHeight * factor,
  9410. outerWidth: original.outerWidth * factor
  9411. }
  9412. });
  9413. elem.effect( o );
  9414. };
  9415. $.effects.effect.scale = function( o, done ) {
  9416. // Create element
  9417. var el = $( this ),
  9418. options = $.extend( true, {}, o ),
  9419. mode = $.effects.setMode( el, o.mode || "effect" ),
  9420. percent = parseInt( o.percent, 10 ) ||
  9421. ( parseInt( o.percent, 10 ) === 0 ? 0 : ( mode === "hide" ? 0 : 100 ) ),
  9422. direction = o.direction || "both",
  9423. origin = o.origin,
  9424. original = {
  9425. height: el.height(),
  9426. width: el.width(),
  9427. outerHeight: el.outerHeight(),
  9428. outerWidth: el.outerWidth()
  9429. },
  9430. factor = {
  9431. y: direction !== "horizontal" ? (percent / 100) : 1,
  9432. x: direction !== "vertical" ? (percent / 100) : 1
  9433. };
  9434. // We are going to pass this effect to the size effect:
  9435. options.effect = "size";
  9436. options.queue = false;
  9437. options.complete = done;
  9438. // Set default origin and restore for show/hide
  9439. if ( mode !== "effect" ) {
  9440. options.origin = origin || ["middle","center"];
  9441. options.restore = true;
  9442. }
  9443. options.from = o.from || ( mode === "show" ? {
  9444. height: 0,
  9445. width: 0,
  9446. outerHeight: 0,
  9447. outerWidth: 0
  9448. } : original );
  9449. options.to = {
  9450. height: original.height * factor.y,
  9451. width: original.width * factor.x,
  9452. outerHeight: original.outerHeight * factor.y,
  9453. outerWidth: original.outerWidth * factor.x
  9454. };
  9455. // Fade option to support puff
  9456. if ( options.fade ) {
  9457. if ( mode === "show" ) {
  9458. options.from.opacity = 0;
  9459. options.to.opacity = 1;
  9460. }
  9461. if ( mode === "hide" ) {
  9462. options.from.opacity = 1;
  9463. options.to.opacity = 0;
  9464. }
  9465. }
  9466. // Animate
  9467. el.effect( options );
  9468. };
  9469. $.effects.effect.size = function( o, done ) {
  9470. // Create element
  9471. var original, baseline, factor,
  9472. el = $( this ),
  9473. props0 = [ "position", "top", "bottom", "left", "right", "width", "height", "overflow", "opacity" ],
  9474. // Always restore
  9475. props1 = [ "position", "top", "bottom", "left", "right", "overflow", "opacity" ],
  9476. // Copy for children
  9477. props2 = [ "width", "height", "overflow" ],
  9478. cProps = [ "fontSize" ],
  9479. vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ],
  9480. hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ],
  9481. // Set options
  9482. mode = $.effects.setMode( el, o.mode || "effect" ),
  9483. restore = o.restore || mode !== "effect",
  9484. scale = o.scale || "both",
  9485. origin = o.origin || [ "middle", "center" ],
  9486. position = el.css( "position" ),
  9487. props = restore ? props0 : props1,
  9488. zero = {
  9489. height: 0,
  9490. width: 0,
  9491. outerHeight: 0,
  9492. outerWidth: 0
  9493. };
  9494. if ( mode === "show" ) {
  9495. el.show();
  9496. }
  9497. original = {
  9498. height: el.height(),
  9499. width: el.width(),
  9500. outerHeight: el.outerHeight(),
  9501. outerWidth: el.outerWidth()
  9502. };
  9503. if ( o.mode === "toggle" && mode === "show" ) {
  9504. el.from = o.to || zero;
  9505. el.to = o.from || original;
  9506. } else {
  9507. el.from = o.from || ( mode === "show" ? zero : original );
  9508. el.to = o.to || ( mode === "hide" ? zero : original );
  9509. }
  9510. // Set scaling factor
  9511. factor = {
  9512. from: {
  9513. y: el.from.height / original.height,
  9514. x: el.from.width / original.width
  9515. },
  9516. to: {
  9517. y: el.to.height / original.height,
  9518. x: el.to.width / original.width
  9519. }
  9520. };
  9521. // Scale the css box
  9522. if ( scale === "box" || scale === "both" ) {
  9523. // Vertical props scaling
  9524. if ( factor.from.y !== factor.to.y ) {
  9525. props = props.concat( vProps );
  9526. el.from = $.effects.setTransition( el, vProps, factor.from.y, el.from );
  9527. el.to = $.effects.setTransition( el, vProps, factor.to.y, el.to );
  9528. }
  9529. // Horizontal props scaling
  9530. if ( factor.from.x !== factor.to.x ) {
  9531. props = props.concat( hProps );
  9532. el.from = $.effects.setTransition( el, hProps, factor.from.x, el.from );
  9533. el.to = $.effects.setTransition( el, hProps, factor.to.x, el.to );
  9534. }
  9535. }
  9536. // Scale the content
  9537. if ( scale === "content" || scale === "both" ) {
  9538. // Vertical props scaling
  9539. if ( factor.from.y !== factor.to.y ) {
  9540. props = props.concat( cProps ).concat( props2 );
  9541. el.from = $.effects.setTransition( el, cProps, factor.from.y, el.from );
  9542. el.to = $.effects.setTransition( el, cProps, factor.to.y, el.to );
  9543. }
  9544. }
  9545. $.effects.save( el, props );
  9546. el.show();
  9547. $.effects.createWrapper( el );
  9548. el.css( "overflow", "hidden" ).css( el.from );
  9549. // Adjust
  9550. if (origin) { // Calculate baseline shifts
  9551. baseline = $.effects.getBaseline( origin, original );
  9552. el.from.top = ( original.outerHeight - el.outerHeight() ) * baseline.y;
  9553. el.from.left = ( original.outerWidth - el.outerWidth() ) * baseline.x;
  9554. el.to.top = ( original.outerHeight - el.to.outerHeight ) * baseline.y;
  9555. el.to.left = ( original.outerWidth - el.to.outerWidth ) * baseline.x;
  9556. }
  9557. el.css( el.from ); // set top & left
  9558. // Animate
  9559. if ( scale === "content" || scale === "both" ) { // Scale the children
  9560. // Add margins/font-size
  9561. vProps = vProps.concat([ "marginTop", "marginBottom" ]).concat(cProps);
  9562. hProps = hProps.concat([ "marginLeft", "marginRight" ]);
  9563. props2 = props0.concat(vProps).concat(hProps);
  9564. el.find( "*[width]" ).each( function(){
  9565. var child = $( this ),
  9566. c_original = {
  9567. height: child.height(),
  9568. width: child.width(),
  9569. outerHeight: child.outerHeight(),
  9570. outerWidth: child.outerWidth()
  9571. };
  9572. if (restore) {
  9573. $.effects.save(child, props2);
  9574. }
  9575. child.from = {
  9576. height: c_original.height * factor.from.y,
  9577. width: c_original.width * factor.from.x,
  9578. outerHeight: c_original.outerHeight * factor.from.y,
  9579. outerWidth: c_original.outerWidth * factor.from.x
  9580. };
  9581. child.to = {
  9582. height: c_original.height * factor.to.y,
  9583. width: c_original.width * factor.to.x,
  9584. outerHeight: c_original.height * factor.to.y,
  9585. outerWidth: c_original.width * factor.to.x
  9586. };
  9587. // Vertical props scaling
  9588. if ( factor.from.y !== factor.to.y ) {
  9589. child.from = $.effects.setTransition( child, vProps, factor.from.y, child.from );
  9590. child.to = $.effects.setTransition( child, vProps, factor.to.y, child.to );
  9591. }
  9592. // Horizontal props scaling
  9593. if ( factor.from.x !== factor.to.x ) {
  9594. child.from = $.effects.setTransition( child, hProps, factor.from.x, child.from );
  9595. child.to = $.effects.setTransition( child, hProps, factor.to.x, child.to );
  9596. }
  9597. // Animate children
  9598. child.css( child.from );
  9599. child.animate( child.to, o.duration, o.easing, function() {
  9600. // Restore children
  9601. if ( restore ) {
  9602. $.effects.restore( child, props2 );
  9603. }
  9604. });
  9605. });
  9606. }
  9607. // Animate
  9608. el.animate( el.to, {
  9609. queue: false,
  9610. duration: o.duration,
  9611. easing: o.easing,
  9612. complete: function() {
  9613. if ( el.to.opacity === 0 ) {
  9614. el.css( "opacity", el.from.opacity );
  9615. }
  9616. if( mode === "hide" ) {
  9617. el.hide();
  9618. }
  9619. $.effects.restore( el, props );
  9620. if ( !restore ) {
  9621. // we need to calculate our new positioning based on the scaling
  9622. if ( position === "static" ) {
  9623. el.css({
  9624. position: "relative",
  9625. top: el.to.top,
  9626. left: el.to.left
  9627. });
  9628. } else {
  9629. $.each([ "top", "left" ], function( idx, pos ) {
  9630. el.css( pos, function( _, str ) {
  9631. var val = parseInt( str, 10 ),
  9632. toRef = idx ? el.to.left : el.to.top;
  9633. // if original was "auto", recalculate the new value from wrapper
  9634. if ( str === "auto" ) {
  9635. return toRef + "px";
  9636. }
  9637. return val + toRef + "px";
  9638. });
  9639. });
  9640. }
  9641. }
  9642. $.effects.removeWrapper( el );
  9643. done();
  9644. }
  9645. });
  9646. };
  9647. })(jQuery);
  9648. (function( $, undefined ) {
  9649. $.effects.effect.shake = function( o, done ) {
  9650. var el = $( this ),
  9651. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  9652. mode = $.effects.setMode( el, o.mode || "effect" ),
  9653. direction = o.direction || "left",
  9654. distance = o.distance || 20,
  9655. times = o.times || 3,
  9656. anims = times * 2 + 1,
  9657. speed = Math.round(o.duration/anims),
  9658. ref = (direction === "up" || direction === "down") ? "top" : "left",
  9659. positiveMotion = (direction === "up" || direction === "left"),
  9660. animation = {},
  9661. animation1 = {},
  9662. animation2 = {},
  9663. i,
  9664. // we will need to re-assemble the queue to stack our animations in place
  9665. queue = el.queue(),
  9666. queuelen = queue.length;
  9667. $.effects.save( el, props );
  9668. el.show();
  9669. $.effects.createWrapper( el );
  9670. // Animation
  9671. animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance;
  9672. animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2;
  9673. animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2;
  9674. // Animate
  9675. el.animate( animation, speed, o.easing );
  9676. // Shakes
  9677. for ( i = 1; i < times; i++ ) {
  9678. el.animate( animation1, speed, o.easing ).animate( animation2, speed, o.easing );
  9679. }
  9680. el
  9681. .animate( animation1, speed, o.easing )
  9682. .animate( animation, speed / 2, o.easing )
  9683. .queue(function() {
  9684. if ( mode === "hide" ) {
  9685. el.hide();
  9686. }
  9687. $.effects.restore( el, props );
  9688. $.effects.removeWrapper( el );
  9689. done();
  9690. });
  9691. // inject all the animations we just queued to be first in line (after "inprogress")
  9692. if ( queuelen > 1) {
  9693. queue.splice.apply( queue,
  9694. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  9695. }
  9696. el.dequeue();
  9697. };
  9698. })(jQuery);
  9699. (function( $, undefined ) {
  9700. $.effects.effect.slide = function( o, done ) {
  9701. // Create element
  9702. var el = $( this ),
  9703. props = [ "position", "top", "bottom", "left", "right", "width", "height" ],
  9704. mode = $.effects.setMode( el, o.mode || "show" ),
  9705. show = mode === "show",
  9706. direction = o.direction || "left",
  9707. ref = (direction === "up" || direction === "down") ? "top" : "left",
  9708. positiveMotion = (direction === "up" || direction === "left"),
  9709. distance,
  9710. animation = {};
  9711. // Adjust
  9712. $.effects.save( el, props );
  9713. el.show();
  9714. distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]( true );
  9715. $.effects.createWrapper( el ).css({
  9716. overflow: "hidden"
  9717. });
  9718. if ( show ) {
  9719. el.css( ref, positiveMotion ? (isNaN(distance) ? "-" + distance : -distance) : distance );
  9720. }
  9721. // Animation
  9722. animation[ ref ] = ( show ?
  9723. ( positiveMotion ? "+=" : "-=") :
  9724. ( positiveMotion ? "-=" : "+=")) +
  9725. distance;
  9726. // Animate
  9727. el.animate( animation, {
  9728. queue: false,
  9729. duration: o.duration,
  9730. easing: o.easing,
  9731. complete: function() {
  9732. if ( mode === "hide" ) {
  9733. el.hide();
  9734. }
  9735. $.effects.restore( el, props );
  9736. $.effects.removeWrapper( el );
  9737. done();
  9738. }
  9739. });
  9740. };
  9741. })(jQuery);
  9742. (function( $, undefined ) {
  9743. $.effects.effect.transfer = function( o, done ) {
  9744. var elem = $( this ),
  9745. target = $( o.to ),
  9746. targetFixed = target.css( "position" ) === "fixed",
  9747. body = $("body"),
  9748. fixTop = targetFixed ? body.scrollTop() : 0,
  9749. fixLeft = targetFixed ? body.scrollLeft() : 0,
  9750. endPosition = target.offset(),
  9751. animation = {
  9752. top: endPosition.top - fixTop ,
  9753. left: endPosition.left - fixLeft ,
  9754. height: target.innerHeight(),
  9755. width: target.innerWidth()
  9756. },
  9757. startPosition = elem.offset(),
  9758. transfer = $( "<div class='ui-effects-transfer'></div>" )
  9759. .appendTo( document.body )
  9760. .addClass( o.className )
  9761. .css({
  9762. top: startPosition.top - fixTop ,
  9763. left: startPosition.left - fixLeft ,
  9764. height: elem.innerHeight(),
  9765. width: elem.innerWidth(),
  9766. position: targetFixed ? "fixed" : "absolute"
  9767. })
  9768. .animate( animation, o.duration, o.easing, function() {
  9769. transfer.remove();
  9770. done();
  9771. });
  9772. };
  9773. })(jQuery);
  9774. (function( $, undefined ) {
  9775. $.widget( "ui.menu", {
  9776. version: "1.10.3",
  9777. defaultElement: "<ul>",
  9778. delay: 300,
  9779. options: {
  9780. icons: {
  9781. submenu: "ui-icon-carat-1-e"
  9782. },
  9783. menus: "ul",
  9784. position: {
  9785. my: "left top",
  9786. at: "right top"
  9787. },
  9788. role: "menu",
  9789. // callbacks
  9790. blur: null,
  9791. focus: null,
  9792. select: null
  9793. },
  9794. _create: function() {
  9795. this.activeMenu = this.element;
  9796. // flag used to prevent firing of the click handler
  9797. // as the event bubbles up through nested menus
  9798. this.mouseHandled = false;
  9799. this.element
  9800. .uniqueId()
  9801. .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
  9802. .toggleClass( "ui-menu-icons", !!this.element.find( ".ui-icon" ).length )
  9803. .attr({
  9804. role: this.options.role,
  9805. tabIndex: 0
  9806. })
  9807. // need to catch all clicks on disabled menu
  9808. // not possible through _on
  9809. .bind( "click" + this.eventNamespace, $.proxy(function( event ) {
  9810. if ( this.options.disabled ) {
  9811. event.preventDefault();
  9812. }
  9813. }, this ));
  9814. if ( this.options.disabled ) {
  9815. this.element
  9816. .addClass( "ui-state-disabled" )
  9817. .attr( "aria-disabled", "true" );
  9818. }
  9819. this._on({
  9820. // Prevent focus from sticking to links inside menu after clicking
  9821. // them (focus should always stay on UL during navigation).
  9822. "mousedown .ui-menu-item > a": function( event ) {
  9823. event.preventDefault();
  9824. },
  9825. "click .ui-state-disabled > a": function( event ) {
  9826. event.preventDefault();
  9827. },
  9828. "click .ui-menu-item:has(a)": function( event ) {
  9829. var target = $( event.target ).closest( ".ui-menu-item" );
  9830. if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
  9831. this.mouseHandled = true;
  9832. this.select( event );
  9833. // Open submenu on click
  9834. if ( target.has( ".ui-menu" ).length ) {
  9835. this.expand( event );
  9836. } else if ( !this.element.is( ":focus" ) ) {
  9837. // Redirect focus to the menu
  9838. this.element.trigger( "focus", [ true ] );
  9839. // If the active item is on the top level, let it stay active.
  9840. // Otherwise, blur the active item since it is no longer visible.
  9841. if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
  9842. clearTimeout( this.timer );
  9843. }
  9844. }
  9845. }
  9846. },
  9847. "mouseenter .ui-menu-item": function( event ) {
  9848. var target = $( event.currentTarget );
  9849. // Remove ui-state-active class from siblings of the newly focused menu item
  9850. // to avoid a jump caused by adjacent elements both having a class with a border
  9851. target.siblings().children( ".ui-state-active" ).removeClass( "ui-state-active" );
  9852. this.focus( event, target );
  9853. },
  9854. mouseleave: "collapseAll",
  9855. "mouseleave .ui-menu": "collapseAll",
  9856. focus: function( event, keepActiveItem ) {
  9857. // If there's already an active item, keep it active
  9858. // If not, activate the first item
  9859. var item = this.active || this.element.children( ".ui-menu-item" ).eq( 0 );
  9860. if ( !keepActiveItem ) {
  9861. this.focus( event, item );
  9862. }
  9863. },
  9864. blur: function( event ) {
  9865. this._delay(function() {
  9866. if ( !$.contains( this.element[0], this.document[0].activeElement ) ) {
  9867. this.collapseAll( event );
  9868. }
  9869. });
  9870. },
  9871. keydown: "_keydown"
  9872. });
  9873. this.refresh();
  9874. // Clicks outside of a menu collapse any open menus
  9875. this._on( this.document, {
  9876. click: function( event ) {
  9877. if ( !$( event.target ).closest( ".ui-menu" ).length ) {
  9878. this.collapseAll( event );
  9879. }
  9880. // Reset the mouseHandled flag
  9881. this.mouseHandled = false;
  9882. }
  9883. });
  9884. },
  9885. _destroy: function() {
  9886. // Destroy (sub)menus
  9887. this.element
  9888. .removeAttr( "aria-activedescendant" )
  9889. .find( ".ui-menu" ).addBack()
  9890. .removeClass( "ui-menu ui-widget ui-widget-content ui-corner-all ui-menu-icons" )
  9891. .removeAttr( "role" )
  9892. .removeAttr( "tabIndex" )
  9893. .removeAttr( "aria-labelledby" )
  9894. .removeAttr( "aria-expanded" )
  9895. .removeAttr( "aria-hidden" )
  9896. .removeAttr( "aria-disabled" )
  9897. .removeUniqueId()
  9898. .show();
  9899. // Destroy menu items
  9900. this.element.find( ".ui-menu-item" )
  9901. .removeClass( "ui-menu-item" )
  9902. .removeAttr( "role" )
  9903. .removeAttr( "aria-disabled" )
  9904. .children( "a" )
  9905. .removeUniqueId()
  9906. .removeClass( "ui-corner-all ui-state-hover" )
  9907. .removeAttr( "tabIndex" )
  9908. .removeAttr( "role" )
  9909. .removeAttr( "aria-haspopup" )
  9910. .children().each( function() {
  9911. var elem = $( this );
  9912. if ( elem.data( "ui-menu-submenu-carat" ) ) {
  9913. elem.remove();
  9914. }
  9915. });
  9916. // Destroy menu dividers
  9917. this.element.find( ".ui-menu-divider" ).removeClass( "ui-menu-divider ui-widget-content" );
  9918. },
  9919. _keydown: function( event ) {
  9920. /*jshint maxcomplexity:20*/
  9921. var match, prev, character, skip, regex,
  9922. preventDefault = true;
  9923. function escape( value ) {
  9924. return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
  9925. }
  9926. switch ( event.keyCode ) {
  9927. case $.ui.keyCode.PAGE_UP:
  9928. this.previousPage( event );
  9929. break;
  9930. case $.ui.keyCode.PAGE_DOWN:
  9931. this.nextPage( event );
  9932. break;
  9933. case $.ui.keyCode.HOME:
  9934. this._move( "first", "first", event );
  9935. break;
  9936. case $.ui.keyCode.END:
  9937. this._move( "last", "last", event );
  9938. break;
  9939. case $.ui.keyCode.UP:
  9940. this.previous( event );
  9941. break;
  9942. case $.ui.keyCode.DOWN:
  9943. this.next( event );
  9944. break;
  9945. case $.ui.keyCode.LEFT:
  9946. this.collapse( event );
  9947. break;
  9948. case $.ui.keyCode.RIGHT:
  9949. if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
  9950. this.expand( event );
  9951. }
  9952. break;
  9953. case $.ui.keyCode.ENTER:
  9954. case $.ui.keyCode.SPACE:
  9955. this._activate( event );
  9956. break;
  9957. case $.ui.keyCode.ESCAPE:
  9958. this.collapse( event );
  9959. break;
  9960. default:
  9961. preventDefault = false;
  9962. prev = this.previousFilter || "";
  9963. character = String.fromCharCode( event.keyCode );
  9964. skip = false;
  9965. clearTimeout( this.filterTimer );
  9966. if ( character === prev ) {
  9967. skip = true;
  9968. } else {
  9969. character = prev + character;
  9970. }
  9971. regex = new RegExp( "^" + escape( character ), "i" );
  9972. match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
  9973. return regex.test( $( this ).children( "a" ).text() );
  9974. });
  9975. match = skip && match.index( this.active.next() ) !== -1 ?
  9976. this.active.nextAll( ".ui-menu-item" ) :
  9977. match;
  9978. // If no matches on the current filter, reset to the last character pressed
  9979. // to move down the menu to the first item that starts with that character
  9980. if ( !match.length ) {
  9981. character = String.fromCharCode( event.keyCode );
  9982. regex = new RegExp( "^" + escape( character ), "i" );
  9983. match = this.activeMenu.children( ".ui-menu-item" ).filter(function() {
  9984. return regex.test( $( this ).children( "a" ).text() );
  9985. });
  9986. }
  9987. if ( match.length ) {
  9988. this.focus( event, match );
  9989. if ( match.length > 1 ) {
  9990. this.previousFilter = character;
  9991. this.filterTimer = this._delay(function() {
  9992. delete this.previousFilter;
  9993. }, 1000 );
  9994. } else {
  9995. delete this.previousFilter;
  9996. }
  9997. } else {
  9998. delete this.previousFilter;
  9999. }
  10000. }
  10001. if ( preventDefault ) {
  10002. event.preventDefault();
  10003. }
  10004. },
  10005. _activate: function( event ) {
  10006. if ( !this.active.is( ".ui-state-disabled" ) ) {
  10007. if ( this.active.children( "a[aria-haspopup='true']" ).length ) {
  10008. this.expand( event );
  10009. } else {
  10010. this.select( event );
  10011. }
  10012. }
  10013. },
  10014. refresh: function() {
  10015. var menus,
  10016. icon = this.options.icons.submenu,
  10017. submenus = this.element.find( this.options.menus );
  10018. // Initialize nested menus
  10019. submenus.filter( ":not(.ui-menu)" )
  10020. .addClass( "ui-menu ui-widget ui-widget-content ui-corner-all" )
  10021. .hide()
  10022. .attr({
  10023. role: this.options.role,
  10024. "aria-hidden": "true",
  10025. "aria-expanded": "false"
  10026. })
  10027. .each(function() {
  10028. var menu = $( this ),
  10029. item = menu.prev( "a" ),
  10030. submenuCarat = $( "<span>" )
  10031. .addClass( "ui-menu-icon ui-icon " + icon )
  10032. .data( "ui-menu-submenu-carat", true );
  10033. item
  10034. .attr( "aria-haspopup", "true" )
  10035. .prepend( submenuCarat );
  10036. menu.attr( "aria-labelledby", item.attr( "id" ) );
  10037. });
  10038. menus = submenus.add( this.element );
  10039. // Don't refresh list items that are already adapted
  10040. menus.children( ":not(.ui-menu-item):has(a)" )
  10041. .addClass( "ui-menu-item" )
  10042. .attr( "role", "presentation" )
  10043. .children( "a" )
  10044. .uniqueId()
  10045. .addClass( "ui-corner-all" )
  10046. .attr({
  10047. tabIndex: -1,
  10048. role: this._itemRole()
  10049. });
  10050. // Initialize unlinked menu-items containing spaces and/or dashes only as dividers
  10051. menus.children( ":not(.ui-menu-item)" ).each(function() {
  10052. var item = $( this );
  10053. // hyphen, em dash, en dash
  10054. if ( !/[^\-\u2014\u2013\s]/.test( item.text() ) ) {
  10055. item.addClass( "ui-widget-content ui-menu-divider" );
  10056. }
  10057. });
  10058. // Add aria-disabled attribute to any disabled menu item
  10059. menus.children( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
  10060. // If the active item has been removed, blur the menu
  10061. if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  10062. this.blur();
  10063. }
  10064. },
  10065. _itemRole: function() {
  10066. return {
  10067. menu: "menuitem",
  10068. listbox: "option"
  10069. }[ this.options.role ];
  10070. },
  10071. _setOption: function( key, value ) {
  10072. if ( key === "icons" ) {
  10073. this.element.find( ".ui-menu-icon" )
  10074. .removeClass( this.options.icons.submenu )
  10075. .addClass( value.submenu );
  10076. }
  10077. this._super( key, value );
  10078. },
  10079. focus: function( event, item ) {
  10080. var nested, focused;
  10081. this.blur( event, event && event.type === "focus" );
  10082. this._scrollIntoView( item );
  10083. this.active = item.first();
  10084. focused = this.active.children( "a" ).addClass( "ui-state-focus" );
  10085. // Only update aria-activedescendant if there's a role
  10086. // otherwise we assume focus is managed elsewhere
  10087. if ( this.options.role ) {
  10088. this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
  10089. }
  10090. // Highlight active parent menu item, if any
  10091. this.active
  10092. .parent()
  10093. .closest( ".ui-menu-item" )
  10094. .children( "a:first" )
  10095. .addClass( "ui-state-active" );
  10096. if ( event && event.type === "keydown" ) {
  10097. this._close();
  10098. } else {
  10099. this.timer = this._delay(function() {
  10100. this._close();
  10101. }, this.delay );
  10102. }
  10103. nested = item.children( ".ui-menu" );
  10104. if ( nested.length && ( /^mouse/.test( event.type ) ) ) {
  10105. this._startOpening(nested);
  10106. }
  10107. this.activeMenu = item.parent();
  10108. this._trigger( "focus", event, { item: item } );
  10109. },
  10110. _scrollIntoView: function( item ) {
  10111. var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
  10112. if ( this._hasScroll() ) {
  10113. borderTop = parseFloat( $.css( this.activeMenu[0], "borderTopWidth" ) ) || 0;
  10114. paddingTop = parseFloat( $.css( this.activeMenu[0], "paddingTop" ) ) || 0;
  10115. offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
  10116. scroll = this.activeMenu.scrollTop();
  10117. elementHeight = this.activeMenu.height();
  10118. itemHeight = item.height();
  10119. if ( offset < 0 ) {
  10120. this.activeMenu.scrollTop( scroll + offset );
  10121. } else if ( offset + itemHeight > elementHeight ) {
  10122. this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
  10123. }
  10124. }
  10125. },
  10126. blur: function( event, fromFocus ) {
  10127. if ( !fromFocus ) {
  10128. clearTimeout( this.timer );
  10129. }
  10130. if ( !this.active ) {
  10131. return;
  10132. }
  10133. this.active.children( "a" ).removeClass( "ui-state-focus" );
  10134. this.active = null;
  10135. this._trigger( "blur", event, { item: this.active } );
  10136. },
  10137. _startOpening: function( submenu ) {
  10138. clearTimeout( this.timer );
  10139. // Don't open if already open fixes a Firefox bug that caused a .5 pixel
  10140. // shift in the submenu position when mousing over the carat icon
  10141. if ( submenu.attr( "aria-hidden" ) !== "true" ) {
  10142. return;
  10143. }
  10144. this.timer = this._delay(function() {
  10145. this._close();
  10146. this._open( submenu );
  10147. }, this.delay );
  10148. },
  10149. _open: function( submenu ) {
  10150. var position = $.extend({
  10151. of: this.active
  10152. }, this.options.position );
  10153. clearTimeout( this.timer );
  10154. this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
  10155. .hide()
  10156. .attr( "aria-hidden", "true" );
  10157. submenu
  10158. .show()
  10159. .removeAttr( "aria-hidden" )
  10160. .attr( "aria-expanded", "true" )
  10161. .position( position );
  10162. },
  10163. collapseAll: function( event, all ) {
  10164. clearTimeout( this.timer );
  10165. this.timer = this._delay(function() {
  10166. // If we were passed an event, look for the submenu that contains the event
  10167. var currentMenu = all ? this.element :
  10168. $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
  10169. // If we found no valid submenu ancestor, use the main menu to close all sub menus anyway
  10170. if ( !currentMenu.length ) {
  10171. currentMenu = this.element;
  10172. }
  10173. this._close( currentMenu );
  10174. this.blur( event );
  10175. this.activeMenu = currentMenu;
  10176. }, this.delay );
  10177. },
  10178. // With no arguments, closes the currently active menu - if nothing is active
  10179. // it closes all menus. If passed an argument, it will search for menus BELOW
  10180. _close: function( startMenu ) {
  10181. if ( !startMenu ) {
  10182. startMenu = this.active ? this.active.parent() : this.element;
  10183. }
  10184. startMenu
  10185. .find( ".ui-menu" )
  10186. .hide()
  10187. .attr( "aria-hidden", "true" )
  10188. .attr( "aria-expanded", "false" )
  10189. .end()
  10190. .find( "a.ui-state-active" )
  10191. .removeClass( "ui-state-active" );
  10192. },
  10193. collapse: function( event ) {
  10194. var newItem = this.active &&
  10195. this.active.parent().closest( ".ui-menu-item", this.element );
  10196. if ( newItem && newItem.length ) {
  10197. this._close();
  10198. this.focus( event, newItem );
  10199. }
  10200. },
  10201. expand: function( event ) {
  10202. var newItem = this.active &&
  10203. this.active
  10204. .children( ".ui-menu " )
  10205. .children( ".ui-menu-item" )
  10206. .first();
  10207. if ( newItem && newItem.length ) {
  10208. this._open( newItem.parent() );
  10209. // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
  10210. this._delay(function() {
  10211. this.focus( event, newItem );
  10212. });
  10213. }
  10214. },
  10215. next: function( event ) {
  10216. this._move( "next", "first", event );
  10217. },
  10218. previous: function( event ) {
  10219. this._move( "prev", "last", event );
  10220. },
  10221. isFirstItem: function() {
  10222. return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
  10223. },
  10224. isLastItem: function() {
  10225. return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
  10226. },
  10227. _move: function( direction, filter, event ) {
  10228. var next;
  10229. if ( this.active ) {
  10230. if ( direction === "first" || direction === "last" ) {
  10231. next = this.active
  10232. [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
  10233. .eq( -1 );
  10234. } else {
  10235. next = this.active
  10236. [ direction + "All" ]( ".ui-menu-item" )
  10237. .eq( 0 );
  10238. }
  10239. }
  10240. if ( !next || !next.length || !this.active ) {
  10241. next = this.activeMenu.children( ".ui-menu-item" )[ filter ]();
  10242. }
  10243. this.focus( event, next );
  10244. },
  10245. nextPage: function( event ) {
  10246. var item, base, height;
  10247. if ( !this.active ) {
  10248. this.next( event );
  10249. return;
  10250. }
  10251. if ( this.isLastItem() ) {
  10252. return;
  10253. }
  10254. if ( this._hasScroll() ) {
  10255. base = this.active.offset().top;
  10256. height = this.element.height();
  10257. this.active.nextAll( ".ui-menu-item" ).each(function() {
  10258. item = $( this );
  10259. return item.offset().top - base - height < 0;
  10260. });
  10261. this.focus( event, item );
  10262. } else {
  10263. this.focus( event, this.activeMenu.children( ".ui-menu-item" )
  10264. [ !this.active ? "first" : "last" ]() );
  10265. }
  10266. },
  10267. previousPage: function( event ) {
  10268. var item, base, height;
  10269. if ( !this.active ) {
  10270. this.next( event );
  10271. return;
  10272. }
  10273. if ( this.isFirstItem() ) {
  10274. return;
  10275. }
  10276. if ( this._hasScroll() ) {
  10277. base = this.active.offset().top;
  10278. height = this.element.height();
  10279. this.active.prevAll( ".ui-menu-item" ).each(function() {
  10280. item = $( this );
  10281. return item.offset().top - base + height > 0;
  10282. });
  10283. this.focus( event, item );
  10284. } else {
  10285. this.focus( event, this.activeMenu.children( ".ui-menu-item" ).first() );
  10286. }
  10287. },
  10288. _hasScroll: function() {
  10289. return this.element.outerHeight() < this.element.prop( "scrollHeight" );
  10290. },
  10291. select: function( event ) {
  10292. // TODO: It should never be possible to not have an active item at this
  10293. // point, but the tests don't trigger mouseenter before click.
  10294. this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
  10295. var ui = { item: this.active };
  10296. if ( !this.active.has( ".ui-menu" ).length ) {
  10297. this.collapseAll( event, true );
  10298. }
  10299. this._trigger( "select", event, ui );
  10300. }
  10301. });
  10302. }( jQuery ));
  10303. (function( $, undefined ) {
  10304. $.ui = $.ui || {};
  10305. var cachedScrollbarWidth,
  10306. max = Math.max,
  10307. abs = Math.abs,
  10308. round = Math.round,
  10309. rhorizontal = /left|center|right/,
  10310. rvertical = /top|center|bottom/,
  10311. roffset = /[\+\-]\d+(\.[\d]+)?%?/,
  10312. rposition = /^\w+/,
  10313. rpercent = /%$/,
  10314. _position = $.fn.position;
  10315. function getOffsets( offsets, width, height ) {
  10316. return [
  10317. parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ),
  10318. parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
  10319. ];
  10320. }
  10321. function parseCss( element, property ) {
  10322. return parseInt( $.css( element, property ), 10 ) || 0;
  10323. }
  10324. function getDimensions( elem ) {
  10325. var raw = elem[0];
  10326. if ( raw.nodeType === 9 ) {
  10327. return {
  10328. width: elem.width(),
  10329. height: elem.height(),
  10330. offset: { top: 0, left: 0 }
  10331. };
  10332. }
  10333. if ( $.isWindow( raw ) ) {
  10334. return {
  10335. width: elem.width(),
  10336. height: elem.height(),
  10337. offset: { top: elem.scrollTop(), left: elem.scrollLeft() }
  10338. };
  10339. }
  10340. if ( raw.preventDefault ) {
  10341. return {
  10342. width: 0,
  10343. height: 0,
  10344. offset: { top: raw.pageY, left: raw.pageX }
  10345. };
  10346. }
  10347. return {
  10348. width: elem.outerWidth(),
  10349. height: elem.outerHeight(),
  10350. offset: elem.offset()
  10351. };
  10352. }
  10353. $.position = {
  10354. scrollbarWidth: function() {
  10355. if ( cachedScrollbarWidth !== undefined ) {
  10356. return cachedScrollbarWidth;
  10357. }
  10358. var w1, w2,
  10359. div = $( "<div style='display:block;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>" ),
  10360. innerDiv = div.children()[0];
  10361. $( "body" ).append( div );
  10362. w1 = innerDiv.offsetWidth;
  10363. div.css( "overflow", "scroll" );
  10364. w2 = innerDiv.offsetWidth;
  10365. if ( w1 === w2 ) {
  10366. w2 = div[0].clientWidth;
  10367. }
  10368. div.remove();
  10369. return (cachedScrollbarWidth = w1 - w2);
  10370. },
  10371. getScrollInfo: function( within ) {
  10372. var overflowX = within.isWindow ? "" : within.element.css( "overflow-x" ),
  10373. overflowY = within.isWindow ? "" : within.element.css( "overflow-y" ),
  10374. hasOverflowX = overflowX === "scroll" ||
  10375. ( overflowX === "auto" && within.width < within.element[0].scrollWidth ),
  10376. hasOverflowY = overflowY === "scroll" ||
  10377. ( overflowY === "auto" && within.height < within.element[0].scrollHeight );
  10378. return {
  10379. width: hasOverflowY ? $.position.scrollbarWidth() : 0,
  10380. height: hasOverflowX ? $.position.scrollbarWidth() : 0
  10381. };
  10382. },
  10383. getWithinInfo: function( element ) {
  10384. var withinElement = $( element || window ),
  10385. isWindow = $.isWindow( withinElement[0] );
  10386. return {
  10387. element: withinElement,
  10388. isWindow: isWindow,
  10389. offset: withinElement.offset() || { left: 0, top: 0 },
  10390. scrollLeft: withinElement.scrollLeft(),
  10391. scrollTop: withinElement.scrollTop(),
  10392. width: isWindow ? withinElement.width() : withinElement.outerWidth(),
  10393. height: isWindow ? withinElement.height() : withinElement.outerHeight()
  10394. };
  10395. }
  10396. };
  10397. $.fn.position = function( options ) {
  10398. if ( !options || !options.of ) {
  10399. return _position.apply( this, arguments );
  10400. }
  10401. // make a copy, we don't want to modify arguments
  10402. options = $.extend( {}, options );
  10403. var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
  10404. target = $( options.of ),
  10405. within = $.position.getWithinInfo( options.within ),
  10406. scrollInfo = $.position.getScrollInfo( within ),
  10407. collision = ( options.collision || "flip" ).split( " " ),
  10408. offsets = {};
  10409. dimensions = getDimensions( target );
  10410. if ( target[0].preventDefault ) {
  10411. // force left top to allow flipping
  10412. options.at = "left top";
  10413. }
  10414. targetWidth = dimensions.width;
  10415. targetHeight = dimensions.height;
  10416. targetOffset = dimensions.offset;
  10417. // clone to reuse original targetOffset later
  10418. basePosition = $.extend( {}, targetOffset );
  10419. // force my and at to have valid horizontal and vertical positions
  10420. // if a value is missing or invalid, it will be converted to center
  10421. $.each( [ "my", "at" ], function() {
  10422. var pos = ( options[ this ] || "" ).split( " " ),
  10423. horizontalOffset,
  10424. verticalOffset;
  10425. if ( pos.length === 1) {
  10426. pos = rhorizontal.test( pos[ 0 ] ) ?
  10427. pos.concat( [ "center" ] ) :
  10428. rvertical.test( pos[ 0 ] ) ?
  10429. [ "center" ].concat( pos ) :
  10430. [ "center", "center" ];
  10431. }
  10432. pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center";
  10433. pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center";
  10434. // calculate offsets
  10435. horizontalOffset = roffset.exec( pos[ 0 ] );
  10436. verticalOffset = roffset.exec( pos[ 1 ] );
  10437. offsets[ this ] = [
  10438. horizontalOffset ? horizontalOffset[ 0 ] : 0,
  10439. verticalOffset ? verticalOffset[ 0 ] : 0
  10440. ];
  10441. // reduce to just the positions without the offsets
  10442. options[ this ] = [
  10443. rposition.exec( pos[ 0 ] )[ 0 ],
  10444. rposition.exec( pos[ 1 ] )[ 0 ]
  10445. ];
  10446. });
  10447. // normalize collision option
  10448. if ( collision.length === 1 ) {
  10449. collision[ 1 ] = collision[ 0 ];
  10450. }
  10451. if ( options.at[ 0 ] === "right" ) {
  10452. basePosition.left += targetWidth;
  10453. } else if ( options.at[ 0 ] === "center" ) {
  10454. basePosition.left += targetWidth / 2;
  10455. }
  10456. if ( options.at[ 1 ] === "bottom" ) {
  10457. basePosition.top += targetHeight;
  10458. } else if ( options.at[ 1 ] === "center" ) {
  10459. basePosition.top += targetHeight / 2;
  10460. }
  10461. atOffset = getOffsets( offsets.at, targetWidth, targetHeight );
  10462. basePosition.left += atOffset[ 0 ];
  10463. basePosition.top += atOffset[ 1 ];
  10464. return this.each(function() {
  10465. var collisionPosition, using,
  10466. elem = $( this ),
  10467. elemWidth = elem.outerWidth(),
  10468. elemHeight = elem.outerHeight(),
  10469. marginLeft = parseCss( this, "marginLeft" ),
  10470. marginTop = parseCss( this, "marginTop" ),
  10471. collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) + scrollInfo.width,
  10472. collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) + scrollInfo.height,
  10473. position = $.extend( {}, basePosition ),
  10474. myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() );
  10475. if ( options.my[ 0 ] === "right" ) {
  10476. position.left -= elemWidth;
  10477. } else if ( options.my[ 0 ] === "center" ) {
  10478. position.left -= elemWidth / 2;
  10479. }
  10480. if ( options.my[ 1 ] === "bottom" ) {
  10481. position.top -= elemHeight;
  10482. } else if ( options.my[ 1 ] === "center" ) {
  10483. position.top -= elemHeight / 2;
  10484. }
  10485. position.left += myOffset[ 0 ];
  10486. position.top += myOffset[ 1 ];
  10487. // if the browser doesn't support fractions, then round for consistent results
  10488. if ( !$.support.offsetFractions ) {
  10489. position.left = round( position.left );
  10490. position.top = round( position.top );
  10491. }
  10492. collisionPosition = {
  10493. marginLeft: marginLeft,
  10494. marginTop: marginTop
  10495. };
  10496. $.each( [ "left", "top" ], function( i, dir ) {
  10497. if ( $.ui.position[ collision[ i ] ] ) {
  10498. $.ui.position[ collision[ i ] ][ dir ]( position, {
  10499. targetWidth: targetWidth,
  10500. targetHeight: targetHeight,
  10501. elemWidth: elemWidth,
  10502. elemHeight: elemHeight,
  10503. collisionPosition: collisionPosition,
  10504. collisionWidth: collisionWidth,
  10505. collisionHeight: collisionHeight,
  10506. offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
  10507. my: options.my,
  10508. at: options.at,
  10509. within: within,
  10510. elem : elem
  10511. });
  10512. }
  10513. });
  10514. if ( options.using ) {
  10515. // adds feedback as second argument to using callback, if present
  10516. using = function( props ) {
  10517. var left = targetOffset.left - position.left,
  10518. right = left + targetWidth - elemWidth,
  10519. top = targetOffset.top - position.top,
  10520. bottom = top + targetHeight - elemHeight,
  10521. feedback = {
  10522. target: {
  10523. element: target,
  10524. left: targetOffset.left,
  10525. top: targetOffset.top,
  10526. width: targetWidth,
  10527. height: targetHeight
  10528. },
  10529. element: {
  10530. element: elem,
  10531. left: position.left,
  10532. top: position.top,
  10533. width: elemWidth,
  10534. height: elemHeight
  10535. },
  10536. horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
  10537. vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
  10538. };
  10539. if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
  10540. feedback.horizontal = "center";
  10541. }
  10542. if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
  10543. feedback.vertical = "middle";
  10544. }
  10545. if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
  10546. feedback.important = "horizontal";
  10547. } else {
  10548. feedback.important = "vertical";
  10549. }
  10550. options.using.call( this, props, feedback );
  10551. };
  10552. }
  10553. elem.offset( $.extend( position, { using: using } ) );
  10554. });
  10555. };
  10556. $.ui.position = {
  10557. fit: {
  10558. left: function( position, data ) {
  10559. var within = data.within,
  10560. withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
  10561. outerWidth = within.width,
  10562. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  10563. overLeft = withinOffset - collisionPosLeft,
  10564. overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
  10565. newOverRight;
  10566. // element is wider than within
  10567. if ( data.collisionWidth > outerWidth ) {
  10568. // element is initially over the left side of within
  10569. if ( overLeft > 0 && overRight <= 0 ) {
  10570. newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset;
  10571. position.left += overLeft - newOverRight;
  10572. // element is initially over right side of within
  10573. } else if ( overRight > 0 && overLeft <= 0 ) {
  10574. position.left = withinOffset;
  10575. // element is initially over both left and right sides of within
  10576. } else {
  10577. if ( overLeft > overRight ) {
  10578. position.left = withinOffset + outerWidth - data.collisionWidth;
  10579. } else {
  10580. position.left = withinOffset;
  10581. }
  10582. }
  10583. // too far left -> align with left edge
  10584. } else if ( overLeft > 0 ) {
  10585. position.left += overLeft;
  10586. // too far right -> align with right edge
  10587. } else if ( overRight > 0 ) {
  10588. position.left -= overRight;
  10589. // adjust based on position and margin
  10590. } else {
  10591. position.left = max( position.left - collisionPosLeft, position.left );
  10592. }
  10593. },
  10594. top: function( position, data ) {
  10595. var within = data.within,
  10596. withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
  10597. outerHeight = data.within.height,
  10598. collisionPosTop = position.top - data.collisionPosition.marginTop,
  10599. overTop = withinOffset - collisionPosTop,
  10600. overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
  10601. newOverBottom;
  10602. // element is taller than within
  10603. if ( data.collisionHeight > outerHeight ) {
  10604. // element is initially over the top of within
  10605. if ( overTop > 0 && overBottom <= 0 ) {
  10606. newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset;
  10607. position.top += overTop - newOverBottom;
  10608. // element is initially over bottom of within
  10609. } else if ( overBottom > 0 && overTop <= 0 ) {
  10610. position.top = withinOffset;
  10611. // element is initially over both top and bottom of within
  10612. } else {
  10613. if ( overTop > overBottom ) {
  10614. position.top = withinOffset + outerHeight - data.collisionHeight;
  10615. } else {
  10616. position.top = withinOffset;
  10617. }
  10618. }
  10619. // too far up -> align with top
  10620. } else if ( overTop > 0 ) {
  10621. position.top += overTop;
  10622. // too far down -> align with bottom edge
  10623. } else if ( overBottom > 0 ) {
  10624. position.top -= overBottom;
  10625. // adjust based on position and margin
  10626. } else {
  10627. position.top = max( position.top - collisionPosTop, position.top );
  10628. }
  10629. }
  10630. },
  10631. flip: {
  10632. left: function( position, data ) {
  10633. var within = data.within,
  10634. withinOffset = within.offset.left + within.scrollLeft,
  10635. outerWidth = within.width,
  10636. offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
  10637. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  10638. overLeft = collisionPosLeft - offsetLeft,
  10639. overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
  10640. myOffset = data.my[ 0 ] === "left" ?
  10641. -data.elemWidth :
  10642. data.my[ 0 ] === "right" ?
  10643. data.elemWidth :
  10644. 0,
  10645. atOffset = data.at[ 0 ] === "left" ?
  10646. data.targetWidth :
  10647. data.at[ 0 ] === "right" ?
  10648. -data.targetWidth :
  10649. 0,
  10650. offset = -2 * data.offset[ 0 ],
  10651. newOverRight,
  10652. newOverLeft;
  10653. if ( overLeft < 0 ) {
  10654. newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset;
  10655. if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
  10656. position.left += myOffset + atOffset + offset;
  10657. }
  10658. }
  10659. else if ( overRight > 0 ) {
  10660. newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft;
  10661. if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
  10662. position.left += myOffset + atOffset + offset;
  10663. }
  10664. }
  10665. },
  10666. top: function( position, data ) {
  10667. var within = data.within,
  10668. withinOffset = within.offset.top + within.scrollTop,
  10669. outerHeight = within.height,
  10670. offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
  10671. collisionPosTop = position.top - data.collisionPosition.marginTop,
  10672. overTop = collisionPosTop - offsetTop,
  10673. overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
  10674. top = data.my[ 1 ] === "top",
  10675. myOffset = top ?
  10676. -data.elemHeight :
  10677. data.my[ 1 ] === "bottom" ?
  10678. data.elemHeight :
  10679. 0,
  10680. atOffset = data.at[ 1 ] === "top" ?
  10681. data.targetHeight :
  10682. data.at[ 1 ] === "bottom" ?
  10683. -data.targetHeight :
  10684. 0,
  10685. offset = -2 * data.offset[ 1 ],
  10686. newOverTop,
  10687. newOverBottom;
  10688. if ( overTop < 0 ) {
  10689. newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset;
  10690. if ( ( position.top + myOffset + atOffset + offset) > overTop && ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) ) {
  10691. position.top += myOffset + atOffset + offset;
  10692. }
  10693. }
  10694. else if ( overBottom > 0 ) {
  10695. newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop;
  10696. if ( ( position.top + myOffset + atOffset + offset) > overBottom && ( newOverTop > 0 || abs( newOverTop ) < overBottom ) ) {
  10697. position.top += myOffset + atOffset + offset;
  10698. }
  10699. }
  10700. }
  10701. },
  10702. flipfit: {
  10703. left: function() {
  10704. $.ui.position.flip.left.apply( this, arguments );
  10705. $.ui.position.fit.left.apply( this, arguments );
  10706. },
  10707. top: function() {
  10708. $.ui.position.flip.top.apply( this, arguments );
  10709. $.ui.position.fit.top.apply( this, arguments );
  10710. }
  10711. }
  10712. };
  10713. // fraction support test
  10714. (function () {
  10715. var testElement, testElementParent, testElementStyle, offsetLeft, i,
  10716. body = document.getElementsByTagName( "body" )[ 0 ],
  10717. div = document.createElement( "div" );
  10718. //Create a "fake body" for testing based on method used in jQuery.support
  10719. testElement = document.createElement( body ? "div" : "body" );
  10720. testElementStyle = {
  10721. visibility: "hidden",
  10722. width: 0,
  10723. height: 0,
  10724. border: 0,
  10725. margin: 0,
  10726. background: "none"
  10727. };
  10728. if ( body ) {
  10729. $.extend( testElementStyle, {
  10730. position: "absolute",
  10731. left: "-1000px",
  10732. top: "-1000px"
  10733. });
  10734. }
  10735. for ( i in testElementStyle ) {
  10736. testElement.style[ i ] = testElementStyle[ i ];
  10737. }
  10738. testElement.appendChild( div );
  10739. testElementParent = body || document.documentElement;
  10740. testElementParent.insertBefore( testElement, testElementParent.firstChild );
  10741. div.style.cssText = "position: absolute; left: 10.7432222px;";
  10742. offsetLeft = $( div ).offset().left;
  10743. $.support.offsetFractions = offsetLeft > 10 && offsetLeft < 11;
  10744. testElement.innerHTML = "";
  10745. testElementParent.removeChild( testElement );
  10746. })();
  10747. }( jQuery ) );
  10748. (function( $, undefined ) {
  10749. $.widget( "ui.progressbar", {
  10750. version: "1.10.3",
  10751. options: {
  10752. max: 100,
  10753. value: 0,
  10754. change: null,
  10755. complete: null
  10756. },
  10757. min: 0,
  10758. _create: function() {
  10759. // Constrain initial value
  10760. this.oldValue = this.options.value = this._constrainedValue();
  10761. this.element
  10762. .addClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  10763. .attr({
  10764. // Only set static values, aria-valuenow and aria-valuemax are
  10765. // set inside _refreshValue()
  10766. role: "progressbar",
  10767. "aria-valuemin": this.min
  10768. });
  10769. this.valueDiv = $( "<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>" )
  10770. .appendTo( this.element );
  10771. this._refreshValue();
  10772. },
  10773. _destroy: function() {
  10774. this.element
  10775. .removeClass( "ui-progressbar ui-widget ui-widget-content ui-corner-all" )
  10776. .removeAttr( "role" )
  10777. .removeAttr( "aria-valuemin" )
  10778. .removeAttr( "aria-valuemax" )
  10779. .removeAttr( "aria-valuenow" );
  10780. this.valueDiv.remove();
  10781. },
  10782. value: function( newValue ) {
  10783. if ( newValue === undefined ) {
  10784. return this.options.value;
  10785. }
  10786. this.options.value = this._constrainedValue( newValue );
  10787. this._refreshValue();
  10788. },
  10789. _constrainedValue: function( newValue ) {
  10790. if ( newValue === undefined ) {
  10791. newValue = this.options.value;
  10792. }
  10793. this.indeterminate = newValue === false;
  10794. // sanitize value
  10795. if ( typeof newValue !== "number" ) {
  10796. newValue = 0;
  10797. }
  10798. return this.indeterminate ? false :
  10799. Math.min( this.options.max, Math.max( this.min, newValue ) );
  10800. },
  10801. _setOptions: function( options ) {
  10802. // Ensure "value" option is set after other values (like max)
  10803. var value = options.value;
  10804. delete options.value;
  10805. this._super( options );
  10806. this.options.value = this._constrainedValue( value );
  10807. this._refreshValue();
  10808. },
  10809. _setOption: function( key, value ) {
  10810. if ( key === "max" ) {
  10811. // Don't allow a max less than min
  10812. value = Math.max( this.min, value );
  10813. }
  10814. this._super( key, value );
  10815. },
  10816. _percentage: function() {
  10817. return this.indeterminate ? 100 : 100 * ( this.options.value - this.min ) / ( this.options.max - this.min );
  10818. },
  10819. _refreshValue: function() {
  10820. var value = this.options.value,
  10821. percentage = this._percentage();
  10822. this.valueDiv
  10823. .toggle( this.indeterminate || value > this.min )
  10824. .toggleClass( "ui-corner-right", value === this.options.max )
  10825. .width( percentage.toFixed(0) + "%" );
  10826. this.element.toggleClass( "ui-progressbar-indeterminate", this.indeterminate );
  10827. if ( this.indeterminate ) {
  10828. this.element.removeAttr( "aria-valuenow" );
  10829. if ( !this.overlayDiv ) {
  10830. this.overlayDiv = $( "<div class='ui-progressbar-overlay'></div>" ).appendTo( this.valueDiv );
  10831. }
  10832. } else {
  10833. this.element.attr({
  10834. "aria-valuemax": this.options.max,
  10835. "aria-valuenow": value
  10836. });
  10837. if ( this.overlayDiv ) {
  10838. this.overlayDiv.remove();
  10839. this.overlayDiv = null;
  10840. }
  10841. }
  10842. if ( this.oldValue !== value ) {
  10843. this.oldValue = value;
  10844. this._trigger( "change" );
  10845. }
  10846. if ( value === this.options.max ) {
  10847. this._trigger( "complete" );
  10848. }
  10849. }
  10850. });
  10851. })( jQuery );
  10852. (function( $, undefined ) {
  10853. // number of pages in a slider
  10854. // (how many times can you page up/down to go through the whole range)
  10855. var numPages = 5;
  10856. $.widget( "ui.slider", $.ui.mouse, {
  10857. version: "1.10.3",
  10858. widgetEventPrefix: "slide",
  10859. options: {
  10860. animate: false,
  10861. distance: 0,
  10862. max: 100,
  10863. min: 0,
  10864. orientation: "horizontal",
  10865. range: false,
  10866. step: 1,
  10867. value: 0,
  10868. values: null,
  10869. // callbacks
  10870. change: null,
  10871. slide: null,
  10872. start: null,
  10873. stop: null
  10874. },
  10875. _create: function() {
  10876. this._keySliding = false;
  10877. this._mouseSliding = false;
  10878. this._animateOff = true;
  10879. this._handleIndex = null;
  10880. this._detectOrientation();
  10881. this._mouseInit();
  10882. this.element
  10883. .addClass( "ui-slider" +
  10884. " ui-slider-" + this.orientation +
  10885. " ui-widget" +
  10886. " ui-widget-content" +
  10887. " ui-corner-all");
  10888. this._refresh();
  10889. this._setOption( "disabled", this.options.disabled );
  10890. this._animateOff = false;
  10891. },
  10892. _refresh: function() {
  10893. this._createRange();
  10894. this._createHandles();
  10895. this._setupEvents();
  10896. this._refreshValue();
  10897. },
  10898. _createHandles: function() {
  10899. var i, handleCount,
  10900. options = this.options,
  10901. existingHandles = this.element.find( ".ui-slider-handle" ).addClass( "ui-state-default ui-corner-all" ),
  10902. handle = "<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>",
  10903. handles = [];
  10904. handleCount = ( options.values && options.values.length ) || 1;
  10905. if ( existingHandles.length > handleCount ) {
  10906. existingHandles.slice( handleCount ).remove();
  10907. existingHandles = existingHandles.slice( 0, handleCount );
  10908. }
  10909. for ( i = existingHandles.length; i < handleCount; i++ ) {
  10910. handles.push( handle );
  10911. }
  10912. this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );
  10913. this.handle = this.handles.eq( 0 );
  10914. this.handles.each(function( i ) {
  10915. $( this ).data( "ui-slider-handle-index", i );
  10916. });
  10917. },
  10918. _createRange: function() {
  10919. var options = this.options,
  10920. classes = "";
  10921. if ( options.range ) {
  10922. if ( options.range === true ) {
  10923. if ( !options.values ) {
  10924. options.values = [ this._valueMin(), this._valueMin() ];
  10925. } else if ( options.values.length && options.values.length !== 2 ) {
  10926. options.values = [ options.values[0], options.values[0] ];
  10927. } else if ( $.isArray( options.values ) ) {
  10928. options.values = options.values.slice(0);
  10929. }
  10930. }
  10931. if ( !this.range || !this.range.length ) {
  10932. this.range = $( "<div></div>" )
  10933. .appendTo( this.element );
  10934. classes = "ui-slider-range" +
  10935. // note: this isn't the most fittingly semantic framework class for this element,
  10936. // but worked best visually with a variety of themes
  10937. " ui-widget-header ui-corner-all";
  10938. } else {
  10939. this.range.removeClass( "ui-slider-range-min ui-slider-range-max" )
  10940. // Handle range switching from true to min/max
  10941. .css({
  10942. "left": "",
  10943. "bottom": ""
  10944. });
  10945. }
  10946. this.range.addClass( classes +
  10947. ( ( options.range === "min" || options.range === "max" ) ? " ui-slider-range-" + options.range : "" ) );
  10948. } else {
  10949. this.range = $([]);
  10950. }
  10951. },
  10952. _setupEvents: function() {
  10953. var elements = this.handles.add( this.range ).filter( "a" );
  10954. this._off( elements );
  10955. this._on( elements, this._handleEvents );
  10956. this._hoverable( elements );
  10957. this._focusable( elements );
  10958. },
  10959. _destroy: function() {
  10960. this.handles.remove();
  10961. this.range.remove();
  10962. this.element
  10963. .removeClass( "ui-slider" +
  10964. " ui-slider-horizontal" +
  10965. " ui-slider-vertical" +
  10966. " ui-widget" +
  10967. " ui-widget-content" +
  10968. " ui-corner-all" );
  10969. this._mouseDestroy();
  10970. },
  10971. _mouseCapture: function( event ) {
  10972. var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
  10973. that = this,
  10974. o = this.options;
  10975. if ( o.disabled ) {
  10976. return false;
  10977. }
  10978. this.elementSize = {
  10979. width: this.element.outerWidth(),
  10980. height: this.element.outerHeight()
  10981. };
  10982. this.elementOffset = this.element.offset();
  10983. position = { x: event.pageX, y: event.pageY };
  10984. normValue = this._normValueFromMouse( position );
  10985. distance = this._valueMax() - this._valueMin() + 1;
  10986. this.handles.each(function( i ) {
  10987. var thisDistance = Math.abs( normValue - that.values(i) );
  10988. if (( distance > thisDistance ) ||
  10989. ( distance === thisDistance &&
  10990. (i === that._lastChangedValue || that.values(i) === o.min ))) {
  10991. distance = thisDistance;
  10992. closestHandle = $( this );
  10993. index = i;
  10994. }
  10995. });
  10996. allowed = this._start( event, index );
  10997. if ( allowed === false ) {
  10998. return false;
  10999. }
  11000. this._mouseSliding = true;
  11001. this._handleIndex = index;
  11002. closestHandle
  11003. .addClass( "ui-state-active" )
  11004. .focus();
  11005. offset = closestHandle.offset();
  11006. mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" );
  11007. this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
  11008. left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
  11009. top: event.pageY - offset.top -
  11010. ( closestHandle.height() / 2 ) -
  11011. ( parseInt( closestHandle.css("borderTopWidth"), 10 ) || 0 ) -
  11012. ( parseInt( closestHandle.css("borderBottomWidth"), 10 ) || 0) +
  11013. ( parseInt( closestHandle.css("marginTop"), 10 ) || 0)
  11014. };
  11015. if ( !this.handles.hasClass( "ui-state-hover" ) ) {
  11016. this._slide( event, index, normValue );
  11017. }
  11018. this._animateOff = true;
  11019. return true;
  11020. },
  11021. _mouseStart: function() {
  11022. return true;
  11023. },
  11024. _mouseDrag: function( event ) {
  11025. var position = { x: event.pageX, y: event.pageY },
  11026. normValue = this._normValueFromMouse( position );
  11027. this._slide( event, this._handleIndex, normValue );
  11028. return false;
  11029. },
  11030. _mouseStop: function( event ) {
  11031. this.handles.removeClass( "ui-state-active" );
  11032. this._mouseSliding = false;
  11033. this._stop( event, this._handleIndex );
  11034. this._change( event, this._handleIndex );
  11035. this._handleIndex = null;
  11036. this._clickOffset = null;
  11037. this._animateOff = false;
  11038. return false;
  11039. },
  11040. _detectOrientation: function() {
  11041. this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
  11042. },
  11043. _normValueFromMouse: function( position ) {
  11044. var pixelTotal,
  11045. pixelMouse,
  11046. percentMouse,
  11047. valueTotal,
  11048. valueMouse;
  11049. if ( this.orientation === "horizontal" ) {
  11050. pixelTotal = this.elementSize.width;
  11051. pixelMouse = position.x - this.elementOffset.left - ( this._clickOffset ? this._clickOffset.left : 0 );
  11052. } else {
  11053. pixelTotal = this.elementSize.height;
  11054. pixelMouse = position.y - this.elementOffset.top - ( this._clickOffset ? this._clickOffset.top : 0 );
  11055. }
  11056. percentMouse = ( pixelMouse / pixelTotal );
  11057. if ( percentMouse > 1 ) {
  11058. percentMouse = 1;
  11059. }
  11060. if ( percentMouse < 0 ) {
  11061. percentMouse = 0;
  11062. }
  11063. if ( this.orientation === "vertical" ) {
  11064. percentMouse = 1 - percentMouse;
  11065. }
  11066. valueTotal = this._valueMax() - this._valueMin();
  11067. valueMouse = this._valueMin() + percentMouse * valueTotal;
  11068. return this._trimAlignValue( valueMouse );
  11069. },
  11070. _start: function( event, index ) {
  11071. var uiHash = {
  11072. handle: this.handles[ index ],
  11073. value: this.value()
  11074. };
  11075. if ( this.options.values && this.options.values.length ) {
  11076. uiHash.value = this.values( index );
  11077. uiHash.values = this.values();
  11078. }
  11079. return this._trigger( "start", event, uiHash );
  11080. },
  11081. _slide: function( event, index, newVal ) {
  11082. var otherVal,
  11083. newValues,
  11084. allowed;
  11085. if ( this.options.values && this.options.values.length ) {
  11086. otherVal = this.values( index ? 0 : 1 );
  11087. if ( ( this.options.values.length === 2 && this.options.range === true ) &&
  11088. ( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) )
  11089. ) {
  11090. newVal = otherVal;
  11091. }
  11092. if ( newVal !== this.values( index ) ) {
  11093. newValues = this.values();
  11094. newValues[ index ] = newVal;
  11095. // A slide can be canceled by returning false from the slide callback
  11096. allowed = this._trigger( "slide", event, {
  11097. handle: this.handles[ index ],
  11098. value: newVal,
  11099. values: newValues
  11100. } );
  11101. otherVal = this.values( index ? 0 : 1 );
  11102. if ( allowed !== false ) {
  11103. this.values( index, newVal, true );
  11104. }
  11105. }
  11106. } else {
  11107. if ( newVal !== this.value() ) {
  11108. // A slide can be canceled by returning false from the slide callback
  11109. allowed = this._trigger( "slide", event, {
  11110. handle: this.handles[ index ],
  11111. value: newVal
  11112. } );
  11113. if ( allowed !== false ) {
  11114. this.value( newVal );
  11115. }
  11116. }
  11117. }
  11118. },
  11119. _stop: function( event, index ) {
  11120. var uiHash = {
  11121. handle: this.handles[ index ],
  11122. value: this.value()
  11123. };
  11124. if ( this.options.values && this.options.values.length ) {
  11125. uiHash.value = this.values( index );
  11126. uiHash.values = this.values();
  11127. }
  11128. this._trigger( "stop", event, uiHash );
  11129. },
  11130. _change: function( event, index ) {
  11131. if ( !this._keySliding && !this._mouseSliding ) {
  11132. var uiHash = {
  11133. handle: this.handles[ index ],
  11134. value: this.value()
  11135. };
  11136. if ( this.options.values && this.options.values.length ) {
  11137. uiHash.value = this.values( index );
  11138. uiHash.values = this.values();
  11139. }
  11140. //store the last changed value index for reference when handles overlap
  11141. this._lastChangedValue = index;
  11142. this._trigger( "change", event, uiHash );
  11143. }
  11144. },
  11145. value: function( newValue ) {
  11146. if ( arguments.length ) {
  11147. this.options.value = this._trimAlignValue( newValue );
  11148. this._refreshValue();
  11149. this._change( null, 0 );
  11150. return;
  11151. }
  11152. return this._value();
  11153. },
  11154. values: function( index, newValue ) {
  11155. var vals,
  11156. newValues,
  11157. i;
  11158. if ( arguments.length > 1 ) {
  11159. this.options.values[ index ] = this._trimAlignValue( newValue );
  11160. this._refreshValue();
  11161. this._change( null, index );
  11162. return;
  11163. }
  11164. if ( arguments.length ) {
  11165. if ( $.isArray( arguments[ 0 ] ) ) {
  11166. vals = this.options.values;
  11167. newValues = arguments[ 0 ];
  11168. for ( i = 0; i < vals.length; i += 1 ) {
  11169. vals[ i ] = this._trimAlignValue( newValues[ i ] );
  11170. this._change( null, i );
  11171. }
  11172. this._refreshValue();
  11173. } else {
  11174. if ( this.options.values && this.options.values.length ) {
  11175. return this._values( index );
  11176. } else {
  11177. return this.value();
  11178. }
  11179. }
  11180. } else {
  11181. return this._values();
  11182. }
  11183. },
  11184. _setOption: function( key, value ) {
  11185. var i,
  11186. valsLength = 0;
  11187. if ( key === "range" && this.options.range === true ) {
  11188. if ( value === "min" ) {
  11189. this.options.value = this._values( 0 );
  11190. this.options.values = null;
  11191. } else if ( value === "max" ) {
  11192. this.options.value = this._values( this.options.values.length-1 );
  11193. this.options.values = null;
  11194. }
  11195. }
  11196. if ( $.isArray( this.options.values ) ) {
  11197. valsLength = this.options.values.length;
  11198. }
  11199. $.Widget.prototype._setOption.apply( this, arguments );
  11200. switch ( key ) {
  11201. case "orientation":
  11202. this._detectOrientation();
  11203. this.element
  11204. .removeClass( "ui-slider-horizontal ui-slider-vertical" )
  11205. .addClass( "ui-slider-" + this.orientation );
  11206. this._refreshValue();
  11207. break;
  11208. case "value":
  11209. this._animateOff = true;
  11210. this._refreshValue();
  11211. this._change( null, 0 );
  11212. this._animateOff = false;
  11213. break;
  11214. case "values":
  11215. this._animateOff = true;
  11216. this._refreshValue();
  11217. for ( i = 0; i < valsLength; i += 1 ) {
  11218. this._change( null, i );
  11219. }
  11220. this._animateOff = false;
  11221. break;
  11222. case "min":
  11223. case "max":
  11224. this._animateOff = true;
  11225. this._refreshValue();
  11226. this._animateOff = false;
  11227. break;
  11228. case "range":
  11229. this._animateOff = true;
  11230. this._refresh();
  11231. this._animateOff = false;
  11232. break;
  11233. }
  11234. },
  11235. //internal value getter
  11236. // _value() returns value trimmed by min and max, aligned by step
  11237. _value: function() {
  11238. var val = this.options.value;
  11239. val = this._trimAlignValue( val );
  11240. return val;
  11241. },
  11242. //internal values getter
  11243. // _values() returns array of values trimmed by min and max, aligned by step
  11244. // _values( index ) returns single value trimmed by min and max, aligned by step
  11245. _values: function( index ) {
  11246. var val,
  11247. vals,
  11248. i;
  11249. if ( arguments.length ) {
  11250. val = this.options.values[ index ];
  11251. val = this._trimAlignValue( val );
  11252. return val;
  11253. } else if ( this.options.values && this.options.values.length ) {
  11254. // .slice() creates a copy of the array
  11255. // this copy gets trimmed by min and max and then returned
  11256. vals = this.options.values.slice();
  11257. for ( i = 0; i < vals.length; i+= 1) {
  11258. vals[ i ] = this._trimAlignValue( vals[ i ] );
  11259. }
  11260. return vals;
  11261. } else {
  11262. return [];
  11263. }
  11264. },
  11265. // returns the step-aligned value that val is closest to, between (inclusive) min and max
  11266. _trimAlignValue: function( val ) {
  11267. if ( val <= this._valueMin() ) {
  11268. return this._valueMin();
  11269. }
  11270. if ( val >= this._valueMax() ) {
  11271. return this._valueMax();
  11272. }
  11273. var step = ( this.options.step > 0 ) ? this.options.step : 1,
  11274. valModStep = (val - this._valueMin()) % step,
  11275. alignValue = val - valModStep;
  11276. if ( Math.abs(valModStep) * 2 >= step ) {
  11277. alignValue += ( valModStep > 0 ) ? step : ( -step );
  11278. }
  11279. // Since JavaScript has problems with large floats, round
  11280. // the final value to 5 digits after the decimal point (see #4124)
  11281. return parseFloat( alignValue.toFixed(5) );
  11282. },
  11283. _valueMin: function() {
  11284. return this.options.min;
  11285. },
  11286. _valueMax: function() {
  11287. return this.options.max;
  11288. },
  11289. _refreshValue: function() {
  11290. var lastValPercent, valPercent, value, valueMin, valueMax,
  11291. oRange = this.options.range,
  11292. o = this.options,
  11293. that = this,
  11294. animate = ( !this._animateOff ) ? o.animate : false,
  11295. _set = {};
  11296. if ( this.options.values && this.options.values.length ) {
  11297. this.handles.each(function( i ) {
  11298. valPercent = ( that.values(i) - that._valueMin() ) / ( that._valueMax() - that._valueMin() ) * 100;
  11299. _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  11300. $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  11301. if ( that.options.range === true ) {
  11302. if ( that.orientation === "horizontal" ) {
  11303. if ( i === 0 ) {
  11304. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { left: valPercent + "%" }, o.animate );
  11305. }
  11306. if ( i === 1 ) {
  11307. that.range[ animate ? "animate" : "css" ]( { width: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  11308. }
  11309. } else {
  11310. if ( i === 0 ) {
  11311. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { bottom: ( valPercent ) + "%" }, o.animate );
  11312. }
  11313. if ( i === 1 ) {
  11314. that.range[ animate ? "animate" : "css" ]( { height: ( valPercent - lastValPercent ) + "%" }, { queue: false, duration: o.animate } );
  11315. }
  11316. }
  11317. }
  11318. lastValPercent = valPercent;
  11319. });
  11320. } else {
  11321. value = this.value();
  11322. valueMin = this._valueMin();
  11323. valueMax = this._valueMax();
  11324. valPercent = ( valueMax !== valueMin ) ?
  11325. ( value - valueMin ) / ( valueMax - valueMin ) * 100 :
  11326. 0;
  11327. _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  11328. this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  11329. if ( oRange === "min" && this.orientation === "horizontal" ) {
  11330. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { width: valPercent + "%" }, o.animate );
  11331. }
  11332. if ( oRange === "max" && this.orientation === "horizontal" ) {
  11333. this.range[ animate ? "animate" : "css" ]( { width: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  11334. }
  11335. if ( oRange === "min" && this.orientation === "vertical" ) {
  11336. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( { height: valPercent + "%" }, o.animate );
  11337. }
  11338. if ( oRange === "max" && this.orientation === "vertical" ) {
  11339. this.range[ animate ? "animate" : "css" ]( { height: ( 100 - valPercent ) + "%" }, { queue: false, duration: o.animate } );
  11340. }
  11341. }
  11342. },
  11343. _handleEvents: {
  11344. keydown: function( event ) {
  11345. /*jshint maxcomplexity:25*/
  11346. var allowed, curVal, newVal, step,
  11347. index = $( event.target ).data( "ui-slider-handle-index" );
  11348. switch ( event.keyCode ) {
  11349. case $.ui.keyCode.HOME:
  11350. case $.ui.keyCode.END:
  11351. case $.ui.keyCode.PAGE_UP:
  11352. case $.ui.keyCode.PAGE_DOWN:
  11353. case $.ui.keyCode.UP:
  11354. case $.ui.keyCode.RIGHT:
  11355. case $.ui.keyCode.DOWN:
  11356. case $.ui.keyCode.LEFT:
  11357. event.preventDefault();
  11358. if ( !this._keySliding ) {
  11359. this._keySliding = true;
  11360. $( event.target ).addClass( "ui-state-active" );
  11361. allowed = this._start( event, index );
  11362. if ( allowed === false ) {
  11363. return;
  11364. }
  11365. }
  11366. break;
  11367. }
  11368. step = this.options.step;
  11369. if ( this.options.values && this.options.values.length ) {
  11370. curVal = newVal = this.values( index );
  11371. } else {
  11372. curVal = newVal = this.value();
  11373. }
  11374. switch ( event.keyCode ) {
  11375. case $.ui.keyCode.HOME:
  11376. newVal = this._valueMin();
  11377. break;
  11378. case $.ui.keyCode.END:
  11379. newVal = this._valueMax();
  11380. break;
  11381. case $.ui.keyCode.PAGE_UP:
  11382. newVal = this._trimAlignValue( curVal + ( (this._valueMax() - this._valueMin()) / numPages ) );
  11383. break;
  11384. case $.ui.keyCode.PAGE_DOWN:
  11385. newVal = this._trimAlignValue( curVal - ( (this._valueMax() - this._valueMin()) / numPages ) );
  11386. break;
  11387. case $.ui.keyCode.UP:
  11388. case $.ui.keyCode.RIGHT:
  11389. if ( curVal === this._valueMax() ) {
  11390. return;
  11391. }
  11392. newVal = this._trimAlignValue( curVal + step );
  11393. break;
  11394. case $.ui.keyCode.DOWN:
  11395. case $.ui.keyCode.LEFT:
  11396. if ( curVal === this._valueMin() ) {
  11397. return;
  11398. }
  11399. newVal = this._trimAlignValue( curVal - step );
  11400. break;
  11401. }
  11402. this._slide( event, index, newVal );
  11403. },
  11404. click: function( event ) {
  11405. event.preventDefault();
  11406. },
  11407. keyup: function( event ) {
  11408. var index = $( event.target ).data( "ui-slider-handle-index" );
  11409. if ( this._keySliding ) {
  11410. this._keySliding = false;
  11411. this._stop( event, index );
  11412. this._change( event, index );
  11413. $( event.target ).removeClass( "ui-state-active" );
  11414. }
  11415. }
  11416. }
  11417. });
  11418. }(jQuery));
  11419. (function( $ ) {
  11420. function modifier( fn ) {
  11421. return function() {
  11422. var previous = this.element.val();
  11423. fn.apply( this, arguments );
  11424. this._refresh();
  11425. if ( previous !== this.element.val() ) {
  11426. this._trigger( "change" );
  11427. }
  11428. };
  11429. }
  11430. $.widget( "ui.spinner", {
  11431. version: "1.10.3",
  11432. defaultElement: "<input>",
  11433. widgetEventPrefix: "spin",
  11434. options: {
  11435. culture: null,
  11436. icons: {
  11437. down: "ui-icon-triangle-1-s",
  11438. up: "ui-icon-triangle-1-n"
  11439. },
  11440. incremental: true,
  11441. max: null,
  11442. min: null,
  11443. numberFormat: null,
  11444. page: 10,
  11445. step: 1,
  11446. change: null,
  11447. spin: null,
  11448. start: null,
  11449. stop: null
  11450. },
  11451. _create: function() {
  11452. // handle string values that need to be parsed
  11453. this._setOption( "max", this.options.max );
  11454. this._setOption( "min", this.options.min );
  11455. this._setOption( "step", this.options.step );
  11456. // format the value, but don't constrain
  11457. this._value( this.element.val(), true );
  11458. this._draw();
  11459. this._on( this._events );
  11460. this._refresh();
  11461. // turning off autocomplete prevents the browser from remembering the
  11462. // value when navigating through history, so we re-enable autocomplete
  11463. // if the page is unloaded before the widget is destroyed. #7790
  11464. this._on( this.window, {
  11465. beforeunload: function() {
  11466. this.element.removeAttr( "autocomplete" );
  11467. }
  11468. });
  11469. },
  11470. _getCreateOptions: function() {
  11471. var options = {},
  11472. element = this.element;
  11473. $.each( [ "min", "max", "step" ], function( i, option ) {
  11474. var value = element.attr( option );
  11475. if ( value !== undefined && value.length ) {
  11476. options[ option ] = value;
  11477. }
  11478. });
  11479. return options;
  11480. },
  11481. _events: {
  11482. keydown: function( event ) {
  11483. if ( this._start( event ) && this._keydown( event ) ) {
  11484. event.preventDefault();
  11485. }
  11486. },
  11487. keyup: "_stop",
  11488. focus: function() {
  11489. this.previous = this.element.val();
  11490. },
  11491. blur: function( event ) {
  11492. if ( this.cancelBlur ) {
  11493. delete this.cancelBlur;
  11494. return;
  11495. }
  11496. this._stop();
  11497. this._refresh();
  11498. if ( this.previous !== this.element.val() ) {
  11499. this._trigger( "change", event );
  11500. }
  11501. },
  11502. mousewheel: function( event, delta ) {
  11503. if ( !delta ) {
  11504. return;
  11505. }
  11506. if ( !this.spinning && !this._start( event ) ) {
  11507. return false;
  11508. }
  11509. this._spin( (delta > 0 ? 1 : -1) * this.options.step, event );
  11510. clearTimeout( this.mousewheelTimer );
  11511. this.mousewheelTimer = this._delay(function() {
  11512. if ( this.spinning ) {
  11513. this._stop( event );
  11514. }
  11515. }, 100 );
  11516. event.preventDefault();
  11517. },
  11518. "mousedown .ui-spinner-button": function( event ) {
  11519. var previous;
  11520. // We never want the buttons to have focus; whenever the user is
  11521. // interacting with the spinner, the focus should be on the input.
  11522. // If the input is focused then this.previous is properly set from
  11523. // when the input first received focus. If the input is not focused
  11524. // then we need to set this.previous based on the value before spinning.
  11525. previous = this.element[0] === this.document[0].activeElement ?
  11526. this.previous : this.element.val();
  11527. function checkFocus() {
  11528. var isActive = this.element[0] === this.document[0].activeElement;
  11529. if ( !isActive ) {
  11530. this.element.focus();
  11531. this.previous = previous;
  11532. // support: IE
  11533. // IE sets focus asynchronously, so we need to check if focus
  11534. // moved off of the input because the user clicked on the button.
  11535. this._delay(function() {
  11536. this.previous = previous;
  11537. });
  11538. }
  11539. }
  11540. // ensure focus is on (or stays on) the text field
  11541. event.preventDefault();
  11542. checkFocus.call( this );
  11543. // support: IE
  11544. // IE doesn't prevent moving focus even with event.preventDefault()
  11545. // so we set a flag to know when we should ignore the blur event
  11546. // and check (again) if focus moved off of the input.
  11547. this.cancelBlur = true;
  11548. this._delay(function() {
  11549. delete this.cancelBlur;
  11550. checkFocus.call( this );
  11551. });
  11552. if ( this._start( event ) === false ) {
  11553. return;
  11554. }
  11555. this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  11556. },
  11557. "mouseup .ui-spinner-button": "_stop",
  11558. "mouseenter .ui-spinner-button": function( event ) {
  11559. // button will add ui-state-active if mouse was down while mouseleave and kept down
  11560. if ( !$( event.currentTarget ).hasClass( "ui-state-active" ) ) {
  11561. return;
  11562. }
  11563. if ( this._start( event ) === false ) {
  11564. return false;
  11565. }
  11566. this._repeat( null, $( event.currentTarget ).hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  11567. },
  11568. // TODO: do we really want to consider this a stop?
  11569. // shouldn't we just stop the repeater and wait until mouseup before
  11570. // we trigger the stop event?
  11571. "mouseleave .ui-spinner-button": "_stop"
  11572. },
  11573. _draw: function() {
  11574. var uiSpinner = this.uiSpinner = this.element
  11575. .addClass( "ui-spinner-input" )
  11576. .attr( "autocomplete", "off" )
  11577. .wrap( this._uiSpinnerHtml() )
  11578. .parent()
  11579. // add buttons
  11580. .append( this._buttonHtml() );
  11581. this.element.attr( "role", "spinbutton" );
  11582. // button bindings
  11583. this.buttons = uiSpinner.find( ".ui-spinner-button" )
  11584. .attr( "tabIndex", -1 )
  11585. .button()
  11586. .removeClass( "ui-corner-all" );
  11587. // IE 6 doesn't understand height: 50% for the buttons
  11588. // unless the wrapper has an explicit height
  11589. if ( this.buttons.height() > Math.ceil( uiSpinner.height() * 0.5 ) &&
  11590. uiSpinner.height() > 0 ) {
  11591. uiSpinner.height( uiSpinner.height() );
  11592. }
  11593. // disable spinner if element was already disabled
  11594. if ( this.options.disabled ) {
  11595. this.disable();
  11596. }
  11597. },
  11598. _keydown: function( event ) {
  11599. var options = this.options,
  11600. keyCode = $.ui.keyCode;
  11601. switch ( event.keyCode ) {
  11602. case keyCode.UP:
  11603. this._repeat( null, 1, event );
  11604. return true;
  11605. case keyCode.DOWN:
  11606. this._repeat( null, -1, event );
  11607. return true;
  11608. case keyCode.PAGE_UP:
  11609. this._repeat( null, options.page, event );
  11610. return true;
  11611. case keyCode.PAGE_DOWN:
  11612. this._repeat( null, -options.page, event );
  11613. return true;
  11614. }
  11615. return false;
  11616. },
  11617. _uiSpinnerHtml: function() {
  11618. return "<span class='ui-spinner ui-widget ui-widget-content ui-corner-all'></span>";
  11619. },
  11620. _buttonHtml: function() {
  11621. return "" +
  11622. "<a class='ui-spinner-button ui-spinner-up ui-corner-tr'>" +
  11623. "<span class='ui-icon " + this.options.icons.up + "'>&#9650;</span>" +
  11624. "</a>" +
  11625. "<a class='ui-spinner-button ui-spinner-down ui-corner-br'>" +
  11626. "<span class='ui-icon " + this.options.icons.down + "'>&#9660;</span>" +
  11627. "</a>";
  11628. },
  11629. _start: function( event ) {
  11630. if ( !this.spinning && this._trigger( "start", event ) === false ) {
  11631. return false;
  11632. }
  11633. if ( !this.counter ) {
  11634. this.counter = 1;
  11635. }
  11636. this.spinning = true;
  11637. return true;
  11638. },
  11639. _repeat: function( i, steps, event ) {
  11640. i = i || 500;
  11641. clearTimeout( this.timer );
  11642. this.timer = this._delay(function() {
  11643. this._repeat( 40, steps, event );
  11644. }, i );
  11645. this._spin( steps * this.options.step, event );
  11646. },
  11647. _spin: function( step, event ) {
  11648. var value = this.value() || 0;
  11649. if ( !this.counter ) {
  11650. this.counter = 1;
  11651. }
  11652. value = this._adjustValue( value + step * this._increment( this.counter ) );
  11653. if ( !this.spinning || this._trigger( "spin", event, { value: value } ) !== false) {
  11654. this._value( value );
  11655. this.counter++;
  11656. }
  11657. },
  11658. _increment: function( i ) {
  11659. var incremental = this.options.incremental;
  11660. if ( incremental ) {
  11661. return $.isFunction( incremental ) ?
  11662. incremental( i ) :
  11663. Math.floor( i*i*i/50000 - i*i/500 + 17*i/200 + 1 );
  11664. }
  11665. return 1;
  11666. },
  11667. _precision: function() {
  11668. var precision = this._precisionOf( this.options.step );
  11669. if ( this.options.min !== null ) {
  11670. precision = Math.max( precision, this._precisionOf( this.options.min ) );
  11671. }
  11672. return precision;
  11673. },
  11674. _precisionOf: function( num ) {
  11675. var str = num.toString(),
  11676. decimal = str.indexOf( "." );
  11677. return decimal === -1 ? 0 : str.length - decimal - 1;
  11678. },
  11679. _adjustValue: function( value ) {
  11680. var base, aboveMin,
  11681. options = this.options;
  11682. // make sure we're at a valid step
  11683. // - find out where we are relative to the base (min or 0)
  11684. base = options.min !== null ? options.min : 0;
  11685. aboveMin = value - base;
  11686. // - round to the nearest step
  11687. aboveMin = Math.round(aboveMin / options.step) * options.step;
  11688. // - rounding is based on 0, so adjust back to our base
  11689. value = base + aboveMin;
  11690. // fix precision from bad JS floating point math
  11691. value = parseFloat( value.toFixed( this._precision() ) );
  11692. // clamp the value
  11693. if ( options.max !== null && value > options.max) {
  11694. return options.max;
  11695. }
  11696. if ( options.min !== null && value < options.min ) {
  11697. return options.min;
  11698. }
  11699. return value;
  11700. },
  11701. _stop: function( event ) {
  11702. if ( !this.spinning ) {
  11703. return;
  11704. }
  11705. clearTimeout( this.timer );
  11706. clearTimeout( this.mousewheelTimer );
  11707. this.counter = 0;
  11708. this.spinning = false;
  11709. this._trigger( "stop", event );
  11710. },
  11711. _setOption: function( key, value ) {
  11712. if ( key === "culture" || key === "numberFormat" ) {
  11713. var prevValue = this._parse( this.element.val() );
  11714. this.options[ key ] = value;
  11715. this.element.val( this._format( prevValue ) );
  11716. return;
  11717. }
  11718. if ( key === "max" || key === "min" || key === "step" ) {
  11719. if ( typeof value === "string" ) {
  11720. value = this._parse( value );
  11721. }
  11722. }
  11723. if ( key === "icons" ) {
  11724. this.buttons.first().find( ".ui-icon" )
  11725. .removeClass( this.options.icons.up )
  11726. .addClass( value.up );
  11727. this.buttons.last().find( ".ui-icon" )
  11728. .removeClass( this.options.icons.down )
  11729. .addClass( value.down );
  11730. }
  11731. this._super( key, value );
  11732. if ( key === "disabled" ) {
  11733. if ( value ) {
  11734. this.element.prop( "disabled", true );
  11735. this.buttons.button( "disable" );
  11736. } else {
  11737. this.element.prop( "disabled", false );
  11738. this.buttons.button( "enable" );
  11739. }
  11740. }
  11741. },
  11742. _setOptions: modifier(function( options ) {
  11743. this._super( options );
  11744. this._value( this.element.val() );
  11745. }),
  11746. _parse: function( val ) {
  11747. if ( typeof val === "string" && val !== "" ) {
  11748. val = window.Globalize && this.options.numberFormat ?
  11749. Globalize.parseFloat( val, 10, this.options.culture ) : +val;
  11750. }
  11751. return val === "" || isNaN( val ) ? null : val;
  11752. },
  11753. _format: function( value ) {
  11754. if ( value === "" ) {
  11755. return "";
  11756. }
  11757. return window.Globalize && this.options.numberFormat ?
  11758. Globalize.format( value, this.options.numberFormat, this.options.culture ) :
  11759. value;
  11760. },
  11761. _refresh: function() {
  11762. this.element.attr({
  11763. "aria-valuemin": this.options.min,
  11764. "aria-valuemax": this.options.max,
  11765. // TODO: what should we do with values that can't be parsed?
  11766. "aria-valuenow": this._parse( this.element.val() )
  11767. });
  11768. },
  11769. // update the value without triggering change
  11770. _value: function( value, allowAny ) {
  11771. var parsed;
  11772. if ( value !== "" ) {
  11773. parsed = this._parse( value );
  11774. if ( parsed !== null ) {
  11775. if ( !allowAny ) {
  11776. parsed = this._adjustValue( parsed );
  11777. }
  11778. value = this._format( parsed );
  11779. }
  11780. }
  11781. this.element.val( value );
  11782. this._refresh();
  11783. },
  11784. _destroy: function() {
  11785. this.element
  11786. .removeClass( "ui-spinner-input" )
  11787. .prop( "disabled", false )
  11788. .removeAttr( "autocomplete" )
  11789. .removeAttr( "role" )
  11790. .removeAttr( "aria-valuemin" )
  11791. .removeAttr( "aria-valuemax" )
  11792. .removeAttr( "aria-valuenow" );
  11793. this.uiSpinner.replaceWith( this.element );
  11794. },
  11795. stepUp: modifier(function( steps ) {
  11796. this._stepUp( steps );
  11797. }),
  11798. _stepUp: function( steps ) {
  11799. if ( this._start() ) {
  11800. this._spin( (steps || 1) * this.options.step );
  11801. this._stop();
  11802. }
  11803. },
  11804. stepDown: modifier(function( steps ) {
  11805. this._stepDown( steps );
  11806. }),
  11807. _stepDown: function( steps ) {
  11808. if ( this._start() ) {
  11809. this._spin( (steps || 1) * -this.options.step );
  11810. this._stop();
  11811. }
  11812. },
  11813. pageUp: modifier(function( pages ) {
  11814. this._stepUp( (pages || 1) * this.options.page );
  11815. }),
  11816. pageDown: modifier(function( pages ) {
  11817. this._stepDown( (pages || 1) * this.options.page );
  11818. }),
  11819. value: function( newVal ) {
  11820. if ( !arguments.length ) {
  11821. return this._parse( this.element.val() );
  11822. }
  11823. modifier( this._value ).call( this, newVal );
  11824. },
  11825. widget: function() {
  11826. return this.uiSpinner;
  11827. }
  11828. });
  11829. }( jQuery ) );
  11830. (function( $, undefined ) {
  11831. var tabId = 0,
  11832. rhash = /#.*$/;
  11833. function getNextTabId() {
  11834. return ++tabId;
  11835. }
  11836. function isLocal( anchor ) {
  11837. return anchor.hash.length > 1 &&
  11838. decodeURIComponent( anchor.href.replace( rhash, "" ) ) ===
  11839. decodeURIComponent( location.href.replace( rhash, "" ) );
  11840. }
  11841. $.widget( "ui.tabs", {
  11842. version: "1.10.3",
  11843. delay: 300,
  11844. options: {
  11845. active: null,
  11846. collapsible: false,
  11847. event: "click",
  11848. heightStyle: "content",
  11849. hide: null,
  11850. show: null,
  11851. // callbacks
  11852. activate: null,
  11853. beforeActivate: null,
  11854. beforeLoad: null,
  11855. load: null
  11856. },
  11857. _create: function() {
  11858. var that = this,
  11859. options = this.options;
  11860. this.running = false;
  11861. this.element
  11862. .addClass( "ui-tabs ui-widget ui-widget-content ui-corner-all" )
  11863. .toggleClass( "ui-tabs-collapsible", options.collapsible )
  11864. // Prevent users from focusing disabled tabs via click
  11865. .delegate( ".ui-tabs-nav > li", "mousedown" + this.eventNamespace, function( event ) {
  11866. if ( $( this ).is( ".ui-state-disabled" ) ) {
  11867. event.preventDefault();
  11868. }
  11869. })
  11870. // support: IE <9
  11871. // Preventing the default action in mousedown doesn't prevent IE
  11872. // from focusing the element, so if the anchor gets focused, blur.
  11873. // We don't have to worry about focusing the previously focused
  11874. // element since clicking on a non-focusable element should focus
  11875. // the body anyway.
  11876. .delegate( ".ui-tabs-anchor", "focus" + this.eventNamespace, function() {
  11877. if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) {
  11878. this.blur();
  11879. }
  11880. });
  11881. this._processTabs();
  11882. options.active = this._initialActive();
  11883. // Take disabling tabs via class attribute from HTML
  11884. // into account and update option properly.
  11885. if ( $.isArray( options.disabled ) ) {
  11886. options.disabled = $.unique( options.disabled.concat(
  11887. $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
  11888. return that.tabs.index( li );
  11889. })
  11890. ) ).sort();
  11891. }
  11892. // check for length avoids error when initializing empty list
  11893. if ( this.options.active !== false && this.anchors.length ) {
  11894. this.active = this._findActive( options.active );
  11895. } else {
  11896. this.active = $();
  11897. }
  11898. this._refresh();
  11899. if ( this.active.length ) {
  11900. this.load( options.active );
  11901. }
  11902. },
  11903. _initialActive: function() {
  11904. var active = this.options.active,
  11905. collapsible = this.options.collapsible,
  11906. locationHash = location.hash.substring( 1 );
  11907. if ( active === null ) {
  11908. // check the fragment identifier in the URL
  11909. if ( locationHash ) {
  11910. this.tabs.each(function( i, tab ) {
  11911. if ( $( tab ).attr( "aria-controls" ) === locationHash ) {
  11912. active = i;
  11913. return false;
  11914. }
  11915. });
  11916. }
  11917. // check for a tab marked active via a class
  11918. if ( active === null ) {
  11919. active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) );
  11920. }
  11921. // no active tab, set to false
  11922. if ( active === null || active === -1 ) {
  11923. active = this.tabs.length ? 0 : false;
  11924. }
  11925. }
  11926. // handle numbers: negative, out of range
  11927. if ( active !== false ) {
  11928. active = this.tabs.index( this.tabs.eq( active ) );
  11929. if ( active === -1 ) {
  11930. active = collapsible ? false : 0;
  11931. }
  11932. }
  11933. // don't allow collapsible: false and active: false
  11934. if ( !collapsible && active === false && this.anchors.length ) {
  11935. active = 0;
  11936. }
  11937. return active;
  11938. },
  11939. _getCreateEventData: function() {
  11940. return {
  11941. tab: this.active,
  11942. panel: !this.active.length ? $() : this._getPanelForTab( this.active )
  11943. };
  11944. },
  11945. _tabKeydown: function( event ) {
  11946. /*jshint maxcomplexity:15*/
  11947. var focusedTab = $( this.document[0].activeElement ).closest( "li" ),
  11948. selectedIndex = this.tabs.index( focusedTab ),
  11949. goingForward = true;
  11950. if ( this._handlePageNav( event ) ) {
  11951. return;
  11952. }
  11953. switch ( event.keyCode ) {
  11954. case $.ui.keyCode.RIGHT:
  11955. case $.ui.keyCode.DOWN:
  11956. selectedIndex++;
  11957. break;
  11958. case $.ui.keyCode.UP:
  11959. case $.ui.keyCode.LEFT:
  11960. goingForward = false;
  11961. selectedIndex--;
  11962. break;
  11963. case $.ui.keyCode.END:
  11964. selectedIndex = this.anchors.length - 1;
  11965. break;
  11966. case $.ui.keyCode.HOME:
  11967. selectedIndex = 0;
  11968. break;
  11969. case $.ui.keyCode.SPACE:
  11970. // Activate only, no collapsing
  11971. event.preventDefault();
  11972. clearTimeout( this.activating );
  11973. this._activate( selectedIndex );
  11974. return;
  11975. case $.ui.keyCode.ENTER:
  11976. // Toggle (cancel delayed activation, allow collapsing)
  11977. event.preventDefault();
  11978. clearTimeout( this.activating );
  11979. // Determine if we should collapse or activate
  11980. this._activate( selectedIndex === this.options.active ? false : selectedIndex );
  11981. return;
  11982. default:
  11983. return;
  11984. }
  11985. // Focus the appropriate tab, based on which key was pressed
  11986. event.preventDefault();
  11987. clearTimeout( this.activating );
  11988. selectedIndex = this._focusNextTab( selectedIndex, goingForward );
  11989. // Navigating with control key will prevent automatic activation
  11990. if ( !event.ctrlKey ) {
  11991. // Update aria-selected immediately so that AT think the tab is already selected.
  11992. // Otherwise AT may confuse the user by stating that they need to activate the tab,
  11993. // but the tab will already be activated by the time the announcement finishes.
  11994. focusedTab.attr( "aria-selected", "false" );
  11995. this.tabs.eq( selectedIndex ).attr( "aria-selected", "true" );
  11996. this.activating = this._delay(function() {
  11997. this.option( "active", selectedIndex );
  11998. }, this.delay );
  11999. }
  12000. },
  12001. _panelKeydown: function( event ) {
  12002. if ( this._handlePageNav( event ) ) {
  12003. return;
  12004. }
  12005. // Ctrl+up moves focus to the current tab
  12006. if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) {
  12007. event.preventDefault();
  12008. this.active.focus();
  12009. }
  12010. },
  12011. // Alt+page up/down moves focus to the previous/next tab (and activates)
  12012. _handlePageNav: function( event ) {
  12013. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP ) {
  12014. this._activate( this._focusNextTab( this.options.active - 1, false ) );
  12015. return true;
  12016. }
  12017. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN ) {
  12018. this._activate( this._focusNextTab( this.options.active + 1, true ) );
  12019. return true;
  12020. }
  12021. },
  12022. _findNextTab: function( index, goingForward ) {
  12023. var lastTabIndex = this.tabs.length - 1;
  12024. function constrain() {
  12025. if ( index > lastTabIndex ) {
  12026. index = 0;
  12027. }
  12028. if ( index < 0 ) {
  12029. index = lastTabIndex;
  12030. }
  12031. return index;
  12032. }
  12033. while ( $.inArray( constrain(), this.options.disabled ) !== -1 ) {
  12034. index = goingForward ? index + 1 : index - 1;
  12035. }
  12036. return index;
  12037. },
  12038. _focusNextTab: function( index, goingForward ) {
  12039. index = this._findNextTab( index, goingForward );
  12040. this.tabs.eq( index ).focus();
  12041. return index;
  12042. },
  12043. _setOption: function( key, value ) {
  12044. if ( key === "active" ) {
  12045. // _activate() will handle invalid values and update this.options
  12046. this._activate( value );
  12047. return;
  12048. }
  12049. if ( key === "disabled" ) {
  12050. // don't use the widget factory's disabled handling
  12051. this._setupDisabled( value );
  12052. return;
  12053. }
  12054. this._super( key, value);
  12055. if ( key === "collapsible" ) {
  12056. this.element.toggleClass( "ui-tabs-collapsible", value );
  12057. // Setting collapsible: false while collapsed; open first panel
  12058. if ( !value && this.options.active === false ) {
  12059. this._activate( 0 );
  12060. }
  12061. }
  12062. if ( key === "event" ) {
  12063. this._setupEvents( value );
  12064. }
  12065. if ( key === "heightStyle" ) {
  12066. this._setupHeightStyle( value );
  12067. }
  12068. },
  12069. _tabId: function( tab ) {
  12070. return tab.attr( "aria-controls" ) || "ui-tabs-" + getNextTabId();
  12071. },
  12072. _sanitizeSelector: function( hash ) {
  12073. return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
  12074. },
  12075. refresh: function() {
  12076. var options = this.options,
  12077. lis = this.tablist.children( ":has(a[href])" );
  12078. // get disabled tabs from class attribute from HTML
  12079. // this will get converted to a boolean if needed in _refresh()
  12080. options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) {
  12081. return lis.index( tab );
  12082. });
  12083. this._processTabs();
  12084. // was collapsed or no tabs
  12085. if ( options.active === false || !this.anchors.length ) {
  12086. options.active = false;
  12087. this.active = $();
  12088. // was active, but active tab is gone
  12089. } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) {
  12090. // all remaining tabs are disabled
  12091. if ( this.tabs.length === options.disabled.length ) {
  12092. options.active = false;
  12093. this.active = $();
  12094. // activate previous tab
  12095. } else {
  12096. this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) );
  12097. }
  12098. // was active, active tab still exists
  12099. } else {
  12100. // make sure active index is correct
  12101. options.active = this.tabs.index( this.active );
  12102. }
  12103. this._refresh();
  12104. },
  12105. _refresh: function() {
  12106. this._setupDisabled( this.options.disabled );
  12107. this._setupEvents( this.options.event );
  12108. this._setupHeightStyle( this.options.heightStyle );
  12109. this.tabs.not( this.active ).attr({
  12110. "aria-selected": "false",
  12111. tabIndex: -1
  12112. });
  12113. this.panels.not( this._getPanelForTab( this.active ) )
  12114. .hide()
  12115. .attr({
  12116. "aria-expanded": "false",
  12117. "aria-hidden": "true"
  12118. });
  12119. // Make sure one tab is in the tab order
  12120. if ( !this.active.length ) {
  12121. this.tabs.eq( 0 ).attr( "tabIndex", 0 );
  12122. } else {
  12123. this.active
  12124. .addClass( "ui-tabs-active ui-state-active" )
  12125. .attr({
  12126. "aria-selected": "true",
  12127. tabIndex: 0
  12128. });
  12129. this._getPanelForTab( this.active )
  12130. .show()
  12131. .attr({
  12132. "aria-expanded": "true",
  12133. "aria-hidden": "false"
  12134. });
  12135. }
  12136. },
  12137. _processTabs: function() {
  12138. var that = this;
  12139. this.tablist = this._getList()
  12140. .addClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  12141. .attr( "role", "tablist" );
  12142. this.tabs = this.tablist.find( "> li:has(a[href])" )
  12143. .addClass( "ui-state-default ui-corner-top" )
  12144. .attr({
  12145. role: "tab",
  12146. tabIndex: -1
  12147. });
  12148. this.anchors = this.tabs.map(function() {
  12149. return $( "a", this )[ 0 ];
  12150. })
  12151. .addClass( "ui-tabs-anchor" )
  12152. .attr({
  12153. role: "presentation",
  12154. tabIndex: -1
  12155. });
  12156. this.panels = $();
  12157. this.anchors.each(function( i, anchor ) {
  12158. var selector, panel, panelId,
  12159. anchorId = $( anchor ).uniqueId().attr( "id" ),
  12160. tab = $( anchor ).closest( "li" ),
  12161. originalAriaControls = tab.attr( "aria-controls" );
  12162. // inline tab
  12163. if ( isLocal( anchor ) ) {
  12164. selector = anchor.hash;
  12165. panel = that.element.find( that._sanitizeSelector( selector ) );
  12166. // remote tab
  12167. } else {
  12168. panelId = that._tabId( tab );
  12169. selector = "#" + panelId;
  12170. panel = that.element.find( selector );
  12171. if ( !panel.length ) {
  12172. panel = that._createPanel( panelId );
  12173. panel.insertAfter( that.panels[ i - 1 ] || that.tablist );
  12174. }
  12175. panel.attr( "aria-live", "polite" );
  12176. }
  12177. if ( panel.length) {
  12178. that.panels = that.panels.add( panel );
  12179. }
  12180. if ( originalAriaControls ) {
  12181. tab.data( "ui-tabs-aria-controls", originalAriaControls );
  12182. }
  12183. tab.attr({
  12184. "aria-controls": selector.substring( 1 ),
  12185. "aria-labelledby": anchorId
  12186. });
  12187. panel.attr( "aria-labelledby", anchorId );
  12188. });
  12189. this.panels
  12190. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  12191. .attr( "role", "tabpanel" );
  12192. },
  12193. // allow overriding how to find the list for rare usage scenarios (#7715)
  12194. _getList: function() {
  12195. return this.element.find( "ol,ul" ).eq( 0 );
  12196. },
  12197. _createPanel: function( id ) {
  12198. return $( "<div>" )
  12199. .attr( "id", id )
  12200. .addClass( "ui-tabs-panel ui-widget-content ui-corner-bottom" )
  12201. .data( "ui-tabs-destroy", true );
  12202. },
  12203. _setupDisabled: function( disabled ) {
  12204. if ( $.isArray( disabled ) ) {
  12205. if ( !disabled.length ) {
  12206. disabled = false;
  12207. } else if ( disabled.length === this.anchors.length ) {
  12208. disabled = true;
  12209. }
  12210. }
  12211. // disable tabs
  12212. for ( var i = 0, li; ( li = this.tabs[ i ] ); i++ ) {
  12213. if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
  12214. $( li )
  12215. .addClass( "ui-state-disabled" )
  12216. .attr( "aria-disabled", "true" );
  12217. } else {
  12218. $( li )
  12219. .removeClass( "ui-state-disabled" )
  12220. .removeAttr( "aria-disabled" );
  12221. }
  12222. }
  12223. this.options.disabled = disabled;
  12224. },
  12225. _setupEvents: function( event ) {
  12226. var events = {
  12227. click: function( event ) {
  12228. event.preventDefault();
  12229. }
  12230. };
  12231. if ( event ) {
  12232. $.each( event.split(" "), function( index, eventName ) {
  12233. events[ eventName ] = "_eventHandler";
  12234. });
  12235. }
  12236. this._off( this.anchors.add( this.tabs ).add( this.panels ) );
  12237. this._on( this.anchors, events );
  12238. this._on( this.tabs, { keydown: "_tabKeydown" } );
  12239. this._on( this.panels, { keydown: "_panelKeydown" } );
  12240. this._focusable( this.tabs );
  12241. this._hoverable( this.tabs );
  12242. },
  12243. _setupHeightStyle: function( heightStyle ) {
  12244. var maxHeight,
  12245. parent = this.element.parent();
  12246. if ( heightStyle === "fill" ) {
  12247. maxHeight = parent.height();
  12248. maxHeight -= this.element.outerHeight() - this.element.height();
  12249. this.element.siblings( ":visible" ).each(function() {
  12250. var elem = $( this ),
  12251. position = elem.css( "position" );
  12252. if ( position === "absolute" || position === "fixed" ) {
  12253. return;
  12254. }
  12255. maxHeight -= elem.outerHeight( true );
  12256. });
  12257. this.element.children().not( this.panels ).each(function() {
  12258. maxHeight -= $( this ).outerHeight( true );
  12259. });
  12260. this.panels.each(function() {
  12261. $( this ).height( Math.max( 0, maxHeight -
  12262. $( this ).innerHeight() + $( this ).height() ) );
  12263. })
  12264. .css( "overflow", "auto" );
  12265. } else if ( heightStyle === "auto" ) {
  12266. maxHeight = 0;
  12267. this.panels.each(function() {
  12268. maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
  12269. }).height( maxHeight );
  12270. }
  12271. },
  12272. _eventHandler: function( event ) {
  12273. var options = this.options,
  12274. active = this.active,
  12275. anchor = $( event.currentTarget ),
  12276. tab = anchor.closest( "li" ),
  12277. clickedIsActive = tab[ 0 ] === active[ 0 ],
  12278. collapsing = clickedIsActive && options.collapsible,
  12279. toShow = collapsing ? $() : this._getPanelForTab( tab ),
  12280. toHide = !active.length ? $() : this._getPanelForTab( active ),
  12281. eventData = {
  12282. oldTab: active,
  12283. oldPanel: toHide,
  12284. newTab: collapsing ? $() : tab,
  12285. newPanel: toShow
  12286. };
  12287. event.preventDefault();
  12288. if ( tab.hasClass( "ui-state-disabled" ) ||
  12289. // tab is already loading
  12290. tab.hasClass( "ui-tabs-loading" ) ||
  12291. // can't switch durning an animation
  12292. this.running ||
  12293. // click on active header, but not collapsible
  12294. ( clickedIsActive && !options.collapsible ) ||
  12295. // allow canceling activation
  12296. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  12297. return;
  12298. }
  12299. options.active = collapsing ? false : this.tabs.index( tab );
  12300. this.active = clickedIsActive ? $() : tab;
  12301. if ( this.xhr ) {
  12302. this.xhr.abort();
  12303. }
  12304. if ( !toHide.length && !toShow.length ) {
  12305. $.error( "jQuery UI Tabs: Mismatching fragment identifier." );
  12306. }
  12307. if ( toShow.length ) {
  12308. this.load( this.tabs.index( tab ), event );
  12309. }
  12310. this._toggle( event, eventData );
  12311. },
  12312. // handles show/hide for selecting tabs
  12313. _toggle: function( event, eventData ) {
  12314. var that = this,
  12315. toShow = eventData.newPanel,
  12316. toHide = eventData.oldPanel;
  12317. this.running = true;
  12318. function complete() {
  12319. that.running = false;
  12320. that._trigger( "activate", event, eventData );
  12321. }
  12322. function show() {
  12323. eventData.newTab.closest( "li" ).addClass( "ui-tabs-active ui-state-active" );
  12324. if ( toShow.length && that.options.show ) {
  12325. that._show( toShow, that.options.show, complete );
  12326. } else {
  12327. toShow.show();
  12328. complete();
  12329. }
  12330. }
  12331. // start out by hiding, then showing, then completing
  12332. if ( toHide.length && this.options.hide ) {
  12333. this._hide( toHide, this.options.hide, function() {
  12334. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  12335. show();
  12336. });
  12337. } else {
  12338. eventData.oldTab.closest( "li" ).removeClass( "ui-tabs-active ui-state-active" );
  12339. toHide.hide();
  12340. show();
  12341. }
  12342. toHide.attr({
  12343. "aria-expanded": "false",
  12344. "aria-hidden": "true"
  12345. });
  12346. eventData.oldTab.attr( "aria-selected", "false" );
  12347. // If we're switching tabs, remove the old tab from the tab order.
  12348. // If we're opening from collapsed state, remove the previous tab from the tab order.
  12349. // If we're collapsing, then keep the collapsing tab in the tab order.
  12350. if ( toShow.length && toHide.length ) {
  12351. eventData.oldTab.attr( "tabIndex", -1 );
  12352. } else if ( toShow.length ) {
  12353. this.tabs.filter(function() {
  12354. return $( this ).attr( "tabIndex" ) === 0;
  12355. })
  12356. .attr( "tabIndex", -1 );
  12357. }
  12358. toShow.attr({
  12359. "aria-expanded": "true",
  12360. "aria-hidden": "false"
  12361. });
  12362. eventData.newTab.attr({
  12363. "aria-selected": "true",
  12364. tabIndex: 0
  12365. });
  12366. },
  12367. _activate: function( index ) {
  12368. var anchor,
  12369. active = this._findActive( index );
  12370. // trying to activate the already active panel
  12371. if ( active[ 0 ] === this.active[ 0 ] ) {
  12372. return;
  12373. }
  12374. // trying to collapse, simulate a click on the current active header
  12375. if ( !active.length ) {
  12376. active = this.active;
  12377. }
  12378. anchor = active.find( ".ui-tabs-anchor" )[ 0 ];
  12379. this._eventHandler({
  12380. target: anchor,
  12381. currentTarget: anchor,
  12382. preventDefault: $.noop
  12383. });
  12384. },
  12385. _findActive: function( index ) {
  12386. return index === false ? $() : this.tabs.eq( index );
  12387. },
  12388. _getIndex: function( index ) {
  12389. // meta-function to give users option to provide a href string instead of a numerical index.
  12390. if ( typeof index === "string" ) {
  12391. index = this.anchors.index( this.anchors.filter( "[href$='" + index + "']" ) );
  12392. }
  12393. return index;
  12394. },
  12395. _destroy: function() {
  12396. if ( this.xhr ) {
  12397. this.xhr.abort();
  12398. }
  12399. this.element.removeClass( "ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible" );
  12400. this.tablist
  12401. .removeClass( "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" )
  12402. .removeAttr( "role" );
  12403. this.anchors
  12404. .removeClass( "ui-tabs-anchor" )
  12405. .removeAttr( "role" )
  12406. .removeAttr( "tabIndex" )
  12407. .removeUniqueId();
  12408. this.tabs.add( this.panels ).each(function() {
  12409. if ( $.data( this, "ui-tabs-destroy" ) ) {
  12410. $( this ).remove();
  12411. } else {
  12412. $( this )
  12413. .removeClass( "ui-state-default ui-state-active ui-state-disabled " +
  12414. "ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel" )
  12415. .removeAttr( "tabIndex" )
  12416. .removeAttr( "aria-live" )
  12417. .removeAttr( "aria-busy" )
  12418. .removeAttr( "aria-selected" )
  12419. .removeAttr( "aria-labelledby" )
  12420. .removeAttr( "aria-hidden" )
  12421. .removeAttr( "aria-expanded" )
  12422. .removeAttr( "role" );
  12423. }
  12424. });
  12425. this.tabs.each(function() {
  12426. var li = $( this ),
  12427. prev = li.data( "ui-tabs-aria-controls" );
  12428. if ( prev ) {
  12429. li
  12430. .attr( "aria-controls", prev )
  12431. .removeData( "ui-tabs-aria-controls" );
  12432. } else {
  12433. li.removeAttr( "aria-controls" );
  12434. }
  12435. });
  12436. this.panels.show();
  12437. if ( this.options.heightStyle !== "content" ) {
  12438. this.panels.css( "height", "" );
  12439. }
  12440. },
  12441. enable: function( index ) {
  12442. var disabled = this.options.disabled;
  12443. if ( disabled === false ) {
  12444. return;
  12445. }
  12446. if ( index === undefined ) {
  12447. disabled = false;
  12448. } else {
  12449. index = this._getIndex( index );
  12450. if ( $.isArray( disabled ) ) {
  12451. disabled = $.map( disabled, function( num ) {
  12452. return num !== index ? num : null;
  12453. });
  12454. } else {
  12455. disabled = $.map( this.tabs, function( li, num ) {
  12456. return num !== index ? num : null;
  12457. });
  12458. }
  12459. }
  12460. this._setupDisabled( disabled );
  12461. },
  12462. disable: function( index ) {
  12463. var disabled = this.options.disabled;
  12464. if ( disabled === true ) {
  12465. return;
  12466. }
  12467. if ( index === undefined ) {
  12468. disabled = true;
  12469. } else {
  12470. index = this._getIndex( index );
  12471. if ( $.inArray( index, disabled ) !== -1 ) {
  12472. return;
  12473. }
  12474. if ( $.isArray( disabled ) ) {
  12475. disabled = $.merge( [ index ], disabled ).sort();
  12476. } else {
  12477. disabled = [ index ];
  12478. }
  12479. }
  12480. this._setupDisabled( disabled );
  12481. },
  12482. load: function( index, event ) {
  12483. index = this._getIndex( index );
  12484. var that = this,
  12485. tab = this.tabs.eq( index ),
  12486. anchor = tab.find( ".ui-tabs-anchor" ),
  12487. panel = this._getPanelForTab( tab ),
  12488. eventData = {
  12489. tab: tab,
  12490. panel: panel
  12491. };
  12492. // not remote
  12493. if ( isLocal( anchor[ 0 ] ) ) {
  12494. return;
  12495. }
  12496. this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
  12497. // support: jQuery <1.8
  12498. // jQuery <1.8 returns false if the request is canceled in beforeSend,
  12499. // but as of 1.8, $.ajax() always returns a jqXHR object.
  12500. if ( this.xhr && this.xhr.statusText !== "canceled" ) {
  12501. tab.addClass( "ui-tabs-loading" );
  12502. panel.attr( "aria-busy", "true" );
  12503. this.xhr
  12504. .success(function( response ) {
  12505. // support: jQuery <1.8
  12506. // http://bugs.jquery.com/ticket/11778
  12507. setTimeout(function() {
  12508. panel.html( response );
  12509. that._trigger( "load", event, eventData );
  12510. }, 1 );
  12511. })
  12512. .complete(function( jqXHR, status ) {
  12513. // support: jQuery <1.8
  12514. // http://bugs.jquery.com/ticket/11778
  12515. setTimeout(function() {
  12516. if ( status === "abort" ) {
  12517. that.panels.stop( false, true );
  12518. }
  12519. tab.removeClass( "ui-tabs-loading" );
  12520. panel.removeAttr( "aria-busy" );
  12521. if ( jqXHR === that.xhr ) {
  12522. delete that.xhr;
  12523. }
  12524. }, 1 );
  12525. });
  12526. }
  12527. },
  12528. _ajaxSettings: function( anchor, event, eventData ) {
  12529. var that = this;
  12530. return {
  12531. url: anchor.attr( "href" ),
  12532. beforeSend: function( jqXHR, settings ) {
  12533. return that._trigger( "beforeLoad", event,
  12534. $.extend( { jqXHR : jqXHR, ajaxSettings: settings }, eventData ) );
  12535. }
  12536. };
  12537. },
  12538. _getPanelForTab: function( tab ) {
  12539. var id = $( tab ).attr( "aria-controls" );
  12540. return this.element.find( this._sanitizeSelector( "#" + id ) );
  12541. }
  12542. });
  12543. })( jQuery );
  12544. (function( $ ) {
  12545. var increments = 0;
  12546. function addDescribedBy( elem, id ) {
  12547. var describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ );
  12548. describedby.push( id );
  12549. elem
  12550. .data( "ui-tooltip-id", id )
  12551. .attr( "aria-describedby", $.trim( describedby.join( " " ) ) );
  12552. }
  12553. function removeDescribedBy( elem ) {
  12554. var id = elem.data( "ui-tooltip-id" ),
  12555. describedby = (elem.attr( "aria-describedby" ) || "").split( /\s+/ ),
  12556. index = $.inArray( id, describedby );
  12557. if ( index !== -1 ) {
  12558. describedby.splice( index, 1 );
  12559. }
  12560. elem.removeData( "ui-tooltip-id" );
  12561. describedby = $.trim( describedby.join( " " ) );
  12562. if ( describedby ) {
  12563. elem.attr( "aria-describedby", describedby );
  12564. } else {
  12565. elem.removeAttr( "aria-describedby" );
  12566. }
  12567. }
  12568. $.widget( "ui.tooltip", {
  12569. version: "1.10.3",
  12570. options: {
  12571. content: function() {
  12572. // support: IE<9, Opera in jQuery <1.7
  12573. // .text() can't accept undefined, so coerce to a string
  12574. var title = $( this ).attr( "title" ) || "";
  12575. // Escape title, since we're going from an attribute to raw HTML
  12576. return $( "<a>" ).text( title ).html();
  12577. },
  12578. hide: true,
  12579. // Disabled elements have inconsistent behavior across browsers (#8661)
  12580. items: "[title]:not([disabled])",
  12581. position: {
  12582. my: "left top+15",
  12583. at: "left bottom",
  12584. collision: "flipfit flip"
  12585. },
  12586. show: true,
  12587. tooltipClass: null,
  12588. track: false,
  12589. // callbacks
  12590. close: null,
  12591. open: null
  12592. },
  12593. _create: function() {
  12594. this._on({
  12595. mouseover: "open",
  12596. focusin: "open"
  12597. });
  12598. // IDs of generated tooltips, needed for destroy
  12599. this.tooltips = {};
  12600. // IDs of parent tooltips where we removed the title attribute
  12601. this.parents = {};
  12602. if ( this.options.disabled ) {
  12603. this._disable();
  12604. }
  12605. },
  12606. _setOption: function( key, value ) {
  12607. var that = this;
  12608. if ( key === "disabled" ) {
  12609. this[ value ? "_disable" : "_enable" ]();
  12610. this.options[ key ] = value;
  12611. // disable element style changes
  12612. return;
  12613. }
  12614. this._super( key, value );
  12615. if ( key === "content" ) {
  12616. $.each( this.tooltips, function( id, element ) {
  12617. that._updateContent( element );
  12618. });
  12619. }
  12620. },
  12621. _disable: function() {
  12622. var that = this;
  12623. // close open tooltips
  12624. $.each( this.tooltips, function( id, element ) {
  12625. var event = $.Event( "blur" );
  12626. event.target = event.currentTarget = element[0];
  12627. that.close( event, true );
  12628. });
  12629. // remove title attributes to prevent native tooltips
  12630. this.element.find( this.options.items ).addBack().each(function() {
  12631. var element = $( this );
  12632. if ( element.is( "[title]" ) ) {
  12633. element
  12634. .data( "ui-tooltip-title", element.attr( "title" ) )
  12635. .attr( "title", "" );
  12636. }
  12637. });
  12638. },
  12639. _enable: function() {
  12640. // restore title attributes
  12641. this.element.find( this.options.items ).addBack().each(function() {
  12642. var element = $( this );
  12643. if ( element.data( "ui-tooltip-title" ) ) {
  12644. element.attr( "title", element.data( "ui-tooltip-title" ) );
  12645. }
  12646. });
  12647. },
  12648. open: function( event ) {
  12649. var that = this,
  12650. target = $( event ? event.target : this.element )
  12651. // we need closest here due to mouseover bubbling,
  12652. // but always pointing at the same event target
  12653. .closest( this.options.items );
  12654. // No element to show a tooltip for or the tooltip is already open
  12655. if ( !target.length || target.data( "ui-tooltip-id" ) ) {
  12656. return;
  12657. }
  12658. if ( target.attr( "title" ) ) {
  12659. target.data( "ui-tooltip-title", target.attr( "title" ) );
  12660. }
  12661. target.data( "ui-tooltip-open", true );
  12662. // kill parent tooltips, custom or native, for hover
  12663. if ( event && event.type === "mouseover" ) {
  12664. target.parents().each(function() {
  12665. var parent = $( this ),
  12666. blurEvent;
  12667. if ( parent.data( "ui-tooltip-open" ) ) {
  12668. blurEvent = $.Event( "blur" );
  12669. blurEvent.target = blurEvent.currentTarget = this;
  12670. that.close( blurEvent, true );
  12671. }
  12672. if ( parent.attr( "title" ) ) {
  12673. parent.uniqueId();
  12674. that.parents[ this.id ] = {
  12675. element: this,
  12676. title: parent.attr( "title" )
  12677. };
  12678. parent.attr( "title", "" );
  12679. }
  12680. });
  12681. }
  12682. this._updateContent( target, event );
  12683. },
  12684. _updateContent: function( target, event ) {
  12685. var content,
  12686. contentOption = this.options.content,
  12687. that = this,
  12688. eventType = event ? event.type : null;
  12689. if ( typeof contentOption === "string" ) {
  12690. return this._open( event, target, contentOption );
  12691. }
  12692. content = contentOption.call( target[0], function( response ) {
  12693. // ignore async response if tooltip was closed already
  12694. if ( !target.data( "ui-tooltip-open" ) ) {
  12695. return;
  12696. }
  12697. // IE may instantly serve a cached response for ajax requests
  12698. // delay this call to _open so the other call to _open runs first
  12699. that._delay(function() {
  12700. // jQuery creates a special event for focusin when it doesn't
  12701. // exist natively. To improve performance, the native event
  12702. // object is reused and the type is changed. Therefore, we can't
  12703. // rely on the type being correct after the event finished
  12704. // bubbling, so we set it back to the previous value. (#8740)
  12705. if ( event ) {
  12706. event.type = eventType;
  12707. }
  12708. this._open( event, target, response );
  12709. });
  12710. });
  12711. if ( content ) {
  12712. this._open( event, target, content );
  12713. }
  12714. },
  12715. _open: function( event, target, content ) {
  12716. var tooltip, events, delayedShow,
  12717. positionOption = $.extend( {}, this.options.position );
  12718. if ( !content ) {
  12719. return;
  12720. }
  12721. // Content can be updated multiple times. If the tooltip already
  12722. // exists, then just update the content and bail.
  12723. tooltip = this._find( target );
  12724. if ( tooltip.length ) {
  12725. tooltip.find( ".ui-tooltip-content" ).html( content );
  12726. return;
  12727. }
  12728. // if we have a title, clear it to prevent the native tooltip
  12729. // we have to check first to avoid defining a title if none exists
  12730. // (we don't want to cause an element to start matching [title])
  12731. //
  12732. // We use removeAttr only for key events, to allow IE to export the correct
  12733. // accessible attributes. For mouse events, set to empty string to avoid
  12734. // native tooltip showing up (happens only when removing inside mouseover).
  12735. if ( target.is( "[title]" ) ) {
  12736. if ( event && event.type === "mouseover" ) {
  12737. target.attr( "title", "" );
  12738. } else {
  12739. target.removeAttr( "title" );
  12740. }
  12741. }
  12742. tooltip = this._tooltip( target );
  12743. addDescribedBy( target, tooltip.attr( "id" ) );
  12744. tooltip.find( ".ui-tooltip-content" ).html( content );
  12745. function position( event ) {
  12746. positionOption.of = event;
  12747. if ( tooltip.is( ":hidden" ) ) {
  12748. return;
  12749. }
  12750. tooltip.position( positionOption );
  12751. }
  12752. if ( this.options.track && event && /^mouse/.test( event.type ) ) {
  12753. this._on( this.document, {
  12754. mousemove: position
  12755. });
  12756. // trigger once to override element-relative positioning
  12757. position( event );
  12758. } else {
  12759. tooltip.position( $.extend({
  12760. of: target
  12761. }, this.options.position ) );
  12762. }
  12763. tooltip.hide();
  12764. this._show( tooltip, this.options.show );
  12765. // Handle tracking tooltips that are shown with a delay (#8644). As soon
  12766. // as the tooltip is visible, position the tooltip using the most recent
  12767. // event.
  12768. if ( this.options.show && this.options.show.delay ) {
  12769. delayedShow = this.delayedShow = setInterval(function() {
  12770. if ( tooltip.is( ":visible" ) ) {
  12771. position( positionOption.of );
  12772. clearInterval( delayedShow );
  12773. }
  12774. }, $.fx.interval );
  12775. }
  12776. this._trigger( "open", event, { tooltip: tooltip } );
  12777. events = {
  12778. keyup: function( event ) {
  12779. if ( event.keyCode === $.ui.keyCode.ESCAPE ) {
  12780. var fakeEvent = $.Event(event);
  12781. fakeEvent.currentTarget = target[0];
  12782. this.close( fakeEvent, true );
  12783. }
  12784. },
  12785. remove: function() {
  12786. this._removeTooltip( tooltip );
  12787. }
  12788. };
  12789. if ( !event || event.type === "mouseover" ) {
  12790. events.mouseleave = "close";
  12791. }
  12792. if ( !event || event.type === "focusin" ) {
  12793. events.focusout = "close";
  12794. }
  12795. this._on( true, target, events );
  12796. },
  12797. close: function( event ) {
  12798. var that = this,
  12799. target = $( event ? event.currentTarget : this.element ),
  12800. tooltip = this._find( target );
  12801. // disabling closes the tooltip, so we need to track when we're closing
  12802. // to avoid an infinite loop in case the tooltip becomes disabled on close
  12803. if ( this.closing ) {
  12804. return;
  12805. }
  12806. // Clear the interval for delayed tracking tooltips
  12807. clearInterval( this.delayedShow );
  12808. // only set title if we had one before (see comment in _open())
  12809. if ( target.data( "ui-tooltip-title" ) ) {
  12810. target.attr( "title", target.data( "ui-tooltip-title" ) );
  12811. }
  12812. removeDescribedBy( target );
  12813. tooltip.stop( true );
  12814. this._hide( tooltip, this.options.hide, function() {
  12815. that._removeTooltip( $( this ) );
  12816. });
  12817. target.removeData( "ui-tooltip-open" );
  12818. this._off( target, "mouseleave focusout keyup" );
  12819. // Remove 'remove' binding only on delegated targets
  12820. if ( target[0] !== this.element[0] ) {
  12821. this._off( target, "remove" );
  12822. }
  12823. this._off( this.document, "mousemove" );
  12824. if ( event && event.type === "mouseleave" ) {
  12825. $.each( this.parents, function( id, parent ) {
  12826. $( parent.element ).attr( "title", parent.title );
  12827. delete that.parents[ id ];
  12828. });
  12829. }
  12830. this.closing = true;
  12831. this._trigger( "close", event, { tooltip: tooltip } );
  12832. this.closing = false;
  12833. },
  12834. _tooltip: function( element ) {
  12835. var id = "ui-tooltip-" + increments++,
  12836. tooltip = $( "<div>" )
  12837. .attr({
  12838. id: id,
  12839. role: "tooltip"
  12840. })
  12841. .addClass( "ui-tooltip ui-widget ui-corner-all ui-widget-content " +
  12842. ( this.options.tooltipClass || "" ) );
  12843. $( "<div>" )
  12844. .addClass( "ui-tooltip-content" )
  12845. .appendTo( tooltip );
  12846. tooltip.appendTo( this.document[0].body );
  12847. this.tooltips[ id ] = element;
  12848. return tooltip;
  12849. },
  12850. _find: function( target ) {
  12851. var id = target.data( "ui-tooltip-id" );
  12852. return id ? $( "#" + id ) : $();
  12853. },
  12854. _removeTooltip: function( tooltip ) {
  12855. tooltip.remove();
  12856. delete this.tooltips[ tooltip.attr( "id" ) ];
  12857. },
  12858. _destroy: function() {
  12859. var that = this;
  12860. // close open tooltips
  12861. $.each( this.tooltips, function( id, element ) {
  12862. // Delegate to close method to handle common cleanup
  12863. var event = $.Event( "blur" );
  12864. event.target = event.currentTarget = element[0];
  12865. that.close( event, true );
  12866. // Remove immediately; destroying an open tooltip doesn't use the
  12867. // hide animation
  12868. $( "#" + id ).remove();
  12869. // Restore the title
  12870. if ( element.data( "ui-tooltip-title" ) ) {
  12871. element.attr( "title", element.data( "ui-tooltip-title" ) );
  12872. element.removeData( "ui-tooltip-title" );
  12873. }
  12874. });
  12875. }
  12876. });
  12877. }( jQuery ) );