Built files from Bizgaze WebServer
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

jquery-ui.js 577KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014
  1. /*! jQuery UI - v1.10.4 - 2014-01-17
  2. * http://jqueryui.com
  3. * Includes: jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.position.js, jquery.ui.accordion.js, jquery.ui.autocomplete.js, jquery.ui.button.js, jquery.ui.datepicker.js, jquery.ui.dialog.js, jquery.ui.draggable.js, jquery.ui.droppable.js, jquery.ui.effect.js, jquery.ui.effect-blind.js, jquery.ui.effect-bounce.js, jquery.ui.effect-clip.js, jquery.ui.effect-drop.js, jquery.ui.effect-explode.js, jquery.ui.effect-fade.js, jquery.ui.effect-fold.js, jquery.ui.effect-highlight.js, jquery.ui.effect-pulsate.js, jquery.ui.effect-scale.js, jquery.ui.effect-shake.js, jquery.ui.effect-slide.js, jquery.ui.effect-transfer.js, jquery.ui.menu.js, jquery.ui.progressbar.js, jquery.ui.resizable.js, jquery.ui.selectable.js, jquery.ui.slider.js, jquery.ui.sortable.js, jquery.ui.spinner.js, jquery.ui.tabs.js, jquery.ui.tooltip.js
  4. * Copyright 2014 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.4",
  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) : 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 (arguments.length === 1) {
  551. return curOption[key] === undefined ? null : curOption[key];
  552. }
  553. curOption[key] = value;
  554. } else {
  555. if (arguments.length === 1) {
  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.4",
  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. $.ui = $.ui || {};
  861. var cachedScrollbarWidth,
  862. max = Math.max,
  863. abs = Math.abs,
  864. round = Math.round,
  865. rhorizontal = /left|center|right/,
  866. rvertical = /top|center|bottom/,
  867. roffset = /[\+\-]\d+(\.[\d]+)?%?/,
  868. rposition = /^\w+/,
  869. rpercent = /%$/,
  870. _position = $.fn.position;
  871. function getOffsets(offsets, width, height) {
  872. return [
  873. parseFloat(offsets[0]) * (rpercent.test(offsets[0]) ? width / 100 : 1),
  874. parseFloat(offsets[1]) * (rpercent.test(offsets[1]) ? height / 100 : 1)
  875. ];
  876. }
  877. function parseCss(element, property) {
  878. return parseInt($.css(element, property), 10) || 0;
  879. }
  880. function getDimensions(elem) {
  881. var raw = elem[0];
  882. if (raw.nodeType === 9) {
  883. return {
  884. width: elem.width(),
  885. height: elem.height(),
  886. offset: { top: 0, left: 0 }
  887. };
  888. }
  889. if ($.isWindow(raw)) {
  890. return {
  891. width: elem.width(),
  892. height: elem.height(),
  893. offset: { top: elem.scrollTop(), left: elem.scrollLeft() }
  894. };
  895. }
  896. if (raw.preventDefault) {
  897. return {
  898. width: 0,
  899. height: 0,
  900. offset: { top: raw.pageY, left: raw.pageX }
  901. };
  902. }
  903. return {
  904. width: elem.outerWidth(),
  905. height: elem.outerHeight(),
  906. offset: elem.offset()
  907. };
  908. }
  909. $.position = {
  910. scrollbarWidth: function () {
  911. if (cachedScrollbarWidth !== undefined) {
  912. return cachedScrollbarWidth;
  913. }
  914. var w1, w2,
  915. div = $("<div style='display:block;position:absolute;width:50px;height:50px;overflow:hidden;'><div style='height:100px;width:auto;'></div></div>"),
  916. innerDiv = div.children()[0];
  917. $("body").append(div);
  918. w1 = innerDiv.offsetWidth;
  919. div.css("overflow", "scroll");
  920. w2 = innerDiv.offsetWidth;
  921. if (w1 === w2) {
  922. w2 = div[0].clientWidth;
  923. }
  924. div.remove();
  925. return (cachedScrollbarWidth = w1 - w2);
  926. },
  927. getScrollInfo: function (within) {
  928. var overflowX = within.isWindow || within.isDocument ? "" :
  929. within.element.css("overflow-x"),
  930. overflowY = within.isWindow || within.isDocument ? "" :
  931. within.element.css("overflow-y"),
  932. hasOverflowX = overflowX === "scroll" ||
  933. (overflowX === "auto" && within.width < within.element[0].scrollWidth),
  934. hasOverflowY = overflowY === "scroll" ||
  935. (overflowY === "auto" && within.height < within.element[0].scrollHeight);
  936. return {
  937. width: hasOverflowY ? $.position.scrollbarWidth() : 0,
  938. height: hasOverflowX ? $.position.scrollbarWidth() : 0
  939. };
  940. },
  941. getWithinInfo: function (element) {
  942. var withinElement = $(element || window),
  943. isWindow = $.isWindow(withinElement[0]),
  944. isDocument = !!withinElement[0] && withinElement[0].nodeType === 9;
  945. return {
  946. element: withinElement,
  947. isWindow: isWindow,
  948. isDocument: isDocument,
  949. offset: withinElement.offset() || { left: 0, top: 0 },
  950. scrollLeft: withinElement.scrollLeft(),
  951. scrollTop: withinElement.scrollTop(),
  952. width: isWindow ? withinElement.width() : withinElement.outerWidth(),
  953. height: isWindow ? withinElement.height() : withinElement.outerHeight()
  954. };
  955. }
  956. };
  957. $.fn.position = function (options) {
  958. if (!options || !options.of) {
  959. return _position.apply(this, arguments);
  960. }
  961. // make a copy, we don't want to modify arguments
  962. options = $.extend({}, options);
  963. var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
  964. target = $(options.of),
  965. within = $.position.getWithinInfo(options.within),
  966. scrollInfo = $.position.getScrollInfo(within),
  967. collision = (options.collision || "flip").split(" "),
  968. offsets = {};
  969. dimensions = getDimensions(target);
  970. if (target[0].preventDefault) {
  971. // force left top to allow flipping
  972. options.at = "left top";
  973. }
  974. targetWidth = dimensions.width;
  975. targetHeight = dimensions.height;
  976. targetOffset = dimensions.offset;
  977. // clone to reuse original targetOffset later
  978. basePosition = $.extend({}, targetOffset);
  979. // force my and at to have valid horizontal and vertical positions
  980. // if a value is missing or invalid, it will be converted to center
  981. $.each(["my", "at"], function () {
  982. var pos = (options[this] || "").split(" "),
  983. horizontalOffset,
  984. verticalOffset;
  985. if (pos.length === 1) {
  986. pos = rhorizontal.test(pos[0]) ?
  987. pos.concat(["center"]) :
  988. rvertical.test(pos[0]) ?
  989. ["center"].concat(pos) :
  990. ["center", "center"];
  991. }
  992. pos[0] = rhorizontal.test(pos[0]) ? pos[0] : "center";
  993. pos[1] = rvertical.test(pos[1]) ? pos[1] : "center";
  994. // calculate offsets
  995. horizontalOffset = roffset.exec(pos[0]);
  996. verticalOffset = roffset.exec(pos[1]);
  997. offsets[this] = [
  998. horizontalOffset ? horizontalOffset[0] : 0,
  999. verticalOffset ? verticalOffset[0] : 0
  1000. ];
  1001. // reduce to just the positions without the offsets
  1002. options[this] = [
  1003. rposition.exec(pos[0])[0],
  1004. rposition.exec(pos[1])[0]
  1005. ];
  1006. });
  1007. // normalize collision option
  1008. if (collision.length === 1) {
  1009. collision[1] = collision[0];
  1010. }
  1011. if (options.at[0] === "right") {
  1012. basePosition.left += targetWidth;
  1013. } else if (options.at[0] === "center") {
  1014. basePosition.left += targetWidth / 2;
  1015. }
  1016. if (options.at[1] === "bottom") {
  1017. basePosition.top += targetHeight;
  1018. } else if (options.at[1] === "center") {
  1019. basePosition.top += targetHeight / 2;
  1020. }
  1021. atOffset = getOffsets(offsets.at, targetWidth, targetHeight);
  1022. basePosition.left += atOffset[0];
  1023. basePosition.top += atOffset[1];
  1024. return this.each(function () {
  1025. var collisionPosition, using,
  1026. elem = $(this),
  1027. elemWidth = elem.outerWidth(),
  1028. elemHeight = elem.outerHeight(),
  1029. marginLeft = parseCss(this, "marginLeft"),
  1030. marginTop = parseCss(this, "marginTop"),
  1031. collisionWidth = elemWidth + marginLeft + parseCss(this, "marginRight") + scrollInfo.width,
  1032. collisionHeight = elemHeight + marginTop + parseCss(this, "marginBottom") + scrollInfo.height,
  1033. position = $.extend({}, basePosition),
  1034. myOffset = getOffsets(offsets.my, elem.outerWidth(), elem.outerHeight());
  1035. if (options.my[0] === "right") {
  1036. position.left -= elemWidth;
  1037. } else if (options.my[0] === "center") {
  1038. position.left -= elemWidth / 2;
  1039. }
  1040. if (options.my[1] === "bottom") {
  1041. position.top -= elemHeight;
  1042. } else if (options.my[1] === "center") {
  1043. position.top -= elemHeight / 2;
  1044. }
  1045. position.left += myOffset[0];
  1046. position.top += myOffset[1];
  1047. // if the browser doesn't support fractions, then round for consistent results
  1048. if (!$.support.offsetFractions) {
  1049. position.left = round(position.left);
  1050. position.top = round(position.top);
  1051. }
  1052. collisionPosition = {
  1053. marginLeft: marginLeft,
  1054. marginTop: marginTop
  1055. };
  1056. $.each(["left", "top"], function (i, dir) {
  1057. if ($.ui.position[collision[i]]) {
  1058. $.ui.position[collision[i]][dir](position, {
  1059. targetWidth: targetWidth,
  1060. targetHeight: targetHeight,
  1061. elemWidth: elemWidth,
  1062. elemHeight: elemHeight,
  1063. collisionPosition: collisionPosition,
  1064. collisionWidth: collisionWidth,
  1065. collisionHeight: collisionHeight,
  1066. offset: [atOffset[0] + myOffset[0], atOffset[1] + myOffset[1]],
  1067. my: options.my,
  1068. at: options.at,
  1069. within: within,
  1070. elem: elem
  1071. });
  1072. }
  1073. });
  1074. if (options.using) {
  1075. // adds feedback as second argument to using callback, if present
  1076. using = function (props) {
  1077. var left = targetOffset.left - position.left,
  1078. right = left + targetWidth - elemWidth,
  1079. top = targetOffset.top - position.top,
  1080. bottom = top + targetHeight - elemHeight,
  1081. feedback = {
  1082. target: {
  1083. element: target,
  1084. left: targetOffset.left,
  1085. top: targetOffset.top,
  1086. width: targetWidth,
  1087. height: targetHeight
  1088. },
  1089. element: {
  1090. element: elem,
  1091. left: position.left,
  1092. top: position.top,
  1093. width: elemWidth,
  1094. height: elemHeight
  1095. },
  1096. horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
  1097. vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
  1098. };
  1099. if (targetWidth < elemWidth && abs(left + right) < targetWidth) {
  1100. feedback.horizontal = "center";
  1101. }
  1102. if (targetHeight < elemHeight && abs(top + bottom) < targetHeight) {
  1103. feedback.vertical = "middle";
  1104. }
  1105. if (max(abs(left), abs(right)) > max(abs(top), abs(bottom))) {
  1106. feedback.important = "horizontal";
  1107. } else {
  1108. feedback.important = "vertical";
  1109. }
  1110. options.using.call(this, props, feedback);
  1111. };
  1112. }
  1113. elem.offset($.extend(position, { using: using }));
  1114. });
  1115. };
  1116. $.ui.position = {
  1117. fit: {
  1118. left: function (position, data) {
  1119. var within = data.within,
  1120. withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
  1121. outerWidth = within.width,
  1122. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  1123. overLeft = withinOffset - collisionPosLeft,
  1124. overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
  1125. newOverRight;
  1126. // element is wider than within
  1127. if (data.collisionWidth > outerWidth) {
  1128. // element is initially over the left side of within
  1129. if (overLeft > 0 && overRight <= 0) {
  1130. newOverRight = position.left + overLeft + data.collisionWidth - outerWidth - withinOffset;
  1131. position.left += overLeft - newOverRight;
  1132. // element is initially over right side of within
  1133. } else if (overRight > 0 && overLeft <= 0) {
  1134. position.left = withinOffset;
  1135. // element is initially over both left and right sides of within
  1136. } else {
  1137. if (overLeft > overRight) {
  1138. position.left = withinOffset + outerWidth - data.collisionWidth;
  1139. } else {
  1140. position.left = withinOffset;
  1141. }
  1142. }
  1143. // too far left -> align with left edge
  1144. } else if (overLeft > 0) {
  1145. position.left += overLeft;
  1146. // too far right -> align with right edge
  1147. } else if (overRight > 0) {
  1148. position.left -= overRight;
  1149. // adjust based on position and margin
  1150. } else {
  1151. position.left = max(position.left - collisionPosLeft, position.left);
  1152. }
  1153. },
  1154. top: function (position, data) {
  1155. var within = data.within,
  1156. withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
  1157. outerHeight = data.within.height,
  1158. collisionPosTop = position.top - data.collisionPosition.marginTop,
  1159. overTop = withinOffset - collisionPosTop,
  1160. overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
  1161. newOverBottom;
  1162. // element is taller than within
  1163. if (data.collisionHeight > outerHeight) {
  1164. // element is initially over the top of within
  1165. if (overTop > 0 && overBottom <= 0) {
  1166. newOverBottom = position.top + overTop + data.collisionHeight - outerHeight - withinOffset;
  1167. position.top += overTop - newOverBottom;
  1168. // element is initially over bottom of within
  1169. } else if (overBottom > 0 && overTop <= 0) {
  1170. position.top = withinOffset;
  1171. // element is initially over both top and bottom of within
  1172. } else {
  1173. if (overTop > overBottom) {
  1174. position.top = withinOffset + outerHeight - data.collisionHeight;
  1175. } else {
  1176. position.top = withinOffset;
  1177. }
  1178. }
  1179. // too far up -> align with top
  1180. } else if (overTop > 0) {
  1181. position.top += overTop;
  1182. // too far down -> align with bottom edge
  1183. } else if (overBottom > 0) {
  1184. position.top -= overBottom;
  1185. // adjust based on position and margin
  1186. } else {
  1187. position.top = max(position.top - collisionPosTop, position.top);
  1188. }
  1189. }
  1190. },
  1191. flip: {
  1192. left: function (position, data) {
  1193. var within = data.within,
  1194. withinOffset = within.offset.left + within.scrollLeft,
  1195. outerWidth = within.width,
  1196. offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
  1197. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  1198. overLeft = collisionPosLeft - offsetLeft,
  1199. overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
  1200. myOffset = data.my[0] === "left" ?
  1201. -data.elemWidth :
  1202. data.my[0] === "right" ?
  1203. data.elemWidth :
  1204. 0,
  1205. atOffset = data.at[0] === "left" ?
  1206. data.targetWidth :
  1207. data.at[0] === "right" ?
  1208. -data.targetWidth :
  1209. 0,
  1210. offset = -2 * data.offset[0],
  1211. newOverRight,
  1212. newOverLeft;
  1213. if (overLeft < 0) {
  1214. newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth - outerWidth - withinOffset;
  1215. if (newOverRight < 0 || newOverRight < abs(overLeft)) {
  1216. position.left += myOffset + atOffset + offset;
  1217. }
  1218. }
  1219. else if (overRight > 0) {
  1220. newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset + atOffset + offset - offsetLeft;
  1221. if (newOverLeft > 0 || abs(newOverLeft) < overRight) {
  1222. position.left += myOffset + atOffset + offset;
  1223. }
  1224. }
  1225. },
  1226. top: function (position, data) {
  1227. var within = data.within,
  1228. withinOffset = within.offset.top + within.scrollTop,
  1229. outerHeight = within.height,
  1230. offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
  1231. collisionPosTop = position.top - data.collisionPosition.marginTop,
  1232. overTop = collisionPosTop - offsetTop,
  1233. overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
  1234. top = data.my[1] === "top",
  1235. myOffset = top ?
  1236. -data.elemHeight :
  1237. data.my[1] === "bottom" ?
  1238. data.elemHeight :
  1239. 0,
  1240. atOffset = data.at[1] === "top" ?
  1241. data.targetHeight :
  1242. data.at[1] === "bottom" ?
  1243. -data.targetHeight :
  1244. 0,
  1245. offset = -2 * data.offset[1],
  1246. newOverTop,
  1247. newOverBottom;
  1248. if (overTop < 0) {
  1249. newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight - outerHeight - withinOffset;
  1250. if ((position.top + myOffset + atOffset + offset) > overTop && (newOverBottom < 0 || newOverBottom < abs(overTop))) {
  1251. position.top += myOffset + atOffset + offset;
  1252. }
  1253. }
  1254. else if (overBottom > 0) {
  1255. newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset + offset - offsetTop;
  1256. if ((position.top + myOffset + atOffset + offset) > overBottom && (newOverTop > 0 || abs(newOverTop) < overBottom)) {
  1257. position.top += myOffset + atOffset + offset;
  1258. }
  1259. }
  1260. }
  1261. },
  1262. flipfit: {
  1263. left: function () {
  1264. $.ui.position.flip.left.apply(this, arguments);
  1265. $.ui.position.fit.left.apply(this, arguments);
  1266. },
  1267. top: function () {
  1268. $.ui.position.flip.top.apply(this, arguments);
  1269. $.ui.position.fit.top.apply(this, arguments);
  1270. }
  1271. }
  1272. };
  1273. // fraction support test
  1274. (function () {
  1275. var testElement, testElementParent, testElementStyle, offsetLeft, i,
  1276. body = document.getElementsByTagName("body")[0],
  1277. div = document.createElement("div");
  1278. //Create a "fake body" for testing based on method used in jQuery.support
  1279. testElement = document.createElement(body ? "div" : "body");
  1280. testElementStyle = {
  1281. visibility: "hidden",
  1282. width: 0,
  1283. height: 0,
  1284. border: 0,
  1285. margin: 0,
  1286. background: "none"
  1287. };
  1288. if (body) {
  1289. $.extend(testElementStyle, {
  1290. position: "absolute",
  1291. left: "-1000px",
  1292. top: "-1000px"
  1293. });
  1294. }
  1295. for (i in testElementStyle) {
  1296. testElement.style[i] = testElementStyle[i];
  1297. }
  1298. testElement.appendChild(div);
  1299. testElementParent = body || document.documentElement;
  1300. testElementParent.insertBefore(testElement, testElementParent.firstChild);
  1301. div.style.cssText = "position: absolute; left: 10.7432222px;";
  1302. offsetLeft = $(div).offset().left;
  1303. $.support.offsetFractions = offsetLeft > 10 && offsetLeft < 11;
  1304. testElement.innerHTML = "";
  1305. testElementParent.removeChild(testElement);
  1306. })();
  1307. }(jQuery));
  1308. (function ($, undefined) {
  1309. var uid = 0,
  1310. hideProps = {},
  1311. showProps = {};
  1312. hideProps.height = hideProps.paddingTop = hideProps.paddingBottom =
  1313. hideProps.borderTopWidth = hideProps.borderBottomWidth = "hide";
  1314. showProps.height = showProps.paddingTop = showProps.paddingBottom =
  1315. showProps.borderTopWidth = showProps.borderBottomWidth = "show";
  1316. $.widget("ui.accordion", {
  1317. version: "1.10.4",
  1318. options: {
  1319. active: 0,
  1320. animate: {},
  1321. collapsible: false,
  1322. event: "click",
  1323. header: "> li > :first-child,> :not(li):even",
  1324. heightStyle: "auto",
  1325. icons: {
  1326. activeHeader: "ui-icon-triangle-1-s",
  1327. header: "ui-icon-triangle-1-e"
  1328. },
  1329. // callbacks
  1330. activate: null,
  1331. beforeActivate: null
  1332. },
  1333. _create: function () {
  1334. var options = this.options;
  1335. this.prevShow = this.prevHide = $();
  1336. this.element.addClass("ui-accordion ui-widget ui-helper-reset")
  1337. // ARIA
  1338. .attr("role", "tablist");
  1339. // don't allow collapsible: false and active: false / null
  1340. if (!options.collapsible && (options.active === false || options.active == null)) {
  1341. options.active = 0;
  1342. }
  1343. this._processPanels();
  1344. // handle negative values
  1345. if (options.active < 0) {
  1346. options.active += this.headers.length;
  1347. }
  1348. this._refresh();
  1349. },
  1350. _getCreateEventData: function () {
  1351. return {
  1352. header: this.active,
  1353. panel: !this.active.length ? $() : this.active.next(),
  1354. content: !this.active.length ? $() : this.active.next()
  1355. };
  1356. },
  1357. _createIcons: function () {
  1358. var icons = this.options.icons;
  1359. if (icons) {
  1360. $("<span>")
  1361. .addClass("ui-accordion-header-icon ui-icon " + icons.header)
  1362. .prependTo(this.headers);
  1363. this.active.children(".ui-accordion-header-icon")
  1364. .removeClass(icons.header)
  1365. .addClass(icons.activeHeader);
  1366. this.headers.addClass("ui-accordion-icons");
  1367. }
  1368. },
  1369. _destroyIcons: function () {
  1370. this.headers
  1371. .removeClass("ui-accordion-icons")
  1372. .children(".ui-accordion-header-icon")
  1373. .remove();
  1374. },
  1375. _destroy: function () {
  1376. var contents;
  1377. // clean up main element
  1378. this.element
  1379. .removeClass("ui-accordion ui-widget ui-helper-reset")
  1380. .removeAttr("role");
  1381. // clean up headers
  1382. this.headers
  1383. .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")
  1384. .removeAttr("role")
  1385. .removeAttr("aria-expanded")
  1386. .removeAttr("aria-selected")
  1387. .removeAttr("aria-controls")
  1388. .removeAttr("tabIndex")
  1389. .each(function () {
  1390. if (/^ui-accordion/.test(this.id)) {
  1391. this.removeAttribute("id");
  1392. }
  1393. });
  1394. this._destroyIcons();
  1395. // clean up content panels
  1396. contents = this.headers.next()
  1397. .css("display", "")
  1398. .removeAttr("role")
  1399. .removeAttr("aria-hidden")
  1400. .removeAttr("aria-labelledby")
  1401. .removeClass("ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-state-disabled")
  1402. .each(function () {
  1403. if (/^ui-accordion/.test(this.id)) {
  1404. this.removeAttribute("id");
  1405. }
  1406. });
  1407. if (this.options.heightStyle !== "content") {
  1408. contents.css("height", "");
  1409. }
  1410. },
  1411. _setOption: function (key, value) {
  1412. if (key === "active") {
  1413. // _activate() will handle invalid values and update this.options
  1414. this._activate(value);
  1415. return;
  1416. }
  1417. if (key === "event") {
  1418. if (this.options.event) {
  1419. this._off(this.headers, this.options.event);
  1420. }
  1421. this._setupEvents(value);
  1422. }
  1423. this._super(key, value);
  1424. // setting collapsible: false while collapsed; open first panel
  1425. if (key === "collapsible" && !value && this.options.active === false) {
  1426. this._activate(0);
  1427. }
  1428. if (key === "icons") {
  1429. this._destroyIcons();
  1430. if (value) {
  1431. this._createIcons();
  1432. }
  1433. }
  1434. // #5332 - opacity doesn't cascade to positioned elements in IE
  1435. // so we need to add the disabled class to the headers and panels
  1436. if (key === "disabled") {
  1437. this.headers.add(this.headers.next())
  1438. .toggleClass("ui-state-disabled", !!value);
  1439. }
  1440. },
  1441. _keydown: function (event) {
  1442. if (event.altKey || event.ctrlKey) {
  1443. return;
  1444. }
  1445. var keyCode = $.ui.keyCode,
  1446. length = this.headers.length,
  1447. currentIndex = this.headers.index(event.target),
  1448. toFocus = false;
  1449. switch (event.keyCode) {
  1450. case keyCode.RIGHT:
  1451. case keyCode.DOWN:
  1452. toFocus = this.headers[(currentIndex + 1) % length];
  1453. break;
  1454. case keyCode.LEFT:
  1455. case keyCode.UP:
  1456. toFocus = this.headers[(currentIndex - 1 + length) % length];
  1457. break;
  1458. case keyCode.SPACE:
  1459. case keyCode.ENTER:
  1460. this._eventHandler(event);
  1461. break;
  1462. case keyCode.HOME:
  1463. toFocus = this.headers[0];
  1464. break;
  1465. case keyCode.END:
  1466. toFocus = this.headers[length - 1];
  1467. break;
  1468. }
  1469. if (toFocus) {
  1470. $(event.target).attr("tabIndex", -1);
  1471. $(toFocus).attr("tabIndex", 0);
  1472. toFocus.focus();
  1473. event.preventDefault();
  1474. }
  1475. },
  1476. _panelKeyDown: function (event) {
  1477. if (event.keyCode === $.ui.keyCode.UP && event.ctrlKey) {
  1478. $(event.currentTarget).prev().focus();
  1479. }
  1480. },
  1481. refresh: function () {
  1482. var options = this.options;
  1483. this._processPanels();
  1484. // was collapsed or no panel
  1485. if ((options.active === false && options.collapsible === true) || !this.headers.length) {
  1486. options.active = false;
  1487. this.active = $();
  1488. // active false only when collapsible is true
  1489. } else if (options.active === false) {
  1490. this._activate(0);
  1491. // was active, but active panel is gone
  1492. } else if (this.active.length && !$.contains(this.element[0], this.active[0])) {
  1493. // all remaining panel are disabled
  1494. if (this.headers.length === this.headers.find(".ui-state-disabled").length) {
  1495. options.active = false;
  1496. this.active = $();
  1497. // activate previous panel
  1498. } else {
  1499. this._activate(Math.max(0, options.active - 1));
  1500. }
  1501. // was active, active panel still exists
  1502. } else {
  1503. // make sure active index is correct
  1504. options.active = this.headers.index(this.active);
  1505. }
  1506. this._destroyIcons();
  1507. this._refresh();
  1508. },
  1509. _processPanels: function () {
  1510. this.headers = this.element.find(this.options.header)
  1511. .addClass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-all");
  1512. this.headers.next()
  1513. .addClass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom")
  1514. .filter(":not(.ui-accordion-content-active)")
  1515. .hide();
  1516. },
  1517. _refresh: function () {
  1518. var maxHeight,
  1519. options = this.options,
  1520. heightStyle = options.heightStyle,
  1521. parent = this.element.parent(),
  1522. accordionId = this.accordionId = "ui-accordion-" +
  1523. (this.element.attr("id") || ++uid);
  1524. this.active = this._findActive(options.active)
  1525. .addClass("ui-accordion-header-active ui-state-active ui-corner-top")
  1526. .removeClass("ui-corner-all");
  1527. this.active.next()
  1528. .addClass("ui-accordion-content-active")
  1529. .show();
  1530. this.headers
  1531. .attr("role", "tab")
  1532. .each(function (i) {
  1533. var header = $(this),
  1534. headerId = header.attr("id"),
  1535. panel = header.next(),
  1536. panelId = panel.attr("id");
  1537. if (!headerId) {
  1538. headerId = accordionId + "-header-" + i;
  1539. header.attr("id", headerId);
  1540. }
  1541. if (!panelId) {
  1542. panelId = accordionId + "-panel-" + i;
  1543. panel.attr("id", panelId);
  1544. }
  1545. header.attr("aria-controls", panelId);
  1546. panel.attr("aria-labelledby", headerId);
  1547. })
  1548. .next()
  1549. .attr("role", "tabpanel");
  1550. this.headers
  1551. .not(this.active)
  1552. .attr({
  1553. "aria-selected": "false",
  1554. "aria-expanded": "false",
  1555. tabIndex: -1
  1556. })
  1557. .next()
  1558. .attr({
  1559. "aria-hidden": "true"
  1560. })
  1561. .hide();
  1562. // make sure at least one header is in the tab order
  1563. if (!this.active.length) {
  1564. this.headers.eq(0).attr("tabIndex", 0);
  1565. } else {
  1566. this.active.attr({
  1567. "aria-selected": "true",
  1568. "aria-expanded": "true",
  1569. tabIndex: 0
  1570. })
  1571. .next()
  1572. .attr({
  1573. "aria-hidden": "false"
  1574. });
  1575. }
  1576. this._createIcons();
  1577. this._setupEvents(options.event);
  1578. if (heightStyle === "fill") {
  1579. maxHeight = parent.height();
  1580. this.element.siblings(":visible").each(function () {
  1581. var elem = $(this),
  1582. position = elem.css("position");
  1583. if (position === "absolute" || position === "fixed") {
  1584. return;
  1585. }
  1586. maxHeight -= elem.outerHeight(true);
  1587. });
  1588. this.headers.each(function () {
  1589. maxHeight -= $(this).outerHeight(true);
  1590. });
  1591. this.headers.next()
  1592. .each(function () {
  1593. $(this).height(Math.max(0, maxHeight -
  1594. $(this).innerHeight() + $(this).height()));
  1595. })
  1596. .css("overflow", "auto");
  1597. } else if (heightStyle === "auto") {
  1598. maxHeight = 0;
  1599. this.headers.next()
  1600. .each(function () {
  1601. maxHeight = Math.max(maxHeight, $(this).css("height", "").height());
  1602. })
  1603. .height(maxHeight);
  1604. }
  1605. },
  1606. _activate: function (index) {
  1607. var active = this._findActive(index)[0];
  1608. // trying to activate the already active panel
  1609. if (active === this.active[0]) {
  1610. return;
  1611. }
  1612. // trying to collapse, simulate a click on the currently active header
  1613. active = active || this.active[0];
  1614. this._eventHandler({
  1615. target: active,
  1616. currentTarget: active,
  1617. preventDefault: $.noop
  1618. });
  1619. },
  1620. _findActive: function (selector) {
  1621. return typeof selector === "number" ? this.headers.eq(selector) : $();
  1622. },
  1623. _setupEvents: function (event) {
  1624. var events = {
  1625. keydown: "_keydown"
  1626. };
  1627. if (event) {
  1628. $.each(event.split(" "), function (index, eventName) {
  1629. events[eventName] = "_eventHandler";
  1630. });
  1631. }
  1632. this._off(this.headers.add(this.headers.next()));
  1633. this._on(this.headers, events);
  1634. this._on(this.headers.next(), { keydown: "_panelKeyDown" });
  1635. this._hoverable(this.headers);
  1636. this._focusable(this.headers);
  1637. },
  1638. _eventHandler: function (event) {
  1639. var options = this.options,
  1640. active = this.active,
  1641. clicked = $(event.currentTarget),
  1642. clickedIsActive = clicked[0] === active[0],
  1643. collapsing = clickedIsActive && options.collapsible,
  1644. toShow = collapsing ? $() : clicked.next(),
  1645. toHide = active.next(),
  1646. eventData = {
  1647. oldHeader: active,
  1648. oldPanel: toHide,
  1649. newHeader: collapsing ? $() : clicked,
  1650. newPanel: toShow
  1651. };
  1652. event.preventDefault();
  1653. if (
  1654. // click on active header, but not collapsible
  1655. (clickedIsActive && !options.collapsible) ||
  1656. // allow canceling activation
  1657. (this._trigger("beforeActivate", event, eventData) === false)) {
  1658. return;
  1659. }
  1660. options.active = collapsing ? false : this.headers.index(clicked);
  1661. // when the call to ._toggle() comes after the class changes
  1662. // it causes a very odd bug in IE 8 (see #6720)
  1663. this.active = clickedIsActive ? $() : clicked;
  1664. this._toggle(eventData);
  1665. // switch classes
  1666. // corner classes on the previously active header stay after the animation
  1667. active.removeClass("ui-accordion-header-active ui-state-active");
  1668. if (options.icons) {
  1669. active.children(".ui-accordion-header-icon")
  1670. .removeClass(options.icons.activeHeader)
  1671. .addClass(options.icons.header);
  1672. }
  1673. if (!clickedIsActive) {
  1674. clicked
  1675. .removeClass("ui-corner-all")
  1676. .addClass("ui-accordion-header-active ui-state-active ui-corner-top");
  1677. if (options.icons) {
  1678. clicked.children(".ui-accordion-header-icon")
  1679. .removeClass(options.icons.header)
  1680. .addClass(options.icons.activeHeader);
  1681. }
  1682. clicked
  1683. .next()
  1684. .addClass("ui-accordion-content-active");
  1685. }
  1686. },
  1687. _toggle: function (data) {
  1688. var toShow = data.newPanel,
  1689. toHide = this.prevShow.length ? this.prevShow : data.oldPanel;
  1690. // handle activating a panel during the animation for another activation
  1691. this.prevShow.add(this.prevHide).stop(true, true);
  1692. this.prevShow = toShow;
  1693. this.prevHide = toHide;
  1694. if (this.options.animate) {
  1695. this._animate(toShow, toHide, data);
  1696. } else {
  1697. toHide.hide();
  1698. toShow.show();
  1699. this._toggleComplete(data);
  1700. }
  1701. toHide.attr({
  1702. "aria-hidden": "true"
  1703. });
  1704. toHide.prev().attr("aria-selected", "false");
  1705. // if we're switching panels, remove the old header from the tab order
  1706. // if we're opening from collapsed state, remove the previous header from the tab order
  1707. // if we're collapsing, then keep the collapsing header in the tab order
  1708. if (toShow.length && toHide.length) {
  1709. toHide.prev().attr({
  1710. "tabIndex": -1,
  1711. "aria-expanded": "false"
  1712. });
  1713. } else if (toShow.length) {
  1714. this.headers.filter(function () {
  1715. return $(this).attr("tabIndex") === 0;
  1716. })
  1717. .attr("tabIndex", -1);
  1718. }
  1719. toShow
  1720. .attr("aria-hidden", "false")
  1721. .prev()
  1722. .attr({
  1723. "aria-selected": "true",
  1724. tabIndex: 0,
  1725. "aria-expanded": "true"
  1726. });
  1727. },
  1728. _animate: function (toShow, toHide, data) {
  1729. var total, easing, duration,
  1730. that = this,
  1731. adjust = 0,
  1732. down = toShow.length &&
  1733. (!toHide.length || (toShow.index() < toHide.index())),
  1734. animate = this.options.animate || {},
  1735. options = down && animate.down || animate,
  1736. complete = function () {
  1737. that._toggleComplete(data);
  1738. };
  1739. if (typeof options === "number") {
  1740. duration = options;
  1741. }
  1742. if (typeof options === "string") {
  1743. easing = options;
  1744. }
  1745. // fall back from options to animation in case of partial down settings
  1746. easing = easing || options.easing || animate.easing;
  1747. duration = duration || options.duration || animate.duration;
  1748. if (!toHide.length) {
  1749. return toShow.animate(showProps, duration, easing, complete);
  1750. }
  1751. if (!toShow.length) {
  1752. return toHide.animate(hideProps, duration, easing, complete);
  1753. }
  1754. total = toShow.show().outerHeight();
  1755. toHide.animate(hideProps, {
  1756. duration: duration,
  1757. easing: easing,
  1758. step: function (now, fx) {
  1759. fx.now = Math.round(now);
  1760. }
  1761. });
  1762. toShow
  1763. .hide()
  1764. .animate(showProps, {
  1765. duration: duration,
  1766. easing: easing,
  1767. complete: complete,
  1768. step: function (now, fx) {
  1769. fx.now = Math.round(now);
  1770. if (fx.prop !== "height") {
  1771. adjust += fx.now;
  1772. } else if (that.options.heightStyle !== "content") {
  1773. fx.now = Math.round(total - toHide.outerHeight() - adjust);
  1774. adjust = 0;
  1775. }
  1776. }
  1777. });
  1778. },
  1779. _toggleComplete: function (data) {
  1780. var toHide = data.oldPanel;
  1781. toHide
  1782. .removeClass("ui-accordion-content-active")
  1783. .prev()
  1784. .removeClass("ui-corner-top")
  1785. .addClass("ui-corner-all");
  1786. // Work around for rendering bug in IE (#5421)
  1787. if (toHide.length) {
  1788. toHide.parent()[0].className = toHide.parent()[0].className;
  1789. }
  1790. this._trigger("activate", null, data);
  1791. }
  1792. });
  1793. })(jQuery);
  1794. (function ($, undefined) {
  1795. $.widget("ui.autocomplete", {
  1796. version: "1.10.4",
  1797. defaultElement: "<input>",
  1798. options: {
  1799. appendTo: null,
  1800. autoFocus: false,
  1801. delay: 300,
  1802. minLength: 1,
  1803. position: {
  1804. my: "left top",
  1805. at: "left bottom",
  1806. collision: "none"
  1807. },
  1808. source: null,
  1809. // callbacks
  1810. change: null,
  1811. close: null,
  1812. focus: null,
  1813. open: null,
  1814. response: null,
  1815. search: null,
  1816. select: null
  1817. },
  1818. requestIndex: 0,
  1819. pending: 0,
  1820. _create: function () {
  1821. // Some browsers only repeat keydown events, not keypress events,
  1822. // so we use the suppressKeyPress flag to determine if we've already
  1823. // handled the keydown event. #7269
  1824. // Unfortunately the code for & in keypress is the same as the up arrow,
  1825. // so we use the suppressKeyPressRepeat flag to avoid handling keypress
  1826. // events when we know the keydown event was used to modify the
  1827. // search term. #7799
  1828. var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
  1829. nodeName = this.element[0].nodeName.toLowerCase(),
  1830. isTextarea = nodeName === "textarea",
  1831. isInput = nodeName === "input";
  1832. this.isMultiLine =
  1833. // Textareas are always multi-line
  1834. isTextarea ? true :
  1835. // Inputs are always single-line, even if inside a contentEditable element
  1836. // IE also treats inputs as contentEditable
  1837. isInput ? false :
  1838. // All other element types are determined by whether or not they're contentEditable
  1839. this.element.prop("isContentEditable");
  1840. this.valueMethod = this.element[isTextarea || isInput ? "val" : "text"];
  1841. this.isNewMenu = true;
  1842. this.element
  1843. .addClass("ui-autocomplete-input")
  1844. .attr("autocomplete", "off");
  1845. this._on(this.element, {
  1846. keydown: function (event) {
  1847. if (this.element.prop("readOnly")) {
  1848. suppressKeyPress = true;
  1849. suppressInput = true;
  1850. suppressKeyPressRepeat = true;
  1851. return;
  1852. }
  1853. suppressKeyPress = false;
  1854. suppressInput = false;
  1855. suppressKeyPressRepeat = false;
  1856. var keyCode = $.ui.keyCode;
  1857. switch (event.keyCode) {
  1858. case keyCode.PAGE_UP:
  1859. suppressKeyPress = true;
  1860. this._move("previousPage", event);
  1861. break;
  1862. case keyCode.PAGE_DOWN:
  1863. suppressKeyPress = true;
  1864. this._move("nextPage", event);
  1865. break;
  1866. case keyCode.UP:
  1867. suppressKeyPress = true;
  1868. this._keyEvent("previous", event);
  1869. break;
  1870. case keyCode.DOWN:
  1871. suppressKeyPress = true;
  1872. this._keyEvent("next", event);
  1873. break;
  1874. case keyCode.ENTER:
  1875. case keyCode.NUMPAD_ENTER:
  1876. // when menu is open and has focus
  1877. if (this.menu.active) {
  1878. // #6055 - Opera still allows the keypress to occur
  1879. // which causes forms to submit
  1880. suppressKeyPress = true;
  1881. event.preventDefault();
  1882. this.menu.select(event);
  1883. }
  1884. break;
  1885. case keyCode.TAB:
  1886. if (this.menu.active) {
  1887. this.menu.select(event);
  1888. }
  1889. break;
  1890. case keyCode.ESCAPE:
  1891. if (this.menu.element.is(":visible")) {
  1892. this._value(this.term);
  1893. this.close(event);
  1894. // Different browsers have different default behavior for escape
  1895. // Single press can mean undo or clear
  1896. // Double press in IE means clear the whole form
  1897. event.preventDefault();
  1898. }
  1899. break;
  1900. default:
  1901. suppressKeyPressRepeat = true;
  1902. // search timeout should be triggered before the input value is changed
  1903. this._searchTimeout(event);
  1904. break;
  1905. }
  1906. },
  1907. keypress: function (event) {
  1908. if (suppressKeyPress) {
  1909. suppressKeyPress = false;
  1910. if (!this.isMultiLine || this.menu.element.is(":visible")) {
  1911. event.preventDefault();
  1912. }
  1913. return;
  1914. }
  1915. if (suppressKeyPressRepeat) {
  1916. return;
  1917. }
  1918. // replicate some key handlers to allow them to repeat in Firefox and Opera
  1919. var keyCode = $.ui.keyCode;
  1920. switch (event.keyCode) {
  1921. case keyCode.PAGE_UP:
  1922. this._move("previousPage", event);
  1923. break;
  1924. case keyCode.PAGE_DOWN:
  1925. this._move("nextPage", event);
  1926. break;
  1927. case keyCode.UP:
  1928. this._keyEvent("previous", event);
  1929. break;
  1930. case keyCode.DOWN:
  1931. this._keyEvent("next", event);
  1932. break;
  1933. }
  1934. },
  1935. input: function (event) {
  1936. if (suppressInput) {
  1937. suppressInput = false;
  1938. event.preventDefault();
  1939. return;
  1940. }
  1941. this._searchTimeout(event);
  1942. },
  1943. focus: function () {
  1944. this.selectedItem = null;
  1945. this.previous = this._value();
  1946. },
  1947. blur: function (event) {
  1948. if (this.cancelBlur) {
  1949. delete this.cancelBlur;
  1950. return;
  1951. }
  1952. clearTimeout(this.searching);
  1953. this.close(event);
  1954. this._change(event);
  1955. }
  1956. });
  1957. this._initSource();
  1958. this.menu = $("<ul>")
  1959. .addClass("ui-autocomplete ui-front")
  1960. .appendTo(this._appendTo())
  1961. .menu({
  1962. // disable ARIA support, the live region takes care of that
  1963. role: null
  1964. })
  1965. .hide()
  1966. .data("ui-menu");
  1967. this._on(this.menu.element, {
  1968. mousedown: function (event) {
  1969. // prevent moving focus out of the text field
  1970. event.preventDefault();
  1971. // IE doesn't prevent moving focus even with event.preventDefault()
  1972. // so we set a flag to know when we should ignore the blur event
  1973. this.cancelBlur = true;
  1974. this._delay(function () {
  1975. delete this.cancelBlur;
  1976. });
  1977. // clicking on the scrollbar causes focus to shift to the body
  1978. // but we can't detect a mouseup or a click immediately afterward
  1979. // so we have to track the next mousedown and close the menu if
  1980. // the user clicks somewhere outside of the autocomplete
  1981. var menuElement = this.menu.element[0];
  1982. if (!$(event.target).closest(".ui-menu-item").length) {
  1983. this._delay(function () {
  1984. var that = this;
  1985. this.document.one("mousedown", function (event) {
  1986. if (event.target !== that.element[0] &&
  1987. event.target !== menuElement &&
  1988. !$.contains(menuElement, event.target)) {
  1989. that.close();
  1990. }
  1991. });
  1992. });
  1993. }
  1994. },
  1995. menufocus: function (event, ui) {
  1996. // support: Firefox
  1997. // Prevent accidental activation of menu items in Firefox (#7024 #9118)
  1998. if (this.isNewMenu) {
  1999. this.isNewMenu = false;
  2000. if (event.originalEvent && /^mouse/.test(event.originalEvent.type)) {
  2001. this.menu.blur();
  2002. this.document.one("mousemove", function () {
  2003. $(event.target).trigger(event.originalEvent);
  2004. });
  2005. return;
  2006. }
  2007. }
  2008. var item = ui.item.data("ui-autocomplete-item");
  2009. if (false !== this._trigger("focus", event, { item: item })) {
  2010. // use value to match what will end up in the input, if it was a key event
  2011. if (event.originalEvent && /^key/.test(event.originalEvent.type)) {
  2012. this._value(item.value);
  2013. }
  2014. } else {
  2015. // Normally the input is populated with the item's value as the
  2016. // menu is navigated, causing screen readers to notice a change and
  2017. // announce the item. Since the focus event was canceled, this doesn't
  2018. // happen, so we update the live region so that screen readers can
  2019. // still notice the change and announce it.
  2020. this.liveRegion.text(item.value);
  2021. }
  2022. },
  2023. menuselect: function (event, ui) {
  2024. var item = ui.item.data("ui-autocomplete-item"),
  2025. previous = this.previous;
  2026. // only trigger when focus was lost (click on menu)
  2027. if (this.element[0] !== this.document[0].activeElement) {
  2028. this.element.focus();
  2029. this.previous = previous;
  2030. // #6109 - IE triggers two focus events and the second
  2031. // is asynchronous, so we need to reset the previous
  2032. // term synchronously and asynchronously :-(
  2033. this._delay(function () {
  2034. this.previous = previous;
  2035. this.selectedItem = item;
  2036. });
  2037. }
  2038. if (false !== this._trigger("select", event, { item: item })) {
  2039. this._value(item.value);
  2040. }
  2041. // reset the term after the select event
  2042. // this allows custom select handling to work properly
  2043. this.term = this._value();
  2044. this.close(event);
  2045. this.selectedItem = item;
  2046. }
  2047. });
  2048. this.liveRegion = $("<span>", {
  2049. role: "status",
  2050. "aria-live": "polite"
  2051. })
  2052. .addClass("ui-helper-hidden-accessible")
  2053. .insertBefore(this.element);
  2054. // turning off autocomplete prevents the browser from remembering the
  2055. // value when navigating through history, so we re-enable autocomplete
  2056. // if the page is unloaded before the widget is destroyed. #7790
  2057. this._on(this.window, {
  2058. beforeunload: function () {
  2059. this.element.removeAttr("autocomplete");
  2060. }
  2061. });
  2062. },
  2063. _destroy: function () {
  2064. clearTimeout(this.searching);
  2065. this.element
  2066. .removeClass("ui-autocomplete-input")
  2067. .removeAttr("autocomplete");
  2068. this.menu.element.remove();
  2069. this.liveRegion.remove();
  2070. },
  2071. _setOption: function (key, value) {
  2072. this._super(key, value);
  2073. if (key === "source") {
  2074. this._initSource();
  2075. }
  2076. if (key === "appendTo") {
  2077. this.menu.element.appendTo(this._appendTo());
  2078. }
  2079. if (key === "disabled" && value && this.xhr) {
  2080. this.xhr.abort();
  2081. }
  2082. },
  2083. _appendTo: function () {
  2084. var element = this.options.appendTo;
  2085. if (element) {
  2086. element = element.jquery || element.nodeType ?
  2087. $(element) :
  2088. this.document.find(element).eq(0);
  2089. }
  2090. if (!element) {
  2091. element = this.element.closest(".ui-front");
  2092. }
  2093. if (!element.length) {
  2094. element = this.document[0].body;
  2095. }
  2096. return element;
  2097. },
  2098. _initSource: function () {
  2099. var array, url,
  2100. that = this;
  2101. if ($.isArray(this.options.source)) {
  2102. array = this.options.source;
  2103. this.source = function (request, response) {
  2104. response($.ui.autocomplete.filter(array, request.term));
  2105. };
  2106. } else if (typeof this.options.source === "string") {
  2107. url = this.options.source;
  2108. this.source = function (request, response) {
  2109. if (that.xhr) {
  2110. that.xhr.abort();
  2111. }
  2112. that.xhr = $.ajax({
  2113. url: url,
  2114. data: request,
  2115. dataType: "json",
  2116. success: function (data) {
  2117. response(data);
  2118. },
  2119. error: function () {
  2120. response([]);
  2121. }
  2122. });
  2123. };
  2124. } else {
  2125. this.source = this.options.source;
  2126. }
  2127. },
  2128. _searchTimeout: function (event) {
  2129. clearTimeout(this.searching);
  2130. this.searching = this._delay(function () {
  2131. // only search if the value has changed
  2132. if (this.term !== this._value()) {
  2133. this.selectedItem = null;
  2134. this.search(null, event);
  2135. }
  2136. }, this.options.delay);
  2137. },
  2138. search: function (value, event) {
  2139. value = value != null ? value : this._value();
  2140. // always save the actual value, not the one passed as an argument
  2141. this.term = this._value();
  2142. if (value.length < this.options.minLength) {
  2143. return this.close(event);
  2144. }
  2145. if (this._trigger("search", event) === false) {
  2146. return;
  2147. }
  2148. return this._search(value);
  2149. },
  2150. _search: function (value) {
  2151. this.pending++;
  2152. this.element.addClass("ui-autocomplete-loading");
  2153. this.cancelSearch = false;
  2154. this.source({ term: value }, this._response());
  2155. },
  2156. _response: function () {
  2157. var index = ++this.requestIndex;
  2158. return $.proxy(function (content) {
  2159. if (index === this.requestIndex) {
  2160. this.__response(content);
  2161. }
  2162. this.pending--;
  2163. if (!this.pending) {
  2164. this.element.removeClass("ui-autocomplete-loading");
  2165. }
  2166. }, this);
  2167. },
  2168. __response: function (content) {
  2169. if (content) {
  2170. content = this._normalize(content);
  2171. }
  2172. this._trigger("response", null, { content: content });
  2173. if (!this.options.disabled && content && content.length && !this.cancelSearch) {
  2174. this._suggest(content);
  2175. this._trigger("open");
  2176. } else {
  2177. // use ._close() instead of .close() so we don't cancel future searches
  2178. this._close();
  2179. }
  2180. },
  2181. close: function (event) {
  2182. this.cancelSearch = true;
  2183. this._close(event);
  2184. },
  2185. _close: function (event) {
  2186. if (this.menu.element.is(":visible")) {
  2187. this.menu.element.hide();
  2188. this.menu.blur();
  2189. this.isNewMenu = true;
  2190. this._trigger("close", event);
  2191. }
  2192. },
  2193. _change: function (event) {
  2194. if (this.previous !== this._value()) {
  2195. this._trigger("change", event, { item: this.selectedItem });
  2196. }
  2197. },
  2198. _normalize: function (items) {
  2199. // assume all items have the right format when the first item is complete
  2200. if (items.length && items[0].label && items[0].value) {
  2201. return items;
  2202. }
  2203. return $.map(items, function (item) {
  2204. if (typeof item === "string") {
  2205. return {
  2206. label: item,
  2207. value: item
  2208. };
  2209. }
  2210. return $.extend({
  2211. label: item.label || item.value,
  2212. value: item.value || item.label
  2213. }, item);
  2214. });
  2215. },
  2216. _suggest: function (items) {
  2217. var ul = this.menu.element.empty();
  2218. this._renderMenu(ul, items);
  2219. this.isNewMenu = true;
  2220. this.menu.refresh();
  2221. // size and position menu
  2222. ul.show();
  2223. this._resizeMenu();
  2224. ul.position($.extend({
  2225. of: this.element
  2226. }, this.options.position));
  2227. if (this.options.autoFocus) {
  2228. this.menu.next();
  2229. }
  2230. },
  2231. _resizeMenu: function () {
  2232. var ul = this.menu.element;
  2233. ul.outerWidth(Math.max(
  2234. // Firefox wraps long text (possibly a rounding bug)
  2235. // so we add 1px to avoid the wrapping (#7513)
  2236. ul.width("").outerWidth() + 1,
  2237. this.element.outerWidth()
  2238. ));
  2239. },
  2240. _renderMenu: function (ul, items) {
  2241. var that = this;
  2242. $.each(items, function (index, item) {
  2243. that._renderItemData(ul, item);
  2244. });
  2245. },
  2246. _renderItemData: function (ul, item) {
  2247. return this._renderItem(ul, item).data("ui-autocomplete-item", item);
  2248. },
  2249. _renderItem: function (ul, item) {
  2250. return $("<li>")
  2251. .append($("<a>").text(item.label))
  2252. .appendTo(ul);
  2253. },
  2254. _move: function (direction, event) {
  2255. if (!this.menu.element.is(":visible")) {
  2256. this.search(null, event);
  2257. return;
  2258. }
  2259. if (this.menu.isFirstItem() && /^previous/.test(direction) ||
  2260. this.menu.isLastItem() && /^next/.test(direction)) {
  2261. this._value(this.term);
  2262. this.menu.blur();
  2263. return;
  2264. }
  2265. this.menu[direction](event);
  2266. },
  2267. widget: function () {
  2268. return this.menu.element;
  2269. },
  2270. _value: function () {
  2271. return this.valueMethod.apply(this.element, arguments);
  2272. },
  2273. _keyEvent: function (keyEvent, event) {
  2274. if (!this.isMultiLine || this.menu.element.is(":visible")) {
  2275. this._move(keyEvent, event);
  2276. // prevents moving cursor to beginning/end of the text field in some browsers
  2277. event.preventDefault();
  2278. }
  2279. }
  2280. });
  2281. $.extend($.ui.autocomplete, {
  2282. escapeRegex: function (value) {
  2283. return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
  2284. },
  2285. filter: function (array, term) {
  2286. var matcher = new RegExp($.ui.autocomplete.escapeRegex(term), "i");
  2287. return $.grep(array, function (value) {
  2288. return matcher.test(value.label || value.value || value);
  2289. });
  2290. }
  2291. });
  2292. // live region extension, adding a `messages` option
  2293. // NOTE: This is an experimental API. We are still investigating
  2294. // a full solution for string manipulation and internationalization.
  2295. $.widget("ui.autocomplete", $.ui.autocomplete, {
  2296. options: {
  2297. messages: {
  2298. noResults: "No search results.",
  2299. results: function (amount) {
  2300. return amount + (amount > 1 ? " results are" : " result is") +
  2301. " available, use up and down arrow keys to navigate.";
  2302. }
  2303. }
  2304. },
  2305. __response: function (content) {
  2306. var message;
  2307. this._superApply(arguments);
  2308. if (this.options.disabled || this.cancelSearch) {
  2309. return;
  2310. }
  2311. if (content && content.length) {
  2312. message = this.options.messages.results(content.length);
  2313. } else {
  2314. message = this.options.messages.noResults;
  2315. }
  2316. this.liveRegion.text(message);
  2317. }
  2318. });
  2319. }(jQuery));
  2320. (function ($, undefined) {
  2321. var lastActive,
  2322. baseClasses = "ui-button ui-widget ui-state-default ui-corner-all",
  2323. 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",
  2324. formResetHandler = function () {
  2325. var form = $(this);
  2326. setTimeout(function () {
  2327. form.find(":ui-button").button("refresh");
  2328. }, 1);
  2329. },
  2330. radioGroup = function (radio) {
  2331. var name = radio.name,
  2332. form = radio.form,
  2333. radios = $([]);
  2334. if (name) {
  2335. name = name.replace(/'/g, "\\'");
  2336. if (form) {
  2337. radios = $(form).find("[name='" + name + "']");
  2338. } else {
  2339. radios = $("[name='" + name + "']", radio.ownerDocument)
  2340. .filter(function () {
  2341. return !this.form;
  2342. });
  2343. }
  2344. }
  2345. return radios;
  2346. };
  2347. $.widget("ui.button", {
  2348. version: "1.10.4",
  2349. defaultElement: "<button>",
  2350. options: {
  2351. disabled: null,
  2352. text: true,
  2353. label: null,
  2354. icons: {
  2355. primary: null,
  2356. secondary: null
  2357. }
  2358. },
  2359. _create: function () {
  2360. this.element.closest("form")
  2361. .unbind("reset" + this.eventNamespace)
  2362. .bind("reset" + this.eventNamespace, formResetHandler);
  2363. if (typeof this.options.disabled !== "boolean") {
  2364. this.options.disabled = !!this.element.prop("disabled");
  2365. } else {
  2366. this.element.prop("disabled", this.options.disabled);
  2367. }
  2368. this._determineButtonType();
  2369. this.hasTitle = !!this.buttonElement.attr("title");
  2370. var that = this,
  2371. options = this.options,
  2372. toggleButton = this.type === "checkbox" || this.type === "radio",
  2373. activeClass = !toggleButton ? "ui-state-active" : "";
  2374. if (options.label === null) {
  2375. options.label = (this.type === "input" ? this.buttonElement.val() : this.buttonElement.html());
  2376. }
  2377. this._hoverable(this.buttonElement);
  2378. this.buttonElement
  2379. .addClass(baseClasses)
  2380. .attr("role", "button")
  2381. .bind("mouseenter" + this.eventNamespace, function () {
  2382. if (options.disabled) {
  2383. return;
  2384. }
  2385. if (this === lastActive) {
  2386. $(this).addClass("ui-state-active");
  2387. }
  2388. })
  2389. .bind("mouseleave" + this.eventNamespace, function () {
  2390. if (options.disabled) {
  2391. return;
  2392. }
  2393. $(this).removeClass(activeClass);
  2394. })
  2395. .bind("click" + this.eventNamespace, function (event) {
  2396. if (options.disabled) {
  2397. event.preventDefault();
  2398. event.stopImmediatePropagation();
  2399. }
  2400. });
  2401. // Can't use _focusable() because the element that receives focus
  2402. // and the element that gets the ui-state-focus class are different
  2403. this._on({
  2404. focus: function () {
  2405. this.buttonElement.addClass("ui-state-focus");
  2406. },
  2407. blur: function () {
  2408. this.buttonElement.removeClass("ui-state-focus");
  2409. }
  2410. });
  2411. if (toggleButton) {
  2412. this.element.bind("change" + this.eventNamespace, function () {
  2413. that.refresh();
  2414. });
  2415. }
  2416. if (this.type === "checkbox") {
  2417. this.buttonElement.bind("click" + this.eventNamespace, function () {
  2418. if (options.disabled) {
  2419. return false;
  2420. }
  2421. });
  2422. } else if (this.type === "radio") {
  2423. this.buttonElement.bind("click" + this.eventNamespace, function () {
  2424. if (options.disabled) {
  2425. return false;
  2426. }
  2427. $(this).addClass("ui-state-active");
  2428. that.buttonElement.attr("aria-pressed", "true");
  2429. var radio = that.element[0];
  2430. radioGroup(radio)
  2431. .not(radio)
  2432. .map(function () {
  2433. return $(this).button("widget")[0];
  2434. })
  2435. .removeClass("ui-state-active")
  2436. .attr("aria-pressed", "false");
  2437. });
  2438. } else {
  2439. this.buttonElement
  2440. .bind("mousedown" + this.eventNamespace, function () {
  2441. if (options.disabled) {
  2442. return false;
  2443. }
  2444. $(this).addClass("ui-state-active");
  2445. lastActive = this;
  2446. that.document.one("mouseup", function () {
  2447. lastActive = null;
  2448. });
  2449. })
  2450. .bind("mouseup" + this.eventNamespace, function () {
  2451. if (options.disabled) {
  2452. return false;
  2453. }
  2454. $(this).removeClass("ui-state-active");
  2455. })
  2456. .bind("keydown" + this.eventNamespace, function (event) {
  2457. if (options.disabled) {
  2458. return false;
  2459. }
  2460. if (event.keyCode === $.ui.keyCode.SPACE || event.keyCode === $.ui.keyCode.ENTER) {
  2461. $(this).addClass("ui-state-active");
  2462. }
  2463. })
  2464. // see #8559, we bind to blur here in case the button element loses
  2465. // focus between keydown and keyup, it would be left in an "active" state
  2466. .bind("keyup" + this.eventNamespace + " blur" + this.eventNamespace, function () {
  2467. $(this).removeClass("ui-state-active");
  2468. });
  2469. if (this.buttonElement.is("a")) {
  2470. this.buttonElement.keyup(function (event) {
  2471. if (event.keyCode === $.ui.keyCode.SPACE) {
  2472. // TODO pass through original event correctly (just as 2nd argument doesn't work)
  2473. $(this).click();
  2474. }
  2475. });
  2476. }
  2477. }
  2478. // TODO: pull out $.Widget's handling for the disabled option into
  2479. // $.Widget.prototype._setOptionDisabled so it's easy to proxy and can
  2480. // be overridden by individual plugins
  2481. this._setOption("disabled", options.disabled);
  2482. this._resetButton();
  2483. },
  2484. _determineButtonType: function () {
  2485. var ancestor, labelSelector, checked;
  2486. if (this.element.is("[type=checkbox]")) {
  2487. this.type = "checkbox";
  2488. } else if (this.element.is("[type=radio]")) {
  2489. this.type = "radio";
  2490. } else if (this.element.is("input")) {
  2491. this.type = "input";
  2492. } else {
  2493. this.type = "button";
  2494. }
  2495. if (this.type === "checkbox" || this.type === "radio") {
  2496. // we don't search against the document in case the element
  2497. // is disconnected from the DOM
  2498. ancestor = this.element.parents().last();
  2499. labelSelector = "label[for='" + this.element.attr("id") + "']";
  2500. this.buttonElement = ancestor.find(labelSelector);
  2501. if (!this.buttonElement.length) {
  2502. ancestor = ancestor.length ? ancestor.siblings() : this.element.siblings();
  2503. this.buttonElement = ancestor.filter(labelSelector);
  2504. if (!this.buttonElement.length) {
  2505. this.buttonElement = ancestor.find(labelSelector);
  2506. }
  2507. }
  2508. this.element.addClass("ui-helper-hidden-accessible");
  2509. checked = this.element.is(":checked");
  2510. if (checked) {
  2511. this.buttonElement.addClass("ui-state-active");
  2512. }
  2513. this.buttonElement.prop("aria-pressed", checked);
  2514. } else {
  2515. this.buttonElement = this.element;
  2516. }
  2517. },
  2518. widget: function () {
  2519. return this.buttonElement;
  2520. },
  2521. _destroy: function () {
  2522. this.element
  2523. .removeClass("ui-helper-hidden-accessible");
  2524. this.buttonElement
  2525. .removeClass(baseClasses + " ui-state-active " + typeClasses)
  2526. .removeAttr("role")
  2527. .removeAttr("aria-pressed")
  2528. .html(this.buttonElement.find(".ui-button-text").html());
  2529. if (!this.hasTitle) {
  2530. this.buttonElement.removeAttr("title");
  2531. }
  2532. },
  2533. _setOption: function (key, value) {
  2534. this._super(key, value);
  2535. if (key === "disabled") {
  2536. this.element.prop("disabled", !!value);
  2537. if (value) {
  2538. this.buttonElement.removeClass("ui-state-focus");
  2539. }
  2540. return;
  2541. }
  2542. this._resetButton();
  2543. },
  2544. refresh: function () {
  2545. //See #8237 & #8828
  2546. var isDisabled = this.element.is("input, button") ? this.element.is(":disabled") : this.element.hasClass("ui-button-disabled");
  2547. if (isDisabled !== this.options.disabled) {
  2548. this._setOption("disabled", isDisabled);
  2549. }
  2550. if (this.type === "radio") {
  2551. radioGroup(this.element[0]).each(function () {
  2552. if ($(this).is(":checked")) {
  2553. $(this).button("widget")
  2554. .addClass("ui-state-active")
  2555. .attr("aria-pressed", "true");
  2556. } else {
  2557. $(this).button("widget")
  2558. .removeClass("ui-state-active")
  2559. .attr("aria-pressed", "false");
  2560. }
  2561. });
  2562. } else if (this.type === "checkbox") {
  2563. if (this.element.is(":checked")) {
  2564. this.buttonElement
  2565. .addClass("ui-state-active")
  2566. .attr("aria-pressed", "true");
  2567. } else {
  2568. this.buttonElement
  2569. .removeClass("ui-state-active")
  2570. .attr("aria-pressed", "false");
  2571. }
  2572. }
  2573. },
  2574. _resetButton: function () {
  2575. if (this.type === "input") {
  2576. if (this.options.label) {
  2577. this.element.val(this.options.label);
  2578. }
  2579. return;
  2580. }
  2581. var buttonElement = this.buttonElement.removeClass(typeClasses),
  2582. buttonText = $("<span></span>", this.document[0])
  2583. .addClass("ui-button-text")
  2584. .html(this.options.label)
  2585. .appendTo(buttonElement.empty())
  2586. .text(),
  2587. icons = this.options.icons,
  2588. multipleIcons = icons.primary && icons.secondary,
  2589. buttonClasses = [];
  2590. if (icons.primary || icons.secondary) {
  2591. if (this.options.text) {
  2592. buttonClasses.push("ui-button-text-icon" + (multipleIcons ? "s" : (icons.primary ? "-primary" : "-secondary")));
  2593. }
  2594. if (icons.primary) {
  2595. buttonElement.prepend("<span class='ui-button-icon-primary ui-icon " + icons.primary + "'></span>");
  2596. }
  2597. if (icons.secondary) {
  2598. buttonElement.append("<span class='ui-button-icon-secondary ui-icon " + icons.secondary + "'></span>");
  2599. }
  2600. if (!this.options.text) {
  2601. buttonClasses.push(multipleIcons ? "ui-button-icons-only" : "ui-button-icon-only");
  2602. if (!this.hasTitle) {
  2603. buttonElement.attr("title", $.trim(buttonText));
  2604. }
  2605. }
  2606. } else {
  2607. buttonClasses.push("ui-button-text-only");
  2608. }
  2609. buttonElement.addClass(buttonClasses.join(" "));
  2610. }
  2611. });
  2612. $.widget("ui.buttonset", {
  2613. version: "1.10.4",
  2614. options: {
  2615. items: "button, input[type=button], input[type=submit], input[type=reset], input[type=checkbox], input[type=radio], a, :data(ui-button)"
  2616. },
  2617. _create: function () {
  2618. this.element.addClass("ui-buttonset");
  2619. },
  2620. _init: function () {
  2621. this.refresh();
  2622. },
  2623. _setOption: function (key, value) {
  2624. if (key === "disabled") {
  2625. this.buttons.button("option", key, value);
  2626. }
  2627. this._super(key, value);
  2628. },
  2629. refresh: function () {
  2630. var rtl = this.element.css("direction") === "rtl";
  2631. this.buttons = this.element.find(this.options.items)
  2632. .filter(":ui-button")
  2633. .button("refresh")
  2634. .end()
  2635. .not(":ui-button")
  2636. .button()
  2637. .end()
  2638. .map(function () {
  2639. return $(this).button("widget")[0];
  2640. })
  2641. .removeClass("ui-corner-all ui-corner-left ui-corner-right")
  2642. .filter(":first")
  2643. .addClass(rtl ? "ui-corner-right" : "ui-corner-left")
  2644. .end()
  2645. .filter(":last")
  2646. .addClass(rtl ? "ui-corner-left" : "ui-corner-right")
  2647. .end()
  2648. .end();
  2649. },
  2650. _destroy: function () {
  2651. this.element.removeClass("ui-buttonset");
  2652. this.buttons
  2653. .map(function () {
  2654. return $(this).button("widget")[0];
  2655. })
  2656. .removeClass("ui-corner-left ui-corner-right")
  2657. .end()
  2658. .button("destroy");
  2659. }
  2660. });
  2661. }(jQuery));
  2662. (function ($, undefined) {
  2663. $.extend($.ui, { datepicker: { version: "1.10.4" } });
  2664. var PROP_NAME = "datepicker",
  2665. instActive;
  2666. /* Date picker manager.
  2667. Use the singleton instance of this class, $.datepicker, to interact with the date picker.
  2668. Settings for (groups of) date pickers are maintained in an instance object,
  2669. allowing multiple different settings on the same page. */
  2670. function Datepicker() {
  2671. this._curInst = null; // The current instance in use
  2672. this._keyEvent = false; // If the last event was a key event
  2673. this._disabledInputs = []; // List of date picker inputs that have been disabled
  2674. this._datepickerShowing = false; // True if the popup picker is showing , false if not
  2675. this._inDialog = false; // True if showing within a "dialog", false if not
  2676. this._mainDivId = "ui-datepicker-div"; // The ID of the main datepicker division
  2677. this._inlineClass = "ui-datepicker-inline"; // The name of the inline marker class
  2678. this._appendClass = "ui-datepicker-append"; // The name of the append marker class
  2679. this._triggerClass = "ui-datepicker-trigger"; // The name of the trigger marker class
  2680. this._dialogClass = "ui-datepicker-dialog"; // The name of the dialog marker class
  2681. this._disableClass = "ui-datepicker-disabled"; // The name of the disabled covering marker class
  2682. this._unselectableClass = "ui-datepicker-unselectable"; // The name of the unselectable cell marker class
  2683. this._currentClass = "ui-datepicker-current-day"; // The name of the current day marker class
  2684. this._dayOverClass = "ui-datepicker-days-cell-over"; // The name of the day hover marker class
  2685. this.regional = []; // Available regional settings, indexed by language code
  2686. this.regional[""] = { // Default regional settings
  2687. closeText: "Done", // Display text for close link
  2688. prevText: "Prev", // Display text for previous month link
  2689. nextText: "Next", // Display text for next month link
  2690. currentText: "Today", // Display text for current month link
  2691. monthNames: ["January", "February", "March", "April", "May", "June",
  2692. "July", "August", "September", "October", "November", "December"], // Names of months for drop-down and formatting
  2693. monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], // For formatting
  2694. dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], // For formatting
  2695. dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], // For formatting
  2696. dayNamesMin: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"], // Column headings for days starting at Sunday
  2697. weekHeader: "Wk", // Column header for week of the year
  2698. dateFormat: "mm/dd/yy", // See format options on parseDate
  2699. firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
  2700. isRTL: false, // True if right-to-left language, false if left-to-right
  2701. showMonthAfterYear: false, // True if the year select precedes month, false for month then year
  2702. yearSuffix: "" // Additional text to append to the year in the month headers
  2703. };
  2704. this._defaults = { // Global defaults for all the date picker instances
  2705. showOn: "focus", // "focus" for popup on focus,
  2706. // "button" for trigger button, or "both" for either
  2707. showAnim: "fadeIn", // Name of jQuery animation for popup
  2708. showOptions: {}, // Options for enhanced animations
  2709. defaultDate: null, // Used when field is blank: actual date,
  2710. // +/-number for offset from today, null for today
  2711. appendText: "", // Display text following the input box, e.g. showing the format
  2712. buttonText: "...", // Text for trigger button
  2713. buttonImage: "", // URL for trigger button image
  2714. buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
  2715. hideIfNoPrevNext: false, // True to hide next/previous month links
  2716. // if not applicable, false to just disable them
  2717. navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
  2718. gotoCurrent: false, // True if today link goes back to current selection instead
  2719. changeMonth: false, // True if month can be selected directly, false if only prev/next
  2720. changeYear: false, // True if year can be selected directly, false if only prev/next
  2721. yearRange: "c-10:c+10", // Range of years to display in drop-down,
  2722. // either relative to today's year (-nn:+nn), relative to currently displayed year
  2723. // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
  2724. showOtherMonths: false, // True to show dates in other months, false to leave blank
  2725. selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
  2726. showWeek: false, // True to show week of the year, false to not show it
  2727. calculateWeek: this.iso8601Week, // How to calculate the week of the year,
  2728. // takes a Date and returns the number of the week for it
  2729. shortYearCutoff: "+10", // Short year values < this are in the current century,
  2730. // > this are in the previous century,
  2731. // string value starting with "+" for current year + value
  2732. minDate: null, // The earliest selectable date, or null for no limit
  2733. maxDate: null, // The latest selectable date, or null for no limit
  2734. duration: "fast", // Duration of display/closure
  2735. beforeShowDay: null, // Function that takes a date and returns an array with
  2736. // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "",
  2737. // [2] = cell title (optional), e.g. $.datepicker.noWeekends
  2738. beforeShow: null, // Function that takes an input field and
  2739. // returns a set of custom settings for the date picker
  2740. onSelect: null, // Define a callback function when a date is selected
  2741. onChangeMonthYear: null, // Define a callback function when the month or year is changed
  2742. onClose: null, // Define a callback function when the datepicker is closed
  2743. numberOfMonths: 1, // Number of months to show at a time
  2744. showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
  2745. stepMonths: 1, // Number of months to step back/forward
  2746. stepBigMonths: 12, // Number of months to step back/forward for the big links
  2747. altField: "", // Selector for an alternate field to store selected dates into
  2748. altFormat: "", // The date format to use for the alternate field
  2749. constrainInput: true, // The input is constrained by the current date format
  2750. showButtonPanel: false, // True to show button panel, false to not show it
  2751. autoSize: false, // True to size the input for the date format, false to leave as is
  2752. disabled: false // The initial disabled state
  2753. };
  2754. $.extend(this._defaults, this.regional[""]);
  2755. this.dpDiv = bindHover($("<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>"));
  2756. }
  2757. $.extend(Datepicker.prototype, {
  2758. /* Class name added to elements to indicate already configured with a date picker. */
  2759. markerClassName: "hasDatepicker",
  2760. //Keep track of the maximum number of rows displayed (see #7043)
  2761. maxRows: 4,
  2762. // TODO rename to "widget" when switching to widget factory
  2763. _widgetDatepicker: function () {
  2764. return this.dpDiv;
  2765. },
  2766. /* Override the default settings for all instances of the date picker.
  2767. * @param settings object - the new settings to use as defaults (anonymous object)
  2768. * @return the manager object
  2769. */
  2770. setDefaults: function (settings) {
  2771. extendRemove(this._defaults, settings || {});
  2772. return this;
  2773. },
  2774. /* Attach the date picker to a jQuery selection.
  2775. * @param target element - the target input field or division or span
  2776. * @param settings object - the new settings to use for this date picker instance (anonymous)
  2777. */
  2778. _attachDatepicker: function (target, settings) {
  2779. var nodeName, inline, inst;
  2780. nodeName = target.nodeName.toLowerCase();
  2781. inline = (nodeName === "div" || nodeName === "span");
  2782. if (!target.id) {
  2783. this.uuid += 1;
  2784. target.id = "dp" + this.uuid;
  2785. }
  2786. inst = this._newInst($(target), inline);
  2787. inst.settings = $.extend({}, settings || {});
  2788. if (nodeName === "input") {
  2789. this._connectDatepicker(target, inst);
  2790. } else if (inline) {
  2791. this._inlineDatepicker(target, inst);
  2792. }
  2793. },
  2794. /* Create a new instance object. */
  2795. _newInst: function (target, inline) {
  2796. var id = target[0].id.replace(/([^A-Za-z0-9_\-])/g, "\\\\$1"); // escape jQuery meta chars
  2797. return {
  2798. id: id, input: target, // associated target
  2799. selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
  2800. drawMonth: 0, drawYear: 0, // month being drawn
  2801. inline: inline, // is datepicker inline or not
  2802. dpDiv: (!inline ? this.dpDiv : // presentation div
  2803. bindHover($("<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>")))
  2804. };
  2805. },
  2806. /* Attach the date picker to an input field. */
  2807. _connectDatepicker: function (target, inst) {
  2808. var input = $(target);
  2809. inst.append = $([]);
  2810. inst.trigger = $([]);
  2811. if (input.hasClass(this.markerClassName)) {
  2812. return;
  2813. }
  2814. this._attachments(input, inst);
  2815. input.addClass(this.markerClassName).keydown(this._doKeyDown).
  2816. keypress(this._doKeyPress).keyup(this._doKeyUp);
  2817. this._autoSize(inst);
  2818. $.data(target, PROP_NAME, inst);
  2819. //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
  2820. if (inst.settings.disabled) {
  2821. this._disableDatepicker(target);
  2822. }
  2823. },
  2824. /* Make attachments based on settings. */
  2825. _attachments: function (input, inst) {
  2826. var showOn, buttonText, buttonImage,
  2827. appendText = this._get(inst, "appendText"),
  2828. isRTL = this._get(inst, "isRTL");
  2829. if (inst.append) {
  2830. inst.append.remove();
  2831. }
  2832. if (appendText) {
  2833. inst.append = $("<span class='" + this._appendClass + "'>" + appendText + "</span>");
  2834. input[isRTL ? "before" : "after"](inst.append);
  2835. }
  2836. input.unbind("focus", this._showDatepicker);
  2837. if (inst.trigger) {
  2838. inst.trigger.remove();
  2839. }
  2840. showOn = this._get(inst, "showOn");
  2841. if (showOn === "focus" || showOn === "both") { // pop-up date picker when in the marked field
  2842. input.focus(this._showDatepicker);
  2843. }
  2844. if (showOn === "button" || showOn === "both") { // pop-up date picker when button clicked
  2845. buttonText = this._get(inst, "buttonText");
  2846. buttonImage = this._get(inst, "buttonImage");
  2847. inst.trigger = $(this._get(inst, "buttonImageOnly") ?
  2848. $("<img/>").addClass(this._triggerClass).
  2849. attr({ src: buttonImage, alt: buttonText, title: buttonText }) :
  2850. $("<button type='button'></button>").addClass(this._triggerClass).
  2851. html(!buttonImage ? buttonText : $("<img/>").attr(
  2852. { src: buttonImage, alt: buttonText, title: buttonText })));
  2853. input[isRTL ? "before" : "after"](inst.trigger);
  2854. inst.trigger.click(function () {
  2855. if ($.datepicker._datepickerShowing && $.datepicker._lastInput === input[0]) {
  2856. $.datepicker._hideDatepicker();
  2857. } else if ($.datepicker._datepickerShowing && $.datepicker._lastInput !== input[0]) {
  2858. $.datepicker._hideDatepicker();
  2859. $.datepicker._showDatepicker(input[0]);
  2860. } else {
  2861. $.datepicker._showDatepicker(input[0]);
  2862. }
  2863. return false;
  2864. });
  2865. }
  2866. },
  2867. /* Apply the maximum length for the date format. */
  2868. _autoSize: function (inst) {
  2869. if (this._get(inst, "autoSize") && !inst.inline) {
  2870. var findMax, max, maxI, i,
  2871. date = new Date(2009, 12 - 1, 20), // Ensure double digits
  2872. dateFormat = this._get(inst, "dateFormat");
  2873. if (dateFormat.match(/[DM]/)) {
  2874. findMax = function (names) {
  2875. max = 0;
  2876. maxI = 0;
  2877. for (i = 0; i < names.length; i++) {
  2878. if (names[i].length > max) {
  2879. max = names[i].length;
  2880. maxI = i;
  2881. }
  2882. }
  2883. return maxI;
  2884. };
  2885. date.setMonth(findMax(this._get(inst, (dateFormat.match(/MM/) ?
  2886. "monthNames" : "monthNamesShort"))));
  2887. date.setDate(findMax(this._get(inst, (dateFormat.match(/DD/) ?
  2888. "dayNames" : "dayNamesShort"))) + 20 - date.getDay());
  2889. }
  2890. inst.input.attr("size", this._formatDate(inst, date).length);
  2891. }
  2892. },
  2893. /* Attach an inline date picker to a div. */
  2894. _inlineDatepicker: function (target, inst) {
  2895. var divSpan = $(target);
  2896. if (divSpan.hasClass(this.markerClassName)) {
  2897. return;
  2898. }
  2899. divSpan.addClass(this.markerClassName).append(inst.dpDiv);
  2900. $.data(target, PROP_NAME, inst);
  2901. this._setDate(inst, this._getDefaultDate(inst), true);
  2902. this._updateDatepicker(inst);
  2903. this._updateAlternate(inst);
  2904. //If disabled option is true, disable the datepicker before showing it (see ticket #5665)
  2905. if (inst.settings.disabled) {
  2906. this._disableDatepicker(target);
  2907. }
  2908. // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
  2909. // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
  2910. inst.dpDiv.css("display", "block");
  2911. },
  2912. /* Pop-up the date picker in a "dialog" box.
  2913. * @param input element - ignored
  2914. * @param date string or Date - the initial date to display
  2915. * @param onSelect function - the function to call when a date is selected
  2916. * @param settings object - update the dialog date picker instance's settings (anonymous object)
  2917. * @param pos int[2] - coordinates for the dialog's position within the screen or
  2918. * event - with x/y coordinates or
  2919. * leave empty for default (screen centre)
  2920. * @return the manager object
  2921. */
  2922. _dialogDatepicker: function (input, date, onSelect, settings, pos) {
  2923. var id, browserWidth, browserHeight, scrollX, scrollY,
  2924. inst = this._dialogInst; // internal instance
  2925. if (!inst) {
  2926. this.uuid += 1;
  2927. id = "dp" + this.uuid;
  2928. this._dialogInput = $("<input type='text' id='" + id +
  2929. "' style='position: absolute; top: -100px; width: 0px;'/>");
  2930. this._dialogInput.keydown(this._doKeyDown);
  2931. $("body").append(this._dialogInput);
  2932. inst = this._dialogInst = this._newInst(this._dialogInput, false);
  2933. inst.settings = {};
  2934. $.data(this._dialogInput[0], PROP_NAME, inst);
  2935. }
  2936. extendRemove(inst.settings, settings || {});
  2937. date = (date && date.constructor === Date ? this._formatDate(inst, date) : date);
  2938. this._dialogInput.val(date);
  2939. this._pos = (pos ? (pos.length ? pos : [pos.pageX, pos.pageY]) : null);
  2940. if (!this._pos) {
  2941. browserWidth = document.documentElement.clientWidth;
  2942. browserHeight = document.documentElement.clientHeight;
  2943. scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
  2944. scrollY = document.documentElement.scrollTop || document.body.scrollTop;
  2945. this._pos = // should use actual width/height below
  2946. [(browserWidth / 2) - 100 + scrollX, (browserHeight / 2) - 150 + scrollY];
  2947. }
  2948. // move input on screen for focus, but hidden behind dialog
  2949. this._dialogInput.css("left", (this._pos[0] + 20) + "px").css("top", this._pos[1] + "px");
  2950. inst.settings.onSelect = onSelect;
  2951. this._inDialog = true;
  2952. this.dpDiv.addClass(this._dialogClass);
  2953. this._showDatepicker(this._dialogInput[0]);
  2954. if ($.blockUI) {
  2955. $.blockUI(this.dpDiv);
  2956. }
  2957. $.data(this._dialogInput[0], PROP_NAME, inst);
  2958. return this;
  2959. },
  2960. /* Detach a datepicker from its control.
  2961. * @param target element - the target input field or division or span
  2962. */
  2963. _destroyDatepicker: function (target) {
  2964. var nodeName,
  2965. $target = $(target),
  2966. inst = $.data(target, PROP_NAME);
  2967. if (!$target.hasClass(this.markerClassName)) {
  2968. return;
  2969. }
  2970. nodeName = target.nodeName.toLowerCase();
  2971. $.removeData(target, PROP_NAME);
  2972. if (nodeName === "input") {
  2973. inst.append.remove();
  2974. inst.trigger.remove();
  2975. $target.removeClass(this.markerClassName).
  2976. unbind("focus", this._showDatepicker).
  2977. unbind("keydown", this._doKeyDown).
  2978. unbind("keypress", this._doKeyPress).
  2979. unbind("keyup", this._doKeyUp);
  2980. } else if (nodeName === "div" || nodeName === "span") {
  2981. $target.removeClass(this.markerClassName).empty();
  2982. }
  2983. },
  2984. /* Enable the date picker to a jQuery selection.
  2985. * @param target element - the target input field or division or span
  2986. */
  2987. _enableDatepicker: function (target) {
  2988. var nodeName, inline,
  2989. $target = $(target),
  2990. inst = $.data(target, PROP_NAME);
  2991. if (!$target.hasClass(this.markerClassName)) {
  2992. return;
  2993. }
  2994. nodeName = target.nodeName.toLowerCase();
  2995. if (nodeName === "input") {
  2996. target.disabled = false;
  2997. inst.trigger.filter("button").
  2998. each(function () { this.disabled = false; }).end().
  2999. filter("img").css({ opacity: "1.0", cursor: "" });
  3000. } else if (nodeName === "div" || nodeName === "span") {
  3001. inline = $target.children("." + this._inlineClass);
  3002. inline.children().removeClass("ui-state-disabled");
  3003. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  3004. prop("disabled", false);
  3005. }
  3006. this._disabledInputs = $.map(this._disabledInputs,
  3007. function (value) { return (value === target ? null : value); }); // delete entry
  3008. },
  3009. /* Disable the date picker to a jQuery selection.
  3010. * @param target element - the target input field or division or span
  3011. */
  3012. _disableDatepicker: function (target) {
  3013. var nodeName, inline,
  3014. $target = $(target),
  3015. inst = $.data(target, PROP_NAME);
  3016. if (!$target.hasClass(this.markerClassName)) {
  3017. return;
  3018. }
  3019. nodeName = target.nodeName.toLowerCase();
  3020. if (nodeName === "input") {
  3021. target.disabled = true;
  3022. inst.trigger.filter("button").
  3023. each(function () { this.disabled = true; }).end().
  3024. filter("img").css({ opacity: "0.5", cursor: "default" });
  3025. } else if (nodeName === "div" || nodeName === "span") {
  3026. inline = $target.children("." + this._inlineClass);
  3027. inline.children().addClass("ui-state-disabled");
  3028. inline.find("select.ui-datepicker-month, select.ui-datepicker-year").
  3029. prop("disabled", true);
  3030. }
  3031. this._disabledInputs = $.map(this._disabledInputs,
  3032. function (value) { return (value === target ? null : value); }); // delete entry
  3033. this._disabledInputs[this._disabledInputs.length] = target;
  3034. },
  3035. /* Is the first field in a jQuery collection disabled as a datepicker?
  3036. * @param target element - the target input field or division or span
  3037. * @return boolean - true if disabled, false if enabled
  3038. */
  3039. _isDisabledDatepicker: function (target) {
  3040. if (!target) {
  3041. return false;
  3042. }
  3043. for (var i = 0; i < this._disabledInputs.length; i++) {
  3044. if (this._disabledInputs[i] === target) {
  3045. return true;
  3046. }
  3047. }
  3048. return false;
  3049. },
  3050. /* Retrieve the instance data for the target control.
  3051. * @param target element - the target input field or division or span
  3052. * @return object - the associated instance data
  3053. * @throws error if a jQuery problem getting data
  3054. */
  3055. _getInst: function (target) {
  3056. try {
  3057. return $.data(target, PROP_NAME);
  3058. }
  3059. catch (err) {
  3060. throw "Missing instance data for this datepicker";
  3061. }
  3062. },
  3063. /* Update or retrieve the settings for a date picker attached to an input field or division.
  3064. * @param target element - the target input field or division or span
  3065. * @param name object - the new settings to update or
  3066. * string - the name of the setting to change or retrieve,
  3067. * when retrieving also "all" for all instance settings or
  3068. * "defaults" for all global defaults
  3069. * @param value any - the new value for the setting
  3070. * (omit if above is an object or to retrieve a value)
  3071. */
  3072. _optionDatepicker: function (target, name, value) {
  3073. var settings, date, minDate, maxDate,
  3074. inst = this._getInst(target);
  3075. if (arguments.length === 2 && typeof name === "string") {
  3076. return (name === "defaults" ? $.extend({}, $.datepicker._defaults) :
  3077. (inst ? (name === "all" ? $.extend({}, inst.settings) :
  3078. this._get(inst, name)) : null));
  3079. }
  3080. settings = name || {};
  3081. if (typeof name === "string") {
  3082. settings = {};
  3083. settings[name] = value;
  3084. }
  3085. if (inst) {
  3086. if (this._curInst === inst) {
  3087. this._hideDatepicker();
  3088. }
  3089. date = this._getDateDatepicker(target, true);
  3090. minDate = this._getMinMaxDate(inst, "min");
  3091. maxDate = this._getMinMaxDate(inst, "max");
  3092. extendRemove(inst.settings, settings);
  3093. // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
  3094. if (minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined) {
  3095. inst.settings.minDate = this._formatDate(inst, minDate);
  3096. }
  3097. if (maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined) {
  3098. inst.settings.maxDate = this._formatDate(inst, maxDate);
  3099. }
  3100. if ("disabled" in settings) {
  3101. if (settings.disabled) {
  3102. this._disableDatepicker(target);
  3103. } else {
  3104. this._enableDatepicker(target);
  3105. }
  3106. }
  3107. this._attachments($(target), inst);
  3108. this._autoSize(inst);
  3109. this._setDate(inst, date);
  3110. this._updateAlternate(inst);
  3111. this._updateDatepicker(inst);
  3112. }
  3113. },
  3114. // change method deprecated
  3115. _changeDatepicker: function (target, name, value) {
  3116. this._optionDatepicker(target, name, value);
  3117. },
  3118. /* Redraw the date picker attached to an input field or division.
  3119. * @param target element - the target input field or division or span
  3120. */
  3121. _refreshDatepicker: function (target) {
  3122. var inst = this._getInst(target);
  3123. if (inst) {
  3124. this._updateDatepicker(inst);
  3125. }
  3126. },
  3127. /* Set the dates for a jQuery selection.
  3128. * @param target element - the target input field or division or span
  3129. * @param date Date - the new date
  3130. */
  3131. _setDateDatepicker: function (target, date) {
  3132. var inst = this._getInst(target);
  3133. if (inst) {
  3134. this._setDate(inst, date);
  3135. this._updateDatepicker(inst);
  3136. this._updateAlternate(inst);
  3137. }
  3138. },
  3139. /* Get the date(s) for the first entry in a jQuery selection.
  3140. * @param target element - the target input field or division or span
  3141. * @param noDefault boolean - true if no default date is to be used
  3142. * @return Date - the current date
  3143. */
  3144. _getDateDatepicker: function (target, noDefault) {
  3145. var inst = this._getInst(target);
  3146. if (inst && !inst.inline) {
  3147. this._setDateFromField(inst, noDefault);
  3148. }
  3149. return (inst ? this._getDate(inst) : null);
  3150. },
  3151. /* Handle keystrokes. */
  3152. _doKeyDown: function (event) {
  3153. var onSelect, dateStr, sel,
  3154. inst = $.datepicker._getInst(event.target),
  3155. handled = true,
  3156. isRTL = inst.dpDiv.is(".ui-datepicker-rtl");
  3157. inst._keyEvent = true;
  3158. if ($.datepicker._datepickerShowing) {
  3159. switch (event.keyCode) {
  3160. case 9: $.datepicker._hideDatepicker();
  3161. handled = false;
  3162. break; // hide on tab out
  3163. case 13: sel = $("td." + $.datepicker._dayOverClass + ":not(." +
  3164. $.datepicker._currentClass + ")", inst.dpDiv);
  3165. if (sel[0]) {
  3166. $.datepicker._selectDay(event.target, inst.selectedMonth, inst.selectedYear, sel[0]);
  3167. }
  3168. onSelect = $.datepicker._get(inst, "onSelect");
  3169. if (onSelect) {
  3170. dateStr = $.datepicker._formatDate(inst);
  3171. // trigger custom callback
  3172. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]);
  3173. } else {
  3174. $.datepicker._hideDatepicker();
  3175. }
  3176. return false; // don't submit the form
  3177. case 27: $.datepicker._hideDatepicker();
  3178. break; // hide on escape
  3179. case 33: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  3180. -$.datepicker._get(inst, "stepBigMonths") :
  3181. -$.datepicker._get(inst, "stepMonths")), "M");
  3182. break; // previous month/year on page up/+ ctrl
  3183. case 34: $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  3184. +$.datepicker._get(inst, "stepBigMonths") :
  3185. +$.datepicker._get(inst, "stepMonths")), "M");
  3186. break; // next month/year on page down/+ ctrl
  3187. case 35: if (event.ctrlKey || event.metaKey) {
  3188. $.datepicker._clearDate(event.target);
  3189. }
  3190. handled = event.ctrlKey || event.metaKey;
  3191. break; // clear on ctrl or command +end
  3192. case 36: if (event.ctrlKey || event.metaKey) {
  3193. $.datepicker._gotoToday(event.target);
  3194. }
  3195. handled = event.ctrlKey || event.metaKey;
  3196. break; // current on ctrl or command +home
  3197. case 37: if (event.ctrlKey || event.metaKey) {
  3198. $.datepicker._adjustDate(event.target, (isRTL ? +1 : -1), "D");
  3199. }
  3200. handled = event.ctrlKey || event.metaKey;
  3201. // -1 day on ctrl or command +left
  3202. if (event.originalEvent.altKey) {
  3203. $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  3204. -$.datepicker._get(inst, "stepBigMonths") :
  3205. -$.datepicker._get(inst, "stepMonths")), "M");
  3206. }
  3207. // next month/year on alt +left on Mac
  3208. break;
  3209. case 38: if (event.ctrlKey || event.metaKey) {
  3210. $.datepicker._adjustDate(event.target, -7, "D");
  3211. }
  3212. handled = event.ctrlKey || event.metaKey;
  3213. break; // -1 week on ctrl or command +up
  3214. case 39: if (event.ctrlKey || event.metaKey) {
  3215. $.datepicker._adjustDate(event.target, (isRTL ? -1 : +1), "D");
  3216. }
  3217. handled = event.ctrlKey || event.metaKey;
  3218. // +1 day on ctrl or command +right
  3219. if (event.originalEvent.altKey) {
  3220. $.datepicker._adjustDate(event.target, (event.ctrlKey ?
  3221. +$.datepicker._get(inst, "stepBigMonths") :
  3222. +$.datepicker._get(inst, "stepMonths")), "M");
  3223. }
  3224. // next month/year on alt +right
  3225. break;
  3226. case 40: if (event.ctrlKey || event.metaKey) {
  3227. $.datepicker._adjustDate(event.target, +7, "D");
  3228. }
  3229. handled = event.ctrlKey || event.metaKey;
  3230. break; // +1 week on ctrl or command +down
  3231. default: handled = false;
  3232. }
  3233. } else if (event.keyCode === 36 && event.ctrlKey) { // display the date picker on ctrl+home
  3234. $.datepicker._showDatepicker(this);
  3235. } else {
  3236. handled = false;
  3237. }
  3238. if (handled) {
  3239. event.preventDefault();
  3240. event.stopPropagation();
  3241. }
  3242. },
  3243. /* Filter entered characters - based on date format. */
  3244. _doKeyPress: function (event) {
  3245. var chars, chr,
  3246. inst = $.datepicker._getInst(event.target);
  3247. if ($.datepicker._get(inst, "constrainInput")) {
  3248. chars = $.datepicker._possibleChars($.datepicker._get(inst, "dateFormat"));
  3249. chr = String.fromCharCode(event.charCode == null ? event.keyCode : event.charCode);
  3250. return event.ctrlKey || event.metaKey || (chr < " " || !chars || chars.indexOf(chr) > -1);
  3251. }
  3252. },
  3253. /* Synchronise manual entry and field/alternate field. */
  3254. _doKeyUp: function (event) {
  3255. var date,
  3256. inst = $.datepicker._getInst(event.target);
  3257. if (inst.input.val() !== inst.lastVal) {
  3258. try {
  3259. date = $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
  3260. (inst.input ? inst.input.val() : null),
  3261. $.datepicker._getFormatConfig(inst));
  3262. if (date) { // only if valid
  3263. $.datepicker._setDateFromField(inst);
  3264. $.datepicker._updateAlternate(inst);
  3265. $.datepicker._updateDatepicker(inst);
  3266. }
  3267. }
  3268. catch (err) {
  3269. }
  3270. }
  3271. return true;
  3272. },
  3273. /* Pop-up the date picker for a given input field.
  3274. * If false returned from beforeShow event handler do not show.
  3275. * @param input element - the input field attached to the date picker or
  3276. * event - if triggered by focus
  3277. */
  3278. _showDatepicker: function (input) {
  3279. input = input.target || input;
  3280. if (input.nodeName.toLowerCase() !== "input") { // find from button/image trigger
  3281. input = $("input", input.parentNode)[0];
  3282. }
  3283. if ($.datepicker._isDisabledDatepicker(input) || $.datepicker._lastInput === input) { // already here
  3284. return;
  3285. }
  3286. var inst, beforeShow, beforeShowSettings, isFixed,
  3287. offset, showAnim, duration;
  3288. inst = $.datepicker._getInst(input);
  3289. if ($.datepicker._curInst && $.datepicker._curInst !== inst) {
  3290. $.datepicker._curInst.dpDiv.stop(true, true);
  3291. if (inst && $.datepicker._datepickerShowing) {
  3292. $.datepicker._hideDatepicker($.datepicker._curInst.input[0]);
  3293. }
  3294. }
  3295. beforeShow = $.datepicker._get(inst, "beforeShow");
  3296. beforeShowSettings = beforeShow ? beforeShow.apply(input, [input, inst]) : {};
  3297. if (beforeShowSettings === false) {
  3298. return;
  3299. }
  3300. extendRemove(inst.settings, beforeShowSettings);
  3301. inst.lastVal = null;
  3302. $.datepicker._lastInput = input;
  3303. $.datepicker._setDateFromField(inst);
  3304. if ($.datepicker._inDialog) { // hide cursor
  3305. input.value = "";
  3306. }
  3307. if (!$.datepicker._pos) { // position below input
  3308. $.datepicker._pos = $.datepicker._findPos(input);
  3309. $.datepicker._pos[1] += input.offsetHeight; // add the height
  3310. }
  3311. isFixed = false;
  3312. $(input).parents().each(function () {
  3313. isFixed |= $(this).css("position") === "fixed";
  3314. return !isFixed;
  3315. });
  3316. offset = { left: $.datepicker._pos[0], top: $.datepicker._pos[1] };
  3317. $.datepicker._pos = null;
  3318. //to avoid flashes on Firefox
  3319. inst.dpDiv.empty();
  3320. // determine sizing offscreen
  3321. inst.dpDiv.css({ position: "absolute", display: "block", top: "-1000px" });
  3322. $.datepicker._updateDatepicker(inst);
  3323. // fix width for dynamic number of date pickers
  3324. // and adjust position before showing
  3325. offset = $.datepicker._checkOffset(inst, offset, isFixed);
  3326. inst.dpDiv.css({
  3327. position: ($.datepicker._inDialog && $.blockUI ?
  3328. "static" : (isFixed ? "fixed" : "absolute")), display: "none",
  3329. left: offset.left + "px", top: offset.top + "px"
  3330. });
  3331. if (!inst.inline) {
  3332. showAnim = $.datepicker._get(inst, "showAnim");
  3333. duration = $.datepicker._get(inst, "duration");
  3334. inst.dpDiv.zIndex($(input).zIndex() + 1);
  3335. $.datepicker._datepickerShowing = true;
  3336. if ($.effects && $.effects.effect[showAnim]) {
  3337. inst.dpDiv.show(showAnim, $.datepicker._get(inst, "showOptions"), duration);
  3338. } else {
  3339. inst.dpDiv[showAnim || "show"](showAnim ? duration : null);
  3340. }
  3341. if ($.datepicker._shouldFocusInput(inst)) {
  3342. inst.input.focus();
  3343. }
  3344. $.datepicker._curInst = inst;
  3345. }
  3346. },
  3347. /* Generate the date picker content. */
  3348. _updateDatepicker: function (inst) {
  3349. this.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
  3350. instActive = inst; // for delegate hover events
  3351. inst.dpDiv.empty().append(this._generateHTML(inst));
  3352. this._attachHandlers(inst);
  3353. inst.dpDiv.find("." + this._dayOverClass + " a").mouseover();
  3354. var origyearshtml,
  3355. numMonths = this._getNumberOfMonths(inst),
  3356. cols = numMonths[1],
  3357. width = 17;
  3358. inst.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width("");
  3359. if (cols > 1) {
  3360. inst.dpDiv.addClass("ui-datepicker-multi-" + cols).css("width", (width * cols) + "em");
  3361. }
  3362. inst.dpDiv[(numMonths[0] !== 1 || numMonths[1] !== 1 ? "add" : "remove") +
  3363. "Class"]("ui-datepicker-multi");
  3364. inst.dpDiv[(this._get(inst, "isRTL") ? "add" : "remove") +
  3365. "Class"]("ui-datepicker-rtl");
  3366. if (inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput(inst)) {
  3367. inst.input.focus();
  3368. }
  3369. // deffered render of the years select (to avoid flashes on Firefox)
  3370. if (inst.yearshtml) {
  3371. origyearshtml = inst.yearshtml;
  3372. setTimeout(function () {
  3373. //assure that inst.yearshtml didn't change.
  3374. if (origyearshtml === inst.yearshtml && inst.yearshtml) {
  3375. inst.dpDiv.find("select.ui-datepicker-year:first").replaceWith(inst.yearshtml);
  3376. }
  3377. origyearshtml = inst.yearshtml = null;
  3378. }, 0);
  3379. }
  3380. },
  3381. // #6694 - don't focus the input if it's already focused
  3382. // this breaks the change event in IE
  3383. // Support: IE and jQuery <1.9
  3384. _shouldFocusInput: function (inst) {
  3385. return inst.input && inst.input.is(":visible") && !inst.input.is(":disabled") && !inst.input.is(":focus");
  3386. },
  3387. /* Check positioning to remain on screen. */
  3388. _checkOffset: function (inst, offset, isFixed) {
  3389. var dpWidth = inst.dpDiv.outerWidth(),
  3390. dpHeight = inst.dpDiv.outerHeight(),
  3391. inputWidth = inst.input ? inst.input.outerWidth() : 0,
  3392. inputHeight = inst.input ? inst.input.outerHeight() : 0,
  3393. viewWidth = document.documentElement.clientWidth + (isFixed ? 0 : $(document).scrollLeft()),
  3394. viewHeight = document.documentElement.clientHeight + (isFixed ? 0 : $(document).scrollTop());
  3395. offset.left -= (this._get(inst, "isRTL") ? (dpWidth - inputWidth) : 0);
  3396. offset.left -= (isFixed && offset.left === inst.input.offset().left) ? $(document).scrollLeft() : 0;
  3397. offset.top -= (isFixed && offset.top === (inst.input.offset().top + inputHeight)) ? $(document).scrollTop() : 0;
  3398. // now check if datepicker is showing outside window viewport - move to a better place if so.
  3399. offset.left -= Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
  3400. Math.abs(offset.left + dpWidth - viewWidth) : 0);
  3401. offset.top -= Math.min(offset.top, (offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
  3402. Math.abs(dpHeight + inputHeight) : 0);
  3403. return offset;
  3404. },
  3405. /* Find an object's position on the screen. */
  3406. _findPos: function (obj) {
  3407. var position,
  3408. inst = this._getInst(obj),
  3409. isRTL = this._get(inst, "isRTL");
  3410. while (obj && (obj.type === "hidden" || obj.nodeType !== 1 || $.expr.filters.hidden(obj))) {
  3411. obj = obj[isRTL ? "previousSibling" : "nextSibling"];
  3412. }
  3413. position = $(obj).offset();
  3414. return [position.left, position.top];
  3415. },
  3416. /* Hide the date picker from view.
  3417. * @param input element - the input field attached to the date picker
  3418. */
  3419. _hideDatepicker: function (input) {
  3420. var showAnim, duration, postProcess, onClose,
  3421. inst = this._curInst;
  3422. if (!inst || (input && inst !== $.data(input, PROP_NAME))) {
  3423. return;
  3424. }
  3425. if (this._datepickerShowing) {
  3426. showAnim = this._get(inst, "showAnim");
  3427. duration = this._get(inst, "duration");
  3428. postProcess = function () {
  3429. $.datepicker._tidyDialog(inst);
  3430. };
  3431. // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
  3432. if ($.effects && ($.effects.effect[showAnim] || $.effects[showAnim])) {
  3433. inst.dpDiv.hide(showAnim, $.datepicker._get(inst, "showOptions"), duration, postProcess);
  3434. } else {
  3435. inst.dpDiv[(showAnim === "slideDown" ? "slideUp" :
  3436. (showAnim === "fadeIn" ? "fadeOut" : "hide"))]((showAnim ? duration : null), postProcess);
  3437. }
  3438. if (!showAnim) {
  3439. postProcess();
  3440. }
  3441. this._datepickerShowing = false;
  3442. onClose = this._get(inst, "onClose");
  3443. if (onClose) {
  3444. onClose.apply((inst.input ? inst.input[0] : null), [(inst.input ? inst.input.val() : ""), inst]);
  3445. }
  3446. this._lastInput = null;
  3447. if (this._inDialog) {
  3448. this._dialogInput.css({ position: "absolute", left: "0", top: "-100px" });
  3449. if ($.blockUI) {
  3450. $.unblockUI();
  3451. $("body").append(this.dpDiv);
  3452. }
  3453. }
  3454. this._inDialog = false;
  3455. }
  3456. },
  3457. /* Tidy up after a dialog display. */
  3458. _tidyDialog: function (inst) {
  3459. inst.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar");
  3460. },
  3461. /* Close date picker if clicked elsewhere. */
  3462. _checkExternalClick: function (event) {
  3463. if (!$.datepicker._curInst) {
  3464. return;
  3465. }
  3466. var $target = $(event.target),
  3467. inst = $.datepicker._getInst($target[0]);
  3468. if ((($target[0].id !== $.datepicker._mainDivId &&
  3469. $target.parents("#" + $.datepicker._mainDivId).length === 0 &&
  3470. !$target.hasClass($.datepicker.markerClassName) &&
  3471. !$target.closest("." + $.datepicker._triggerClass).length &&
  3472. $.datepicker._datepickerShowing && !($.datepicker._inDialog && $.blockUI))) ||
  3473. ($target.hasClass($.datepicker.markerClassName) && $.datepicker._curInst !== inst)) {
  3474. $.datepicker._hideDatepicker();
  3475. }
  3476. },
  3477. /* Adjust one of the date sub-fields. */
  3478. _adjustDate: function (id, offset, period) {
  3479. var target = $(id),
  3480. inst = this._getInst(target[0]);
  3481. if (this._isDisabledDatepicker(target[0])) {
  3482. return;
  3483. }
  3484. this._adjustInstDate(inst, offset +
  3485. (period === "M" ? this._get(inst, "showCurrentAtPos") : 0), // undo positioning
  3486. period);
  3487. this._updateDatepicker(inst);
  3488. },
  3489. /* Action for current link. */
  3490. _gotoToday: function (id) {
  3491. var date,
  3492. target = $(id),
  3493. inst = this._getInst(target[0]);
  3494. if (this._get(inst, "gotoCurrent") && inst.currentDay) {
  3495. inst.selectedDay = inst.currentDay;
  3496. inst.drawMonth = inst.selectedMonth = inst.currentMonth;
  3497. inst.drawYear = inst.selectedYear = inst.currentYear;
  3498. } else {
  3499. date = new Date();
  3500. inst.selectedDay = date.getDate();
  3501. inst.drawMonth = inst.selectedMonth = date.getMonth();
  3502. inst.drawYear = inst.selectedYear = date.getFullYear();
  3503. }
  3504. this._notifyChange(inst);
  3505. this._adjustDate(target);
  3506. },
  3507. /* Action for selecting a new month/year. */
  3508. _selectMonthYear: function (id, select, period) {
  3509. var target = $(id),
  3510. inst = this._getInst(target[0]);
  3511. inst["selected" + (period === "M" ? "Month" : "Year")] =
  3512. inst["draw" + (period === "M" ? "Month" : "Year")] =
  3513. parseInt(select.options[select.selectedIndex].value, 10);
  3514. this._notifyChange(inst);
  3515. this._adjustDate(target);
  3516. },
  3517. /* Action for selecting a day. */
  3518. _selectDay: function (id, month, year, td) {
  3519. var inst,
  3520. target = $(id);
  3521. if ($(td).hasClass(this._unselectableClass) || this._isDisabledDatepicker(target[0])) {
  3522. return;
  3523. }
  3524. inst = this._getInst(target[0]);
  3525. inst.selectedDay = inst.currentDay = $("a", td).html();
  3526. inst.selectedMonth = inst.currentMonth = month;
  3527. inst.selectedYear = inst.currentYear = year;
  3528. this._selectDate(id, this._formatDate(inst,
  3529. inst.currentDay, inst.currentMonth, inst.currentYear));
  3530. },
  3531. /* Erase the input field and hide the date picker. */
  3532. _clearDate: function (id) {
  3533. var target = $(id);
  3534. this._selectDate(target, "");
  3535. },
  3536. /* Update the input field with the selected date. */
  3537. _selectDate: function (id, dateStr) {
  3538. var onSelect,
  3539. target = $(id),
  3540. inst = this._getInst(target[0]);
  3541. dateStr = (dateStr != null ? dateStr : this._formatDate(inst));
  3542. if (inst.input) {
  3543. inst.input.val(dateStr);
  3544. }
  3545. this._updateAlternate(inst);
  3546. onSelect = this._get(inst, "onSelect");
  3547. if (onSelect) {
  3548. onSelect.apply((inst.input ? inst.input[0] : null), [dateStr, inst]); // trigger custom callback
  3549. } else if (inst.input) {
  3550. inst.input.trigger("change"); // fire the change event
  3551. }
  3552. if (inst.inline) {
  3553. this._updateDatepicker(inst);
  3554. } else {
  3555. this._hideDatepicker();
  3556. this._lastInput = inst.input[0];
  3557. if (typeof (inst.input[0]) !== "object") {
  3558. inst.input.focus(); // restore focus
  3559. }
  3560. this._lastInput = null;
  3561. }
  3562. },
  3563. /* Update any alternate field to synchronise with the main field. */
  3564. _updateAlternate: function (inst) {
  3565. var altFormat, date, dateStr,
  3566. altField = this._get(inst, "altField");
  3567. if (altField) { // update alternate field too
  3568. altFormat = this._get(inst, "altFormat") || this._get(inst, "dateFormat");
  3569. date = this._getDate(inst);
  3570. dateStr = this.formatDate(altFormat, date, this._getFormatConfig(inst));
  3571. $(altField).each(function () { $(this).val(dateStr); });
  3572. }
  3573. },
  3574. /* Set as beforeShowDay function to prevent selection of weekends.
  3575. * @param date Date - the date to customise
  3576. * @return [boolean, string] - is this date selectable?, what is its CSS class?
  3577. */
  3578. noWeekends: function (date) {
  3579. var day = date.getDay();
  3580. return [(day > 0 && day < 6), ""];
  3581. },
  3582. /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
  3583. * @param date Date - the date to get the week for
  3584. * @return number - the number of the week within the year that contains this date
  3585. */
  3586. iso8601Week: function (date) {
  3587. var time,
  3588. checkDate = new Date(date.getTime());
  3589. // Find Thursday of this week starting on Monday
  3590. checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7));
  3591. time = checkDate.getTime();
  3592. checkDate.setMonth(0); // Compare with Jan 1
  3593. checkDate.setDate(1);
  3594. return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
  3595. },
  3596. /* Parse a string value into a date object.
  3597. * See formatDate below for the possible formats.
  3598. *
  3599. * @param format string - the expected format of the date
  3600. * @param value string - the date in the above format
  3601. * @param settings Object - attributes include:
  3602. * shortYearCutoff number - the cutoff year for determining the century (optional)
  3603. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  3604. * dayNames string[7] - names of the days from Sunday (optional)
  3605. * monthNamesShort string[12] - abbreviated names of the months (optional)
  3606. * monthNames string[12] - names of the months (optional)
  3607. * @return Date - the extracted date value or null if value is blank
  3608. */
  3609. parseDate: function (format, value, settings) {
  3610. if (format == null || value == null) {
  3611. throw "Invalid arguments";
  3612. }
  3613. value = (typeof value === "object" ? value.toString() : value + "");
  3614. if (value === "") {
  3615. return null;
  3616. }
  3617. var iFormat, dim, extra,
  3618. iValue = 0,
  3619. shortYearCutoffTemp = (settings ? settings.shortYearCutoff : null) || this._defaults.shortYearCutoff,
  3620. shortYearCutoff = (typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp :
  3621. new Date().getFullYear() % 100 + parseInt(shortYearCutoffTemp, 10)),
  3622. dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
  3623. dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
  3624. monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
  3625. monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
  3626. year = -1,
  3627. month = -1,
  3628. day = -1,
  3629. doy = -1,
  3630. literal = false,
  3631. date,
  3632. // Check whether a format character is doubled
  3633. lookAhead = function (match) {
  3634. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  3635. if (matches) {
  3636. iFormat++;
  3637. }
  3638. return matches;
  3639. },
  3640. // Extract a number from the string value
  3641. getNumber = function (match) {
  3642. var isDoubled = lookAhead(match),
  3643. size = (match === "@" ? 14 : (match === "!" ? 20 :
  3644. (match === "y" && isDoubled ? 4 : (match === "o" ? 3 : 2)))),
  3645. digits = new RegExp("^\\d{1," + size + "}"),
  3646. num = value.substring(iValue).match(digits);
  3647. if (!num) {
  3648. throw "Missing number at position " + iValue;
  3649. }
  3650. iValue += num[0].length;
  3651. return parseInt(num[0], 10);
  3652. },
  3653. // Extract a name from the string value and convert to an index
  3654. getName = function (match, shortNames, longNames) {
  3655. var index = -1,
  3656. names = $.map(lookAhead(match) ? longNames : shortNames, function (v, k) {
  3657. return [[k, v]];
  3658. }).sort(function (a, b) {
  3659. return -(a[1].length - b[1].length);
  3660. });
  3661. $.each(names, function (i, pair) {
  3662. var name = pair[1];
  3663. if (value.substr(iValue, name.length).toLowerCase() === name.toLowerCase()) {
  3664. index = pair[0];
  3665. iValue += name.length;
  3666. return false;
  3667. }
  3668. });
  3669. if (index !== -1) {
  3670. return index + 1;
  3671. } else {
  3672. throw "Unknown name at position " + iValue;
  3673. }
  3674. },
  3675. // Confirm that a literal character matches the string value
  3676. checkLiteral = function () {
  3677. if (value.charAt(iValue) !== format.charAt(iFormat)) {
  3678. throw "Unexpected literal at position " + iValue;
  3679. }
  3680. iValue++;
  3681. };
  3682. for (iFormat = 0; iFormat < format.length; iFormat++) {
  3683. if (literal) {
  3684. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  3685. literal = false;
  3686. } else {
  3687. checkLiteral();
  3688. }
  3689. } else {
  3690. switch (format.charAt(iFormat)) {
  3691. case "d":
  3692. day = getNumber("d");
  3693. break;
  3694. case "D":
  3695. getName("D", dayNamesShort, dayNames);
  3696. break;
  3697. case "o":
  3698. doy = getNumber("o");
  3699. break;
  3700. case "m":
  3701. month = getNumber("m");
  3702. break;
  3703. case "M":
  3704. month = getName("M", monthNamesShort, monthNames);
  3705. break;
  3706. case "y":
  3707. year = getNumber("y");
  3708. break;
  3709. case "@":
  3710. date = new Date(getNumber("@"));
  3711. year = date.getFullYear();
  3712. month = date.getMonth() + 1;
  3713. day = date.getDate();
  3714. break;
  3715. case "!":
  3716. date = new Date((getNumber("!") - this._ticksTo1970) / 10000);
  3717. year = date.getFullYear();
  3718. month = date.getMonth() + 1;
  3719. day = date.getDate();
  3720. break;
  3721. case "'":
  3722. if (lookAhead("'")) {
  3723. checkLiteral();
  3724. } else {
  3725. literal = true;
  3726. }
  3727. break;
  3728. default:
  3729. checkLiteral();
  3730. }
  3731. }
  3732. }
  3733. if (iValue < value.length) {
  3734. extra = value.substr(iValue);
  3735. if (!/^\s+/.test(extra)) {
  3736. throw "Extra/unparsed characters found in date: " + extra;
  3737. }
  3738. }
  3739. if (year === -1) {
  3740. year = new Date().getFullYear();
  3741. } else if (year < 100) {
  3742. year += new Date().getFullYear() - new Date().getFullYear() % 100 +
  3743. (year <= shortYearCutoff ? 0 : -100);
  3744. }
  3745. if (doy > -1) {
  3746. month = 1;
  3747. day = doy;
  3748. do {
  3749. dim = this._getDaysInMonth(year, month - 1);
  3750. if (day <= dim) {
  3751. break;
  3752. }
  3753. month++;
  3754. day -= dim;
  3755. } while (true);
  3756. }
  3757. date = this._daylightSavingAdjust(new Date(year, month - 1, day));
  3758. if (date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day) {
  3759. throw "Invalid date"; // E.g. 31/02/00
  3760. }
  3761. return date;
  3762. },
  3763. /* Standard date formats. */
  3764. ATOM: "yy-mm-dd", // RFC 3339 (ISO 8601)
  3765. COOKIE: "D, dd M yy",
  3766. ISO_8601: "yy-mm-dd",
  3767. RFC_822: "D, d M y",
  3768. RFC_850: "DD, dd-M-y",
  3769. RFC_1036: "D, d M y",
  3770. RFC_1123: "D, d M yy",
  3771. RFC_2822: "D, d M yy",
  3772. RSS: "D, d M y", // RFC 822
  3773. TICKS: "!",
  3774. TIMESTAMP: "@",
  3775. W3C: "yy-mm-dd", // ISO 8601
  3776. _ticksTo1970: (((1970 - 1) * 365 + Math.floor(1970 / 4) - Math.floor(1970 / 100) +
  3777. Math.floor(1970 / 400)) * 24 * 60 * 60 * 10000000),
  3778. /* Format a date object into a string value.
  3779. * The format can be combinations of the following:
  3780. * d - day of month (no leading zero)
  3781. * dd - day of month (two digit)
  3782. * o - day of year (no leading zeros)
  3783. * oo - day of year (three digit)
  3784. * D - day name short
  3785. * DD - day name long
  3786. * m - month of year (no leading zero)
  3787. * mm - month of year (two digit)
  3788. * M - month name short
  3789. * MM - month name long
  3790. * y - year (two digit)
  3791. * yy - year (four digit)
  3792. * @ - Unix timestamp (ms since 01/01/1970)
  3793. * ! - Windows ticks (100ns since 01/01/0001)
  3794. * "..." - literal text
  3795. * '' - single quote
  3796. *
  3797. * @param format string - the desired format of the date
  3798. * @param date Date - the date value to format
  3799. * @param settings Object - attributes include:
  3800. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  3801. * dayNames string[7] - names of the days from Sunday (optional)
  3802. * monthNamesShort string[12] - abbreviated names of the months (optional)
  3803. * monthNames string[12] - names of the months (optional)
  3804. * @return string - the date in the above format
  3805. */
  3806. formatDate: function (format, date, settings) {
  3807. if (!date) {
  3808. return "";
  3809. }
  3810. var iFormat,
  3811. dayNamesShort = (settings ? settings.dayNamesShort : null) || this._defaults.dayNamesShort,
  3812. dayNames = (settings ? settings.dayNames : null) || this._defaults.dayNames,
  3813. monthNamesShort = (settings ? settings.monthNamesShort : null) || this._defaults.monthNamesShort,
  3814. monthNames = (settings ? settings.monthNames : null) || this._defaults.monthNames,
  3815. // Check whether a format character is doubled
  3816. lookAhead = function (match) {
  3817. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  3818. if (matches) {
  3819. iFormat++;
  3820. }
  3821. return matches;
  3822. },
  3823. // Format a number, with leading zero if necessary
  3824. formatNumber = function (match, value, len) {
  3825. var num = "" + value;
  3826. if (lookAhead(match)) {
  3827. while (num.length < len) {
  3828. num = "0" + num;
  3829. }
  3830. }
  3831. return num;
  3832. },
  3833. // Format a name, short or long as requested
  3834. formatName = function (match, value, shortNames, longNames) {
  3835. return (lookAhead(match) ? longNames[value] : shortNames[value]);
  3836. },
  3837. output = "",
  3838. literal = false;
  3839. if (date) {
  3840. for (iFormat = 0; iFormat < format.length; iFormat++) {
  3841. if (literal) {
  3842. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  3843. literal = false;
  3844. } else {
  3845. output += format.charAt(iFormat);
  3846. }
  3847. } else {
  3848. switch (format.charAt(iFormat)) {
  3849. case "d":
  3850. output += formatNumber("d", date.getDate(), 2);
  3851. break;
  3852. case "D":
  3853. output += formatName("D", date.getDay(), dayNamesShort, dayNames);
  3854. break;
  3855. case "o":
  3856. output += formatNumber("o",
  3857. Math.round((new Date(date.getFullYear(), date.getMonth(), date.getDate()).getTime() - new Date(date.getFullYear(), 0, 0).getTime()) / 86400000), 3);
  3858. break;
  3859. case "m":
  3860. output += formatNumber("m", date.getMonth() + 1, 2);
  3861. break;
  3862. case "M":
  3863. output += formatName("M", date.getMonth(), monthNamesShort, monthNames);
  3864. break;
  3865. case "y":
  3866. output += (lookAhead("y") ? date.getFullYear() :
  3867. (date.getYear() % 100 < 10 ? "0" : "") + date.getYear() % 100);
  3868. break;
  3869. case "@":
  3870. output += date.getTime();
  3871. break;
  3872. case "!":
  3873. output += date.getTime() * 10000 + this._ticksTo1970;
  3874. break;
  3875. case "'":
  3876. if (lookAhead("'")) {
  3877. output += "'";
  3878. } else {
  3879. literal = true;
  3880. }
  3881. break;
  3882. default:
  3883. output += format.charAt(iFormat);
  3884. }
  3885. }
  3886. }
  3887. }
  3888. return output;
  3889. },
  3890. /* Extract all possible characters from the date format. */
  3891. _possibleChars: function (format) {
  3892. var iFormat,
  3893. chars = "",
  3894. literal = false,
  3895. // Check whether a format character is doubled
  3896. lookAhead = function (match) {
  3897. var matches = (iFormat + 1 < format.length && format.charAt(iFormat + 1) === match);
  3898. if (matches) {
  3899. iFormat++;
  3900. }
  3901. return matches;
  3902. };
  3903. for (iFormat = 0; iFormat < format.length; iFormat++) {
  3904. if (literal) {
  3905. if (format.charAt(iFormat) === "'" && !lookAhead("'")) {
  3906. literal = false;
  3907. } else {
  3908. chars += format.charAt(iFormat);
  3909. }
  3910. } else {
  3911. switch (format.charAt(iFormat)) {
  3912. case "d": case "m": case "y": case "@":
  3913. chars += "0123456789";
  3914. break;
  3915. case "D": case "M":
  3916. return null; // Accept anything
  3917. case "'":
  3918. if (lookAhead("'")) {
  3919. chars += "'";
  3920. } else {
  3921. literal = true;
  3922. }
  3923. break;
  3924. default:
  3925. chars += format.charAt(iFormat);
  3926. }
  3927. }
  3928. }
  3929. return chars;
  3930. },
  3931. /* Get a setting value, defaulting if necessary. */
  3932. _get: function (inst, name) {
  3933. return inst.settings[name] !== undefined ?
  3934. inst.settings[name] : this._defaults[name];
  3935. },
  3936. /* Parse existing date and initialise date picker. */
  3937. _setDateFromField: function (inst, noDefault) {
  3938. if (inst.input.val() === inst.lastVal) {
  3939. return;
  3940. }
  3941. var dateFormat = this._get(inst, "dateFormat"),
  3942. dates = inst.lastVal = inst.input ? inst.input.val() : null,
  3943. defaultDate = this._getDefaultDate(inst),
  3944. date = defaultDate,
  3945. settings = this._getFormatConfig(inst);
  3946. try {
  3947. date = this.parseDate(dateFormat, dates, settings) || defaultDate;
  3948. } catch (event) {
  3949. dates = (noDefault ? "" : dates);
  3950. }
  3951. inst.selectedDay = date.getDate();
  3952. inst.drawMonth = inst.selectedMonth = date.getMonth();
  3953. inst.drawYear = inst.selectedYear = date.getFullYear();
  3954. inst.currentDay = (dates ? date.getDate() : 0);
  3955. inst.currentMonth = (dates ? date.getMonth() : 0);
  3956. inst.currentYear = (dates ? date.getFullYear() : 0);
  3957. this._adjustInstDate(inst);
  3958. },
  3959. /* Retrieve the default date shown on opening. */
  3960. _getDefaultDate: function (inst) {
  3961. return this._restrictMinMax(inst,
  3962. this._determineDate(inst, this._get(inst, "defaultDate"), new Date()));
  3963. },
  3964. /* A date may be specified as an exact value or a relative one. */
  3965. _determineDate: function (inst, date, defaultDate) {
  3966. var offsetNumeric = function (offset) {
  3967. var date = new Date();
  3968. date.setDate(date.getDate() + offset);
  3969. return date;
  3970. },
  3971. offsetString = function (offset) {
  3972. try {
  3973. return $.datepicker.parseDate($.datepicker._get(inst, "dateFormat"),
  3974. offset, $.datepicker._getFormatConfig(inst));
  3975. }
  3976. catch (e) {
  3977. // Ignore
  3978. }
  3979. var date = (offset.toLowerCase().match(/^c/) ?
  3980. $.datepicker._getDate(inst) : null) || new Date(),
  3981. year = date.getFullYear(),
  3982. month = date.getMonth(),
  3983. day = date.getDate(),
  3984. pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,
  3985. matches = pattern.exec(offset);
  3986. while (matches) {
  3987. switch (matches[2] || "d") {
  3988. case "d": case "D":
  3989. day += parseInt(matches[1], 10); break;
  3990. case "w": case "W":
  3991. day += parseInt(matches[1], 10) * 7; break;
  3992. case "m": case "M":
  3993. month += parseInt(matches[1], 10);
  3994. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  3995. break;
  3996. case "y": case "Y":
  3997. year += parseInt(matches[1], 10);
  3998. day = Math.min(day, $.datepicker._getDaysInMonth(year, month));
  3999. break;
  4000. }
  4001. matches = pattern.exec(offset);
  4002. }
  4003. return new Date(year, month, day);
  4004. },
  4005. newDate = (date == null || date === "" ? defaultDate : (typeof date === "string" ? offsetString(date) :
  4006. (typeof date === "number" ? (isNaN(date) ? defaultDate : offsetNumeric(date)) : new Date(date.getTime()))));
  4007. newDate = (newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate);
  4008. if (newDate) {
  4009. newDate.setHours(0);
  4010. newDate.setMinutes(0);
  4011. newDate.setSeconds(0);
  4012. newDate.setMilliseconds(0);
  4013. }
  4014. return this._daylightSavingAdjust(newDate);
  4015. },
  4016. /* Handle switch to/from daylight saving.
  4017. * Hours may be non-zero on daylight saving cut-over:
  4018. * > 12 when midnight changeover, but then cannot generate
  4019. * midnight datetime, so jump to 1AM, otherwise reset.
  4020. * @param date (Date) the date to check
  4021. * @return (Date) the corrected date
  4022. */
  4023. _daylightSavingAdjust: function (date) {
  4024. if (!date) {
  4025. return null;
  4026. }
  4027. date.setHours(date.getHours() > 12 ? date.getHours() + 2 : 0);
  4028. return date;
  4029. },
  4030. /* Set the date(s) directly. */
  4031. _setDate: function (inst, date, noChange) {
  4032. var clear = !date,
  4033. origMonth = inst.selectedMonth,
  4034. origYear = inst.selectedYear,
  4035. newDate = this._restrictMinMax(inst, this._determineDate(inst, date, new Date()));
  4036. inst.selectedDay = inst.currentDay = newDate.getDate();
  4037. inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
  4038. inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
  4039. if ((origMonth !== inst.selectedMonth || origYear !== inst.selectedYear) && !noChange) {
  4040. this._notifyChange(inst);
  4041. }
  4042. this._adjustInstDate(inst);
  4043. if (inst.input) {
  4044. inst.input.val(clear ? "" : this._formatDate(inst));
  4045. }
  4046. },
  4047. /* Retrieve the date(s) directly. */
  4048. _getDate: function (inst) {
  4049. var startDate = (!inst.currentYear || (inst.input && inst.input.val() === "") ? null :
  4050. this._daylightSavingAdjust(new Date(
  4051. inst.currentYear, inst.currentMonth, inst.currentDay)));
  4052. return startDate;
  4053. },
  4054. /* Attach the onxxx handlers. These are declared statically so
  4055. * they work with static code transformers like Caja.
  4056. */
  4057. _attachHandlers: function (inst) {
  4058. var stepMonths = this._get(inst, "stepMonths"),
  4059. id = "#" + inst.id.replace(/\\\\/g, "\\");
  4060. inst.dpDiv.find("[data-handler]").map(function () {
  4061. var handler = {
  4062. prev: function () {
  4063. $.datepicker._adjustDate(id, -stepMonths, "M");
  4064. },
  4065. next: function () {
  4066. $.datepicker._adjustDate(id, +stepMonths, "M");
  4067. },
  4068. hide: function () {
  4069. $.datepicker._hideDatepicker();
  4070. },
  4071. today: function () {
  4072. $.datepicker._gotoToday(id);
  4073. },
  4074. selectDay: function () {
  4075. $.datepicker._selectDay(id, +this.getAttribute("data-month"), +this.getAttribute("data-year"), this);
  4076. return false;
  4077. },
  4078. selectMonth: function () {
  4079. $.datepicker._selectMonthYear(id, this, "M");
  4080. return false;
  4081. },
  4082. selectYear: function () {
  4083. $.datepicker._selectMonthYear(id, this, "Y");
  4084. return false;
  4085. }
  4086. };
  4087. $(this).bind(this.getAttribute("data-event"), handler[this.getAttribute("data-handler")]);
  4088. });
  4089. },
  4090. /* Generate the HTML for the current state of the date picker. */
  4091. _generateHTML: function (inst) {
  4092. var maxDraw, prevText, prev, nextText, next, currentText, gotoDate,
  4093. controls, buttonPanel, firstDay, showWeek, dayNames, dayNamesMin,
  4094. monthNames, monthNamesShort, beforeShowDay, showOtherMonths,
  4095. selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate,
  4096. cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows,
  4097. printDate, dRow, tbody, daySettings, otherMonth, unselectable,
  4098. tempDate = new Date(),
  4099. today = this._daylightSavingAdjust(
  4100. new Date(tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate())), // clear time
  4101. isRTL = this._get(inst, "isRTL"),
  4102. showButtonPanel = this._get(inst, "showButtonPanel"),
  4103. hideIfNoPrevNext = this._get(inst, "hideIfNoPrevNext"),
  4104. navigationAsDateFormat = this._get(inst, "navigationAsDateFormat"),
  4105. numMonths = this._getNumberOfMonths(inst),
  4106. showCurrentAtPos = this._get(inst, "showCurrentAtPos"),
  4107. stepMonths = this._get(inst, "stepMonths"),
  4108. isMultiMonth = (numMonths[0] !== 1 || numMonths[1] !== 1),
  4109. currentDate = this._daylightSavingAdjust((!inst.currentDay ? new Date(9999, 9, 9) :
  4110. new Date(inst.currentYear, inst.currentMonth, inst.currentDay))),
  4111. minDate = this._getMinMaxDate(inst, "min"),
  4112. maxDate = this._getMinMaxDate(inst, "max"),
  4113. drawMonth = inst.drawMonth - showCurrentAtPos,
  4114. drawYear = inst.drawYear;
  4115. if (drawMonth < 0) {
  4116. drawMonth += 12;
  4117. drawYear--;
  4118. }
  4119. if (maxDate) {
  4120. maxDraw = this._daylightSavingAdjust(new Date(maxDate.getFullYear(),
  4121. maxDate.getMonth() - (numMonths[0] * numMonths[1]) + 1, maxDate.getDate()));
  4122. maxDraw = (minDate && maxDraw < minDate ? minDate : maxDraw);
  4123. while (this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1)) > maxDraw) {
  4124. drawMonth--;
  4125. if (drawMonth < 0) {
  4126. drawMonth = 11;
  4127. drawYear--;
  4128. }
  4129. }
  4130. }
  4131. inst.drawMonth = drawMonth;
  4132. inst.drawYear = drawYear;
  4133. prevText = this._get(inst, "prevText");
  4134. prevText = (!navigationAsDateFormat ? prevText : this.formatDate(prevText,
  4135. this._daylightSavingAdjust(new Date(drawYear, drawMonth - stepMonths, 1)),
  4136. this._getFormatConfig(inst)));
  4137. prev = (this._canAdjustMonth(inst, -1, drawYear, drawMonth) ?
  4138. "<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click'" +
  4139. " title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + (isRTL ? "e" : "w") + "'>" + prevText + "</span></a>" :
  4140. (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>"));
  4141. nextText = this._get(inst, "nextText");
  4142. nextText = (!navigationAsDateFormat ? nextText : this.formatDate(nextText,
  4143. this._daylightSavingAdjust(new Date(drawYear, drawMonth + stepMonths, 1)),
  4144. this._getFormatConfig(inst)));
  4145. next = (this._canAdjustMonth(inst, +1, drawYear, drawMonth) ?
  4146. "<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click'" +
  4147. " title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + (isRTL ? "w" : "e") + "'>" + nextText + "</span></a>" :
  4148. (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>"));
  4149. currentText = this._get(inst, "currentText");
  4150. gotoDate = (this._get(inst, "gotoCurrent") && inst.currentDay ? currentDate : today);
  4151. currentText = (!navigationAsDateFormat ? currentText :
  4152. this.formatDate(currentText, gotoDate, this._getFormatConfig(inst)));
  4153. 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'>" +
  4154. this._get(inst, "closeText") + "</button>" : "");
  4155. buttonPanel = (showButtonPanel) ? "<div class='ui-datepicker-buttonpane ui-widget-content'>" + (isRTL ? controls : "") +
  4156. (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'" +
  4157. ">" + currentText + "</button>" : "") + (isRTL ? "" : controls) + "</div>" : "";
  4158. firstDay = parseInt(this._get(inst, "firstDay"), 10);
  4159. firstDay = (isNaN(firstDay) ? 0 : firstDay);
  4160. showWeek = this._get(inst, "showWeek");
  4161. dayNames = this._get(inst, "dayNames");
  4162. dayNamesMin = this._get(inst, "dayNamesMin");
  4163. monthNames = this._get(inst, "monthNames");
  4164. monthNamesShort = this._get(inst, "monthNamesShort");
  4165. beforeShowDay = this._get(inst, "beforeShowDay");
  4166. showOtherMonths = this._get(inst, "showOtherMonths");
  4167. selectOtherMonths = this._get(inst, "selectOtherMonths");
  4168. defaultDate = this._getDefaultDate(inst);
  4169. html = "";
  4170. dow;
  4171. for (row = 0; row < numMonths[0]; row++) {
  4172. group = "";
  4173. this.maxRows = 4;
  4174. for (col = 0; col < numMonths[1]; col++) {
  4175. selectedDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, inst.selectedDay));
  4176. cornerClass = " ui-corner-all";
  4177. calender = "";
  4178. if (isMultiMonth) {
  4179. calender += "<div class='ui-datepicker-group";
  4180. if (numMonths[1] > 1) {
  4181. switch (col) {
  4182. case 0: calender += " ui-datepicker-group-first";
  4183. cornerClass = " ui-corner-" + (isRTL ? "right" : "left"); break;
  4184. case numMonths[1] - 1: calender += " ui-datepicker-group-last";
  4185. cornerClass = " ui-corner-" + (isRTL ? "left" : "right"); break;
  4186. default: calender += " ui-datepicker-group-middle"; cornerClass = ""; break;
  4187. }
  4188. }
  4189. calender += "'>";
  4190. }
  4191. calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" +
  4192. (/all|left/.test(cornerClass) && row === 0 ? (isRTL ? next : prev) : "") +
  4193. (/all|right/.test(cornerClass) && row === 0 ? (isRTL ? prev : next) : "") +
  4194. this._generateMonthYearHeader(inst, drawMonth, drawYear, minDate, maxDate,
  4195. row > 0 || col > 0, monthNames, monthNamesShort) + // draw month headers
  4196. "</div><table class='ui-datepicker-calendar'><thead>" +
  4197. "<tr>";
  4198. thead = (showWeek ? "<th class='ui-datepicker-week-col'>" + this._get(inst, "weekHeader") + "</th>" : "");
  4199. for (dow = 0; dow < 7; dow++) { // days of the week
  4200. day = (dow + firstDay) % 7;
  4201. thead += "<th" + ((dow + firstDay + 6) % 7 >= 5 ? " class='ui-datepicker-week-end'" : "") + ">" +
  4202. "<span title='" + dayNames[day] + "'>" + dayNamesMin[day] + "</span></th>";
  4203. }
  4204. calender += thead + "</tr></thead><tbody>";
  4205. daysInMonth = this._getDaysInMonth(drawYear, drawMonth);
  4206. if (drawYear === inst.selectedYear && drawMonth === inst.selectedMonth) {
  4207. inst.selectedDay = Math.min(inst.selectedDay, daysInMonth);
  4208. }
  4209. leadDays = (this._getFirstDayOfMonth(drawYear, drawMonth) - firstDay + 7) % 7;
  4210. curRows = Math.ceil((leadDays + daysInMonth) / 7); // calculate the number of rows to generate
  4211. numRows = (isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows); //If multiple months, use the higher number of rows (see #7043)
  4212. this.maxRows = numRows;
  4213. printDate = this._daylightSavingAdjust(new Date(drawYear, drawMonth, 1 - leadDays));
  4214. for (dRow = 0; dRow < numRows; dRow++) { // create date picker rows
  4215. calender += "<tr>";
  4216. tbody = (!showWeek ? "" : "<td class='ui-datepicker-week-col'>" +
  4217. this._get(inst, "calculateWeek")(printDate) + "</td>");
  4218. for (dow = 0; dow < 7; dow++) { // create date picker days
  4219. daySettings = (beforeShowDay ?
  4220. beforeShowDay.apply((inst.input ? inst.input[0] : null), [printDate]) : [true, ""]);
  4221. otherMonth = (printDate.getMonth() !== drawMonth);
  4222. unselectable = (otherMonth && !selectOtherMonths) || !daySettings[0] ||
  4223. (minDate && printDate < minDate) || (maxDate && printDate > maxDate);
  4224. tbody += "<td class='" +
  4225. ((dow + firstDay + 6) % 7 >= 5 ? " ui-datepicker-week-end" : "") + // highlight weekends
  4226. (otherMonth ? " ui-datepicker-other-month" : "") + // highlight days from other months
  4227. ((printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent) || // user pressed key
  4228. (defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime()) ?
  4229. // or defaultDate is current printedDate and defaultDate is selectedDate
  4230. " " + this._dayOverClass : "") + // highlight selected day
  4231. (unselectable ? " " + this._unselectableClass + " ui-state-disabled" : "") + // highlight unselectable days
  4232. (otherMonth && !showOtherMonths ? "" : " " + daySettings[1] + // highlight custom dates
  4233. (printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "") + // highlight selected day
  4234. (printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "")) + "'" + // highlight today (if different)
  4235. ((!otherMonth || showOtherMonths) && daySettings[2] ? " title='" + daySettings[2].replace(/'/g, "&#39;") + "'" : "") + // cell title
  4236. (unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'") + ">" + // actions
  4237. (otherMonth && !showOtherMonths ? "&#xa0;" : // display for other months
  4238. (unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" +
  4239. (printDate.getTime() === today.getTime() ? " ui-state-highlight" : "") +
  4240. (printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "") + // highlight selected day
  4241. (otherMonth ? " ui-priority-secondary" : "") + // distinguish dates from other months
  4242. "' href='#'>" + printDate.getDate() + "</a>")) + "</td>"; // display selectable date
  4243. printDate.setDate(printDate.getDate() + 1);
  4244. printDate = this._daylightSavingAdjust(printDate);
  4245. }
  4246. calender += tbody + "</tr>";
  4247. }
  4248. drawMonth++;
  4249. if (drawMonth > 11) {
  4250. drawMonth = 0;
  4251. drawYear++;
  4252. }
  4253. calender += "</tbody></table>" + (isMultiMonth ? "</div>" +
  4254. ((numMonths[0] > 0 && col === numMonths[1] - 1) ? "<div class='ui-datepicker-row-break'></div>" : "") : "");
  4255. group += calender;
  4256. }
  4257. html += group;
  4258. }
  4259. html += buttonPanel;
  4260. inst._keyEvent = false;
  4261. return html;
  4262. },
  4263. /* Generate the month and year header. */
  4264. _generateMonthYearHeader: function (inst, drawMonth, drawYear, minDate, maxDate,
  4265. secondary, monthNames, monthNamesShort) {
  4266. var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear,
  4267. changeMonth = this._get(inst, "changeMonth"),
  4268. changeYear = this._get(inst, "changeYear"),
  4269. showMonthAfterYear = this._get(inst, "showMonthAfterYear"),
  4270. html = "<div class='ui-datepicker-title'>",
  4271. monthHtml = "";
  4272. // month selection
  4273. if (secondary || !changeMonth) {
  4274. monthHtml += "<span class='ui-datepicker-month'>" + monthNames[drawMonth] + "</span>";
  4275. } else {
  4276. inMinYear = (minDate && minDate.getFullYear() === drawYear);
  4277. inMaxYear = (maxDate && maxDate.getFullYear() === drawYear);
  4278. monthHtml += "<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>";
  4279. for (month = 0; month < 12; month++) {
  4280. if ((!inMinYear || month >= minDate.getMonth()) && (!inMaxYear || month <= maxDate.getMonth())) {
  4281. monthHtml += "<option value='" + month + "'" +
  4282. (month === drawMonth ? " selected='selected'" : "") +
  4283. ">" + monthNamesShort[month] + "</option>";
  4284. }
  4285. }
  4286. monthHtml += "</select>";
  4287. }
  4288. if (!showMonthAfterYear) {
  4289. html += monthHtml + (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "");
  4290. }
  4291. // year selection
  4292. if (!inst.yearshtml) {
  4293. inst.yearshtml = "";
  4294. if (secondary || !changeYear) {
  4295. html += "<span class='ui-datepicker-year'>" + drawYear + "</span>";
  4296. } else {
  4297. // determine range of years to display
  4298. years = this._get(inst, "yearRange").split(":");
  4299. thisYear = new Date().getFullYear();
  4300. determineYear = function (value) {
  4301. var year = (value.match(/c[+\-].*/) ? drawYear + parseInt(value.substring(1), 10) :
  4302. (value.match(/[+\-].*/) ? thisYear + parseInt(value, 10) :
  4303. parseInt(value, 10)));
  4304. return (isNaN(year) ? thisYear : year);
  4305. };
  4306. year = determineYear(years[0]);
  4307. endYear = Math.max(year, determineYear(years[1] || ""));
  4308. year = (minDate ? Math.max(year, minDate.getFullYear()) : year);
  4309. endYear = (maxDate ? Math.min(endYear, maxDate.getFullYear()) : endYear);
  4310. inst.yearshtml += "<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>";
  4311. for (; year <= endYear; year++) {
  4312. inst.yearshtml += "<option value='" + year + "'" +
  4313. (year === drawYear ? " selected='selected'" : "") +
  4314. ">" + year + "</option>";
  4315. }
  4316. inst.yearshtml += "</select>";
  4317. html += inst.yearshtml;
  4318. inst.yearshtml = null;
  4319. }
  4320. }
  4321. html += this._get(inst, "yearSuffix");
  4322. if (showMonthAfterYear) {
  4323. html += (secondary || !(changeMonth && changeYear) ? "&#xa0;" : "") + monthHtml;
  4324. }
  4325. html += "</div>"; // Close datepicker_header
  4326. return html;
  4327. },
  4328. /* Adjust one of the date sub-fields. */
  4329. _adjustInstDate: function (inst, offset, period) {
  4330. var year = inst.drawYear + (period === "Y" ? offset : 0),
  4331. month = inst.drawMonth + (period === "M" ? offset : 0),
  4332. day = Math.min(inst.selectedDay, this._getDaysInMonth(year, month)) + (period === "D" ? offset : 0),
  4333. date = this._restrictMinMax(inst, this._daylightSavingAdjust(new Date(year, month, day)));
  4334. inst.selectedDay = date.getDate();
  4335. inst.drawMonth = inst.selectedMonth = date.getMonth();
  4336. inst.drawYear = inst.selectedYear = date.getFullYear();
  4337. if (period === "M" || period === "Y") {
  4338. this._notifyChange(inst);
  4339. }
  4340. },
  4341. /* Ensure a date is within any min/max bounds. */
  4342. _restrictMinMax: function (inst, date) {
  4343. var minDate = this._getMinMaxDate(inst, "min"),
  4344. maxDate = this._getMinMaxDate(inst, "max"),
  4345. newDate = (minDate && date < minDate ? minDate : date);
  4346. return (maxDate && newDate > maxDate ? maxDate : newDate);
  4347. },
  4348. /* Notify change of month/year. */
  4349. _notifyChange: function (inst) {
  4350. var onChange = this._get(inst, "onChangeMonthYear");
  4351. if (onChange) {
  4352. onChange.apply((inst.input ? inst.input[0] : null),
  4353. [inst.selectedYear, inst.selectedMonth + 1, inst]);
  4354. }
  4355. },
  4356. /* Determine the number of months to show. */
  4357. _getNumberOfMonths: function (inst) {
  4358. var numMonths = this._get(inst, "numberOfMonths");
  4359. return (numMonths == null ? [1, 1] : (typeof numMonths === "number" ? [1, numMonths] : numMonths));
  4360. },
  4361. /* Determine the current maximum date - ensure no time components are set. */
  4362. _getMinMaxDate: function (inst, minMax) {
  4363. return this._determineDate(inst, this._get(inst, minMax + "Date"), null);
  4364. },
  4365. /* Find the number of days in a given month. */
  4366. _getDaysInMonth: function (year, month) {
  4367. return 32 - this._daylightSavingAdjust(new Date(year, month, 32)).getDate();
  4368. },
  4369. /* Find the day of the week of the first of a month. */
  4370. _getFirstDayOfMonth: function (year, month) {
  4371. return new Date(year, month, 1).getDay();
  4372. },
  4373. /* Determines if we should allow a "next/prev" month display change. */
  4374. _canAdjustMonth: function (inst, offset, curYear, curMonth) {
  4375. var numMonths = this._getNumberOfMonths(inst),
  4376. date = this._daylightSavingAdjust(new Date(curYear,
  4377. curMonth + (offset < 0 ? offset : numMonths[0] * numMonths[1]), 1));
  4378. if (offset < 0) {
  4379. date.setDate(this._getDaysInMonth(date.getFullYear(), date.getMonth()));
  4380. }
  4381. return this._isInRange(inst, date);
  4382. },
  4383. /* Is the given date in the accepted range? */
  4384. _isInRange: function (inst, date) {
  4385. var yearSplit, currentYear,
  4386. minDate = this._getMinMaxDate(inst, "min"),
  4387. maxDate = this._getMinMaxDate(inst, "max"),
  4388. minYear = null,
  4389. maxYear = null,
  4390. years = this._get(inst, "yearRange");
  4391. if (years) {
  4392. yearSplit = years.split(":");
  4393. currentYear = new Date().getFullYear();
  4394. minYear = parseInt(yearSplit[0], 10);
  4395. maxYear = parseInt(yearSplit[1], 10);
  4396. if (yearSplit[0].match(/[+\-].*/)) {
  4397. minYear += currentYear;
  4398. }
  4399. if (yearSplit[1].match(/[+\-].*/)) {
  4400. maxYear += currentYear;
  4401. }
  4402. }
  4403. return ((!minDate || date.getTime() >= minDate.getTime()) &&
  4404. (!maxDate || date.getTime() <= maxDate.getTime()) &&
  4405. (!minYear || date.getFullYear() >= minYear) &&
  4406. (!maxYear || date.getFullYear() <= maxYear));
  4407. },
  4408. /* Provide the configuration settings for formatting/parsing. */
  4409. _getFormatConfig: function (inst) {
  4410. var shortYearCutoff = this._get(inst, "shortYearCutoff");
  4411. shortYearCutoff = (typeof shortYearCutoff !== "string" ? shortYearCutoff :
  4412. new Date().getFullYear() % 100 + parseInt(shortYearCutoff, 10));
  4413. return {
  4414. shortYearCutoff: shortYearCutoff,
  4415. dayNamesShort: this._get(inst, "dayNamesShort"), dayNames: this._get(inst, "dayNames"),
  4416. monthNamesShort: this._get(inst, "monthNamesShort"), monthNames: this._get(inst, "monthNames")
  4417. };
  4418. },
  4419. /* Format the given date for display. */
  4420. _formatDate: function (inst, day, month, year) {
  4421. if (!day) {
  4422. inst.currentDay = inst.selectedDay;
  4423. inst.currentMonth = inst.selectedMonth;
  4424. inst.currentYear = inst.selectedYear;
  4425. }
  4426. var date = (day ? (typeof day === "object" ? day :
  4427. this._daylightSavingAdjust(new Date(year, month, day))) :
  4428. this._daylightSavingAdjust(new Date(inst.currentYear, inst.currentMonth, inst.currentDay)));
  4429. return this.formatDate(this._get(inst, "dateFormat"), date, this._getFormatConfig(inst));
  4430. }
  4431. });
  4432. /*
  4433. * Bind hover events for datepicker elements.
  4434. * Done via delegate so the binding only occurs once in the lifetime of the parent div.
  4435. * Global instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
  4436. */
  4437. function bindHover(dpDiv) {
  4438. var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";
  4439. return dpDiv.delegate(selector, "mouseout", function () {
  4440. $(this).removeClass("ui-state-hover");
  4441. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  4442. $(this).removeClass("ui-datepicker-prev-hover");
  4443. }
  4444. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  4445. $(this).removeClass("ui-datepicker-next-hover");
  4446. }
  4447. })
  4448. .delegate(selector, "mouseover", function () {
  4449. if (!$.datepicker._isDisabledDatepicker(instActive.inline ? dpDiv.parent()[0] : instActive.input[0])) {
  4450. $(this).parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover");
  4451. $(this).addClass("ui-state-hover");
  4452. if (this.className.indexOf("ui-datepicker-prev") !== -1) {
  4453. $(this).addClass("ui-datepicker-prev-hover");
  4454. }
  4455. if (this.className.indexOf("ui-datepicker-next") !== -1) {
  4456. $(this).addClass("ui-datepicker-next-hover");
  4457. }
  4458. }
  4459. });
  4460. }
  4461. /* jQuery extend now ignores nulls! */
  4462. function extendRemove(target, props) {
  4463. $.extend(target, props);
  4464. for (var name in props) {
  4465. if (props[name] == null) {
  4466. target[name] = props[name];
  4467. }
  4468. }
  4469. return target;
  4470. }
  4471. /* Invoke the datepicker functionality.
  4472. @param options string - a command, optionally followed by additional parameters or
  4473. Object - settings for attaching new datepicker functionality
  4474. @return jQuery object */
  4475. $.fn.datepicker = function (options) {
  4476. /* Verify an empty collection wasn't passed - Fixes #6976 */
  4477. if (!this.length) {
  4478. return this;
  4479. }
  4480. /* Initialise the date picker. */
  4481. if (!$.datepicker.initialized) {
  4482. $(document).mousedown($.datepicker._checkExternalClick);
  4483. $.datepicker.initialized = true;
  4484. }
  4485. /* Append datepicker main container to body if not exist. */
  4486. if ($("#" + $.datepicker._mainDivId).length === 0) {
  4487. $("body").append($.datepicker.dpDiv);
  4488. }
  4489. var otherArgs = Array.prototype.slice.call(arguments, 1);
  4490. if (typeof options === "string" && (options === "isDisabled" || options === "getDate" || options === "widget")) {
  4491. return $.datepicker["_" + options + "Datepicker"].
  4492. apply($.datepicker, [this[0]].concat(otherArgs));
  4493. }
  4494. if (options === "option" && arguments.length === 2 && typeof arguments[1] === "string") {
  4495. return $.datepicker["_" + options + "Datepicker"].
  4496. apply($.datepicker, [this[0]].concat(otherArgs));
  4497. }
  4498. return this.each(function () {
  4499. typeof options === "string" ?
  4500. $.datepicker["_" + options + "Datepicker"].
  4501. apply($.datepicker, [this].concat(otherArgs)) :
  4502. $.datepicker._attachDatepicker(this, options);
  4503. });
  4504. };
  4505. $.datepicker = new Datepicker(); // singleton instance
  4506. $.datepicker.initialized = false;
  4507. $.datepicker.uuid = new Date().getTime();
  4508. $.datepicker.version = "1.10.4";
  4509. })(jQuery);
  4510. (function ($, undefined) {
  4511. var sizeRelatedOptions = {
  4512. buttons: true,
  4513. height: true,
  4514. maxHeight: true,
  4515. maxWidth: true,
  4516. minHeight: true,
  4517. minWidth: true,
  4518. width: true
  4519. },
  4520. resizableRelatedOptions = {
  4521. maxHeight: true,
  4522. maxWidth: true,
  4523. minHeight: true,
  4524. minWidth: true
  4525. };
  4526. $.widget("ui.dialog", {
  4527. version: "1.10.4",
  4528. options: {
  4529. appendTo: "body",
  4530. autoOpen: true,
  4531. buttons: [],
  4532. closeOnEscape: true,
  4533. closeText: "close",
  4534. dialogClass: "",
  4535. draggable: true,
  4536. hide: null,
  4537. height: "auto",
  4538. maxHeight: null,
  4539. maxWidth: null,
  4540. minHeight: 150,
  4541. minWidth: 150,
  4542. modal: false,
  4543. position: {
  4544. my: "center",
  4545. at: "center",
  4546. of: window,
  4547. collision: "fit",
  4548. // Ensure the titlebar is always visible
  4549. using: function (pos) {
  4550. var topOffset = $(this).css(pos).offset().top;
  4551. if (topOffset < 0) {
  4552. $(this).css("top", pos.top - topOffset);
  4553. }
  4554. }
  4555. },
  4556. resizable: true,
  4557. show: null,
  4558. title: null,
  4559. width: 300,
  4560. // callbacks
  4561. beforeClose: null,
  4562. close: null,
  4563. drag: null,
  4564. dragStart: null,
  4565. dragStop: null,
  4566. focus: null,
  4567. open: null,
  4568. resize: null,
  4569. resizeStart: null,
  4570. resizeStop: null
  4571. },
  4572. _create: function () {
  4573. this.originalCss = {
  4574. display: this.element[0].style.display,
  4575. width: this.element[0].style.width,
  4576. minHeight: this.element[0].style.minHeight,
  4577. maxHeight: this.element[0].style.maxHeight,
  4578. height: this.element[0].style.height
  4579. };
  4580. this.originalPosition = {
  4581. parent: this.element.parent(),
  4582. index: this.element.parent().children().index(this.element)
  4583. };
  4584. this.originalTitle = this.element.attr("title");
  4585. this.options.title = this.options.title || this.originalTitle;
  4586. this._createWrapper();
  4587. this.element
  4588. .show()
  4589. .removeAttr("title")
  4590. .addClass("ui-dialog-content ui-widget-content")
  4591. .appendTo(this.uiDialog);
  4592. this._createTitlebar();
  4593. this._createButtonPane();
  4594. if (this.options.draggable && $.fn.draggable) {
  4595. this._makeDraggable();
  4596. }
  4597. if (this.options.resizable && $.fn.resizable) {
  4598. this._makeResizable();
  4599. }
  4600. this._isOpen = false;
  4601. },
  4602. _init: function () {
  4603. if (this.options.autoOpen) {
  4604. this.open();
  4605. }
  4606. },
  4607. _appendTo: function () {
  4608. var element = this.options.appendTo;
  4609. if (element && (element.jquery || element.nodeType)) {
  4610. return $(element);
  4611. }
  4612. return this.document.find(element || "body").eq(0);
  4613. },
  4614. _destroy: function () {
  4615. var next,
  4616. originalPosition = this.originalPosition;
  4617. this._destroyOverlay();
  4618. this.element
  4619. .removeUniqueId()
  4620. .removeClass("ui-dialog-content ui-widget-content")
  4621. .css(this.originalCss)
  4622. // Without detaching first, the following becomes really slow
  4623. .detach();
  4624. this.uiDialog.stop(true, true).remove();
  4625. if (this.originalTitle) {
  4626. this.element.attr("title", this.originalTitle);
  4627. }
  4628. next = originalPosition.parent.children().eq(originalPosition.index);
  4629. // Don't try to place the dialog next to itself (#8613)
  4630. if (next.length && next[0] !== this.element[0]) {
  4631. next.before(this.element);
  4632. } else {
  4633. originalPosition.parent.append(this.element);
  4634. }
  4635. },
  4636. widget: function () {
  4637. return this.uiDialog;
  4638. },
  4639. disable: $.noop,
  4640. enable: $.noop,
  4641. close: function (event) {
  4642. var activeElement,
  4643. that = this;
  4644. if (!this._isOpen || this._trigger("beforeClose", event) === false) {
  4645. return;
  4646. }
  4647. this._isOpen = false;
  4648. this._destroyOverlay();
  4649. if (!this.opener.filter(":focusable").focus().length) {
  4650. // support: IE9
  4651. // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
  4652. try {
  4653. activeElement = this.document[0].activeElement;
  4654. // Support: IE9, IE10
  4655. // If the <body> is blurred, IE will switch windows, see #4520
  4656. if (activeElement && activeElement.nodeName.toLowerCase() !== "body") {
  4657. // Hiding a focused element doesn't trigger blur in WebKit
  4658. // so in case we have nothing to focus on, explicitly blur the active element
  4659. // https://bugs.webkit.org/show_bug.cgi?id=47182
  4660. $(activeElement).blur();
  4661. }
  4662. } catch (error) { }
  4663. }
  4664. this._hide(this.uiDialog, this.options.hide, function () {
  4665. that._trigger("close", event);
  4666. });
  4667. },
  4668. isOpen: function () {
  4669. return this._isOpen;
  4670. },
  4671. moveToTop: function () {
  4672. this._moveToTop();
  4673. },
  4674. _moveToTop: function (event, silent) {
  4675. var moved = !!this.uiDialog.nextAll(":visible").insertBefore(this.uiDialog).length;
  4676. if (moved && !silent) {
  4677. this._trigger("focus", event);
  4678. }
  4679. return moved;
  4680. },
  4681. open: function () {
  4682. var that = this;
  4683. if (this._isOpen) {
  4684. if (this._moveToTop()) {
  4685. this._focusTabbable();
  4686. }
  4687. return;
  4688. }
  4689. this._isOpen = true;
  4690. this.opener = $(this.document[0].activeElement);
  4691. this._size();
  4692. this._position();
  4693. this._createOverlay();
  4694. this._moveToTop(null, true);
  4695. this._show(this.uiDialog, this.options.show, function () {
  4696. that._focusTabbable();
  4697. that._trigger("focus");
  4698. });
  4699. this._trigger("open");
  4700. },
  4701. _focusTabbable: function () {
  4702. // Set focus to the first match:
  4703. // 1. First element inside the dialog matching [autofocus]
  4704. // 2. Tabbable element inside the content element
  4705. // 3. Tabbable element inside the buttonpane
  4706. // 4. The close button
  4707. // 5. The dialog itself
  4708. var hasFocus = this.element.find("[autofocus]");
  4709. if (!hasFocus.length) {
  4710. hasFocus = this.element.find(":tabbable");
  4711. }
  4712. if (!hasFocus.length) {
  4713. hasFocus = this.uiDialogButtonPane.find(":tabbable");
  4714. }
  4715. if (!hasFocus.length) {
  4716. hasFocus = this.uiDialogTitlebarClose.filter(":tabbable");
  4717. }
  4718. if (!hasFocus.length) {
  4719. hasFocus = this.uiDialog;
  4720. }
  4721. hasFocus.eq(0).focus();
  4722. },
  4723. _keepFocus: function (event) {
  4724. function checkFocus() {
  4725. var activeElement = this.document[0].activeElement,
  4726. isActive = this.uiDialog[0] === activeElement ||
  4727. $.contains(this.uiDialog[0], activeElement);
  4728. if (!isActive) {
  4729. this._focusTabbable();
  4730. }
  4731. }
  4732. event.preventDefault();
  4733. checkFocus.call(this);
  4734. // support: IE
  4735. // IE <= 8 doesn't prevent moving focus even with event.preventDefault()
  4736. // so we check again later
  4737. this._delay(checkFocus);
  4738. },
  4739. _createWrapper: function () {
  4740. this.uiDialog = $("<div>")
  4741. .addClass("ui-dialog ui-widget ui-widget-content ui-corner-all ui-front " +
  4742. this.options.dialogClass)
  4743. .hide()
  4744. .attr({
  4745. // Setting tabIndex makes the div focusable
  4746. tabIndex: -1,
  4747. role: "dialog"
  4748. })
  4749. .appendTo(this._appendTo());
  4750. this._on(this.uiDialog, {
  4751. keydown: function (event) {
  4752. if (this.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
  4753. event.keyCode === $.ui.keyCode.ESCAPE) {
  4754. event.preventDefault();
  4755. this.close(event);
  4756. return;
  4757. }
  4758. // prevent tabbing out of dialogs
  4759. if (event.keyCode !== $.ui.keyCode.TAB) {
  4760. return;
  4761. }
  4762. var tabbables = this.uiDialog.find(":tabbable"),
  4763. first = tabbables.filter(":first"),
  4764. last = tabbables.filter(":last");
  4765. if ((event.target === last[0] || event.target === this.uiDialog[0]) && !event.shiftKey) {
  4766. first.focus(1);
  4767. event.preventDefault();
  4768. } else if ((event.target === first[0] || event.target === this.uiDialog[0]) && event.shiftKey) {
  4769. last.focus(1);
  4770. event.preventDefault();
  4771. }
  4772. },
  4773. mousedown: function (event) {
  4774. if (this._moveToTop(event)) {
  4775. this._focusTabbable();
  4776. }
  4777. }
  4778. });
  4779. // We assume that any existing aria-describedby attribute means
  4780. // that the dialog content is marked up properly
  4781. // otherwise we brute force the content as the description
  4782. if (!this.element.find("[aria-describedby]").length) {
  4783. this.uiDialog.attr({
  4784. "aria-describedby": this.element.uniqueId().attr("id")
  4785. });
  4786. }
  4787. },
  4788. _createTitlebar: function () {
  4789. var uiDialogTitle;
  4790. this.uiDialogTitlebar = $("<div>")
  4791. .addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix")
  4792. .prependTo(this.uiDialog);
  4793. this._on(this.uiDialogTitlebar, {
  4794. mousedown: function (event) {
  4795. // Don't prevent click on close button (#8838)
  4796. // Focusing a dialog that is partially scrolled out of view
  4797. // causes the browser to scroll it into view, preventing the click event
  4798. if (!$(event.target).closest(".ui-dialog-titlebar-close")) {
  4799. // Dialog isn't getting focus when dragging (#8063)
  4800. this.uiDialog.focus();
  4801. }
  4802. }
  4803. });
  4804. // support: IE
  4805. // Use type="button" to prevent enter keypresses in textboxes from closing the
  4806. // dialog in IE (#9312)
  4807. this.uiDialogTitlebarClose = $("<button type='button'></button>")
  4808. .button({
  4809. label: this.options.closeText,
  4810. icons: {
  4811. primary: "ui-icon-closethick"
  4812. },
  4813. text: false
  4814. })
  4815. .addClass("ui-dialog-titlebar-close")
  4816. .appendTo(this.uiDialogTitlebar);
  4817. this._on(this.uiDialogTitlebarClose, {
  4818. click: function (event) {
  4819. event.preventDefault();
  4820. this.close(event);
  4821. }
  4822. });
  4823. uiDialogTitle = $("<span>")
  4824. .uniqueId()
  4825. .addClass("ui-dialog-title")
  4826. .prependTo(this.uiDialogTitlebar);
  4827. this._title(uiDialogTitle);
  4828. this.uiDialog.attr({
  4829. "aria-labelledby": uiDialogTitle.attr("id")
  4830. });
  4831. },
  4832. _title: function (title) {
  4833. if (!this.options.title) {
  4834. title.html("&#160;");
  4835. }
  4836. title.text(this.options.title);
  4837. },
  4838. _createButtonPane: function () {
  4839. this.uiDialogButtonPane = $("<div>")
  4840. .addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix");
  4841. this.uiButtonSet = $("<div>")
  4842. .addClass("ui-dialog-buttonset")
  4843. .appendTo(this.uiDialogButtonPane);
  4844. this._createButtons();
  4845. },
  4846. _createButtons: function () {
  4847. var that = this,
  4848. buttons = this.options.buttons;
  4849. // if we already have a button pane, remove it
  4850. this.uiDialogButtonPane.remove();
  4851. this.uiButtonSet.empty();
  4852. if ($.isEmptyObject(buttons) || ($.isArray(buttons) && !buttons.length)) {
  4853. this.uiDialog.removeClass("ui-dialog-buttons");
  4854. return;
  4855. }
  4856. $.each(buttons, function (name, props) {
  4857. var click, buttonOptions;
  4858. props = $.isFunction(props) ?
  4859. { click: props, text: name } :
  4860. props;
  4861. // Default to a non-submitting button
  4862. props = $.extend({ type: "button" }, props);
  4863. // Change the context for the click callback to be the main element
  4864. click = props.click;
  4865. props.click = function () {
  4866. click.apply(that.element[0], arguments);
  4867. };
  4868. buttonOptions = {
  4869. icons: props.icons,
  4870. text: props.showText
  4871. };
  4872. delete props.icons;
  4873. delete props.showText;
  4874. $("<button></button>", props)
  4875. .button(buttonOptions)
  4876. .appendTo(that.uiButtonSet);
  4877. });
  4878. this.uiDialog.addClass("ui-dialog-buttons");
  4879. this.uiDialogButtonPane.appendTo(this.uiDialog);
  4880. },
  4881. _makeDraggable: function () {
  4882. var that = this,
  4883. options = this.options;
  4884. function filteredUi(ui) {
  4885. return {
  4886. position: ui.position,
  4887. offset: ui.offset
  4888. };
  4889. }
  4890. this.uiDialog.draggable({
  4891. cancel: ".ui-dialog-content, .ui-dialog-titlebar-close",
  4892. handle: ".ui-dialog-titlebar",
  4893. containment: "document",
  4894. start: function (event, ui) {
  4895. $(this).addClass("ui-dialog-dragging");
  4896. that._blockFrames();
  4897. that._trigger("dragStart", event, filteredUi(ui));
  4898. },
  4899. drag: function (event, ui) {
  4900. that._trigger("drag", event, filteredUi(ui));
  4901. },
  4902. stop: function (event, ui) {
  4903. options.position = [
  4904. ui.position.left - that.document.scrollLeft(),
  4905. ui.position.top - that.document.scrollTop()
  4906. ];
  4907. $(this).removeClass("ui-dialog-dragging");
  4908. that._unblockFrames();
  4909. that._trigger("dragStop", event, filteredUi(ui));
  4910. }
  4911. });
  4912. },
  4913. _makeResizable: function () {
  4914. var that = this,
  4915. options = this.options,
  4916. handles = options.resizable,
  4917. // .ui-resizable has position: relative defined in the stylesheet
  4918. // but dialogs have to use absolute or fixed positioning
  4919. position = this.uiDialog.css("position"),
  4920. resizeHandles = typeof handles === "string" ?
  4921. handles :
  4922. "n,e,s,w,se,sw,ne,nw";
  4923. function filteredUi(ui) {
  4924. return {
  4925. originalPosition: ui.originalPosition,
  4926. originalSize: ui.originalSize,
  4927. position: ui.position,
  4928. size: ui.size
  4929. };
  4930. }
  4931. this.uiDialog.resizable({
  4932. cancel: ".ui-dialog-content",
  4933. containment: "document",
  4934. alsoResize: this.element,
  4935. maxWidth: options.maxWidth,
  4936. maxHeight: options.maxHeight,
  4937. minWidth: options.minWidth,
  4938. minHeight: this._minHeight(),
  4939. handles: resizeHandles,
  4940. start: function (event, ui) {
  4941. $(this).addClass("ui-dialog-resizing");
  4942. that._blockFrames();
  4943. that._trigger("resizeStart", event, filteredUi(ui));
  4944. },
  4945. resize: function (event, ui) {
  4946. that._trigger("resize", event, filteredUi(ui));
  4947. },
  4948. stop: function (event, ui) {
  4949. options.height = $(this).height();
  4950. options.width = $(this).width();
  4951. $(this).removeClass("ui-dialog-resizing");
  4952. that._unblockFrames();
  4953. that._trigger("resizeStop", event, filteredUi(ui));
  4954. }
  4955. })
  4956. .css("position", position);
  4957. },
  4958. _minHeight: function () {
  4959. var options = this.options;
  4960. return options.height === "auto" ?
  4961. options.minHeight :
  4962. Math.min(options.minHeight, options.height);
  4963. },
  4964. _position: function () {
  4965. // Need to show the dialog to get the actual offset in the position plugin
  4966. var isVisible = this.uiDialog.is(":visible");
  4967. if (!isVisible) {
  4968. this.uiDialog.show();
  4969. }
  4970. this.uiDialog.position(this.options.position);
  4971. if (!isVisible) {
  4972. this.uiDialog.hide();
  4973. }
  4974. },
  4975. _setOptions: function (options) {
  4976. var that = this,
  4977. resize = false,
  4978. resizableOptions = {};
  4979. $.each(options, function (key, value) {
  4980. that._setOption(key, value);
  4981. if (key in sizeRelatedOptions) {
  4982. resize = true;
  4983. }
  4984. if (key in resizableRelatedOptions) {
  4985. resizableOptions[key] = value;
  4986. }
  4987. });
  4988. if (resize) {
  4989. this._size();
  4990. this._position();
  4991. }
  4992. if (this.uiDialog.is(":data(ui-resizable)")) {
  4993. this.uiDialog.resizable("option", resizableOptions);
  4994. }
  4995. },
  4996. _setOption: function (key, value) {
  4997. var isDraggable, isResizable,
  4998. uiDialog = this.uiDialog;
  4999. if (key === "dialogClass") {
  5000. uiDialog
  5001. .removeClass(this.options.dialogClass)
  5002. .addClass(value);
  5003. }
  5004. if (key === "disabled") {
  5005. return;
  5006. }
  5007. this._super(key, value);
  5008. if (key === "appendTo") {
  5009. this.uiDialog.appendTo(this._appendTo());
  5010. }
  5011. if (key === "buttons") {
  5012. this._createButtons();
  5013. }
  5014. if (key === "closeText") {
  5015. this.uiDialogTitlebarClose.button({
  5016. // Ensure that we always pass a string
  5017. label: "" + value
  5018. });
  5019. }
  5020. if (key === "draggable") {
  5021. isDraggable = uiDialog.is(":data(ui-draggable)");
  5022. if (isDraggable && !value) {
  5023. uiDialog.draggable("destroy");
  5024. }
  5025. if (!isDraggable && value) {
  5026. this._makeDraggable();
  5027. }
  5028. }
  5029. if (key === "position") {
  5030. this._position();
  5031. }
  5032. if (key === "resizable") {
  5033. // currently resizable, becoming non-resizable
  5034. isResizable = uiDialog.is(":data(ui-resizable)");
  5035. if (isResizable && !value) {
  5036. uiDialog.resizable("destroy");
  5037. }
  5038. // currently resizable, changing handles
  5039. if (isResizable && typeof value === "string") {
  5040. uiDialog.resizable("option", "handles", value);
  5041. }
  5042. // currently non-resizable, becoming resizable
  5043. if (!isResizable && value !== false) {
  5044. this._makeResizable();
  5045. }
  5046. }
  5047. if (key === "title") {
  5048. this._title(this.uiDialogTitlebar.find(".ui-dialog-title"));
  5049. }
  5050. },
  5051. _size: function () {
  5052. // If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
  5053. // divs will both have width and height set, so we need to reset them
  5054. var nonContentHeight, minContentHeight, maxContentHeight,
  5055. options = this.options;
  5056. // Reset content sizing
  5057. this.element.show().css({
  5058. width: "auto",
  5059. minHeight: 0,
  5060. maxHeight: "none",
  5061. height: 0
  5062. });
  5063. if (options.minWidth > options.width) {
  5064. options.width = options.minWidth;
  5065. }
  5066. // reset wrapper sizing
  5067. // determine the height of all the non-content elements
  5068. nonContentHeight = this.uiDialog.css({
  5069. height: "auto",
  5070. width: options.width
  5071. })
  5072. .outerHeight();
  5073. minContentHeight = Math.max(0, options.minHeight - nonContentHeight);
  5074. maxContentHeight = typeof options.maxHeight === "number" ?
  5075. Math.max(0, options.maxHeight - nonContentHeight) :
  5076. "none";
  5077. if (options.height === "auto") {
  5078. this.element.css({
  5079. minHeight: minContentHeight,
  5080. maxHeight: maxContentHeight,
  5081. height: "auto"
  5082. });
  5083. } else {
  5084. this.element.height(Math.max(0, options.height - nonContentHeight));
  5085. }
  5086. if (this.uiDialog.is(":data(ui-resizable)")) {
  5087. this.uiDialog.resizable("option", "minHeight", this._minHeight());
  5088. }
  5089. },
  5090. _blockFrames: function () {
  5091. this.iframeBlocks = this.document.find("iframe").map(function () {
  5092. var iframe = $(this);
  5093. return $("<div>")
  5094. .css({
  5095. position: "absolute",
  5096. width: iframe.outerWidth(),
  5097. height: iframe.outerHeight()
  5098. })
  5099. .appendTo(iframe.parent())
  5100. .offset(iframe.offset())[0];
  5101. });
  5102. },
  5103. _unblockFrames: function () {
  5104. if (this.iframeBlocks) {
  5105. this.iframeBlocks.remove();
  5106. delete this.iframeBlocks;
  5107. }
  5108. },
  5109. _allowInteraction: function (event) {
  5110. if ($(event.target).closest(".ui-dialog").length) {
  5111. return true;
  5112. }
  5113. // TODO: Remove hack when datepicker implements
  5114. // the .ui-front logic (#8989)
  5115. return !!$(event.target).closest(".ui-datepicker").length;
  5116. },
  5117. _createOverlay: function () {
  5118. if (!this.options.modal) {
  5119. return;
  5120. }
  5121. var that = this,
  5122. widgetFullName = this.widgetFullName;
  5123. if (!$.ui.dialog.overlayInstances) {
  5124. // Prevent use of anchors and inputs.
  5125. // We use a delay in case the overlay is created from an
  5126. // event that we're going to be cancelling. (#2804)
  5127. this._delay(function () {
  5128. // Handle .dialog().dialog("close") (#4065)
  5129. if ($.ui.dialog.overlayInstances) {
  5130. this.document.bind("focusin.dialog", function (event) {
  5131. if (!that._allowInteraction(event)) {
  5132. event.preventDefault();
  5133. $(".ui-dialog:visible:last .ui-dialog-content")
  5134. .data(widgetFullName)._focusTabbable();
  5135. }
  5136. });
  5137. }
  5138. });
  5139. }
  5140. this.overlay = $("<div>")
  5141. .addClass("ui-widget-overlay ui-front")
  5142. .appendTo(this._appendTo());
  5143. this._on(this.overlay, {
  5144. mousedown: "_keepFocus"
  5145. });
  5146. $.ui.dialog.overlayInstances++;
  5147. },
  5148. _destroyOverlay: function () {
  5149. if (!this.options.modal) {
  5150. return;
  5151. }
  5152. if (this.overlay) {
  5153. $.ui.dialog.overlayInstances--;
  5154. if (!$.ui.dialog.overlayInstances) {
  5155. this.document.unbind("focusin.dialog");
  5156. }
  5157. this.overlay.remove();
  5158. this.overlay = null;
  5159. }
  5160. }
  5161. });
  5162. $.ui.dialog.overlayInstances = 0;
  5163. // DEPRECATED
  5164. if ($.uiBackCompat !== false) {
  5165. // position option with array notation
  5166. // just override with old implementation
  5167. $.widget("ui.dialog", $.ui.dialog, {
  5168. _position: function () {
  5169. var position = this.options.position,
  5170. myAt = [],
  5171. offset = [0, 0],
  5172. isVisible;
  5173. if (position) {
  5174. if (typeof position === "string" || (typeof position === "object" && "0" in position)) {
  5175. myAt = position.split ? position.split(" ") : [position[0], position[1]];
  5176. if (myAt.length === 1) {
  5177. myAt[1] = myAt[0];
  5178. }
  5179. $.each(["left", "top"], function (i, offsetPosition) {
  5180. if (+myAt[i] === myAt[i]) {
  5181. offset[i] = myAt[i];
  5182. myAt[i] = offsetPosition;
  5183. }
  5184. });
  5185. position = {
  5186. my: myAt[0] + (offset[0] < 0 ? offset[0] : "+" + offset[0]) + " " +
  5187. myAt[1] + (offset[1] < 0 ? offset[1] : "+" + offset[1]),
  5188. at: myAt.join(" ")
  5189. };
  5190. }
  5191. position = $.extend({}, $.ui.dialog.prototype.options.position, position);
  5192. } else {
  5193. position = $.ui.dialog.prototype.options.position;
  5194. }
  5195. // need to show the dialog to get the actual offset in the position plugin
  5196. isVisible = this.uiDialog.is(":visible");
  5197. if (!isVisible) {
  5198. this.uiDialog.show();
  5199. }
  5200. this.uiDialog.position(position);
  5201. if (!isVisible) {
  5202. this.uiDialog.hide();
  5203. }
  5204. }
  5205. });
  5206. }
  5207. }(jQuery));
  5208. (function ($, undefined) {
  5209. $.widget("ui.draggable", $.ui.mouse, {
  5210. version: "1.10.4",
  5211. widgetEventPrefix: "drag",
  5212. options: {
  5213. addClasses: true,
  5214. appendTo: "parent",
  5215. axis: false,
  5216. connectToSortable: false,
  5217. containment: false,
  5218. cursor: "auto",
  5219. cursorAt: false,
  5220. grid: false,
  5221. handle: false,
  5222. helper: "original",
  5223. iframeFix: false,
  5224. opacity: false,
  5225. refreshPositions: false,
  5226. revert: false,
  5227. revertDuration: 500,
  5228. scope: "default",
  5229. scroll: true,
  5230. scrollSensitivity: 20,
  5231. scrollSpeed: 20,
  5232. snap: false,
  5233. snapMode: "both",
  5234. snapTolerance: 20,
  5235. stack: false,
  5236. zIndex: false,
  5237. // callbacks
  5238. drag: null,
  5239. start: null,
  5240. stop: null
  5241. },
  5242. _create: function () {
  5243. if (this.options.helper === "original" && !(/^(?:r|a|f)/).test(this.element.css("position"))) {
  5244. this.element[0].style.position = "relative";
  5245. }
  5246. if (this.options.addClasses) {
  5247. this.element.addClass("ui-draggable");
  5248. }
  5249. if (this.options.disabled) {
  5250. this.element.addClass("ui-draggable-disabled");
  5251. }
  5252. this._mouseInit();
  5253. },
  5254. _destroy: function () {
  5255. this.element.removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled");
  5256. this._mouseDestroy();
  5257. },
  5258. _mouseCapture: function (event) {
  5259. var o = this.options;
  5260. // among others, prevent a drag on a resizable-handle
  5261. if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) {
  5262. return false;
  5263. }
  5264. //Quit if we're not on a valid handle
  5265. this.handle = this._getHandle(event);
  5266. if (!this.handle) {
  5267. return false;
  5268. }
  5269. $(o.iframeFix === true ? "iframe" : o.iframeFix).each(function () {
  5270. $("<div class='ui-draggable-iframeFix' style='background: #fff;'></div>")
  5271. .css({
  5272. width: this.offsetWidth + "px", height: this.offsetHeight + "px",
  5273. position: "absolute", opacity: "0.001", zIndex: 1000
  5274. })
  5275. .css($(this).offset())
  5276. .appendTo("body");
  5277. });
  5278. return true;
  5279. },
  5280. _mouseStart: function (event) {
  5281. var o = this.options;
  5282. //Create and append the visible helper
  5283. this.helper = this._createHelper(event);
  5284. this.helper.addClass("ui-draggable-dragging");
  5285. //Cache the helper size
  5286. this._cacheHelperProportions();
  5287. //If ddmanager is used for droppables, set the global draggable
  5288. if ($.ui.ddmanager) {
  5289. $.ui.ddmanager.current = this;
  5290. }
  5291. /*
  5292. * - Position generation -
  5293. * This block generates everything position related - it's the core of draggables.
  5294. */
  5295. //Cache the margins of the original element
  5296. this._cacheMargins();
  5297. //Store the helper's css position
  5298. this.cssPosition = this.helper.css("position");
  5299. this.scrollParent = this.helper.scrollParent();
  5300. this.offsetParent = this.helper.offsetParent();
  5301. this.offsetParentCssPosition = this.offsetParent.css("position");
  5302. //The element's absolute position on the page minus margins
  5303. this.offset = this.positionAbs = this.element.offset();
  5304. this.offset = {
  5305. top: this.offset.top - this.margins.top,
  5306. left: this.offset.left - this.margins.left
  5307. };
  5308. //Reset scroll cache
  5309. this.offset.scroll = false;
  5310. $.extend(this.offset, {
  5311. click: { //Where the click happened, relative to the element
  5312. left: event.pageX - this.offset.left,
  5313. top: event.pageY - this.offset.top
  5314. },
  5315. parent: this._getParentOffset(),
  5316. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  5317. });
  5318. //Generate the original position
  5319. this.originalPosition = this.position = this._generatePosition(event);
  5320. this.originalPageX = event.pageX;
  5321. this.originalPageY = event.pageY;
  5322. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  5323. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  5324. //Set a containment if given in the options
  5325. this._setContainment();
  5326. //Trigger event + callbacks
  5327. if (this._trigger("start", event) === false) {
  5328. this._clear();
  5329. return false;
  5330. }
  5331. //Recache the helper size
  5332. this._cacheHelperProportions();
  5333. //Prepare the droppable offsets
  5334. if ($.ui.ddmanager && !o.dropBehaviour) {
  5335. $.ui.ddmanager.prepareOffsets(this, event);
  5336. }
  5337. this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  5338. //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
  5339. if ($.ui.ddmanager) {
  5340. $.ui.ddmanager.dragStart(this, event);
  5341. }
  5342. return true;
  5343. },
  5344. _mouseDrag: function (event, noPropagation) {
  5345. // reset any necessary cached properties (see #5009)
  5346. if (this.offsetParentCssPosition === "fixed") {
  5347. this.offset.parent = this._getParentOffset();
  5348. }
  5349. //Compute the helpers position
  5350. this.position = this._generatePosition(event);
  5351. this.positionAbs = this._convertPositionTo("absolute");
  5352. //Call plugins and callbacks and use the resulting position if something is returned
  5353. if (!noPropagation) {
  5354. var ui = this._uiHash();
  5355. if (this._trigger("drag", event, ui) === false) {
  5356. this._mouseUp({});
  5357. return false;
  5358. }
  5359. this.position = ui.position;
  5360. }
  5361. if (!this.options.axis || this.options.axis !== "y") {
  5362. this.helper[0].style.left = this.position.left + "px";
  5363. }
  5364. if (!this.options.axis || this.options.axis !== "x") {
  5365. this.helper[0].style.top = this.position.top + "px";
  5366. }
  5367. if ($.ui.ddmanager) {
  5368. $.ui.ddmanager.drag(this, event);
  5369. }
  5370. return false;
  5371. },
  5372. _mouseStop: function (event) {
  5373. //If we are using droppables, inform the manager about the drop
  5374. var that = this,
  5375. dropped = false;
  5376. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  5377. dropped = $.ui.ddmanager.drop(this, event);
  5378. }
  5379. //if a drop comes from outside (a sortable)
  5380. if (this.dropped) {
  5381. dropped = this.dropped;
  5382. this.dropped = false;
  5383. }
  5384. //if the original element is no longer in the DOM don't bother to continue (see #8269)
  5385. if (this.options.helper === "original" && !$.contains(this.element[0].ownerDocument, this.element[0])) {
  5386. return false;
  5387. }
  5388. 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))) {
  5389. $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function () {
  5390. if (that._trigger("stop", event) !== false) {
  5391. that._clear();
  5392. }
  5393. });
  5394. } else {
  5395. if (this._trigger("stop", event) !== false) {
  5396. this._clear();
  5397. }
  5398. }
  5399. return false;
  5400. },
  5401. _mouseUp: function (event) {
  5402. //Remove frame helpers
  5403. $("div.ui-draggable-iframeFix").each(function () {
  5404. this.parentNode.removeChild(this);
  5405. });
  5406. //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
  5407. if ($.ui.ddmanager) {
  5408. $.ui.ddmanager.dragStop(this, event);
  5409. }
  5410. return $.ui.mouse.prototype._mouseUp.call(this, event);
  5411. },
  5412. cancel: function () {
  5413. if (this.helper.is(".ui-draggable-dragging")) {
  5414. this._mouseUp({});
  5415. } else {
  5416. this._clear();
  5417. }
  5418. return this;
  5419. },
  5420. _getHandle: function (event) {
  5421. return this.options.handle ?
  5422. !!$(event.target).closest(this.element.find(this.options.handle)).length :
  5423. true;
  5424. },
  5425. _createHelper: function (event) {
  5426. var o = this.options,
  5427. helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event])) : (o.helper === "clone" ? this.element.clone().removeAttr("id") : this.element);
  5428. if (!helper.parents("body").length) {
  5429. helper.appendTo((o.appendTo === "parent" ? this.element[0].parentNode : o.appendTo));
  5430. }
  5431. if (helper[0] !== this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) {
  5432. helper.css("position", "absolute");
  5433. }
  5434. return helper;
  5435. },
  5436. _adjustOffsetFromHelper: function (obj) {
  5437. if (typeof obj === "string") {
  5438. obj = obj.split(" ");
  5439. }
  5440. if ($.isArray(obj)) {
  5441. obj = { left: +obj[0], top: +obj[1] || 0 };
  5442. }
  5443. if ("left" in obj) {
  5444. this.offset.click.left = obj.left + this.margins.left;
  5445. }
  5446. if ("right" in obj) {
  5447. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  5448. }
  5449. if ("top" in obj) {
  5450. this.offset.click.top = obj.top + this.margins.top;
  5451. }
  5452. if ("bottom" in obj) {
  5453. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  5454. }
  5455. },
  5456. _getParentOffset: function () {
  5457. //Get the offsetParent and cache its position
  5458. var po = this.offsetParent.offset();
  5459. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  5460. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  5461. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  5462. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  5463. if (this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  5464. po.left += this.scrollParent.scrollLeft();
  5465. po.top += this.scrollParent.scrollTop();
  5466. }
  5467. //This needs to be actually done for all browsers, since pageX/pageY includes this information
  5468. //Ugly IE fix
  5469. if ((this.offsetParent[0] === document.body) ||
  5470. (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
  5471. po = { top: 0, left: 0 };
  5472. }
  5473. return {
  5474. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"), 10) || 0),
  5475. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"), 10) || 0)
  5476. };
  5477. },
  5478. _getRelativeOffset: function () {
  5479. if (this.cssPosition === "relative") {
  5480. var p = this.element.position();
  5481. return {
  5482. top: p.top - (parseInt(this.helper.css("top"), 10) || 0) + this.scrollParent.scrollTop(),
  5483. left: p.left - (parseInt(this.helper.css("left"), 10) || 0) + this.scrollParent.scrollLeft()
  5484. };
  5485. } else {
  5486. return { top: 0, left: 0 };
  5487. }
  5488. },
  5489. _cacheMargins: function () {
  5490. this.margins = {
  5491. left: (parseInt(this.element.css("marginLeft"), 10) || 0),
  5492. top: (parseInt(this.element.css("marginTop"), 10) || 0),
  5493. right: (parseInt(this.element.css("marginRight"), 10) || 0),
  5494. bottom: (parseInt(this.element.css("marginBottom"), 10) || 0)
  5495. };
  5496. },
  5497. _cacheHelperProportions: function () {
  5498. this.helperProportions = {
  5499. width: this.helper.outerWidth(),
  5500. height: this.helper.outerHeight()
  5501. };
  5502. },
  5503. _setContainment: function () {
  5504. var over, c, ce,
  5505. o = this.options;
  5506. if (!o.containment) {
  5507. this.containment = null;
  5508. return;
  5509. }
  5510. if (o.containment === "window") {
  5511. this.containment = [
  5512. $(window).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
  5513. $(window).scrollTop() - this.offset.relative.top - this.offset.parent.top,
  5514. $(window).scrollLeft() + $(window).width() - this.helperProportions.width - this.margins.left,
  5515. $(window).scrollTop() + ($(window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
  5516. ];
  5517. return;
  5518. }
  5519. if (o.containment === "document") {
  5520. this.containment = [
  5521. 0,
  5522. 0,
  5523. $(document).width() - this.helperProportions.width - this.margins.left,
  5524. ($(document).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
  5525. ];
  5526. return;
  5527. }
  5528. if (o.containment.constructor === Array) {
  5529. this.containment = o.containment;
  5530. return;
  5531. }
  5532. if (o.containment === "parent") {
  5533. o.containment = this.helper[0].parentNode;
  5534. }
  5535. c = $(o.containment);
  5536. ce = c[0];
  5537. if (!ce) {
  5538. return;
  5539. }
  5540. over = c.css("overflow") !== "hidden";
  5541. this.containment = [
  5542. (parseInt(c.css("borderLeftWidth"), 10) || 0) + (parseInt(c.css("paddingLeft"), 10) || 0),
  5543. (parseInt(c.css("borderTopWidth"), 10) || 0) + (parseInt(c.css("paddingTop"), 10) || 0),
  5544. (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,
  5545. (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
  5546. ];
  5547. this.relative_container = c;
  5548. },
  5549. _convertPositionTo: function (d, pos) {
  5550. if (!pos) {
  5551. pos = this.position;
  5552. }
  5553. var mod = d === "absolute" ? 1 : -1,
  5554. scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent;
  5555. //Cache the scroll
  5556. if (!this.offset.scroll) {
  5557. this.offset.scroll = { top: scroll.scrollTop(), left: scroll.scrollLeft() };
  5558. }
  5559. return {
  5560. top: (
  5561. pos.top + // The absolute mouse position
  5562. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  5563. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  5564. ((this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : this.offset.scroll.top) * mod)
  5565. ),
  5566. left: (
  5567. pos.left + // The absolute mouse position
  5568. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  5569. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  5570. ((this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : this.offset.scroll.left) * mod)
  5571. )
  5572. };
  5573. },
  5574. _generatePosition: function (event) {
  5575. var containment, co, top, left,
  5576. o = this.options,
  5577. scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
  5578. pageX = event.pageX,
  5579. pageY = event.pageY;
  5580. //Cache the scroll
  5581. if (!this.offset.scroll) {
  5582. this.offset.scroll = { top: scroll.scrollTop(), left: scroll.scrollLeft() };
  5583. }
  5584. /*
  5585. * - Position constraining -
  5586. * Constrain the position to a mix of grid, containment.
  5587. */
  5588. // If we are not dragging yet, we won't check for options
  5589. if (this.originalPosition) {
  5590. if (this.containment) {
  5591. if (this.relative_container) {
  5592. co = this.relative_container.offset();
  5593. containment = [
  5594. this.containment[0] + co.left,
  5595. this.containment[1] + co.top,
  5596. this.containment[2] + co.left,
  5597. this.containment[3] + co.top
  5598. ];
  5599. }
  5600. else {
  5601. containment = this.containment;
  5602. }
  5603. if (event.pageX - this.offset.click.left < containment[0]) {
  5604. pageX = containment[0] + this.offset.click.left;
  5605. }
  5606. if (event.pageY - this.offset.click.top < containment[1]) {
  5607. pageY = containment[1] + this.offset.click.top;
  5608. }
  5609. if (event.pageX - this.offset.click.left > containment[2]) {
  5610. pageX = containment[2] + this.offset.click.left;
  5611. }
  5612. if (event.pageY - this.offset.click.top > containment[3]) {
  5613. pageY = containment[3] + this.offset.click.top;
  5614. }
  5615. }
  5616. if (o.grid) {
  5617. //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
  5618. top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
  5619. 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;
  5620. left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
  5621. 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;
  5622. }
  5623. }
  5624. return {
  5625. top: (
  5626. pageY - // The absolute mouse position
  5627. this.offset.click.top - // Click offset (relative to the element)
  5628. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  5629. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  5630. (this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : this.offset.scroll.top)
  5631. ),
  5632. left: (
  5633. pageX - // The absolute mouse position
  5634. this.offset.click.left - // Click offset (relative to the element)
  5635. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  5636. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  5637. (this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : this.offset.scroll.left)
  5638. )
  5639. };
  5640. },
  5641. _clear: function () {
  5642. this.helper.removeClass("ui-draggable-dragging");
  5643. if (this.helper[0] !== this.element[0] && !this.cancelHelperRemoval) {
  5644. this.helper.remove();
  5645. }
  5646. this.helper = null;
  5647. this.cancelHelperRemoval = false;
  5648. },
  5649. // From now on bulk stuff - mainly helpers
  5650. _trigger: function (type, event, ui) {
  5651. ui = ui || this._uiHash();
  5652. $.ui.plugin.call(this, type, [event, ui]);
  5653. //The absolute position has to be recalculated after plugins
  5654. if (type === "drag") {
  5655. this.positionAbs = this._convertPositionTo("absolute");
  5656. }
  5657. return $.Widget.prototype._trigger.call(this, type, event, ui);
  5658. },
  5659. plugins: {},
  5660. _uiHash: function () {
  5661. return {
  5662. helper: this.helper,
  5663. position: this.position,
  5664. originalPosition: this.originalPosition,
  5665. offset: this.positionAbs
  5666. };
  5667. }
  5668. });
  5669. $.ui.plugin.add("draggable", "connectToSortable", {
  5670. start: function (event, ui) {
  5671. var inst = $(this).data("ui-draggable"), o = inst.options,
  5672. uiSortable = $.extend({}, ui, { item: inst.element });
  5673. inst.sortables = [];
  5674. $(o.connectToSortable).each(function () {
  5675. var sortable = $.data(this, "ui-sortable");
  5676. if (sortable && !sortable.options.disabled) {
  5677. inst.sortables.push({
  5678. instance: sortable,
  5679. shouldRevert: sortable.options.revert
  5680. });
  5681. 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).
  5682. sortable._trigger("activate", event, uiSortable);
  5683. }
  5684. });
  5685. },
  5686. stop: function (event, ui) {
  5687. //If we are still over the sortable, we fake the stop event of the sortable, but also remove helper
  5688. var inst = $(this).data("ui-draggable"),
  5689. uiSortable = $.extend({}, ui, { item: inst.element });
  5690. $.each(inst.sortables, function () {
  5691. if (this.instance.isOver) {
  5692. this.instance.isOver = 0;
  5693. inst.cancelHelperRemoval = true; //Don't remove the helper in the draggable instance
  5694. this.instance.cancelHelperRemoval = false; //Remove it in the sortable instance (so sortable plugins like revert still work)
  5695. //The sortable revert is supported, and we have to set a temporary dropped variable on the draggable to support revert: "valid/invalid"
  5696. if (this.shouldRevert) {
  5697. this.instance.options.revert = this.shouldRevert;
  5698. }
  5699. //Trigger the stop of the sortable
  5700. this.instance._mouseStop(event);
  5701. this.instance.options.helper = this.instance.options._helper;
  5702. //If the helper has been the original item, restore properties in the sortable
  5703. if (inst.options.helper === "original") {
  5704. this.instance.currentItem.css({ top: "auto", left: "auto" });
  5705. }
  5706. } else {
  5707. this.instance.cancelHelperRemoval = false; //Remove the helper in the sortable instance
  5708. this.instance._trigger("deactivate", event, uiSortable);
  5709. }
  5710. });
  5711. },
  5712. drag: function (event, ui) {
  5713. var inst = $(this).data("ui-draggable"), that = this;
  5714. $.each(inst.sortables, function () {
  5715. var innermostIntersecting = false,
  5716. thisSortable = this;
  5717. //Copy over some variables to allow calling the sortable's native _intersectsWith
  5718. this.instance.positionAbs = inst.positionAbs;
  5719. this.instance.helperProportions = inst.helperProportions;
  5720. this.instance.offset.click = inst.offset.click;
  5721. if (this.instance._intersectsWith(this.instance.containerCache)) {
  5722. innermostIntersecting = true;
  5723. $.each(inst.sortables, function () {
  5724. this.instance.positionAbs = inst.positionAbs;
  5725. this.instance.helperProportions = inst.helperProportions;
  5726. this.instance.offset.click = inst.offset.click;
  5727. if (this !== thisSortable &&
  5728. this.instance._intersectsWith(this.instance.containerCache) &&
  5729. $.contains(thisSortable.instance.element[0], this.instance.element[0])
  5730. ) {
  5731. innermostIntersecting = false;
  5732. }
  5733. return innermostIntersecting;
  5734. });
  5735. }
  5736. if (innermostIntersecting) {
  5737. //If it intersects, we use a little isOver variable and set it once, so our move-in stuff gets fired only once
  5738. if (!this.instance.isOver) {
  5739. this.instance.isOver = 1;
  5740. //Now we fake the start of dragging for the sortable instance,
  5741. //by cloning the list group item, appending it to the sortable and using it as inst.currentItem
  5742. //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)
  5743. this.instance.currentItem = $(that).clone().removeAttr("id").appendTo(this.instance.element).data("ui-sortable-item", true);
  5744. this.instance.options._helper = this.instance.options.helper; //Store helper option to later restore it
  5745. this.instance.options.helper = function () { return ui.helper[0]; };
  5746. event.target = this.instance.currentItem[0];
  5747. this.instance._mouseCapture(event, true);
  5748. this.instance._mouseStart(event, true, true);
  5749. //Because the browser event is way off the new appended portlet, we modify a couple of variables to reflect the changes
  5750. this.instance.offset.click.top = inst.offset.click.top;
  5751. this.instance.offset.click.left = inst.offset.click.left;
  5752. this.instance.offset.parent.left -= inst.offset.parent.left - this.instance.offset.parent.left;
  5753. this.instance.offset.parent.top -= inst.offset.parent.top - this.instance.offset.parent.top;
  5754. inst._trigger("toSortable", event);
  5755. inst.dropped = this.instance.element; //draggable revert needs that
  5756. //hack so receive/update callbacks work (mostly)
  5757. inst.currentItem = inst.element;
  5758. this.instance.fromOutside = inst;
  5759. }
  5760. //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
  5761. if (this.instance.currentItem) {
  5762. this.instance._mouseDrag(event);
  5763. }
  5764. } else {
  5765. //If it doesn't intersect with the sortable, and it intersected before,
  5766. //we fake the drag stop of the sortable, but make sure it doesn't remove the helper by using cancelHelperRemoval
  5767. if (this.instance.isOver) {
  5768. this.instance.isOver = 0;
  5769. this.instance.cancelHelperRemoval = true;
  5770. //Prevent reverting on this forced stop
  5771. this.instance.options.revert = false;
  5772. // The out event needs to be triggered independently
  5773. this.instance._trigger("out", event, this.instance._uiHash(this.instance));
  5774. this.instance._mouseStop(event, true);
  5775. this.instance.options.helper = this.instance.options._helper;
  5776. //Now we remove our currentItem, the list group clone again, and the placeholder, and animate the helper back to it's original size
  5777. this.instance.currentItem.remove();
  5778. if (this.instance.placeholder) {
  5779. this.instance.placeholder.remove();
  5780. }
  5781. inst._trigger("fromSortable", event);
  5782. inst.dropped = false; //draggable revert needs that
  5783. }
  5784. }
  5785. });
  5786. }
  5787. });
  5788. $.ui.plugin.add("draggable", "cursor", {
  5789. start: function () {
  5790. var t = $("body"), o = $(this).data("ui-draggable").options;
  5791. if (t.css("cursor")) {
  5792. o._cursor = t.css("cursor");
  5793. }
  5794. t.css("cursor", o.cursor);
  5795. },
  5796. stop: function () {
  5797. var o = $(this).data("ui-draggable").options;
  5798. if (o._cursor) {
  5799. $("body").css("cursor", o._cursor);
  5800. }
  5801. }
  5802. });
  5803. $.ui.plugin.add("draggable", "opacity", {
  5804. start: function (event, ui) {
  5805. var t = $(ui.helper), o = $(this).data("ui-draggable").options;
  5806. if (t.css("opacity")) {
  5807. o._opacity = t.css("opacity");
  5808. }
  5809. t.css("opacity", o.opacity);
  5810. },
  5811. stop: function (event, ui) {
  5812. var o = $(this).data("ui-draggable").options;
  5813. if (o._opacity) {
  5814. $(ui.helper).css("opacity", o._opacity);
  5815. }
  5816. }
  5817. });
  5818. $.ui.plugin.add("draggable", "scroll", {
  5819. start: function () {
  5820. var i = $(this).data("ui-draggable");
  5821. if (i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") {
  5822. i.overflowOffset = i.scrollParent.offset();
  5823. }
  5824. },
  5825. drag: function (event) {
  5826. var i = $(this).data("ui-draggable"), o = i.options, scrolled = false;
  5827. if (i.scrollParent[0] !== document && i.scrollParent[0].tagName !== "HTML") {
  5828. if (!o.axis || o.axis !== "x") {
  5829. if ((i.overflowOffset.top + i.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
  5830. i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop + o.scrollSpeed;
  5831. } else if (event.pageY - i.overflowOffset.top < o.scrollSensitivity) {
  5832. i.scrollParent[0].scrollTop = scrolled = i.scrollParent[0].scrollTop - o.scrollSpeed;
  5833. }
  5834. }
  5835. if (!o.axis || o.axis !== "y") {
  5836. if ((i.overflowOffset.left + i.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
  5837. i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft + o.scrollSpeed;
  5838. } else if (event.pageX - i.overflowOffset.left < o.scrollSensitivity) {
  5839. i.scrollParent[0].scrollLeft = scrolled = i.scrollParent[0].scrollLeft - o.scrollSpeed;
  5840. }
  5841. }
  5842. } else {
  5843. if (!o.axis || o.axis !== "x") {
  5844. if (event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
  5845. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  5846. } else if ($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
  5847. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  5848. }
  5849. }
  5850. if (!o.axis || o.axis !== "y") {
  5851. if (event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
  5852. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  5853. } else if ($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
  5854. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  5855. }
  5856. }
  5857. }
  5858. if (scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  5859. $.ui.ddmanager.prepareOffsets(i, event);
  5860. }
  5861. }
  5862. });
  5863. $.ui.plugin.add("draggable", "snap", {
  5864. start: function () {
  5865. var i = $(this).data("ui-draggable"),
  5866. o = i.options;
  5867. i.snapElements = [];
  5868. $(o.snap.constructor !== String ? (o.snap.items || ":data(ui-draggable)") : o.snap).each(function () {
  5869. var $t = $(this),
  5870. $o = $t.offset();
  5871. if (this !== i.element[0]) {
  5872. i.snapElements.push({
  5873. item: this,
  5874. width: $t.outerWidth(), height: $t.outerHeight(),
  5875. top: $o.top, left: $o.left
  5876. });
  5877. }
  5878. });
  5879. },
  5880. drag: function (event, ui) {
  5881. var ts, bs, ls, rs, l, r, t, b, i, first,
  5882. inst = $(this).data("ui-draggable"),
  5883. o = inst.options,
  5884. d = o.snapTolerance,
  5885. x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
  5886. y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
  5887. for (i = inst.snapElements.length - 1; i >= 0; i--) {
  5888. l = inst.snapElements[i].left;
  5889. r = l + inst.snapElements[i].width;
  5890. t = inst.snapElements[i].top;
  5891. b = t + inst.snapElements[i].height;
  5892. if (x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains(inst.snapElements[i].item.ownerDocument, inst.snapElements[i].item)) {
  5893. if (inst.snapElements[i].snapping) {
  5894. (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  5895. }
  5896. inst.snapElements[i].snapping = false;
  5897. continue;
  5898. }
  5899. if (o.snapMode !== "inner") {
  5900. ts = Math.abs(t - y2) <= d;
  5901. bs = Math.abs(b - y1) <= d;
  5902. ls = Math.abs(l - x2) <= d;
  5903. rs = Math.abs(r - x1) <= d;
  5904. if (ts) {
  5905. ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
  5906. }
  5907. if (bs) {
  5908. ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top - inst.margins.top;
  5909. }
  5910. if (ls) {
  5911. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left - inst.margins.left;
  5912. }
  5913. if (rs) {
  5914. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left - inst.margins.left;
  5915. }
  5916. }
  5917. first = (ts || bs || ls || rs);
  5918. if (o.snapMode !== "outer") {
  5919. ts = Math.abs(t - y1) <= d;
  5920. bs = Math.abs(b - y2) <= d;
  5921. ls = Math.abs(l - x1) <= d;
  5922. rs = Math.abs(r - x2) <= d;
  5923. if (ts) {
  5924. ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top - inst.margins.top;
  5925. }
  5926. if (bs) {
  5927. ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top - inst.margins.top;
  5928. }
  5929. if (ls) {
  5930. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left - inst.margins.left;
  5931. }
  5932. if (rs) {
  5933. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left - inst.margins.left;
  5934. }
  5935. }
  5936. if (!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) {
  5937. (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  5938. }
  5939. inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
  5940. }
  5941. }
  5942. });
  5943. $.ui.plugin.add("draggable", "stack", {
  5944. start: function () {
  5945. var min,
  5946. o = this.data("ui-draggable").options,
  5947. group = $.makeArray($(o.stack)).sort(function (a, b) {
  5948. return (parseInt($(a).css("zIndex"), 10) || 0) - (parseInt($(b).css("zIndex"), 10) || 0);
  5949. });
  5950. if (!group.length) { return; }
  5951. min = parseInt($(group[0]).css("zIndex"), 10) || 0;
  5952. $(group).each(function (i) {
  5953. $(this).css("zIndex", min + i);
  5954. });
  5955. this.css("zIndex", (min + group.length));
  5956. }
  5957. });
  5958. $.ui.plugin.add("draggable", "zIndex", {
  5959. start: function (event, ui) {
  5960. var t = $(ui.helper), o = $(this).data("ui-draggable").options;
  5961. if (t.css("zIndex")) {
  5962. o._zIndex = t.css("zIndex");
  5963. }
  5964. t.css("zIndex", o.zIndex);
  5965. },
  5966. stop: function (event, ui) {
  5967. var o = $(this).data("ui-draggable").options;
  5968. if (o._zIndex) {
  5969. $(ui.helper).css("zIndex", o._zIndex);
  5970. }
  5971. }
  5972. });
  5973. })(jQuery);
  5974. (function ($, undefined) {
  5975. function isOverAxis(x, reference, size) {
  5976. return (x > reference) && (x < (reference + size));
  5977. }
  5978. $.widget("ui.droppable", {
  5979. version: "1.10.4",
  5980. widgetEventPrefix: "drop",
  5981. options: {
  5982. accept: "*",
  5983. activeClass: false,
  5984. addClasses: true,
  5985. greedy: false,
  5986. hoverClass: false,
  5987. scope: "default",
  5988. tolerance: "intersect",
  5989. // callbacks
  5990. activate: null,
  5991. deactivate: null,
  5992. drop: null,
  5993. out: null,
  5994. over: null
  5995. },
  5996. _create: function () {
  5997. var proportions,
  5998. o = this.options,
  5999. accept = o.accept;
  6000. this.isover = false;
  6001. this.isout = true;
  6002. this.accept = $.isFunction(accept) ? accept : function (d) {
  6003. return d.is(accept);
  6004. };
  6005. this.proportions = function ( /* valueToWrite */) {
  6006. if (arguments.length) {
  6007. // Store the droppable's proportions
  6008. proportions = arguments[0];
  6009. } else {
  6010. // Retrieve or derive the droppable's proportions
  6011. return proportions ?
  6012. proportions :
  6013. proportions = {
  6014. width: this.element[0].offsetWidth,
  6015. height: this.element[0].offsetHeight
  6016. };
  6017. }
  6018. };
  6019. // Add the reference and positions to the manager
  6020. $.ui.ddmanager.droppables[o.scope] = $.ui.ddmanager.droppables[o.scope] || [];
  6021. $.ui.ddmanager.droppables[o.scope].push(this);
  6022. (o.addClasses && this.element.addClass("ui-droppable"));
  6023. },
  6024. _destroy: function () {
  6025. var i = 0,
  6026. drop = $.ui.ddmanager.droppables[this.options.scope];
  6027. for (; i < drop.length; i++) {
  6028. if (drop[i] === this) {
  6029. drop.splice(i, 1);
  6030. }
  6031. }
  6032. this.element.removeClass("ui-droppable ui-droppable-disabled");
  6033. },
  6034. _setOption: function (key, value) {
  6035. if (key === "accept") {
  6036. this.accept = $.isFunction(value) ? value : function (d) {
  6037. return d.is(value);
  6038. };
  6039. }
  6040. $.Widget.prototype._setOption.apply(this, arguments);
  6041. },
  6042. _activate: function (event) {
  6043. var draggable = $.ui.ddmanager.current;
  6044. if (this.options.activeClass) {
  6045. this.element.addClass(this.options.activeClass);
  6046. }
  6047. if (draggable) {
  6048. this._trigger("activate", event, this.ui(draggable));
  6049. }
  6050. },
  6051. _deactivate: function (event) {
  6052. var draggable = $.ui.ddmanager.current;
  6053. if (this.options.activeClass) {
  6054. this.element.removeClass(this.options.activeClass);
  6055. }
  6056. if (draggable) {
  6057. this._trigger("deactivate", event, this.ui(draggable));
  6058. }
  6059. },
  6060. _over: function (event) {
  6061. var draggable = $.ui.ddmanager.current;
  6062. // Bail if draggable and droppable are same element
  6063. if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
  6064. return;
  6065. }
  6066. if (this.accept.call(this.element[0], (draggable.currentItem || draggable.element))) {
  6067. if (this.options.hoverClass) {
  6068. this.element.addClass(this.options.hoverClass);
  6069. }
  6070. this._trigger("over", event, this.ui(draggable));
  6071. }
  6072. },
  6073. _out: function (event) {
  6074. var draggable = $.ui.ddmanager.current;
  6075. // Bail if draggable and droppable are same element
  6076. if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
  6077. return;
  6078. }
  6079. if (this.accept.call(this.element[0], (draggable.currentItem || draggable.element))) {
  6080. if (this.options.hoverClass) {
  6081. this.element.removeClass(this.options.hoverClass);
  6082. }
  6083. this._trigger("out", event, this.ui(draggable));
  6084. }
  6085. },
  6086. _drop: function (event, custom) {
  6087. var draggable = custom || $.ui.ddmanager.current,
  6088. childrenIntersection = false;
  6089. // Bail if draggable and droppable are same element
  6090. if (!draggable || (draggable.currentItem || draggable.element)[0] === this.element[0]) {
  6091. return false;
  6092. }
  6093. this.element.find(":data(ui-droppable)").not(".ui-draggable-dragging").each(function () {
  6094. var inst = $.data(this, "ui-droppable");
  6095. if (
  6096. inst.options.greedy &&
  6097. !inst.options.disabled &&
  6098. inst.options.scope === draggable.options.scope &&
  6099. inst.accept.call(inst.element[0], (draggable.currentItem || draggable.element)) &&
  6100. $.ui.intersect(draggable, $.extend(inst, { offset: inst.element.offset() }), inst.options.tolerance)
  6101. ) { childrenIntersection = true; return false; }
  6102. });
  6103. if (childrenIntersection) {
  6104. return false;
  6105. }
  6106. if (this.accept.call(this.element[0], (draggable.currentItem || draggable.element))) {
  6107. if (this.options.activeClass) {
  6108. this.element.removeClass(this.options.activeClass);
  6109. }
  6110. if (this.options.hoverClass) {
  6111. this.element.removeClass(this.options.hoverClass);
  6112. }
  6113. this._trigger("drop", event, this.ui(draggable));
  6114. return this.element;
  6115. }
  6116. return false;
  6117. },
  6118. ui: function (c) {
  6119. return {
  6120. draggable: (c.currentItem || c.element),
  6121. helper: c.helper,
  6122. position: c.position,
  6123. offset: c.positionAbs
  6124. };
  6125. }
  6126. });
  6127. $.ui.intersect = function (draggable, droppable, toleranceMode) {
  6128. if (!droppable.offset) {
  6129. return false;
  6130. }
  6131. var draggableLeft, draggableTop,
  6132. x1 = (draggable.positionAbs || draggable.position.absolute).left,
  6133. y1 = (draggable.positionAbs || draggable.position.absolute).top,
  6134. x2 = x1 + draggable.helperProportions.width,
  6135. y2 = y1 + draggable.helperProportions.height,
  6136. l = droppable.offset.left,
  6137. t = droppable.offset.top,
  6138. r = l + droppable.proportions().width,
  6139. b = t + droppable.proportions().height;
  6140. switch (toleranceMode) {
  6141. case "fit":
  6142. return (l <= x1 && x2 <= r && t <= y1 && y2 <= b);
  6143. case "intersect":
  6144. return (l < x1 + (draggable.helperProportions.width / 2) && // Right Half
  6145. x2 - (draggable.helperProportions.width / 2) < r && // Left Half
  6146. t < y1 + (draggable.helperProportions.height / 2) && // Bottom Half
  6147. y2 - (draggable.helperProportions.height / 2) < b); // Top Half
  6148. case "pointer":
  6149. draggableLeft = ((draggable.positionAbs || draggable.position.absolute).left + (draggable.clickOffset || draggable.offset.click).left);
  6150. draggableTop = ((draggable.positionAbs || draggable.position.absolute).top + (draggable.clickOffset || draggable.offset.click).top);
  6151. return isOverAxis(draggableTop, t, droppable.proportions().height) && isOverAxis(draggableLeft, l, droppable.proportions().width);
  6152. case "touch":
  6153. return (
  6154. (y1 >= t && y1 <= b) || // Top edge touching
  6155. (y2 >= t && y2 <= b) || // Bottom edge touching
  6156. (y1 < t && y2 > b) // Surrounded vertically
  6157. ) && (
  6158. (x1 >= l && x1 <= r) || // Left edge touching
  6159. (x2 >= l && x2 <= r) || // Right edge touching
  6160. (x1 < l && x2 > r) // Surrounded horizontally
  6161. );
  6162. default:
  6163. return false;
  6164. }
  6165. };
  6166. /*
  6167. This manager tracks offsets of draggables and droppables
  6168. */
  6169. $.ui.ddmanager = {
  6170. current: null,
  6171. droppables: { "default": [] },
  6172. prepareOffsets: function (t, event) {
  6173. var i, j,
  6174. m = $.ui.ddmanager.droppables[t.options.scope] || [],
  6175. type = event ? event.type : null, // workaround for #2317
  6176. list = (t.currentItem || t.element).find(":data(ui-droppable)").addBack();
  6177. droppablesLoop: for (i = 0; i < m.length; i++) {
  6178. //No disabled and non-accepted
  6179. if (m[i].options.disabled || (t && !m[i].accept.call(m[i].element[0], (t.currentItem || t.element)))) {
  6180. continue;
  6181. }
  6182. // Filter out elements in the current dragged item
  6183. for (j = 0; j < list.length; j++) {
  6184. if (list[j] === m[i].element[0]) {
  6185. m[i].proportions().height = 0;
  6186. continue droppablesLoop;
  6187. }
  6188. }
  6189. m[i].visible = m[i].element.css("display") !== "none";
  6190. if (!m[i].visible) {
  6191. continue;
  6192. }
  6193. //Activate the droppable if used directly from draggables
  6194. if (type === "mousedown") {
  6195. m[i]._activate.call(m[i], event);
  6196. }
  6197. m[i].offset = m[i].element.offset();
  6198. m[i].proportions({ width: m[i].element[0].offsetWidth, height: m[i].element[0].offsetHeight });
  6199. }
  6200. },
  6201. drop: function (draggable, event) {
  6202. var dropped = false;
  6203. // Create a copy of the droppables in case the list changes during the drop (#9116)
  6204. $.each(($.ui.ddmanager.droppables[draggable.options.scope] || []).slice(), function () {
  6205. if (!this.options) {
  6206. return;
  6207. }
  6208. if (!this.options.disabled && this.visible && $.ui.intersect(draggable, this, this.options.tolerance)) {
  6209. dropped = this._drop.call(this, event) || dropped;
  6210. }
  6211. if (!this.options.disabled && this.visible && this.accept.call(this.element[0], (draggable.currentItem || draggable.element))) {
  6212. this.isout = true;
  6213. this.isover = false;
  6214. this._deactivate.call(this, event);
  6215. }
  6216. });
  6217. return dropped;
  6218. },
  6219. dragStart: function (draggable, event) {
  6220. //Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003)
  6221. draggable.element.parentsUntil("body").bind("scroll.droppable", function () {
  6222. if (!draggable.options.refreshPositions) {
  6223. $.ui.ddmanager.prepareOffsets(draggable, event);
  6224. }
  6225. });
  6226. },
  6227. drag: function (draggable, event) {
  6228. //If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
  6229. if (draggable.options.refreshPositions) {
  6230. $.ui.ddmanager.prepareOffsets(draggable, event);
  6231. }
  6232. //Run through all droppables and check their positions based on specific tolerance options
  6233. $.each($.ui.ddmanager.droppables[draggable.options.scope] || [], function () {
  6234. if (this.options.disabled || this.greedyChild || !this.visible) {
  6235. return;
  6236. }
  6237. var parentInstance, scope, parent,
  6238. intersects = $.ui.intersect(draggable, this, this.options.tolerance),
  6239. c = !intersects && this.isover ? "isout" : (intersects && !this.isover ? "isover" : null);
  6240. if (!c) {
  6241. return;
  6242. }
  6243. if (this.options.greedy) {
  6244. // find droppable parents with same scope
  6245. scope = this.options.scope;
  6246. parent = this.element.parents(":data(ui-droppable)").filter(function () {
  6247. return $.data(this, "ui-droppable").options.scope === scope;
  6248. });
  6249. if (parent.length) {
  6250. parentInstance = $.data(parent[0], "ui-droppable");
  6251. parentInstance.greedyChild = (c === "isover");
  6252. }
  6253. }
  6254. // we just moved into a greedy child
  6255. if (parentInstance && c === "isover") {
  6256. parentInstance.isover = false;
  6257. parentInstance.isout = true;
  6258. parentInstance._out.call(parentInstance, event);
  6259. }
  6260. this[c] = true;
  6261. this[c === "isout" ? "isover" : "isout"] = false;
  6262. this[c === "isover" ? "_over" : "_out"].call(this, event);
  6263. // we just moved out of a greedy child
  6264. if (parentInstance && c === "isout") {
  6265. parentInstance.isout = false;
  6266. parentInstance.isover = true;
  6267. parentInstance._over.call(parentInstance, event);
  6268. }
  6269. });
  6270. },
  6271. dragStop: function (draggable, event) {
  6272. draggable.element.parentsUntil("body").unbind("scroll.droppable");
  6273. //Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003)
  6274. if (!draggable.options.refreshPositions) {
  6275. $.ui.ddmanager.prepareOffsets(draggable, event);
  6276. }
  6277. }
  6278. };
  6279. })(jQuery);
  6280. (function ($, undefined) {
  6281. var dataSpace = "ui-effects-";
  6282. $.effects = {
  6283. effect: {}
  6284. };
  6285. /*!
  6286. * jQuery Color Animations v2.1.2
  6287. * https://github.com/jquery/jquery-color
  6288. *
  6289. * Copyright 2013 jQuery Foundation and other contributors
  6290. * Released under the MIT license.
  6291. * http://jquery.org/license
  6292. *
  6293. * Date: Wed Jan 16 08:47:09 2013 -0600
  6294. */
  6295. (function (jQuery, undefined) {
  6296. var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
  6297. // plusequals test for += 100 -= 100
  6298. rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
  6299. // a set of RE's that can match strings and generate color tuples.
  6300. stringParsers = [{
  6301. re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  6302. parse: function (execResult) {
  6303. return [
  6304. execResult[1],
  6305. execResult[2],
  6306. execResult[3],
  6307. execResult[4]
  6308. ];
  6309. }
  6310. }, {
  6311. re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  6312. parse: function (execResult) {
  6313. return [
  6314. execResult[1] * 2.55,
  6315. execResult[2] * 2.55,
  6316. execResult[3] * 2.55,
  6317. execResult[4]
  6318. ];
  6319. }
  6320. }, {
  6321. // this regex ignores A-F because it's compared against an already lowercased string
  6322. re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
  6323. parse: function (execResult) {
  6324. return [
  6325. parseInt(execResult[1], 16),
  6326. parseInt(execResult[2], 16),
  6327. parseInt(execResult[3], 16)
  6328. ];
  6329. }
  6330. }, {
  6331. // this regex ignores A-F because it's compared against an already lowercased string
  6332. re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
  6333. parse: function (execResult) {
  6334. return [
  6335. parseInt(execResult[1] + execResult[1], 16),
  6336. parseInt(execResult[2] + execResult[2], 16),
  6337. parseInt(execResult[3] + execResult[3], 16)
  6338. ];
  6339. }
  6340. }, {
  6341. re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  6342. space: "hsla",
  6343. parse: function (execResult) {
  6344. return [
  6345. execResult[1],
  6346. execResult[2] / 100,
  6347. execResult[3] / 100,
  6348. execResult[4]
  6349. ];
  6350. }
  6351. }],
  6352. // jQuery.Color( )
  6353. color = jQuery.Color = function (color, green, blue, alpha) {
  6354. return new jQuery.Color.fn.parse(color, green, blue, alpha);
  6355. },
  6356. spaces = {
  6357. rgba: {
  6358. props: {
  6359. red: {
  6360. idx: 0,
  6361. type: "byte"
  6362. },
  6363. green: {
  6364. idx: 1,
  6365. type: "byte"
  6366. },
  6367. blue: {
  6368. idx: 2,
  6369. type: "byte"
  6370. }
  6371. }
  6372. },
  6373. hsla: {
  6374. props: {
  6375. hue: {
  6376. idx: 0,
  6377. type: "degrees"
  6378. },
  6379. saturation: {
  6380. idx: 1,
  6381. type: "percent"
  6382. },
  6383. lightness: {
  6384. idx: 2,
  6385. type: "percent"
  6386. }
  6387. }
  6388. }
  6389. },
  6390. propTypes = {
  6391. "byte": {
  6392. floor: true,
  6393. max: 255
  6394. },
  6395. "percent": {
  6396. max: 1
  6397. },
  6398. "degrees": {
  6399. mod: 360,
  6400. floor: true
  6401. }
  6402. },
  6403. support = color.support = {},
  6404. // element for support tests
  6405. supportElem = jQuery("<p>")[0],
  6406. // colors = jQuery.Color.names
  6407. colors,
  6408. // local aliases of functions called often
  6409. each = jQuery.each;
  6410. // determine rgba support immediately
  6411. supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
  6412. support.rgba = supportElem.style.backgroundColor.indexOf("rgba") > -1;
  6413. // define cache name and alpha properties
  6414. // for rgba and hsla spaces
  6415. each(spaces, function (spaceName, space) {
  6416. space.cache = "_" + spaceName;
  6417. space.props.alpha = {
  6418. idx: 3,
  6419. type: "percent",
  6420. def: 1
  6421. };
  6422. });
  6423. function clamp(value, prop, allowEmpty) {
  6424. var type = propTypes[prop.type] || {};
  6425. if (value == null) {
  6426. return (allowEmpty || !prop.def) ? null : prop.def;
  6427. }
  6428. // ~~ is an short way of doing floor for positive numbers
  6429. value = type.floor ? ~~value : parseFloat(value);
  6430. // IE will pass in empty strings as value for alpha,
  6431. // which will hit this case
  6432. if (isNaN(value)) {
  6433. return prop.def;
  6434. }
  6435. if (type.mod) {
  6436. // we add mod before modding to make sure that negatives values
  6437. // get converted properly: -10 -> 350
  6438. return (value + type.mod) % type.mod;
  6439. }
  6440. // for now all property types without mod have min and max
  6441. return 0 > value ? 0 : type.max < value ? type.max : value;
  6442. }
  6443. function stringParse(string) {
  6444. var inst = color(),
  6445. rgba = inst._rgba = [];
  6446. string = string.toLowerCase();
  6447. each(stringParsers, function (i, parser) {
  6448. var parsed,
  6449. match = parser.re.exec(string),
  6450. values = match && parser.parse(match),
  6451. spaceName = parser.space || "rgba";
  6452. if (values) {
  6453. parsed = inst[spaceName](values);
  6454. // if this was an rgba parse the assignment might happen twice
  6455. // oh well....
  6456. inst[spaces[spaceName].cache] = parsed[spaces[spaceName].cache];
  6457. rgba = inst._rgba = parsed._rgba;
  6458. // exit each( stringParsers ) here because we matched
  6459. return false;
  6460. }
  6461. });
  6462. // Found a stringParser that handled it
  6463. if (rgba.length) {
  6464. // if this came from a parsed string, force "transparent" when alpha is 0
  6465. // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
  6466. if (rgba.join() === "0,0,0,0") {
  6467. jQuery.extend(rgba, colors.transparent);
  6468. }
  6469. return inst;
  6470. }
  6471. // named colors
  6472. return colors[string];
  6473. }
  6474. color.fn = jQuery.extend(color.prototype, {
  6475. parse: function (red, green, blue, alpha) {
  6476. if (red === undefined) {
  6477. this._rgba = [null, null, null, null];
  6478. return this;
  6479. }
  6480. if (red.jquery || red.nodeType) {
  6481. red = jQuery(red).css(green);
  6482. green = undefined;
  6483. }
  6484. var inst = this,
  6485. type = jQuery.type(red),
  6486. rgba = this._rgba = [];
  6487. // more than 1 argument specified - assume ( red, green, blue, alpha )
  6488. if (green !== undefined) {
  6489. red = [red, green, blue, alpha];
  6490. type = "array";
  6491. }
  6492. if (type === "string") {
  6493. return this.parse(stringParse(red) || colors._default);
  6494. }
  6495. if (type === "array") {
  6496. each(spaces.rgba.props, function (key, prop) {
  6497. rgba[prop.idx] = clamp(red[prop.idx], prop);
  6498. });
  6499. return this;
  6500. }
  6501. if (type === "object") {
  6502. if (red instanceof color) {
  6503. each(spaces, function (spaceName, space) {
  6504. if (red[space.cache]) {
  6505. inst[space.cache] = red[space.cache].slice();
  6506. }
  6507. });
  6508. } else {
  6509. each(spaces, function (spaceName, space) {
  6510. var cache = space.cache;
  6511. each(space.props, function (key, prop) {
  6512. // if the cache doesn't exist, and we know how to convert
  6513. if (!inst[cache] && space.to) {
  6514. // if the value was null, we don't need to copy it
  6515. // if the key was alpha, we don't need to copy it either
  6516. if (key === "alpha" || red[key] == null) {
  6517. return;
  6518. }
  6519. inst[cache] = space.to(inst._rgba);
  6520. }
  6521. // this is the only case where we allow nulls for ALL properties.
  6522. // call clamp with alwaysAllowEmpty
  6523. inst[cache][prop.idx] = clamp(red[key], prop, true);
  6524. });
  6525. // everything defined but alpha?
  6526. if (inst[cache] && jQuery.inArray(null, inst[cache].slice(0, 3)) < 0) {
  6527. // use the default of 1
  6528. inst[cache][3] = 1;
  6529. if (space.from) {
  6530. inst._rgba = space.from(inst[cache]);
  6531. }
  6532. }
  6533. });
  6534. }
  6535. return this;
  6536. }
  6537. },
  6538. is: function (compare) {
  6539. var is = color(compare),
  6540. same = true,
  6541. inst = this;
  6542. each(spaces, function (_, space) {
  6543. var localCache,
  6544. isCache = is[space.cache];
  6545. if (isCache) {
  6546. localCache = inst[space.cache] || space.to && space.to(inst._rgba) || [];
  6547. each(space.props, function (_, prop) {
  6548. if (isCache[prop.idx] != null) {
  6549. same = (isCache[prop.idx] === localCache[prop.idx]);
  6550. return same;
  6551. }
  6552. });
  6553. }
  6554. return same;
  6555. });
  6556. return same;
  6557. },
  6558. _space: function () {
  6559. var used = [],
  6560. inst = this;
  6561. each(spaces, function (spaceName, space) {
  6562. if (inst[space.cache]) {
  6563. used.push(spaceName);
  6564. }
  6565. });
  6566. return used.pop();
  6567. },
  6568. transition: function (other, distance) {
  6569. var end = color(other),
  6570. spaceName = end._space(),
  6571. space = spaces[spaceName],
  6572. startColor = this.alpha() === 0 ? color("transparent") : this,
  6573. start = startColor[space.cache] || space.to(startColor._rgba),
  6574. result = start.slice();
  6575. end = end[space.cache];
  6576. each(space.props, function (key, prop) {
  6577. var index = prop.idx,
  6578. startValue = start[index],
  6579. endValue = end[index],
  6580. type = propTypes[prop.type] || {};
  6581. // if null, don't override start value
  6582. if (endValue === null) {
  6583. return;
  6584. }
  6585. // if null - use end
  6586. if (startValue === null) {
  6587. result[index] = endValue;
  6588. } else {
  6589. if (type.mod) {
  6590. if (endValue - startValue > type.mod / 2) {
  6591. startValue += type.mod;
  6592. } else if (startValue - endValue > type.mod / 2) {
  6593. startValue -= type.mod;
  6594. }
  6595. }
  6596. result[index] = clamp((endValue - startValue) * distance + startValue, prop);
  6597. }
  6598. });
  6599. return this[spaceName](result);
  6600. },
  6601. blend: function (opaque) {
  6602. // if we are already opaque - return ourself
  6603. if (this._rgba[3] === 1) {
  6604. return this;
  6605. }
  6606. var rgb = this._rgba.slice(),
  6607. a = rgb.pop(),
  6608. blend = color(opaque)._rgba;
  6609. return color(jQuery.map(rgb, function (v, i) {
  6610. return (1 - a) * blend[i] + a * v;
  6611. }));
  6612. },
  6613. toRgbaString: function () {
  6614. var prefix = "rgba(",
  6615. rgba = jQuery.map(this._rgba, function (v, i) {
  6616. return v == null ? (i > 2 ? 1 : 0) : v;
  6617. });
  6618. if (rgba[3] === 1) {
  6619. rgba.pop();
  6620. prefix = "rgb(";
  6621. }
  6622. return prefix + rgba.join() + ")";
  6623. },
  6624. toHslaString: function () {
  6625. var prefix = "hsla(",
  6626. hsla = jQuery.map(this.hsla(), function (v, i) {
  6627. if (v == null) {
  6628. v = i > 2 ? 1 : 0;
  6629. }
  6630. // catch 1 and 2
  6631. if (i && i < 3) {
  6632. v = Math.round(v * 100) + "%";
  6633. }
  6634. return v;
  6635. });
  6636. if (hsla[3] === 1) {
  6637. hsla.pop();
  6638. prefix = "hsl(";
  6639. }
  6640. return prefix + hsla.join() + ")";
  6641. },
  6642. toHexString: function (includeAlpha) {
  6643. var rgba = this._rgba.slice(),
  6644. alpha = rgba.pop();
  6645. if (includeAlpha) {
  6646. rgba.push(~~(alpha * 255));
  6647. }
  6648. return "#" + jQuery.map(rgba, function (v) {
  6649. // default to 0 when nulls exist
  6650. v = (v || 0).toString(16);
  6651. return v.length === 1 ? "0" + v : v;
  6652. }).join("");
  6653. },
  6654. toString: function () {
  6655. return this._rgba[3] === 0 ? "transparent" : this.toRgbaString();
  6656. }
  6657. });
  6658. color.fn.parse.prototype = color.fn;
  6659. // hsla conversions adapted from:
  6660. // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
  6661. function hue2rgb(p, q, h) {
  6662. h = (h + 1) % 1;
  6663. if (h * 6 < 1) {
  6664. return p + (q - p) * h * 6;
  6665. }
  6666. if (h * 2 < 1) {
  6667. return q;
  6668. }
  6669. if (h * 3 < 2) {
  6670. return p + (q - p) * ((2 / 3) - h) * 6;
  6671. }
  6672. return p;
  6673. }
  6674. spaces.hsla.to = function (rgba) {
  6675. if (rgba[0] == null || rgba[1] == null || rgba[2] == null) {
  6676. return [null, null, null, rgba[3]];
  6677. }
  6678. var r = rgba[0] / 255,
  6679. g = rgba[1] / 255,
  6680. b = rgba[2] / 255,
  6681. a = rgba[3],
  6682. max = Math.max(r, g, b),
  6683. min = Math.min(r, g, b),
  6684. diff = max - min,
  6685. add = max + min,
  6686. l = add * 0.5,
  6687. h, s;
  6688. if (min === max) {
  6689. h = 0;
  6690. } else if (r === max) {
  6691. h = (60 * (g - b) / diff) + 360;
  6692. } else if (g === max) {
  6693. h = (60 * (b - r) / diff) + 120;
  6694. } else {
  6695. h = (60 * (r - g) / diff) + 240;
  6696. }
  6697. // chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
  6698. // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
  6699. if (diff === 0) {
  6700. s = 0;
  6701. } else if (l <= 0.5) {
  6702. s = diff / add;
  6703. } else {
  6704. s = diff / (2 - add);
  6705. }
  6706. return [Math.round(h) % 360, s, l, a == null ? 1 : a];
  6707. };
  6708. spaces.hsla.from = function (hsla) {
  6709. if (hsla[0] == null || hsla[1] == null || hsla[2] == null) {
  6710. return [null, null, null, hsla[3]];
  6711. }
  6712. var h = hsla[0] / 360,
  6713. s = hsla[1],
  6714. l = hsla[2],
  6715. a = hsla[3],
  6716. q = l <= 0.5 ? l * (1 + s) : l + s - l * s,
  6717. p = 2 * l - q;
  6718. return [
  6719. Math.round(hue2rgb(p, q, h + (1 / 3)) * 255),
  6720. Math.round(hue2rgb(p, q, h) * 255),
  6721. Math.round(hue2rgb(p, q, h - (1 / 3)) * 255),
  6722. a
  6723. ];
  6724. };
  6725. each(spaces, function (spaceName, space) {
  6726. var props = space.props,
  6727. cache = space.cache,
  6728. to = space.to,
  6729. from = space.from;
  6730. // makes rgba() and hsla()
  6731. color.fn[spaceName] = function (value) {
  6732. // generate a cache for this space if it doesn't exist
  6733. if (to && !this[cache]) {
  6734. this[cache] = to(this._rgba);
  6735. }
  6736. if (value === undefined) {
  6737. return this[cache].slice();
  6738. }
  6739. var ret,
  6740. type = jQuery.type(value),
  6741. arr = (type === "array" || type === "object") ? value : arguments,
  6742. local = this[cache].slice();
  6743. each(props, function (key, prop) {
  6744. var val = arr[type === "object" ? key : prop.idx];
  6745. if (val == null) {
  6746. val = local[prop.idx];
  6747. }
  6748. local[prop.idx] = clamp(val, prop);
  6749. });
  6750. if (from) {
  6751. ret = color(from(local));
  6752. ret[cache] = local;
  6753. return ret;
  6754. } else {
  6755. return color(local);
  6756. }
  6757. };
  6758. // makes red() green() blue() alpha() hue() saturation() lightness()
  6759. each(props, function (key, prop) {
  6760. // alpha is included in more than one space
  6761. if (color.fn[key]) {
  6762. return;
  6763. }
  6764. color.fn[key] = function (value) {
  6765. var vtype = jQuery.type(value),
  6766. fn = (key === "alpha" ? (this._hsla ? "hsla" : "rgba") : spaceName),
  6767. local = this[fn](),
  6768. cur = local[prop.idx],
  6769. match;
  6770. if (vtype === "undefined") {
  6771. return cur;
  6772. }
  6773. if (vtype === "function") {
  6774. value = value.call(this, cur);
  6775. vtype = jQuery.type(value);
  6776. }
  6777. if (value == null && prop.empty) {
  6778. return this;
  6779. }
  6780. if (vtype === "string") {
  6781. match = rplusequals.exec(value);
  6782. if (match) {
  6783. value = cur + parseFloat(match[2]) * (match[1] === "+" ? 1 : -1);
  6784. }
  6785. }
  6786. local[prop.idx] = value;
  6787. return this[fn](local);
  6788. };
  6789. });
  6790. });
  6791. // add cssHook and .fx.step function for each named hook.
  6792. // accept a space separated string of properties
  6793. color.hook = function (hook) {
  6794. var hooks = hook.split(" ");
  6795. each(hooks, function (i, hook) {
  6796. jQuery.cssHooks[hook] = {
  6797. set: function (elem, value) {
  6798. var parsed, curElem,
  6799. backgroundColor = "";
  6800. if (value !== "transparent" && (jQuery.type(value) !== "string" || (parsed = stringParse(value)))) {
  6801. value = color(parsed || value);
  6802. if (!support.rgba && value._rgba[3] !== 1) {
  6803. curElem = hook === "backgroundColor" ? elem.parentNode : elem;
  6804. while (
  6805. (backgroundColor === "" || backgroundColor === "transparent") &&
  6806. curElem && curElem.style
  6807. ) {
  6808. try {
  6809. backgroundColor = jQuery.css(curElem, "backgroundColor");
  6810. curElem = curElem.parentNode;
  6811. } catch (e) {
  6812. }
  6813. }
  6814. value = value.blend(backgroundColor && backgroundColor !== "transparent" ?
  6815. backgroundColor :
  6816. "_default");
  6817. }
  6818. value = value.toRgbaString();
  6819. }
  6820. try {
  6821. elem.style[hook] = value;
  6822. } catch (e) {
  6823. // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
  6824. }
  6825. }
  6826. };
  6827. jQuery.fx.step[hook] = function (fx) {
  6828. if (!fx.colorInit) {
  6829. fx.start = color(fx.elem, hook);
  6830. fx.end = color(fx.end);
  6831. fx.colorInit = true;
  6832. }
  6833. jQuery.cssHooks[hook].set(fx.elem, fx.start.transition(fx.end, fx.pos));
  6834. };
  6835. });
  6836. };
  6837. color.hook(stepHooks);
  6838. jQuery.cssHooks.borderColor = {
  6839. expand: function (value) {
  6840. var expanded = {};
  6841. each(["Top", "Right", "Bottom", "Left"], function (i, part) {
  6842. expanded["border" + part + "Color"] = value;
  6843. });
  6844. return expanded;
  6845. }
  6846. };
  6847. // Basic color names only.
  6848. // Usage of any of the other color names requires adding yourself or including
  6849. // jquery.color.svg-names.js.
  6850. colors = jQuery.Color.names = {
  6851. // 4.1. Basic color keywords
  6852. aqua: "#00ffff",
  6853. black: "#000000",
  6854. blue: "#0000ff",
  6855. fuchsia: "#ff00ff",
  6856. gray: "#808080",
  6857. green: "#008000",
  6858. lime: "#00ff00",
  6859. maroon: "#800000",
  6860. navy: "#000080",
  6861. olive: "#808000",
  6862. purple: "#800080",
  6863. red: "#ff0000",
  6864. silver: "#c0c0c0",
  6865. teal: "#008080",
  6866. white: "#ffffff",
  6867. yellow: "#ffff00",
  6868. // 4.2.3. "transparent" color keyword
  6869. transparent: [null, null, null, 0],
  6870. _default: "#ffffff"
  6871. };
  6872. })(jQuery);
  6873. /******************************************************************************/
  6874. /****************************** CLASS ANIMATIONS ******************************/
  6875. /******************************************************************************/
  6876. (function () {
  6877. var classAnimationActions = ["add", "remove", "toggle"],
  6878. shorthandStyles = {
  6879. border: 1,
  6880. borderBottom: 1,
  6881. borderColor: 1,
  6882. borderLeft: 1,
  6883. borderRight: 1,
  6884. borderTop: 1,
  6885. borderWidth: 1,
  6886. margin: 1,
  6887. padding: 1
  6888. };
  6889. $.each(["borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle"], function (_, prop) {
  6890. $.fx.step[prop] = function (fx) {
  6891. if (fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr) {
  6892. jQuery.style(fx.elem, prop, fx.end);
  6893. fx.setAttr = true;
  6894. }
  6895. };
  6896. });
  6897. function getElementStyles(elem) {
  6898. var key, len,
  6899. style = elem.ownerDocument.defaultView ?
  6900. elem.ownerDocument.defaultView.getComputedStyle(elem, null) :
  6901. elem.currentStyle,
  6902. styles = {};
  6903. if (style && style.length && style[0] && style[style[0]]) {
  6904. len = style.length;
  6905. while (len--) {
  6906. key = style[len];
  6907. if (typeof style[key] === "string") {
  6908. styles[$.camelCase(key)] = style[key];
  6909. }
  6910. }
  6911. // support: Opera, IE <9
  6912. } else {
  6913. for (key in style) {
  6914. if (typeof style[key] === "string") {
  6915. styles[key] = style[key];
  6916. }
  6917. }
  6918. }
  6919. return styles;
  6920. }
  6921. function styleDifference(oldStyle, newStyle) {
  6922. var diff = {},
  6923. name, value;
  6924. for (name in newStyle) {
  6925. value = newStyle[name];
  6926. if (oldStyle[name] !== value) {
  6927. if (!shorthandStyles[name]) {
  6928. if ($.fx.step[name] || !isNaN(parseFloat(value))) {
  6929. diff[name] = value;
  6930. }
  6931. }
  6932. }
  6933. }
  6934. return diff;
  6935. }
  6936. // support: jQuery <1.8
  6937. if (!$.fn.addBack) {
  6938. $.fn.addBack = function (selector) {
  6939. return this.add(selector == null ?
  6940. this.prevObject : this.prevObject.filter(selector)
  6941. );
  6942. };
  6943. }
  6944. $.effects.animateClass = function (value, duration, easing, callback) {
  6945. var o = $.speed(duration, easing, callback);
  6946. return this.queue(function () {
  6947. var animated = $(this),
  6948. baseClass = animated.attr("class") || "",
  6949. applyClassChange,
  6950. allAnimations = o.children ? animated.find("*").addBack() : animated;
  6951. // map the animated objects to store the original styles.
  6952. allAnimations = allAnimations.map(function () {
  6953. var el = $(this);
  6954. return {
  6955. el: el,
  6956. start: getElementStyles(this)
  6957. };
  6958. });
  6959. // apply class change
  6960. applyClassChange = function () {
  6961. $.each(classAnimationActions, function (i, action) {
  6962. if (value[action]) {
  6963. animated[action + "Class"](value[action]);
  6964. }
  6965. });
  6966. };
  6967. applyClassChange();
  6968. // map all animated objects again - calculate new styles and diff
  6969. allAnimations = allAnimations.map(function () {
  6970. this.end = getElementStyles(this.el[0]);
  6971. this.diff = styleDifference(this.start, this.end);
  6972. return this;
  6973. });
  6974. // apply original class
  6975. animated.attr("class", baseClass);
  6976. // map all animated objects again - this time collecting a promise
  6977. allAnimations = allAnimations.map(function () {
  6978. var styleInfo = this,
  6979. dfd = $.Deferred(),
  6980. opts = $.extend({}, o, {
  6981. queue: false,
  6982. complete: function () {
  6983. dfd.resolve(styleInfo);
  6984. }
  6985. });
  6986. this.el.animate(this.diff, opts);
  6987. return dfd.promise();
  6988. });
  6989. // once all animations have completed:
  6990. $.when.apply($, allAnimations.get()).done(function () {
  6991. // set the final class
  6992. applyClassChange();
  6993. // for each animated element,
  6994. // clear all css properties that were animated
  6995. $.each(arguments, function () {
  6996. var el = this.el;
  6997. $.each(this.diff, function (key) {
  6998. el.css(key, "");
  6999. });
  7000. });
  7001. // this is guarnteed to be there if you use jQuery.speed()
  7002. // it also handles dequeuing the next anim...
  7003. o.complete.call(animated[0]);
  7004. });
  7005. });
  7006. };
  7007. $.fn.extend({
  7008. addClass: (function (orig) {
  7009. return function (classNames, speed, easing, callback) {
  7010. return speed ?
  7011. $.effects.animateClass.call(this,
  7012. { add: classNames }, speed, easing, callback) :
  7013. orig.apply(this, arguments);
  7014. };
  7015. })($.fn.addClass),
  7016. removeClass: (function (orig) {
  7017. return function (classNames, speed, easing, callback) {
  7018. return arguments.length > 1 ?
  7019. $.effects.animateClass.call(this,
  7020. { remove: classNames }, speed, easing, callback) :
  7021. orig.apply(this, arguments);
  7022. };
  7023. })($.fn.removeClass),
  7024. toggleClass: (function (orig) {
  7025. return function (classNames, force, speed, easing, callback) {
  7026. if (typeof force === "boolean" || force === undefined) {
  7027. if (!speed) {
  7028. // without speed parameter
  7029. return orig.apply(this, arguments);
  7030. } else {
  7031. return $.effects.animateClass.call(this,
  7032. (force ? { add: classNames } : { remove: classNames }),
  7033. speed, easing, callback);
  7034. }
  7035. } else {
  7036. // without force parameter
  7037. return $.effects.animateClass.call(this,
  7038. { toggle: classNames }, force, speed, easing);
  7039. }
  7040. };
  7041. })($.fn.toggleClass),
  7042. switchClass: function (remove, add, speed, easing, callback) {
  7043. return $.effects.animateClass.call(this, {
  7044. add: add,
  7045. remove: remove
  7046. }, speed, easing, callback);
  7047. }
  7048. });
  7049. })();
  7050. /******************************************************************************/
  7051. /*********************************** EFFECTS **********************************/
  7052. /******************************************************************************/
  7053. (function () {
  7054. $.extend($.effects, {
  7055. version: "1.10.4",
  7056. // Saves a set of properties in a data storage
  7057. save: function (element, set) {
  7058. for (var i = 0; i < set.length; i++) {
  7059. if (set[i] !== null) {
  7060. element.data(dataSpace + set[i], element[0].style[set[i]]);
  7061. }
  7062. }
  7063. },
  7064. // Restores a set of previously saved properties from a data storage
  7065. restore: function (element, set) {
  7066. var val, i;
  7067. for (i = 0; i < set.length; i++) {
  7068. if (set[i] !== null) {
  7069. val = element.data(dataSpace + set[i]);
  7070. // support: jQuery 1.6.2
  7071. // http://bugs.jquery.com/ticket/9917
  7072. // jQuery 1.6.2 incorrectly returns undefined for any falsy value.
  7073. // We can't differentiate between "" and 0 here, so we just assume
  7074. // empty string since it's likely to be a more common value...
  7075. if (val === undefined) {
  7076. val = "";
  7077. }
  7078. element.css(set[i], val);
  7079. }
  7080. }
  7081. },
  7082. setMode: function (el, mode) {
  7083. if (mode === "toggle") {
  7084. mode = el.is(":hidden") ? "show" : "hide";
  7085. }
  7086. return mode;
  7087. },
  7088. // Translates a [top,left] array into a baseline value
  7089. // this should be a little more flexible in the future to handle a string & hash
  7090. getBaseline: function (origin, original) {
  7091. var y, x;
  7092. switch (origin[0]) {
  7093. case "top": y = 0; break;
  7094. case "middle": y = 0.5; break;
  7095. case "bottom": y = 1; break;
  7096. default: y = origin[0] / original.height;
  7097. }
  7098. switch (origin[1]) {
  7099. case "left": x = 0; break;
  7100. case "center": x = 0.5; break;
  7101. case "right": x = 1; break;
  7102. default: x = origin[1] / original.width;
  7103. }
  7104. return {
  7105. x: x,
  7106. y: y
  7107. };
  7108. },
  7109. // Wraps the element around a wrapper that copies position properties
  7110. createWrapper: function (element) {
  7111. // if the element is already wrapped, return it
  7112. if (element.parent().is(".ui-effects-wrapper")) {
  7113. return element.parent();
  7114. }
  7115. // wrap the element
  7116. var props = {
  7117. width: element.outerWidth(true),
  7118. height: element.outerHeight(true),
  7119. "float": element.css("float")
  7120. },
  7121. wrapper = $("<div></div>")
  7122. .addClass("ui-effects-wrapper")
  7123. .css({
  7124. fontSize: "100%",
  7125. background: "transparent",
  7126. border: "none",
  7127. margin: 0,
  7128. padding: 0
  7129. }),
  7130. // Store the size in case width/height are defined in % - Fixes #5245
  7131. size = {
  7132. width: element.width(),
  7133. height: element.height()
  7134. },
  7135. active = document.activeElement;
  7136. // support: Firefox
  7137. // Firefox incorrectly exposes anonymous content
  7138. // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
  7139. try {
  7140. active.id;
  7141. } catch (e) {
  7142. active = document.body;
  7143. }
  7144. element.wrap(wrapper);
  7145. // Fixes #7595 - Elements lose focus when wrapped.
  7146. if (element[0] === active || $.contains(element[0], active)) {
  7147. $(active).focus();
  7148. }
  7149. wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element
  7150. // transfer positioning properties to the wrapper
  7151. if (element.css("position") === "static") {
  7152. wrapper.css({ position: "relative" });
  7153. element.css({ position: "relative" });
  7154. } else {
  7155. $.extend(props, {
  7156. position: element.css("position"),
  7157. zIndex: element.css("z-index")
  7158. });
  7159. $.each(["top", "left", "bottom", "right"], function (i, pos) {
  7160. props[pos] = element.css(pos);
  7161. if (isNaN(parseInt(props[pos], 10))) {
  7162. props[pos] = "auto";
  7163. }
  7164. });
  7165. element.css({
  7166. position: "relative",
  7167. top: 0,
  7168. left: 0,
  7169. right: "auto",
  7170. bottom: "auto"
  7171. });
  7172. }
  7173. element.css(size);
  7174. return wrapper.css(props).show();
  7175. },
  7176. removeWrapper: function (element) {
  7177. var active = document.activeElement;
  7178. if (element.parent().is(".ui-effects-wrapper")) {
  7179. element.parent().replaceWith(element);
  7180. // Fixes #7595 - Elements lose focus when wrapped.
  7181. if (element[0] === active || $.contains(element[0], active)) {
  7182. $(active).focus();
  7183. }
  7184. }
  7185. return element;
  7186. },
  7187. setTransition: function (element, list, factor, value) {
  7188. value = value || {};
  7189. $.each(list, function (i, x) {
  7190. var unit = element.cssUnit(x);
  7191. if (unit[0] > 0) {
  7192. value[x] = unit[0] * factor + unit[1];
  7193. }
  7194. });
  7195. return value;
  7196. }
  7197. });
  7198. // return an effect options object for the given parameters:
  7199. function _normalizeArguments(effect, options, speed, callback) {
  7200. // allow passing all options as the first parameter
  7201. if ($.isPlainObject(effect)) {
  7202. options = effect;
  7203. effect = effect.effect;
  7204. }
  7205. // convert to an object
  7206. effect = { effect: effect };
  7207. // catch (effect, null, ...)
  7208. if (options == null) {
  7209. options = {};
  7210. }
  7211. // catch (effect, callback)
  7212. if ($.isFunction(options)) {
  7213. callback = options;
  7214. speed = null;
  7215. options = {};
  7216. }
  7217. // catch (effect, speed, ?)
  7218. if (typeof options === "number" || $.fx.speeds[options]) {
  7219. callback = speed;
  7220. speed = options;
  7221. options = {};
  7222. }
  7223. // catch (effect, options, callback)
  7224. if ($.isFunction(speed)) {
  7225. callback = speed;
  7226. speed = null;
  7227. }
  7228. // add options to effect
  7229. if (options) {
  7230. $.extend(effect, options);
  7231. }
  7232. speed = speed || options.duration;
  7233. effect.duration = $.fx.off ? 0 :
  7234. typeof speed === "number" ? speed :
  7235. speed in $.fx.speeds ? $.fx.speeds[speed] :
  7236. $.fx.speeds._default;
  7237. effect.complete = callback || options.complete;
  7238. return effect;
  7239. }
  7240. function standardAnimationOption(option) {
  7241. // Valid standard speeds (nothing, number, named speed)
  7242. if (!option || typeof option === "number" || $.fx.speeds[option]) {
  7243. return true;
  7244. }
  7245. // Invalid strings - treat as "normal" speed
  7246. if (typeof option === "string" && !$.effects.effect[option]) {
  7247. return true;
  7248. }
  7249. // Complete callback
  7250. if ($.isFunction(option)) {
  7251. return true;
  7252. }
  7253. // Options hash (but not naming an effect)
  7254. if (typeof option === "object" && !option.effect) {
  7255. return true;
  7256. }
  7257. // Didn't match any standard API
  7258. return false;
  7259. }
  7260. $.fn.extend({
  7261. effect: function ( /* effect, options, speed, callback */) {
  7262. var args = _normalizeArguments.apply(this, arguments),
  7263. mode = args.mode,
  7264. queue = args.queue,
  7265. effectMethod = $.effects.effect[args.effect];
  7266. if ($.fx.off || !effectMethod) {
  7267. // delegate to the original method (e.g., .show()) if possible
  7268. if (mode) {
  7269. return this[mode](args.duration, args.complete);
  7270. } else {
  7271. return this.each(function () {
  7272. if (args.complete) {
  7273. args.complete.call(this);
  7274. }
  7275. });
  7276. }
  7277. }
  7278. function run(next) {
  7279. var elem = $(this),
  7280. complete = args.complete,
  7281. mode = args.mode;
  7282. function done() {
  7283. if ($.isFunction(complete)) {
  7284. complete.call(elem[0]);
  7285. }
  7286. if ($.isFunction(next)) {
  7287. next();
  7288. }
  7289. }
  7290. // If the element already has the correct final state, delegate to
  7291. // the core methods so the internal tracking of "olddisplay" works.
  7292. if (elem.is(":hidden") ? mode === "hide" : mode === "show") {
  7293. elem[mode]();
  7294. done();
  7295. } else {
  7296. effectMethod.call(elem[0], args, done);
  7297. }
  7298. }
  7299. return queue === false ? this.each(run) : this.queue(queue || "fx", run);
  7300. },
  7301. show: (function (orig) {
  7302. return function (option) {
  7303. if (standardAnimationOption(option)) {
  7304. return orig.apply(this, arguments);
  7305. } else {
  7306. var args = _normalizeArguments.apply(this, arguments);
  7307. args.mode = "show";
  7308. return this.effect.call(this, args);
  7309. }
  7310. };
  7311. })($.fn.show),
  7312. hide: (function (orig) {
  7313. return function (option) {
  7314. if (standardAnimationOption(option)) {
  7315. return orig.apply(this, arguments);
  7316. } else {
  7317. var args = _normalizeArguments.apply(this, arguments);
  7318. args.mode = "hide";
  7319. return this.effect.call(this, args);
  7320. }
  7321. };
  7322. })($.fn.hide),
  7323. toggle: (function (orig) {
  7324. return function (option) {
  7325. if (standardAnimationOption(option) || typeof option === "boolean") {
  7326. return orig.apply(this, arguments);
  7327. } else {
  7328. var args = _normalizeArguments.apply(this, arguments);
  7329. args.mode = "toggle";
  7330. return this.effect.call(this, args);
  7331. }
  7332. };
  7333. })($.fn.toggle),
  7334. // helper functions
  7335. cssUnit: function (key) {
  7336. var style = this.css(key),
  7337. val = [];
  7338. $.each(["em", "px", "%", "pt"], function (i, unit) {
  7339. if (style.indexOf(unit) > 0) {
  7340. val = [parseFloat(style), unit];
  7341. }
  7342. });
  7343. return val;
  7344. }
  7345. });
  7346. })();
  7347. /******************************************************************************/
  7348. /*********************************** EASING ***********************************/
  7349. /******************************************************************************/
  7350. (function () {
  7351. // based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
  7352. var baseEasings = {};
  7353. $.each(["Quad", "Cubic", "Quart", "Quint", "Expo"], function (i, name) {
  7354. baseEasings[name] = function (p) {
  7355. return Math.pow(p, i + 2);
  7356. };
  7357. });
  7358. $.extend(baseEasings, {
  7359. Sine: function (p) {
  7360. return 1 - Math.cos(p * Math.PI / 2);
  7361. },
  7362. Circ: function (p) {
  7363. return 1 - Math.sqrt(1 - p * p);
  7364. },
  7365. Elastic: function (p) {
  7366. return p === 0 || p === 1 ? p :
  7367. -Math.pow(2, 8 * (p - 1)) * Math.sin(((p - 1) * 80 - 7.5) * Math.PI / 15);
  7368. },
  7369. Back: function (p) {
  7370. return p * p * (3 * p - 2);
  7371. },
  7372. Bounce: function (p) {
  7373. var pow2,
  7374. bounce = 4;
  7375. while (p < ((pow2 = Math.pow(2, --bounce)) - 1) / 11) { }
  7376. return 1 / Math.pow(4, 3 - bounce) - 7.5625 * Math.pow((pow2 * 3 - 2) / 22 - p, 2);
  7377. }
  7378. });
  7379. $.each(baseEasings, function (name, easeIn) {
  7380. $.easing["easeIn" + name] = easeIn;
  7381. $.easing["easeOut" + name] = function (p) {
  7382. return 1 - easeIn(1 - p);
  7383. };
  7384. $.easing["easeInOut" + name] = function (p) {
  7385. return p < 0.5 ?
  7386. easeIn(p * 2) / 2 :
  7387. 1 - easeIn(p * -2 + 2) / 2;
  7388. };
  7389. });
  7390. })();
  7391. })(jQuery);
  7392. (function ($, undefined) {
  7393. var rvertical = /up|down|vertical/,
  7394. rpositivemotion = /up|left|vertical|horizontal/;
  7395. $.effects.effect.blind = function (o, done) {
  7396. // Create element
  7397. var el = $(this),
  7398. props = ["position", "top", "bottom", "left", "right", "height", "width"],
  7399. mode = $.effects.setMode(el, o.mode || "hide"),
  7400. direction = o.direction || "up",
  7401. vertical = rvertical.test(direction),
  7402. ref = vertical ? "height" : "width",
  7403. ref2 = vertical ? "top" : "left",
  7404. motion = rpositivemotion.test(direction),
  7405. animation = {},
  7406. show = mode === "show",
  7407. wrapper, distance, margin;
  7408. // if already wrapped, the wrapper's properties are my property. #6245
  7409. if (el.parent().is(".ui-effects-wrapper")) {
  7410. $.effects.save(el.parent(), props);
  7411. } else {
  7412. $.effects.save(el, props);
  7413. }
  7414. el.show();
  7415. wrapper = $.effects.createWrapper(el).css({
  7416. overflow: "hidden"
  7417. });
  7418. distance = wrapper[ref]();
  7419. margin = parseFloat(wrapper.css(ref2)) || 0;
  7420. animation[ref] = show ? distance : 0;
  7421. if (!motion) {
  7422. el
  7423. .css(vertical ? "bottom" : "right", 0)
  7424. .css(vertical ? "top" : "left", "auto")
  7425. .css({ position: "absolute" });
  7426. animation[ref2] = show ? margin : distance + margin;
  7427. }
  7428. // start at 0 if we are showing
  7429. if (show) {
  7430. wrapper.css(ref, 0);
  7431. if (!motion) {
  7432. wrapper.css(ref2, margin + distance);
  7433. }
  7434. }
  7435. // Animate
  7436. wrapper.animate(animation, {
  7437. duration: o.duration,
  7438. easing: o.easing,
  7439. queue: false,
  7440. complete: function () {
  7441. if (mode === "hide") {
  7442. el.hide();
  7443. }
  7444. $.effects.restore(el, props);
  7445. $.effects.removeWrapper(el);
  7446. done();
  7447. }
  7448. });
  7449. };
  7450. })(jQuery);
  7451. (function ($, undefined) {
  7452. $.effects.effect.bounce = function (o, done) {
  7453. var el = $(this),
  7454. props = ["position", "top", "bottom", "left", "right", "height", "width"],
  7455. // defaults:
  7456. mode = $.effects.setMode(el, o.mode || "effect"),
  7457. hide = mode === "hide",
  7458. show = mode === "show",
  7459. direction = o.direction || "up",
  7460. distance = o.distance,
  7461. times = o.times || 5,
  7462. // number of internal animations
  7463. anims = times * 2 + (show || hide ? 1 : 0),
  7464. speed = o.duration / anims,
  7465. easing = o.easing,
  7466. // utility:
  7467. ref = (direction === "up" || direction === "down") ? "top" : "left",
  7468. motion = (direction === "up" || direction === "left"),
  7469. i,
  7470. upAnim,
  7471. downAnim,
  7472. // we will need to re-assemble the queue to stack our animations in place
  7473. queue = el.queue(),
  7474. queuelen = queue.length;
  7475. // Avoid touching opacity to prevent clearType and PNG issues in IE
  7476. if (show || hide) {
  7477. props.push("opacity");
  7478. }
  7479. $.effects.save(el, props);
  7480. el.show();
  7481. $.effects.createWrapper(el); // Create Wrapper
  7482. // default distance for the BIGGEST bounce is the outer Distance / 3
  7483. if (!distance) {
  7484. distance = el[ref === "top" ? "outerHeight" : "outerWidth"]() / 3;
  7485. }
  7486. if (show) {
  7487. downAnim = { opacity: 1 };
  7488. downAnim[ref] = 0;
  7489. // if we are showing, force opacity 0 and set the initial position
  7490. // then do the "first" animation
  7491. el.css("opacity", 0)
  7492. .css(ref, motion ? -distance * 2 : distance * 2)
  7493. .animate(downAnim, speed, easing);
  7494. }
  7495. // start at the smallest distance if we are hiding
  7496. if (hide) {
  7497. distance = distance / Math.pow(2, times - 1);
  7498. }
  7499. downAnim = {};
  7500. downAnim[ref] = 0;
  7501. // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
  7502. for (i = 0; i < times; i++) {
  7503. upAnim = {};
  7504. upAnim[ref] = (motion ? "-=" : "+=") + distance;
  7505. el.animate(upAnim, speed, easing)
  7506. .animate(downAnim, speed, easing);
  7507. distance = hide ? distance * 2 : distance / 2;
  7508. }
  7509. // Last Bounce when Hiding
  7510. if (hide) {
  7511. upAnim = { opacity: 0 };
  7512. upAnim[ref] = (motion ? "-=" : "+=") + distance;
  7513. el.animate(upAnim, speed, easing);
  7514. }
  7515. el.queue(function () {
  7516. if (hide) {
  7517. el.hide();
  7518. }
  7519. $.effects.restore(el, props);
  7520. $.effects.removeWrapper(el);
  7521. done();
  7522. });
  7523. // inject all the animations we just queued to be first in line (after "inprogress")
  7524. if (queuelen > 1) {
  7525. queue.splice.apply(queue,
  7526. [1, 0].concat(queue.splice(queuelen, anims + 1)));
  7527. }
  7528. el.dequeue();
  7529. };
  7530. })(jQuery);
  7531. (function ($, undefined) {
  7532. $.effects.effect.clip = function (o, done) {
  7533. // Create element
  7534. var el = $(this),
  7535. props = ["position", "top", "bottom", "left", "right", "height", "width"],
  7536. mode = $.effects.setMode(el, o.mode || "hide"),
  7537. show = mode === "show",
  7538. direction = o.direction || "vertical",
  7539. vert = direction === "vertical",
  7540. size = vert ? "height" : "width",
  7541. position = vert ? "top" : "left",
  7542. animation = {},
  7543. wrapper, animate, distance;
  7544. // Save & Show
  7545. $.effects.save(el, props);
  7546. el.show();
  7547. // Create Wrapper
  7548. wrapper = $.effects.createWrapper(el).css({
  7549. overflow: "hidden"
  7550. });
  7551. animate = (el[0].tagName === "IMG") ? wrapper : el;
  7552. distance = animate[size]();
  7553. // Shift
  7554. if (show) {
  7555. animate.css(size, 0);
  7556. animate.css(position, distance / 2);
  7557. }
  7558. // Create Animation Object:
  7559. animation[size] = show ? distance : 0;
  7560. animation[position] = show ? 0 : distance / 2;
  7561. // Animate
  7562. animate.animate(animation, {
  7563. queue: false,
  7564. duration: o.duration,
  7565. easing: o.easing,
  7566. complete: function () {
  7567. if (!show) {
  7568. el.hide();
  7569. }
  7570. $.effects.restore(el, props);
  7571. $.effects.removeWrapper(el);
  7572. done();
  7573. }
  7574. });
  7575. };
  7576. })(jQuery);
  7577. (function ($, undefined) {
  7578. $.effects.effect.drop = function (o, done) {
  7579. var el = $(this),
  7580. props = ["position", "top", "bottom", "left", "right", "opacity", "height", "width"],
  7581. mode = $.effects.setMode(el, o.mode || "hide"),
  7582. show = mode === "show",
  7583. direction = o.direction || "left",
  7584. ref = (direction === "up" || direction === "down") ? "top" : "left",
  7585. motion = (direction === "up" || direction === "left") ? "pos" : "neg",
  7586. animation = {
  7587. opacity: show ? 1 : 0
  7588. },
  7589. distance;
  7590. // Adjust
  7591. $.effects.save(el, props);
  7592. el.show();
  7593. $.effects.createWrapper(el);
  7594. distance = o.distance || el[ref === "top" ? "outerHeight" : "outerWidth"](true) / 2;
  7595. if (show) {
  7596. el
  7597. .css("opacity", 0)
  7598. .css(ref, motion === "pos" ? -distance : distance);
  7599. }
  7600. // Animation
  7601. animation[ref] = (show ?
  7602. (motion === "pos" ? "+=" : "-=") :
  7603. (motion === "pos" ? "-=" : "+=")) +
  7604. distance;
  7605. // Animate
  7606. el.animate(animation, {
  7607. queue: false,
  7608. duration: o.duration,
  7609. easing: o.easing,
  7610. complete: function () {
  7611. if (mode === "hide") {
  7612. el.hide();
  7613. }
  7614. $.effects.restore(el, props);
  7615. $.effects.removeWrapper(el);
  7616. done();
  7617. }
  7618. });
  7619. };
  7620. })(jQuery);
  7621. (function ($, undefined) {
  7622. $.effects.effect.explode = function (o, done) {
  7623. var rows = o.pieces ? Math.round(Math.sqrt(o.pieces)) : 3,
  7624. cells = rows,
  7625. el = $(this),
  7626. mode = $.effects.setMode(el, o.mode || "hide"),
  7627. show = mode === "show",
  7628. // show and then visibility:hidden the element before calculating offset
  7629. offset = el.show().css("visibility", "hidden").offset(),
  7630. // width and height of a piece
  7631. width = Math.ceil(el.outerWidth() / cells),
  7632. height = Math.ceil(el.outerHeight() / rows),
  7633. pieces = [],
  7634. // loop
  7635. i, j, left, top, mx, my;
  7636. // children animate complete:
  7637. function childComplete() {
  7638. pieces.push(this);
  7639. if (pieces.length === rows * cells) {
  7640. animComplete();
  7641. }
  7642. }
  7643. // clone the element for each row and cell.
  7644. for (i = 0; i < rows; i++) { // ===>
  7645. top = offset.top + i * height;
  7646. my = i - (rows - 1) / 2;
  7647. for (j = 0; j < cells; j++) { // |||
  7648. left = offset.left + j * width;
  7649. mx = j - (cells - 1) / 2;
  7650. // Create a clone of the now hidden main element that will be absolute positioned
  7651. // within a wrapper div off the -left and -top equal to size of our pieces
  7652. el
  7653. .clone()
  7654. .appendTo("body")
  7655. .wrap("<div></div>")
  7656. .css({
  7657. position: "absolute",
  7658. visibility: "visible",
  7659. left: -j * width,
  7660. top: -i * height
  7661. })
  7662. // select the wrapper - make it overflow: hidden and absolute positioned based on
  7663. // where the original was located +left and +top equal to the size of pieces
  7664. .parent()
  7665. .addClass("ui-effects-explode")
  7666. .css({
  7667. position: "absolute",
  7668. overflow: "hidden",
  7669. width: width,
  7670. height: height,
  7671. left: left + (show ? mx * width : 0),
  7672. top: top + (show ? my * height : 0),
  7673. opacity: show ? 0 : 1
  7674. }).animate({
  7675. left: left + (show ? 0 : mx * width),
  7676. top: top + (show ? 0 : my * height),
  7677. opacity: show ? 1 : 0
  7678. }, o.duration || 500, o.easing, childComplete);
  7679. }
  7680. }
  7681. function animComplete() {
  7682. el.css({
  7683. visibility: "visible"
  7684. });
  7685. $(pieces).remove();
  7686. if (!show) {
  7687. el.hide();
  7688. }
  7689. done();
  7690. }
  7691. };
  7692. })(jQuery);
  7693. (function ($, undefined) {
  7694. $.effects.effect.fade = function (o, done) {
  7695. var el = $(this),
  7696. mode = $.effects.setMode(el, o.mode || "toggle");
  7697. el.animate({
  7698. opacity: mode
  7699. }, {
  7700. queue: false,
  7701. duration: o.duration,
  7702. easing: o.easing,
  7703. complete: done
  7704. });
  7705. };
  7706. })(jQuery);
  7707. (function ($, undefined) {
  7708. $.effects.effect.fold = function (o, done) {
  7709. // Create element
  7710. var el = $(this),
  7711. props = ["position", "top", "bottom", "left", "right", "height", "width"],
  7712. mode = $.effects.setMode(el, o.mode || "hide"),
  7713. show = mode === "show",
  7714. hide = mode === "hide",
  7715. size = o.size || 15,
  7716. percent = /([0-9]+)%/.exec(size),
  7717. horizFirst = !!o.horizFirst,
  7718. widthFirst = show !== horizFirst,
  7719. ref = widthFirst ? ["width", "height"] : ["height", "width"],
  7720. duration = o.duration / 2,
  7721. wrapper, distance,
  7722. animation1 = {},
  7723. animation2 = {};
  7724. $.effects.save(el, props);
  7725. el.show();
  7726. // Create Wrapper
  7727. wrapper = $.effects.createWrapper(el).css({
  7728. overflow: "hidden"
  7729. });
  7730. distance = widthFirst ?
  7731. [wrapper.width(), wrapper.height()] :
  7732. [wrapper.height(), wrapper.width()];
  7733. if (percent) {
  7734. size = parseInt(percent[1], 10) / 100 * distance[hide ? 0 : 1];
  7735. }
  7736. if (show) {
  7737. wrapper.css(horizFirst ? {
  7738. height: 0,
  7739. width: size
  7740. } : {
  7741. height: size,
  7742. width: 0
  7743. });
  7744. }
  7745. // Animation
  7746. animation1[ref[0]] = show ? distance[0] : size;
  7747. animation2[ref[1]] = show ? distance[1] : 0;
  7748. // Animate
  7749. wrapper
  7750. .animate(animation1, duration, o.easing)
  7751. .animate(animation2, duration, o.easing, function () {
  7752. if (hide) {
  7753. el.hide();
  7754. }
  7755. $.effects.restore(el, props);
  7756. $.effects.removeWrapper(el);
  7757. done();
  7758. });
  7759. };
  7760. })(jQuery);
  7761. (function ($, undefined) {
  7762. $.effects.effect.highlight = function (o, done) {
  7763. var elem = $(this),
  7764. props = ["backgroundImage", "backgroundColor", "opacity"],
  7765. mode = $.effects.setMode(elem, o.mode || "show"),
  7766. animation = {
  7767. backgroundColor: elem.css("backgroundColor")
  7768. };
  7769. if (mode === "hide") {
  7770. animation.opacity = 0;
  7771. }
  7772. $.effects.save(elem, props);
  7773. elem
  7774. .show()
  7775. .css({
  7776. backgroundImage: "none",
  7777. backgroundColor: o.color || "#ffff99"
  7778. })
  7779. .animate(animation, {
  7780. queue: false,
  7781. duration: o.duration,
  7782. easing: o.easing,
  7783. complete: function () {
  7784. if (mode === "hide") {
  7785. elem.hide();
  7786. }
  7787. $.effects.restore(elem, props);
  7788. done();
  7789. }
  7790. });
  7791. };
  7792. })(jQuery);
  7793. (function ($, undefined) {
  7794. $.effects.effect.pulsate = function (o, done) {
  7795. var elem = $(this),
  7796. mode = $.effects.setMode(elem, o.mode || "show"),
  7797. show = mode === "show",
  7798. hide = mode === "hide",
  7799. showhide = (show || mode === "hide"),
  7800. // showing or hiding leaves of the "last" animation
  7801. anims = ((o.times || 5) * 2) + (showhide ? 1 : 0),
  7802. duration = o.duration / anims,
  7803. animateTo = 0,
  7804. queue = elem.queue(),
  7805. queuelen = queue.length,
  7806. i;
  7807. if (show || !elem.is(":visible")) {
  7808. elem.css("opacity", 0).show();
  7809. animateTo = 1;
  7810. }
  7811. // anims - 1 opacity "toggles"
  7812. for (i = 1; i < anims; i++) {
  7813. elem.animate({
  7814. opacity: animateTo
  7815. }, duration, o.easing);
  7816. animateTo = 1 - animateTo;
  7817. }
  7818. elem.animate({
  7819. opacity: animateTo
  7820. }, duration, o.easing);
  7821. elem.queue(function () {
  7822. if (hide) {
  7823. elem.hide();
  7824. }
  7825. done();
  7826. });
  7827. // We just queued up "anims" animations, we need to put them next in the queue
  7828. if (queuelen > 1) {
  7829. queue.splice.apply(queue,
  7830. [1, 0].concat(queue.splice(queuelen, anims + 1)));
  7831. }
  7832. elem.dequeue();
  7833. };
  7834. })(jQuery);
  7835. (function ($, undefined) {
  7836. $.effects.effect.puff = function (o, done) {
  7837. var elem = $(this),
  7838. mode = $.effects.setMode(elem, o.mode || "hide"),
  7839. hide = mode === "hide",
  7840. percent = parseInt(o.percent, 10) || 150,
  7841. factor = percent / 100,
  7842. original = {
  7843. height: elem.height(),
  7844. width: elem.width(),
  7845. outerHeight: elem.outerHeight(),
  7846. outerWidth: elem.outerWidth()
  7847. };
  7848. $.extend(o, {
  7849. effect: "scale",
  7850. queue: false,
  7851. fade: true,
  7852. mode: mode,
  7853. complete: done,
  7854. percent: hide ? percent : 100,
  7855. from: hide ?
  7856. original :
  7857. {
  7858. height: original.height * factor,
  7859. width: original.width * factor,
  7860. outerHeight: original.outerHeight * factor,
  7861. outerWidth: original.outerWidth * factor
  7862. }
  7863. });
  7864. elem.effect(o);
  7865. };
  7866. $.effects.effect.scale = function (o, done) {
  7867. // Create element
  7868. var el = $(this),
  7869. options = $.extend(true, {}, o),
  7870. mode = $.effects.setMode(el, o.mode || "effect"),
  7871. percent = parseInt(o.percent, 10) ||
  7872. (parseInt(o.percent, 10) === 0 ? 0 : (mode === "hide" ? 0 : 100)),
  7873. direction = o.direction || "both",
  7874. origin = o.origin,
  7875. original = {
  7876. height: el.height(),
  7877. width: el.width(),
  7878. outerHeight: el.outerHeight(),
  7879. outerWidth: el.outerWidth()
  7880. },
  7881. factor = {
  7882. y: direction !== "horizontal" ? (percent / 100) : 1,
  7883. x: direction !== "vertical" ? (percent / 100) : 1
  7884. };
  7885. // We are going to pass this effect to the size effect:
  7886. options.effect = "size";
  7887. options.queue = false;
  7888. options.complete = done;
  7889. // Set default origin and restore for show/hide
  7890. if (mode !== "effect") {
  7891. options.origin = origin || ["middle", "center"];
  7892. options.restore = true;
  7893. }
  7894. options.from = o.from || (mode === "show" ? {
  7895. height: 0,
  7896. width: 0,
  7897. outerHeight: 0,
  7898. outerWidth: 0
  7899. } : original);
  7900. options.to = {
  7901. height: original.height * factor.y,
  7902. width: original.width * factor.x,
  7903. outerHeight: original.outerHeight * factor.y,
  7904. outerWidth: original.outerWidth * factor.x
  7905. };
  7906. // Fade option to support puff
  7907. if (options.fade) {
  7908. if (mode === "show") {
  7909. options.from.opacity = 0;
  7910. options.to.opacity = 1;
  7911. }
  7912. if (mode === "hide") {
  7913. options.from.opacity = 1;
  7914. options.to.opacity = 0;
  7915. }
  7916. }
  7917. // Animate
  7918. el.effect(options);
  7919. };
  7920. $.effects.effect.size = function (o, done) {
  7921. // Create element
  7922. var original, baseline, factor,
  7923. el = $(this),
  7924. props0 = ["position", "top", "bottom", "left", "right", "width", "height", "overflow", "opacity"],
  7925. // Always restore
  7926. props1 = ["position", "top", "bottom", "left", "right", "overflow", "opacity"],
  7927. // Copy for children
  7928. props2 = ["width", "height", "overflow"],
  7929. cProps = ["fontSize"],
  7930. vProps = ["borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom"],
  7931. hProps = ["borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight"],
  7932. // Set options
  7933. mode = $.effects.setMode(el, o.mode || "effect"),
  7934. restore = o.restore || mode !== "effect",
  7935. scale = o.scale || "both",
  7936. origin = o.origin || ["middle", "center"],
  7937. position = el.css("position"),
  7938. props = restore ? props0 : props1,
  7939. zero = {
  7940. height: 0,
  7941. width: 0,
  7942. outerHeight: 0,
  7943. outerWidth: 0
  7944. };
  7945. if (mode === "show") {
  7946. el.show();
  7947. }
  7948. original = {
  7949. height: el.height(),
  7950. width: el.width(),
  7951. outerHeight: el.outerHeight(),
  7952. outerWidth: el.outerWidth()
  7953. };
  7954. if (o.mode === "toggle" && mode === "show") {
  7955. el.from = o.to || zero;
  7956. el.to = o.from || original;
  7957. } else {
  7958. el.from = o.from || (mode === "show" ? zero : original);
  7959. el.to = o.to || (mode === "hide" ? zero : original);
  7960. }
  7961. // Set scaling factor
  7962. factor = {
  7963. from: {
  7964. y: el.from.height / original.height,
  7965. x: el.from.width / original.width
  7966. },
  7967. to: {
  7968. y: el.to.height / original.height,
  7969. x: el.to.width / original.width
  7970. }
  7971. };
  7972. // Scale the css box
  7973. if (scale === "box" || scale === "both") {
  7974. // Vertical props scaling
  7975. if (factor.from.y !== factor.to.y) {
  7976. props = props.concat(vProps);
  7977. el.from = $.effects.setTransition(el, vProps, factor.from.y, el.from);
  7978. el.to = $.effects.setTransition(el, vProps, factor.to.y, el.to);
  7979. }
  7980. // Horizontal props scaling
  7981. if (factor.from.x !== factor.to.x) {
  7982. props = props.concat(hProps);
  7983. el.from = $.effects.setTransition(el, hProps, factor.from.x, el.from);
  7984. el.to = $.effects.setTransition(el, hProps, factor.to.x, el.to);
  7985. }
  7986. }
  7987. // Scale the content
  7988. if (scale === "content" || scale === "both") {
  7989. // Vertical props scaling
  7990. if (factor.from.y !== factor.to.y) {
  7991. props = props.concat(cProps).concat(props2);
  7992. el.from = $.effects.setTransition(el, cProps, factor.from.y, el.from);
  7993. el.to = $.effects.setTransition(el, cProps, factor.to.y, el.to);
  7994. }
  7995. }
  7996. $.effects.save(el, props);
  7997. el.show();
  7998. $.effects.createWrapper(el);
  7999. el.css("overflow", "hidden").css(el.from);
  8000. // Adjust
  8001. if (origin) { // Calculate baseline shifts
  8002. baseline = $.effects.getBaseline(origin, original);
  8003. el.from.top = (original.outerHeight - el.outerHeight()) * baseline.y;
  8004. el.from.left = (original.outerWidth - el.outerWidth()) * baseline.x;
  8005. el.to.top = (original.outerHeight - el.to.outerHeight) * baseline.y;
  8006. el.to.left = (original.outerWidth - el.to.outerWidth) * baseline.x;
  8007. }
  8008. el.css(el.from); // set top & left
  8009. // Animate
  8010. if (scale === "content" || scale === "both") { // Scale the children
  8011. // Add margins/font-size
  8012. vProps = vProps.concat(["marginTop", "marginBottom"]).concat(cProps);
  8013. hProps = hProps.concat(["marginLeft", "marginRight"]);
  8014. props2 = props0.concat(vProps).concat(hProps);
  8015. el.find("*[width]").each(function () {
  8016. var child = $(this),
  8017. c_original = {
  8018. height: child.height(),
  8019. width: child.width(),
  8020. outerHeight: child.outerHeight(),
  8021. outerWidth: child.outerWidth()
  8022. };
  8023. if (restore) {
  8024. $.effects.save(child, props2);
  8025. }
  8026. child.from = {
  8027. height: c_original.height * factor.from.y,
  8028. width: c_original.width * factor.from.x,
  8029. outerHeight: c_original.outerHeight * factor.from.y,
  8030. outerWidth: c_original.outerWidth * factor.from.x
  8031. };
  8032. child.to = {
  8033. height: c_original.height * factor.to.y,
  8034. width: c_original.width * factor.to.x,
  8035. outerHeight: c_original.height * factor.to.y,
  8036. outerWidth: c_original.width * factor.to.x
  8037. };
  8038. // Vertical props scaling
  8039. if (factor.from.y !== factor.to.y) {
  8040. child.from = $.effects.setTransition(child, vProps, factor.from.y, child.from);
  8041. child.to = $.effects.setTransition(child, vProps, factor.to.y, child.to);
  8042. }
  8043. // Horizontal props scaling
  8044. if (factor.from.x !== factor.to.x) {
  8045. child.from = $.effects.setTransition(child, hProps, factor.from.x, child.from);
  8046. child.to = $.effects.setTransition(child, hProps, factor.to.x, child.to);
  8047. }
  8048. // Animate children
  8049. child.css(child.from);
  8050. child.animate(child.to, o.duration, o.easing, function () {
  8051. // Restore children
  8052. if (restore) {
  8053. $.effects.restore(child, props2);
  8054. }
  8055. });
  8056. });
  8057. }
  8058. // Animate
  8059. el.animate(el.to, {
  8060. queue: false,
  8061. duration: o.duration,
  8062. easing: o.easing,
  8063. complete: function () {
  8064. if (el.to.opacity === 0) {
  8065. el.css("opacity", el.from.opacity);
  8066. }
  8067. if (mode === "hide") {
  8068. el.hide();
  8069. }
  8070. $.effects.restore(el, props);
  8071. if (!restore) {
  8072. // we need to calculate our new positioning based on the scaling
  8073. if (position === "static") {
  8074. el.css({
  8075. position: "relative",
  8076. top: el.to.top,
  8077. left: el.to.left
  8078. });
  8079. } else {
  8080. $.each(["top", "left"], function (idx, pos) {
  8081. el.css(pos, function (_, str) {
  8082. var val = parseInt(str, 10),
  8083. toRef = idx ? el.to.left : el.to.top;
  8084. // if original was "auto", recalculate the new value from wrapper
  8085. if (str === "auto") {
  8086. return toRef + "px";
  8087. }
  8088. return val + toRef + "px";
  8089. });
  8090. });
  8091. }
  8092. }
  8093. $.effects.removeWrapper(el);
  8094. done();
  8095. }
  8096. });
  8097. };
  8098. })(jQuery);
  8099. (function ($, undefined) {
  8100. $.effects.effect.shake = function (o, done) {
  8101. var el = $(this),
  8102. props = ["position", "top", "bottom", "left", "right", "height", "width"],
  8103. mode = $.effects.setMode(el, o.mode || "effect"),
  8104. direction = o.direction || "left",
  8105. distance = o.distance || 20,
  8106. times = o.times || 3,
  8107. anims = times * 2 + 1,
  8108. speed = Math.round(o.duration / anims),
  8109. ref = (direction === "up" || direction === "down") ? "top" : "left",
  8110. positiveMotion = (direction === "up" || direction === "left"),
  8111. animation = {},
  8112. animation1 = {},
  8113. animation2 = {},
  8114. i,
  8115. // we will need to re-assemble the queue to stack our animations in place
  8116. queue = el.queue(),
  8117. queuelen = queue.length;
  8118. $.effects.save(el, props);
  8119. el.show();
  8120. $.effects.createWrapper(el);
  8121. // Animation
  8122. animation[ref] = (positiveMotion ? "-=" : "+=") + distance;
  8123. animation1[ref] = (positiveMotion ? "+=" : "-=") + distance * 2;
  8124. animation2[ref] = (positiveMotion ? "-=" : "+=") + distance * 2;
  8125. // Animate
  8126. el.animate(animation, speed, o.easing);
  8127. // Shakes
  8128. for (i = 1; i < times; i++) {
  8129. el.animate(animation1, speed, o.easing).animate(animation2, speed, o.easing);
  8130. }
  8131. el
  8132. .animate(animation1, speed, o.easing)
  8133. .animate(animation, speed / 2, o.easing)
  8134. .queue(function () {
  8135. if (mode === "hide") {
  8136. el.hide();
  8137. }
  8138. $.effects.restore(el, props);
  8139. $.effects.removeWrapper(el);
  8140. done();
  8141. });
  8142. // inject all the animations we just queued to be first in line (after "inprogress")
  8143. if (queuelen > 1) {
  8144. queue.splice.apply(queue,
  8145. [1, 0].concat(queue.splice(queuelen, anims + 1)));
  8146. }
  8147. el.dequeue();
  8148. };
  8149. })(jQuery);
  8150. (function ($, undefined) {
  8151. $.effects.effect.slide = function (o, done) {
  8152. // Create element
  8153. var el = $(this),
  8154. props = ["position", "top", "bottom", "left", "right", "width", "height"],
  8155. mode = $.effects.setMode(el, o.mode || "show"),
  8156. show = mode === "show",
  8157. direction = o.direction || "left",
  8158. ref = (direction === "up" || direction === "down") ? "top" : "left",
  8159. positiveMotion = (direction === "up" || direction === "left"),
  8160. distance,
  8161. animation = {};
  8162. // Adjust
  8163. $.effects.save(el, props);
  8164. el.show();
  8165. distance = o.distance || el[ref === "top" ? "outerHeight" : "outerWidth"](true);
  8166. $.effects.createWrapper(el).css({
  8167. overflow: "hidden"
  8168. });
  8169. if (show) {
  8170. el.css(ref, positiveMotion ? (isNaN(distance) ? "-" + distance : -distance) : distance);
  8171. }
  8172. // Animation
  8173. animation[ref] = (show ?
  8174. (positiveMotion ? "+=" : "-=") :
  8175. (positiveMotion ? "-=" : "+=")) +
  8176. distance;
  8177. // Animate
  8178. el.animate(animation, {
  8179. queue: false,
  8180. duration: o.duration,
  8181. easing: o.easing,
  8182. complete: function () {
  8183. if (mode === "hide") {
  8184. el.hide();
  8185. }
  8186. $.effects.restore(el, props);
  8187. $.effects.removeWrapper(el);
  8188. done();
  8189. }
  8190. });
  8191. };
  8192. })(jQuery);
  8193. (function ($, undefined) {
  8194. $.effects.effect.transfer = function (o, done) {
  8195. var elem = $(this),
  8196. target = $(o.to),
  8197. targetFixed = target.css("position") === "fixed",
  8198. body = $("body"),
  8199. fixTop = targetFixed ? body.scrollTop() : 0,
  8200. fixLeft = targetFixed ? body.scrollLeft() : 0,
  8201. endPosition = target.offset(),
  8202. animation = {
  8203. top: endPosition.top - fixTop,
  8204. left: endPosition.left - fixLeft,
  8205. height: target.innerHeight(),
  8206. width: target.innerWidth()
  8207. },
  8208. startPosition = elem.offset(),
  8209. transfer = $("<div class='ui-effects-transfer'></div>")
  8210. .appendTo(document.body)
  8211. .addClass(o.className)
  8212. .css({
  8213. top: startPosition.top - fixTop,
  8214. left: startPosition.left - fixLeft,
  8215. height: elem.innerHeight(),
  8216. width: elem.innerWidth(),
  8217. position: targetFixed ? "fixed" : "absolute"
  8218. })
  8219. .animate(animation, o.duration, o.easing, function () {
  8220. transfer.remove();
  8221. done();
  8222. });
  8223. };
  8224. })(jQuery);
  8225. (function ($, undefined) {
  8226. $.widget("ui.menu", {
  8227. version: "1.10.4",
  8228. defaultElement: "<ul>",
  8229. delay: 300,
  8230. options: {
  8231. icons: {
  8232. submenu: "ui-icon-carat-1-e"
  8233. },
  8234. menus: "ul",
  8235. position: {
  8236. my: "left top",
  8237. at: "right top"
  8238. },
  8239. role: "menu",
  8240. // callbacks
  8241. blur: null,
  8242. focus: null,
  8243. select: null
  8244. },
  8245. _create: function () {
  8246. this.activeMenu = this.element;
  8247. // flag used to prevent firing of the click handler
  8248. // as the event bubbles up through nested menus
  8249. this.mouseHandled = false;
  8250. this.element
  8251. .uniqueId()
  8252. .addClass("ui-menu ui-widget ui-widget-content ui-corner-all")
  8253. .toggleClass("ui-menu-icons", !!this.element.find(".ui-icon").length)
  8254. .attr({
  8255. role: this.options.role,
  8256. tabIndex: 0
  8257. })
  8258. // need to catch all clicks on disabled menu
  8259. // not possible through _on
  8260. .bind("click" + this.eventNamespace, $.proxy(function (event) {
  8261. if (this.options.disabled) {
  8262. event.preventDefault();
  8263. }
  8264. }, this));
  8265. if (this.options.disabled) {
  8266. this.element
  8267. .addClass("ui-state-disabled")
  8268. .attr("aria-disabled", "true");
  8269. }
  8270. this._on({
  8271. // Prevent focus from sticking to links inside menu after clicking
  8272. // them (focus should always stay on UL during navigation).
  8273. "mousedown .ui-menu-item > a": function (event) {
  8274. event.preventDefault();
  8275. },
  8276. "click .ui-state-disabled > a": function (event) {
  8277. event.preventDefault();
  8278. },
  8279. "click .ui-menu-item:has(a)": function (event) {
  8280. var target = $(event.target).closest(".ui-menu-item");
  8281. if (!this.mouseHandled && target.not(".ui-state-disabled").length) {
  8282. this.select(event);
  8283. // Only set the mouseHandled flag if the event will bubble, see #9469.
  8284. if (!event.isPropagationStopped()) {
  8285. this.mouseHandled = true;
  8286. }
  8287. // Open submenu on click
  8288. if (target.has(".ui-menu").length) {
  8289. this.expand(event);
  8290. } else if (!this.element.is(":focus") && $(this.document[0].activeElement).closest(".ui-menu").length) {
  8291. // Redirect focus to the menu
  8292. this.element.trigger("focus", [true]);
  8293. // If the active item is on the top level, let it stay active.
  8294. // Otherwise, blur the active item since it is no longer visible.
  8295. if (this.active && this.active.parents(".ui-menu").length === 1) {
  8296. clearTimeout(this.timer);
  8297. }
  8298. }
  8299. }
  8300. },
  8301. "mouseenter .ui-menu-item": function (event) {
  8302. var target = $(event.currentTarget);
  8303. // Remove ui-state-active class from siblings of the newly focused menu item
  8304. // to avoid a jump caused by adjacent elements both having a class with a border
  8305. target.siblings().children(".ui-state-active").removeClass("ui-state-active");
  8306. this.focus(event, target);
  8307. },
  8308. mouseleave: "collapseAll",
  8309. "mouseleave .ui-menu": "collapseAll",
  8310. focus: function (event, keepActiveItem) {
  8311. // If there's already an active item, keep it active
  8312. // If not, activate the first item
  8313. var item = this.active || this.element.children(".ui-menu-item").eq(0);
  8314. if (!keepActiveItem) {
  8315. this.focus(event, item);
  8316. }
  8317. },
  8318. blur: function (event) {
  8319. this._delay(function () {
  8320. if (!$.contains(this.element[0], this.document[0].activeElement)) {
  8321. this.collapseAll(event);
  8322. }
  8323. });
  8324. },
  8325. keydown: "_keydown"
  8326. });
  8327. this.refresh();
  8328. // Clicks outside of a menu collapse any open menus
  8329. this._on(this.document, {
  8330. click: function (event) {
  8331. if (!$(event.target).closest(".ui-menu").length) {
  8332. this.collapseAll(event);
  8333. }
  8334. // Reset the mouseHandled flag
  8335. this.mouseHandled = false;
  8336. }
  8337. });
  8338. },
  8339. _destroy: function () {
  8340. // Destroy (sub)menus
  8341. this.element
  8342. .removeAttr("aria-activedescendant")
  8343. .find(".ui-menu").addBack()
  8344. .removeClass("ui-menu ui-widget ui-widget-content ui-corner-all ui-menu-icons")
  8345. .removeAttr("role")
  8346. .removeAttr("tabIndex")
  8347. .removeAttr("aria-labelledby")
  8348. .removeAttr("aria-expanded")
  8349. .removeAttr("aria-hidden")
  8350. .removeAttr("aria-disabled")
  8351. .removeUniqueId()
  8352. .show();
  8353. // Destroy menu items
  8354. this.element.find(".ui-menu-item")
  8355. .removeClass("ui-menu-item")
  8356. .removeAttr("role")
  8357. .removeAttr("aria-disabled")
  8358. .children("a")
  8359. .removeUniqueId()
  8360. .removeClass("ui-corner-all ui-state-hover")
  8361. .removeAttr("tabIndex")
  8362. .removeAttr("role")
  8363. .removeAttr("aria-haspopup")
  8364. .children().each(function () {
  8365. var elem = $(this);
  8366. if (elem.data("ui-menu-submenu-carat")) {
  8367. elem.remove();
  8368. }
  8369. });
  8370. // Destroy menu dividers
  8371. this.element.find(".ui-menu-divider").removeClass("ui-menu-divider ui-widget-content");
  8372. },
  8373. _keydown: function (event) {
  8374. var match, prev, character, skip, regex,
  8375. preventDefault = true;
  8376. function escape(value) {
  8377. return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
  8378. }
  8379. switch (event.keyCode) {
  8380. case $.ui.keyCode.PAGE_UP:
  8381. this.previousPage(event);
  8382. break;
  8383. case $.ui.keyCode.PAGE_DOWN:
  8384. this.nextPage(event);
  8385. break;
  8386. case $.ui.keyCode.HOME:
  8387. this._move("first", "first", event);
  8388. break;
  8389. case $.ui.keyCode.END:
  8390. this._move("last", "last", event);
  8391. break;
  8392. case $.ui.keyCode.UP:
  8393. this.previous(event);
  8394. break;
  8395. case $.ui.keyCode.DOWN:
  8396. this.next(event);
  8397. break;
  8398. case $.ui.keyCode.LEFT:
  8399. this.collapse(event);
  8400. break;
  8401. case $.ui.keyCode.RIGHT:
  8402. if (this.active && !this.active.is(".ui-state-disabled")) {
  8403. this.expand(event);
  8404. }
  8405. break;
  8406. case $.ui.keyCode.ENTER:
  8407. case $.ui.keyCode.SPACE:
  8408. this._activate(event);
  8409. break;
  8410. case $.ui.keyCode.ESCAPE:
  8411. this.collapse(event);
  8412. break;
  8413. default:
  8414. preventDefault = false;
  8415. prev = this.previousFilter || "";
  8416. character = String.fromCharCode(event.keyCode);
  8417. skip = false;
  8418. clearTimeout(this.filterTimer);
  8419. if (character === prev) {
  8420. skip = true;
  8421. } else {
  8422. character = prev + character;
  8423. }
  8424. regex = new RegExp("^" + escape(character), "i");
  8425. match = this.activeMenu.children(".ui-menu-item").filter(function () {
  8426. return regex.test($(this).children("a").text());
  8427. });
  8428. match = skip && match.index(this.active.next()) !== -1 ?
  8429. this.active.nextAll(".ui-menu-item") :
  8430. match;
  8431. // If no matches on the current filter, reset to the last character pressed
  8432. // to move down the menu to the first item that starts with that character
  8433. if (!match.length) {
  8434. character = String.fromCharCode(event.keyCode);
  8435. regex = new RegExp("^" + escape(character), "i");
  8436. match = this.activeMenu.children(".ui-menu-item").filter(function () {
  8437. return regex.test($(this).children("a").text());
  8438. });
  8439. }
  8440. if (match.length) {
  8441. this.focus(event, match);
  8442. if (match.length > 1) {
  8443. this.previousFilter = character;
  8444. this.filterTimer = this._delay(function () {
  8445. delete this.previousFilter;
  8446. }, 1000);
  8447. } else {
  8448. delete this.previousFilter;
  8449. }
  8450. } else {
  8451. delete this.previousFilter;
  8452. }
  8453. }
  8454. if (preventDefault) {
  8455. event.preventDefault();
  8456. }
  8457. },
  8458. _activate: function (event) {
  8459. if (!this.active.is(".ui-state-disabled")) {
  8460. if (this.active.children("a[aria-haspopup='true']").length) {
  8461. this.expand(event);
  8462. } else {
  8463. this.select(event);
  8464. }
  8465. }
  8466. },
  8467. refresh: function () {
  8468. var menus,
  8469. icon = this.options.icons.submenu,
  8470. submenus = this.element.find(this.options.menus);
  8471. this.element.toggleClass("ui-menu-icons", !!this.element.find(".ui-icon").length);
  8472. // Initialize nested menus
  8473. submenus.filter(":not(.ui-menu)")
  8474. .addClass("ui-menu ui-widget ui-widget-content ui-corner-all")
  8475. .hide()
  8476. .attr({
  8477. role: this.options.role,
  8478. "aria-hidden": "true",
  8479. "aria-expanded": "false"
  8480. })
  8481. .each(function () {
  8482. var menu = $(this),
  8483. item = menu.prev("a"),
  8484. submenuCarat = $("<span>")
  8485. .addClass("ui-menu-icon ui-icon " + icon)
  8486. .data("ui-menu-submenu-carat", true);
  8487. item
  8488. .attr("aria-haspopup", "true")
  8489. .prepend(submenuCarat);
  8490. menu.attr("aria-labelledby", item.attr("id"));
  8491. });
  8492. menus = submenus.add(this.element);
  8493. // Don't refresh list items that are already adapted
  8494. menus.children(":not(.ui-menu-item):has(a)")
  8495. .addClass("ui-menu-item")
  8496. .attr("role", "presentation")
  8497. .children("a")
  8498. .uniqueId()
  8499. .addClass("ui-corner-all")
  8500. .attr({
  8501. tabIndex: -1,
  8502. role: this._itemRole()
  8503. });
  8504. // Initialize unlinked menu-items containing spaces and/or dashes only as dividers
  8505. menus.children(":not(.ui-menu-item)").each(function () {
  8506. var item = $(this);
  8507. // hyphen, em dash, en dash
  8508. if (!/[^\-\u2014\u2013\s]/.test(item.text())) {
  8509. item.addClass("ui-widget-content ui-menu-divider");
  8510. }
  8511. });
  8512. // Add aria-disabled attribute to any disabled menu item
  8513. menus.children(".ui-state-disabled").attr("aria-disabled", "true");
  8514. // If the active item has been removed, blur the menu
  8515. if (this.active && !$.contains(this.element[0], this.active[0])) {
  8516. this.blur();
  8517. }
  8518. },
  8519. _itemRole: function () {
  8520. return {
  8521. menu: "menuitem",
  8522. listbox: "option"
  8523. }[this.options.role];
  8524. },
  8525. _setOption: function (key, value) {
  8526. if (key === "icons") {
  8527. this.element.find(".ui-menu-icon")
  8528. .removeClass(this.options.icons.submenu)
  8529. .addClass(value.submenu);
  8530. }
  8531. this._super(key, value);
  8532. },
  8533. focus: function (event, item) {
  8534. var nested, focused;
  8535. this.blur(event, event && event.type === "focus");
  8536. this._scrollIntoView(item);
  8537. this.active = item.first();
  8538. focused = this.active.children("a").addClass("ui-state-focus");
  8539. // Only update aria-activedescendant if there's a role
  8540. // otherwise we assume focus is managed elsewhere
  8541. if (this.options.role) {
  8542. this.element.attr("aria-activedescendant", focused.attr("id"));
  8543. }
  8544. // Highlight active parent menu item, if any
  8545. this.active
  8546. .parent()
  8547. .closest(".ui-menu-item")
  8548. .children("a:first")
  8549. .addClass("ui-state-active");
  8550. if (event && event.type === "keydown") {
  8551. this._close();
  8552. } else {
  8553. this.timer = this._delay(function () {
  8554. this._close();
  8555. }, this.delay);
  8556. }
  8557. nested = item.children(".ui-menu");
  8558. if (nested.length && event && (/^mouse/.test(event.type))) {
  8559. this._startOpening(nested);
  8560. }
  8561. this.activeMenu = item.parent();
  8562. this._trigger("focus", event, { item: item });
  8563. },
  8564. _scrollIntoView: function (item) {
  8565. var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
  8566. if (this._hasScroll()) {
  8567. borderTop = parseFloat($.css(this.activeMenu[0], "borderTopWidth")) || 0;
  8568. paddingTop = parseFloat($.css(this.activeMenu[0], "paddingTop")) || 0;
  8569. offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
  8570. scroll = this.activeMenu.scrollTop();
  8571. elementHeight = this.activeMenu.height();
  8572. itemHeight = item.height();
  8573. if (offset < 0) {
  8574. this.activeMenu.scrollTop(scroll + offset);
  8575. } else if (offset + itemHeight > elementHeight) {
  8576. this.activeMenu.scrollTop(scroll + offset - elementHeight + itemHeight);
  8577. }
  8578. }
  8579. },
  8580. blur: function (event, fromFocus) {
  8581. if (!fromFocus) {
  8582. clearTimeout(this.timer);
  8583. }
  8584. if (!this.active) {
  8585. return;
  8586. }
  8587. this.active.children("a").removeClass("ui-state-focus");
  8588. this.active = null;
  8589. this._trigger("blur", event, { item: this.active });
  8590. },
  8591. _startOpening: function (submenu) {
  8592. clearTimeout(this.timer);
  8593. // Don't open if already open fixes a Firefox bug that caused a .5 pixel
  8594. // shift in the submenu position when mousing over the carat icon
  8595. if (submenu.attr("aria-hidden") !== "true") {
  8596. return;
  8597. }
  8598. this.timer = this._delay(function () {
  8599. this._close();
  8600. this._open(submenu);
  8601. }, this.delay);
  8602. },
  8603. _open: function (submenu) {
  8604. var position = $.extend({
  8605. of: this.active
  8606. }, this.options.position);
  8607. clearTimeout(this.timer);
  8608. this.element.find(".ui-menu").not(submenu.parents(".ui-menu"))
  8609. .hide()
  8610. .attr("aria-hidden", "true");
  8611. submenu
  8612. .show()
  8613. .removeAttr("aria-hidden")
  8614. .attr("aria-expanded", "true")
  8615. .position(position);
  8616. },
  8617. collapseAll: function (event, all) {
  8618. clearTimeout(this.timer);
  8619. this.timer = this._delay(function () {
  8620. // If we were passed an event, look for the submenu that contains the event
  8621. var currentMenu = all ? this.element :
  8622. $(event && event.target).closest(this.element.find(".ui-menu"));
  8623. // If we found no valid submenu ancestor, use the main menu to close all sub menus anyway
  8624. if (!currentMenu.length) {
  8625. currentMenu = this.element;
  8626. }
  8627. this._close(currentMenu);
  8628. this.blur(event);
  8629. this.activeMenu = currentMenu;
  8630. }, this.delay);
  8631. },
  8632. // With no arguments, closes the currently active menu - if nothing is active
  8633. // it closes all menus. If passed an argument, it will search for menus BELOW
  8634. _close: function (startMenu) {
  8635. if (!startMenu) {
  8636. startMenu = this.active ? this.active.parent() : this.element;
  8637. }
  8638. startMenu
  8639. .find(".ui-menu")
  8640. .hide()
  8641. .attr("aria-hidden", "true")
  8642. .attr("aria-expanded", "false")
  8643. .end()
  8644. .find("a.ui-state-active")
  8645. .removeClass("ui-state-active");
  8646. },
  8647. collapse: function (event) {
  8648. var newItem = this.active &&
  8649. this.active.parent().closest(".ui-menu-item", this.element);
  8650. if (newItem && newItem.length) {
  8651. this._close();
  8652. this.focus(event, newItem);
  8653. }
  8654. },
  8655. expand: function (event) {
  8656. var newItem = this.active &&
  8657. this.active
  8658. .children(".ui-menu ")
  8659. .children(".ui-menu-item")
  8660. .first();
  8661. if (newItem && newItem.length) {
  8662. this._open(newItem.parent());
  8663. // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
  8664. this._delay(function () {
  8665. this.focus(event, newItem);
  8666. });
  8667. }
  8668. },
  8669. next: function (event) {
  8670. this._move("next", "first", event);
  8671. },
  8672. previous: function (event) {
  8673. this._move("prev", "last", event);
  8674. },
  8675. isFirstItem: function () {
  8676. return this.active && !this.active.prevAll(".ui-menu-item").length;
  8677. },
  8678. isLastItem: function () {
  8679. return this.active && !this.active.nextAll(".ui-menu-item").length;
  8680. },
  8681. _move: function (direction, filter, event) {
  8682. var next;
  8683. if (this.active) {
  8684. if (direction === "first" || direction === "last") {
  8685. next = this.active
  8686. [direction === "first" ? "prevAll" : "nextAll"](".ui-menu-item")
  8687. .eq(-1);
  8688. } else {
  8689. next = this.active
  8690. [direction + "All"](".ui-menu-item")
  8691. .eq(0);
  8692. }
  8693. }
  8694. if (!next || !next.length || !this.active) {
  8695. next = this.activeMenu.children(".ui-menu-item")[filter]();
  8696. }
  8697. this.focus(event, next);
  8698. },
  8699. nextPage: function (event) {
  8700. var item, base, height;
  8701. if (!this.active) {
  8702. this.next(event);
  8703. return;
  8704. }
  8705. if (this.isLastItem()) {
  8706. return;
  8707. }
  8708. if (this._hasScroll()) {
  8709. base = this.active.offset().top;
  8710. height = this.element.height();
  8711. this.active.nextAll(".ui-menu-item").each(function () {
  8712. item = $(this);
  8713. return item.offset().top - base - height < 0;
  8714. });
  8715. this.focus(event, item);
  8716. } else {
  8717. this.focus(event, this.activeMenu.children(".ui-menu-item")
  8718. [!this.active ? "first" : "last"]());
  8719. }
  8720. },
  8721. previousPage: function (event) {
  8722. var item, base, height;
  8723. if (!this.active) {
  8724. this.next(event);
  8725. return;
  8726. }
  8727. if (this.isFirstItem()) {
  8728. return;
  8729. }
  8730. if (this._hasScroll()) {
  8731. base = this.active.offset().top;
  8732. height = this.element.height();
  8733. this.active.prevAll(".ui-menu-item").each(function () {
  8734. item = $(this);
  8735. return item.offset().top - base + height > 0;
  8736. });
  8737. this.focus(event, item);
  8738. } else {
  8739. this.focus(event, this.activeMenu.children(".ui-menu-item").first());
  8740. }
  8741. },
  8742. _hasScroll: function () {
  8743. return this.element.outerHeight() < this.element.prop("scrollHeight");
  8744. },
  8745. select: function (event) {
  8746. // TODO: It should never be possible to not have an active item at this
  8747. // point, but the tests don't trigger mouseenter before click.
  8748. this.active = this.active || $(event.target).closest(".ui-menu-item");
  8749. var ui = { item: this.active };
  8750. if (!this.active.has(".ui-menu").length) {
  8751. this.collapseAll(event, true);
  8752. }
  8753. this._trigger("select", event, ui);
  8754. }
  8755. });
  8756. }(jQuery));
  8757. (function ($, undefined) {
  8758. $.widget("ui.progressbar", {
  8759. version: "1.10.4",
  8760. options: {
  8761. max: 100,
  8762. value: 0,
  8763. change: null,
  8764. complete: null
  8765. },
  8766. min: 0,
  8767. _create: function () {
  8768. // Constrain initial value
  8769. this.oldValue = this.options.value = this._constrainedValue();
  8770. this.element
  8771. .addClass("ui-progressbar ui-widget ui-widget-content ui-corner-all")
  8772. .attr({
  8773. // Only set static values, aria-valuenow and aria-valuemax are
  8774. // set inside _refreshValue()
  8775. role: "progressbar",
  8776. "aria-valuemin": this.min
  8777. });
  8778. this.valueDiv = $("<div class='ui-progressbar-value ui-widget-header ui-corner-left'></div>")
  8779. .appendTo(this.element);
  8780. this._refreshValue();
  8781. },
  8782. _destroy: function () {
  8783. this.element
  8784. .removeClass("ui-progressbar ui-widget ui-widget-content ui-corner-all")
  8785. .removeAttr("role")
  8786. .removeAttr("aria-valuemin")
  8787. .removeAttr("aria-valuemax")
  8788. .removeAttr("aria-valuenow");
  8789. this.valueDiv.remove();
  8790. },
  8791. value: function (newValue) {
  8792. if (newValue === undefined) {
  8793. return this.options.value;
  8794. }
  8795. this.options.value = this._constrainedValue(newValue);
  8796. this._refreshValue();
  8797. },
  8798. _constrainedValue: function (newValue) {
  8799. if (newValue === undefined) {
  8800. newValue = this.options.value;
  8801. }
  8802. this.indeterminate = newValue === false;
  8803. // sanitize value
  8804. if (typeof newValue !== "number") {
  8805. newValue = 0;
  8806. }
  8807. return this.indeterminate ? false :
  8808. Math.min(this.options.max, Math.max(this.min, newValue));
  8809. },
  8810. _setOptions: function (options) {
  8811. // Ensure "value" option is set after other values (like max)
  8812. var value = options.value;
  8813. delete options.value;
  8814. this._super(options);
  8815. this.options.value = this._constrainedValue(value);
  8816. this._refreshValue();
  8817. },
  8818. _setOption: function (key, value) {
  8819. if (key === "max") {
  8820. // Don't allow a max less than min
  8821. value = Math.max(this.min, value);
  8822. }
  8823. this._super(key, value);
  8824. },
  8825. _percentage: function () {
  8826. return this.indeterminate ? 100 : 100 * (this.options.value - this.min) / (this.options.max - this.min);
  8827. },
  8828. _refreshValue: function () {
  8829. var value = this.options.value,
  8830. percentage = this._percentage();
  8831. this.valueDiv
  8832. .toggle(this.indeterminate || value > this.min)
  8833. .toggleClass("ui-corner-right", value === this.options.max)
  8834. .width(percentage.toFixed(0) + "%");
  8835. this.element.toggleClass("ui-progressbar-indeterminate", this.indeterminate);
  8836. if (this.indeterminate) {
  8837. this.element.removeAttr("aria-valuenow");
  8838. if (!this.overlayDiv) {
  8839. this.overlayDiv = $("<div class='ui-progressbar-overlay'></div>").appendTo(this.valueDiv);
  8840. }
  8841. } else {
  8842. this.element.attr({
  8843. "aria-valuemax": this.options.max,
  8844. "aria-valuenow": value
  8845. });
  8846. if (this.overlayDiv) {
  8847. this.overlayDiv.remove();
  8848. this.overlayDiv = null;
  8849. }
  8850. }
  8851. if (this.oldValue !== value) {
  8852. this.oldValue = value;
  8853. this._trigger("change");
  8854. }
  8855. if (value === this.options.max) {
  8856. this._trigger("complete");
  8857. }
  8858. }
  8859. });
  8860. })(jQuery);
  8861. (function ($, undefined) {
  8862. function num(v) {
  8863. return parseInt(v, 10) || 0;
  8864. }
  8865. function isNumber(value) {
  8866. return !isNaN(parseInt(value, 10));
  8867. }
  8868. $.widget("ui.resizable", $.ui.mouse, {
  8869. version: "1.10.4",
  8870. widgetEventPrefix: "resize",
  8871. options: {
  8872. alsoResize: false,
  8873. animate: false,
  8874. animateDuration: "slow",
  8875. animateEasing: "swing",
  8876. aspectRatio: false,
  8877. autoHide: false,
  8878. containment: false,
  8879. ghost: false,
  8880. grid: false,
  8881. handles: "e,s,se",
  8882. helper: false,
  8883. maxHeight: null,
  8884. maxWidth: null,
  8885. minHeight: 10,
  8886. minWidth: 10,
  8887. // See #7960
  8888. zIndex: 90,
  8889. // callbacks
  8890. resize: null,
  8891. start: null,
  8892. stop: null
  8893. },
  8894. _create: function () {
  8895. var n, i, handle, axis, hname,
  8896. that = this,
  8897. o = this.options;
  8898. this.element.addClass("ui-resizable");
  8899. $.extend(this, {
  8900. _aspectRatio: !!(o.aspectRatio),
  8901. aspectRatio: o.aspectRatio,
  8902. originalElement: this.element,
  8903. _proportionallyResizeElements: [],
  8904. _helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
  8905. });
  8906. //Wrap the element if it cannot hold child nodes
  8907. if (this.element[0].nodeName.match(/canvas|textarea|input|select|button|img/i)) {
  8908. //Create a wrapper element and set the wrapper to the new current internal element
  8909. this.element.wrap(
  8910. $("<div class='ui-wrapper' style='overflow: hidden;'></div>").css({
  8911. position: this.element.css("position"),
  8912. width: this.element.outerWidth(),
  8913. height: this.element.outerHeight(),
  8914. top: this.element.css("top"),
  8915. left: this.element.css("left")
  8916. })
  8917. );
  8918. //Overwrite the original this.element
  8919. this.element = this.element.parent().data(
  8920. "ui-resizable", this.element.data("ui-resizable")
  8921. );
  8922. this.elementIsWrapper = true;
  8923. //Move margins to the wrapper
  8924. this.element.css({ marginLeft: this.originalElement.css("marginLeft"), marginTop: this.originalElement.css("marginTop"), marginRight: this.originalElement.css("marginRight"), marginBottom: this.originalElement.css("marginBottom") });
  8925. this.originalElement.css({ marginLeft: 0, marginTop: 0, marginRight: 0, marginBottom: 0 });
  8926. //Prevent Safari textarea resize
  8927. this.originalResizeStyle = this.originalElement.css("resize");
  8928. this.originalElement.css("resize", "none");
  8929. //Push the actual element to our proportionallyResize internal array
  8930. this._proportionallyResizeElements.push(this.originalElement.css({ position: "static", zoom: 1, display: "block" }));
  8931. // avoid IE jump (hard set the margin)
  8932. this.originalElement.css({ margin: this.originalElement.css("margin") });
  8933. // fix handlers offset
  8934. this._proportionallyResize();
  8935. }
  8936. 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" });
  8937. if (this.handles.constructor === String) {
  8938. if (this.handles === "all") {
  8939. this.handles = "n,e,s,w,se,sw,ne,nw";
  8940. }
  8941. n = this.handles.split(",");
  8942. this.handles = {};
  8943. for (i = 0; i < n.length; i++) {
  8944. handle = $.trim(n[i]);
  8945. hname = "ui-resizable-" + handle;
  8946. axis = $("<div class='ui-resizable-handle " + hname + "'></div>");
  8947. // Apply zIndex to all handles - see #7960
  8948. axis.css({ zIndex: o.zIndex });
  8949. //TODO : What's going on here?
  8950. if ("se" === handle) {
  8951. axis.addClass("ui-icon ui-icon-gripsmall-diagonal-se");
  8952. }
  8953. //Insert into internal handles object and append to element
  8954. this.handles[handle] = ".ui-resizable-" + handle;
  8955. this.element.append(axis);
  8956. }
  8957. }
  8958. this._renderAxis = function (target) {
  8959. var i, axis, padPos, padWrapper;
  8960. target = target || this.element;
  8961. for (i in this.handles) {
  8962. if (this.handles[i].constructor === String) {
  8963. this.handles[i] = $(this.handles[i], this.element).show();
  8964. }
  8965. //Apply pad to wrapper element, needed to fix axis position (textarea, inputs, scrolls)
  8966. if (this.elementIsWrapper && this.originalElement[0].nodeName.match(/textarea|input|select|button/i)) {
  8967. axis = $(this.handles[i], this.element);
  8968. //Checking the correct pad and border
  8969. padWrapper = /sw|ne|nw|se|n|s/.test(i) ? axis.outerHeight() : axis.outerWidth();
  8970. //The padding type i have to apply...
  8971. padPos = ["padding",
  8972. /ne|nw|n/.test(i) ? "Top" :
  8973. /se|sw|s/.test(i) ? "Bottom" :
  8974. /^e$/.test(i) ? "Right" : "Left"].join("");
  8975. target.css(padPos, padWrapper);
  8976. this._proportionallyResize();
  8977. }
  8978. //TODO: What's that good for? There's not anything to be executed left
  8979. if (!$(this.handles[i]).length) {
  8980. continue;
  8981. }
  8982. }
  8983. };
  8984. //TODO: make renderAxis a prototype function
  8985. this._renderAxis(this.element);
  8986. this._handles = $(".ui-resizable-handle", this.element)
  8987. .disableSelection();
  8988. //Matching axis name
  8989. this._handles.mouseover(function () {
  8990. if (!that.resizing) {
  8991. if (this.className) {
  8992. axis = this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);
  8993. }
  8994. //Axis, default = se
  8995. that.axis = axis && axis[1] ? axis[1] : "se";
  8996. }
  8997. });
  8998. //If we want to auto hide the elements
  8999. if (o.autoHide) {
  9000. this._handles.hide();
  9001. $(this.element)
  9002. .addClass("ui-resizable-autohide")
  9003. .mouseenter(function () {
  9004. if (o.disabled) {
  9005. return;
  9006. }
  9007. $(this).removeClass("ui-resizable-autohide");
  9008. that._handles.show();
  9009. })
  9010. .mouseleave(function () {
  9011. if (o.disabled) {
  9012. return;
  9013. }
  9014. if (!that.resizing) {
  9015. $(this).addClass("ui-resizable-autohide");
  9016. that._handles.hide();
  9017. }
  9018. });
  9019. }
  9020. //Initialize the mouse interaction
  9021. this._mouseInit();
  9022. },
  9023. _destroy: function () {
  9024. this._mouseDestroy();
  9025. var wrapper,
  9026. _destroy = function (exp) {
  9027. $(exp).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing")
  9028. .removeData("resizable").removeData("ui-resizable").unbind(".resizable").find(".ui-resizable-handle").remove();
  9029. };
  9030. //TODO: Unwrap at same DOM position
  9031. if (this.elementIsWrapper) {
  9032. _destroy(this.element);
  9033. wrapper = this.element;
  9034. this.originalElement.css({
  9035. position: wrapper.css("position"),
  9036. width: wrapper.outerWidth(),
  9037. height: wrapper.outerHeight(),
  9038. top: wrapper.css("top"),
  9039. left: wrapper.css("left")
  9040. }).insertAfter(wrapper);
  9041. wrapper.remove();
  9042. }
  9043. this.originalElement.css("resize", this.originalResizeStyle);
  9044. _destroy(this.originalElement);
  9045. return this;
  9046. },
  9047. _mouseCapture: function (event) {
  9048. var i, handle,
  9049. capture = false;
  9050. for (i in this.handles) {
  9051. handle = $(this.handles[i])[0];
  9052. if (handle === event.target || $.contains(handle, event.target)) {
  9053. capture = true;
  9054. }
  9055. }
  9056. return !this.options.disabled && capture;
  9057. },
  9058. _mouseStart: function (event) {
  9059. var curleft, curtop, cursor,
  9060. o = this.options,
  9061. iniPos = this.element.position(),
  9062. el = this.element;
  9063. this.resizing = true;
  9064. // bugfix for http://dev.jquery.com/ticket/1749
  9065. if ((/absolute/).test(el.css("position"))) {
  9066. el.css({ position: "absolute", top: el.css("top"), left: el.css("left") });
  9067. } else if (el.is(".ui-draggable")) {
  9068. el.css({ position: "absolute", top: iniPos.top, left: iniPos.left });
  9069. }
  9070. this._renderProxy();
  9071. curleft = num(this.helper.css("left"));
  9072. curtop = num(this.helper.css("top"));
  9073. if (o.containment) {
  9074. curleft += $(o.containment).scrollLeft() || 0;
  9075. curtop += $(o.containment).scrollTop() || 0;
  9076. }
  9077. //Store needed variables
  9078. this.offset = this.helper.offset();
  9079. this.position = { left: curleft, top: curtop };
  9080. this.size = this._helper ? { width: this.helper.width(), height: this.helper.height() } : { width: el.width(), height: el.height() };
  9081. this.originalSize = this._helper ? { width: el.outerWidth(), height: el.outerHeight() } : { width: el.width(), height: el.height() };
  9082. this.originalPosition = { left: curleft, top: curtop };
  9083. this.sizeDiff = { width: el.outerWidth() - el.width(), height: el.outerHeight() - el.height() };
  9084. this.originalMousePosition = { left: event.pageX, top: event.pageY };
  9085. //Aspect Ratio
  9086. this.aspectRatio = (typeof o.aspectRatio === "number") ? o.aspectRatio : ((this.originalSize.width / this.originalSize.height) || 1);
  9087. cursor = $(".ui-resizable-" + this.axis).css("cursor");
  9088. $("body").css("cursor", cursor === "auto" ? this.axis + "-resize" : cursor);
  9089. el.addClass("ui-resizable-resizing");
  9090. this._propagate("start", event);
  9091. return true;
  9092. },
  9093. _mouseDrag: function (event) {
  9094. //Increase performance, avoid regex
  9095. var data,
  9096. el = this.helper, props = {},
  9097. smp = this.originalMousePosition,
  9098. a = this.axis,
  9099. prevTop = this.position.top,
  9100. prevLeft = this.position.left,
  9101. prevWidth = this.size.width,
  9102. prevHeight = this.size.height,
  9103. dx = (event.pageX - smp.left) || 0,
  9104. dy = (event.pageY - smp.top) || 0,
  9105. trigger = this._change[a];
  9106. if (!trigger) {
  9107. return false;
  9108. }
  9109. // Calculate the attrs that will be change
  9110. data = trigger.apply(this, [event, dx, dy]);
  9111. // Put this in the mouseDrag handler since the user can start pressing shift while resizing
  9112. this._updateVirtualBoundaries(event.shiftKey);
  9113. if (this._aspectRatio || event.shiftKey) {
  9114. data = this._updateRatio(data, event);
  9115. }
  9116. data = this._respectSize(data, event);
  9117. this._updateCache(data);
  9118. // plugins callbacks need to be called first
  9119. this._propagate("resize", event);
  9120. if (this.position.top !== prevTop) {
  9121. props.top = this.position.top + "px";
  9122. }
  9123. if (this.position.left !== prevLeft) {
  9124. props.left = this.position.left + "px";
  9125. }
  9126. if (this.size.width !== prevWidth) {
  9127. props.width = this.size.width + "px";
  9128. }
  9129. if (this.size.height !== prevHeight) {
  9130. props.height = this.size.height + "px";
  9131. }
  9132. el.css(props);
  9133. if (!this._helper && this._proportionallyResizeElements.length) {
  9134. this._proportionallyResize();
  9135. }
  9136. // Call the user callback if the element was resized
  9137. if (!$.isEmptyObject(props)) {
  9138. this._trigger("resize", event, this.ui());
  9139. }
  9140. return false;
  9141. },
  9142. _mouseStop: function (event) {
  9143. this.resizing = false;
  9144. var pr, ista, soffseth, soffsetw, s, left, top,
  9145. o = this.options, that = this;
  9146. if (this._helper) {
  9147. pr = this._proportionallyResizeElements;
  9148. ista = pr.length && (/textarea/i).test(pr[0].nodeName);
  9149. soffseth = ista && $.ui.hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height;
  9150. soffsetw = ista ? 0 : that.sizeDiff.width;
  9151. s = { width: (that.helper.width() - soffsetw), height: (that.helper.height() - soffseth) };
  9152. left = (parseInt(that.element.css("left"), 10) + (that.position.left - that.originalPosition.left)) || null;
  9153. top = (parseInt(that.element.css("top"), 10) + (that.position.top - that.originalPosition.top)) || null;
  9154. if (!o.animate) {
  9155. this.element.css($.extend(s, { top: top, left: left }));
  9156. }
  9157. that.helper.height(that.size.height);
  9158. that.helper.width(that.size.width);
  9159. if (this._helper && !o.animate) {
  9160. this._proportionallyResize();
  9161. }
  9162. }
  9163. $("body").css("cursor", "auto");
  9164. this.element.removeClass("ui-resizable-resizing");
  9165. this._propagate("stop", event);
  9166. if (this._helper) {
  9167. this.helper.remove();
  9168. }
  9169. return false;
  9170. },
  9171. _updateVirtualBoundaries: function (forceAspectRatio) {
  9172. var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b,
  9173. o = this.options;
  9174. b = {
  9175. minWidth: isNumber(o.minWidth) ? o.minWidth : 0,
  9176. maxWidth: isNumber(o.maxWidth) ? o.maxWidth : Infinity,
  9177. minHeight: isNumber(o.minHeight) ? o.minHeight : 0,
  9178. maxHeight: isNumber(o.maxHeight) ? o.maxHeight : Infinity
  9179. };
  9180. if (this._aspectRatio || forceAspectRatio) {
  9181. // We want to create an enclosing box whose aspect ration is the requested one
  9182. // First, compute the "projected" size for each dimension based on the aspect ratio and other dimension
  9183. pMinWidth = b.minHeight * this.aspectRatio;
  9184. pMinHeight = b.minWidth / this.aspectRatio;
  9185. pMaxWidth = b.maxHeight * this.aspectRatio;
  9186. pMaxHeight = b.maxWidth / this.aspectRatio;
  9187. if (pMinWidth > b.minWidth) {
  9188. b.minWidth = pMinWidth;
  9189. }
  9190. if (pMinHeight > b.minHeight) {
  9191. b.minHeight = pMinHeight;
  9192. }
  9193. if (pMaxWidth < b.maxWidth) {
  9194. b.maxWidth = pMaxWidth;
  9195. }
  9196. if (pMaxHeight < b.maxHeight) {
  9197. b.maxHeight = pMaxHeight;
  9198. }
  9199. }
  9200. this._vBoundaries = b;
  9201. },
  9202. _updateCache: function (data) {
  9203. this.offset = this.helper.offset();
  9204. if (isNumber(data.left)) {
  9205. this.position.left = data.left;
  9206. }
  9207. if (isNumber(data.top)) {
  9208. this.position.top = data.top;
  9209. }
  9210. if (isNumber(data.height)) {
  9211. this.size.height = data.height;
  9212. }
  9213. if (isNumber(data.width)) {
  9214. this.size.width = data.width;
  9215. }
  9216. },
  9217. _updateRatio: function (data) {
  9218. var cpos = this.position,
  9219. csize = this.size,
  9220. a = this.axis;
  9221. if (isNumber(data.height)) {
  9222. data.width = (data.height * this.aspectRatio);
  9223. } else if (isNumber(data.width)) {
  9224. data.height = (data.width / this.aspectRatio);
  9225. }
  9226. if (a === "sw") {
  9227. data.left = cpos.left + (csize.width - data.width);
  9228. data.top = null;
  9229. }
  9230. if (a === "nw") {
  9231. data.top = cpos.top + (csize.height - data.height);
  9232. data.left = cpos.left + (csize.width - data.width);
  9233. }
  9234. return data;
  9235. },
  9236. _respectSize: function (data) {
  9237. var o = this._vBoundaries,
  9238. a = this.axis,
  9239. ismaxw = isNumber(data.width) && o.maxWidth && (o.maxWidth < data.width), ismaxh = isNumber(data.height) && o.maxHeight && (o.maxHeight < data.height),
  9240. isminw = isNumber(data.width) && o.minWidth && (o.minWidth > data.width), isminh = isNumber(data.height) && o.minHeight && (o.minHeight > data.height),
  9241. dw = this.originalPosition.left + this.originalSize.width,
  9242. dh = this.position.top + this.size.height,
  9243. cw = /sw|nw|w/.test(a), ch = /nw|ne|n/.test(a);
  9244. if (isminw) {
  9245. data.width = o.minWidth;
  9246. }
  9247. if (isminh) {
  9248. data.height = o.minHeight;
  9249. }
  9250. if (ismaxw) {
  9251. data.width = o.maxWidth;
  9252. }
  9253. if (ismaxh) {
  9254. data.height = o.maxHeight;
  9255. }
  9256. if (isminw && cw) {
  9257. data.left = dw - o.minWidth;
  9258. }
  9259. if (ismaxw && cw) {
  9260. data.left = dw - o.maxWidth;
  9261. }
  9262. if (isminh && ch) {
  9263. data.top = dh - o.minHeight;
  9264. }
  9265. if (ismaxh && ch) {
  9266. data.top = dh - o.maxHeight;
  9267. }
  9268. // fixing jump error on top/left - bug #2330
  9269. if (!data.width && !data.height && !data.left && data.top) {
  9270. data.top = null;
  9271. } else if (!data.width && !data.height && !data.top && data.left) {
  9272. data.left = null;
  9273. }
  9274. return data;
  9275. },
  9276. _proportionallyResize: function () {
  9277. if (!this._proportionallyResizeElements.length) {
  9278. return;
  9279. }
  9280. var i, j, borders, paddings, prel,
  9281. element = this.helper || this.element;
  9282. for (i = 0; i < this._proportionallyResizeElements.length; i++) {
  9283. prel = this._proportionallyResizeElements[i];
  9284. if (!this.borderDif) {
  9285. this.borderDif = [];
  9286. borders = [prel.css("borderTopWidth"), prel.css("borderRightWidth"), prel.css("borderBottomWidth"), prel.css("borderLeftWidth")];
  9287. paddings = [prel.css("paddingTop"), prel.css("paddingRight"), prel.css("paddingBottom"), prel.css("paddingLeft")];
  9288. for (j = 0; j < borders.length; j++) {
  9289. this.borderDif[j] = (parseInt(borders[j], 10) || 0) + (parseInt(paddings[j], 10) || 0);
  9290. }
  9291. }
  9292. prel.css({
  9293. height: (element.height() - this.borderDif[0] - this.borderDif[2]) || 0,
  9294. width: (element.width() - this.borderDif[1] - this.borderDif[3]) || 0
  9295. });
  9296. }
  9297. },
  9298. _renderProxy: function () {
  9299. var el = this.element, o = this.options;
  9300. this.elementOffset = el.offset();
  9301. if (this._helper) {
  9302. this.helper = this.helper || $("<div style='overflow:hidden;'></div>");
  9303. this.helper.addClass(this._helper).css({
  9304. width: this.element.outerWidth() - 1,
  9305. height: this.element.outerHeight() - 1,
  9306. position: "absolute",
  9307. left: this.elementOffset.left + "px",
  9308. top: this.elementOffset.top + "px",
  9309. zIndex: ++o.zIndex //TODO: Don't modify option
  9310. });
  9311. this.helper
  9312. .appendTo("body")
  9313. .disableSelection();
  9314. } else {
  9315. this.helper = this.element;
  9316. }
  9317. },
  9318. _change: {
  9319. e: function (event, dx) {
  9320. return { width: this.originalSize.width + dx };
  9321. },
  9322. w: function (event, dx) {
  9323. var cs = this.originalSize, sp = this.originalPosition;
  9324. return { left: sp.left + dx, width: cs.width - dx };
  9325. },
  9326. n: function (event, dx, dy) {
  9327. var cs = this.originalSize, sp = this.originalPosition;
  9328. return { top: sp.top + dy, height: cs.height - dy };
  9329. },
  9330. s: function (event, dx, dy) {
  9331. return { height: this.originalSize.height + dy };
  9332. },
  9333. se: function (event, dx, dy) {
  9334. return $.extend(this._change.s.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
  9335. },
  9336. sw: function (event, dx, dy) {
  9337. return $.extend(this._change.s.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
  9338. },
  9339. ne: function (event, dx, dy) {
  9340. return $.extend(this._change.n.apply(this, arguments), this._change.e.apply(this, [event, dx, dy]));
  9341. },
  9342. nw: function (event, dx, dy) {
  9343. return $.extend(this._change.n.apply(this, arguments), this._change.w.apply(this, [event, dx, dy]));
  9344. }
  9345. },
  9346. _propagate: function (n, event) {
  9347. $.ui.plugin.call(this, n, [event, this.ui()]);
  9348. (n !== "resize" && this._trigger(n, event, this.ui()));
  9349. },
  9350. plugins: {},
  9351. ui: function () {
  9352. return {
  9353. originalElement: this.originalElement,
  9354. element: this.element,
  9355. helper: this.helper,
  9356. position: this.position,
  9357. size: this.size,
  9358. originalSize: this.originalSize,
  9359. originalPosition: this.originalPosition
  9360. };
  9361. }
  9362. });
  9363. /*
  9364. * Resizable Extensions
  9365. */
  9366. $.ui.plugin.add("resizable", "animate", {
  9367. stop: function (event) {
  9368. var that = $(this).data("ui-resizable"),
  9369. o = that.options,
  9370. pr = that._proportionallyResizeElements,
  9371. ista = pr.length && (/textarea/i).test(pr[0].nodeName),
  9372. soffseth = ista && $.ui.hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height,
  9373. soffsetw = ista ? 0 : that.sizeDiff.width,
  9374. style = { width: (that.size.width - soffsetw), height: (that.size.height - soffseth) },
  9375. left = (parseInt(that.element.css("left"), 10) + (that.position.left - that.originalPosition.left)) || null,
  9376. top = (parseInt(that.element.css("top"), 10) + (that.position.top - that.originalPosition.top)) || null;
  9377. that.element.animate(
  9378. $.extend(style, top && left ? { top: top, left: left } : {}), {
  9379. duration: o.animateDuration,
  9380. easing: o.animateEasing,
  9381. step: function () {
  9382. var data = {
  9383. width: parseInt(that.element.css("width"), 10),
  9384. height: parseInt(that.element.css("height"), 10),
  9385. top: parseInt(that.element.css("top"), 10),
  9386. left: parseInt(that.element.css("left"), 10)
  9387. };
  9388. if (pr && pr.length) {
  9389. $(pr[0]).css({ width: data.width, height: data.height });
  9390. }
  9391. // propagating resize, and updating values for each animation step
  9392. that._updateCache(data);
  9393. that._propagate("resize", event);
  9394. }
  9395. }
  9396. );
  9397. }
  9398. });
  9399. $.ui.plugin.add("resizable", "containment", {
  9400. start: function () {
  9401. var element, p, co, ch, cw, width, height,
  9402. that = $(this).data("ui-resizable"),
  9403. o = that.options,
  9404. el = that.element,
  9405. oc = o.containment,
  9406. ce = (oc instanceof $) ? oc.get(0) : (/parent/.test(oc)) ? el.parent().get(0) : oc;
  9407. if (!ce) {
  9408. return;
  9409. }
  9410. that.containerElement = $(ce);
  9411. if (/document/.test(oc) || oc === document) {
  9412. that.containerOffset = { left: 0, top: 0 };
  9413. that.containerPosition = { left: 0, top: 0 };
  9414. that.parentData = {
  9415. element: $(document), left: 0, top: 0,
  9416. width: $(document).width(), height: $(document).height() || document.body.parentNode.scrollHeight
  9417. };
  9418. }
  9419. // i'm a node, so compute top, left, right, bottom
  9420. else {
  9421. element = $(ce);
  9422. p = [];
  9423. $(["Top", "Right", "Left", "Bottom"]).each(function (i, name) { p[i] = num(element.css("padding" + name)); });
  9424. that.containerOffset = element.offset();
  9425. that.containerPosition = element.position();
  9426. that.containerSize = { height: (element.innerHeight() - p[3]), width: (element.innerWidth() - p[1]) };
  9427. co = that.containerOffset;
  9428. ch = that.containerSize.height;
  9429. cw = that.containerSize.width;
  9430. width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw);
  9431. height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch);
  9432. that.parentData = {
  9433. element: ce, left: co.left, top: co.top, width: width, height: height
  9434. };
  9435. }
  9436. },
  9437. resize: function (event) {
  9438. var woset, hoset, isParent, isOffsetRelative,
  9439. that = $(this).data("ui-resizable"),
  9440. o = that.options,
  9441. co = that.containerOffset, cp = that.position,
  9442. pRatio = that._aspectRatio || event.shiftKey,
  9443. cop = { top: 0, left: 0 }, ce = that.containerElement;
  9444. if (ce[0] !== document && (/static/).test(ce.css("position"))) {
  9445. cop = co;
  9446. }
  9447. if (cp.left < (that._helper ? co.left : 0)) {
  9448. that.size.width = that.size.width + (that._helper ? (that.position.left - co.left) : (that.position.left - cop.left));
  9449. if (pRatio) {
  9450. that.size.height = that.size.width / that.aspectRatio;
  9451. }
  9452. that.position.left = o.helper ? co.left : 0;
  9453. }
  9454. if (cp.top < (that._helper ? co.top : 0)) {
  9455. that.size.height = that.size.height + (that._helper ? (that.position.top - co.top) : that.position.top);
  9456. if (pRatio) {
  9457. that.size.width = that.size.height * that.aspectRatio;
  9458. }
  9459. that.position.top = that._helper ? co.top : 0;
  9460. }
  9461. that.offset.left = that.parentData.left + that.position.left;
  9462. that.offset.top = that.parentData.top + that.position.top;
  9463. woset = Math.abs((that._helper ? that.offset.left - cop.left : (that.offset.left - cop.left)) + that.sizeDiff.width);
  9464. hoset = Math.abs((that._helper ? that.offset.top - cop.top : (that.offset.top - co.top)) + that.sizeDiff.height);
  9465. isParent = that.containerElement.get(0) === that.element.parent().get(0);
  9466. isOffsetRelative = /relative|absolute/.test(that.containerElement.css("position"));
  9467. if (isParent && isOffsetRelative) {
  9468. woset -= Math.abs(that.parentData.left);
  9469. }
  9470. if (woset + that.size.width >= that.parentData.width) {
  9471. that.size.width = that.parentData.width - woset;
  9472. if (pRatio) {
  9473. that.size.height = that.size.width / that.aspectRatio;
  9474. }
  9475. }
  9476. if (hoset + that.size.height >= that.parentData.height) {
  9477. that.size.height = that.parentData.height - hoset;
  9478. if (pRatio) {
  9479. that.size.width = that.size.height * that.aspectRatio;
  9480. }
  9481. }
  9482. },
  9483. stop: function () {
  9484. var that = $(this).data("ui-resizable"),
  9485. o = that.options,
  9486. co = that.containerOffset,
  9487. cop = that.containerPosition,
  9488. ce = that.containerElement,
  9489. helper = $(that.helper),
  9490. ho = helper.offset(),
  9491. w = helper.outerWidth() - that.sizeDiff.width,
  9492. h = helper.outerHeight() - that.sizeDiff.height;
  9493. if (that._helper && !o.animate && (/relative/).test(ce.css("position"))) {
  9494. $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
  9495. }
  9496. if (that._helper && !o.animate && (/static/).test(ce.css("position"))) {
  9497. $(this).css({ left: ho.left - cop.left - co.left, width: w, height: h });
  9498. }
  9499. }
  9500. });
  9501. $.ui.plugin.add("resizable", "alsoResize", {
  9502. start: function () {
  9503. var that = $(this).data("ui-resizable"),
  9504. o = that.options,
  9505. _store = function (exp) {
  9506. $(exp).each(function () {
  9507. var el = $(this);
  9508. el.data("ui-resizable-alsoresize", {
  9509. width: parseInt(el.width(), 10), height: parseInt(el.height(), 10),
  9510. left: parseInt(el.css("left"), 10), top: parseInt(el.css("top"), 10)
  9511. });
  9512. });
  9513. };
  9514. if (typeof (o.alsoResize) === "object" && !o.alsoResize.parentNode) {
  9515. if (o.alsoResize.length) { o.alsoResize = o.alsoResize[0]; _store(o.alsoResize); }
  9516. else { $.each(o.alsoResize, function (exp) { _store(exp); }); }
  9517. } else {
  9518. _store(o.alsoResize);
  9519. }
  9520. },
  9521. resize: function (event, ui) {
  9522. var that = $(this).data("ui-resizable"),
  9523. o = that.options,
  9524. os = that.originalSize,
  9525. op = that.originalPosition,
  9526. delta = {
  9527. height: (that.size.height - os.height) || 0, width: (that.size.width - os.width) || 0,
  9528. top: (that.position.top - op.top) || 0, left: (that.position.left - op.left) || 0
  9529. },
  9530. _alsoResize = function (exp, c) {
  9531. $(exp).each(function () {
  9532. var el = $(this), start = $(this).data("ui-resizable-alsoresize"), style = {},
  9533. css = c && c.length ? c : el.parents(ui.originalElement[0]).length ? ["width", "height"] : ["width", "height", "top", "left"];
  9534. $.each(css, function (i, prop) {
  9535. var sum = (start[prop] || 0) + (delta[prop] || 0);
  9536. if (sum && sum >= 0) {
  9537. style[prop] = sum || null;
  9538. }
  9539. });
  9540. el.css(style);
  9541. });
  9542. };
  9543. if (typeof (o.alsoResize) === "object" && !o.alsoResize.nodeType) {
  9544. $.each(o.alsoResize, function (exp, c) { _alsoResize(exp, c); });
  9545. } else {
  9546. _alsoResize(o.alsoResize);
  9547. }
  9548. },
  9549. stop: function () {
  9550. $(this).removeData("resizable-alsoresize");
  9551. }
  9552. });
  9553. $.ui.plugin.add("resizable", "ghost", {
  9554. start: function () {
  9555. var that = $(this).data("ui-resizable"), o = that.options, cs = that.size;
  9556. that.ghost = that.originalElement.clone();
  9557. that.ghost
  9558. .css({ opacity: 0.25, display: "block", position: "relative", height: cs.height, width: cs.width, margin: 0, left: 0, top: 0 })
  9559. .addClass("ui-resizable-ghost")
  9560. .addClass(typeof o.ghost === "string" ? o.ghost : "");
  9561. that.ghost.appendTo(that.helper);
  9562. },
  9563. resize: function () {
  9564. var that = $(this).data("ui-resizable");
  9565. if (that.ghost) {
  9566. that.ghost.css({ position: "relative", height: that.size.height, width: that.size.width });
  9567. }
  9568. },
  9569. stop: function () {
  9570. var that = $(this).data("ui-resizable");
  9571. if (that.ghost && that.helper) {
  9572. that.helper.get(0).removeChild(that.ghost.get(0));
  9573. }
  9574. }
  9575. });
  9576. $.ui.plugin.add("resizable", "grid", {
  9577. resize: function () {
  9578. var that = $(this).data("ui-resizable"),
  9579. o = that.options,
  9580. cs = that.size,
  9581. os = that.originalSize,
  9582. op = that.originalPosition,
  9583. a = that.axis,
  9584. grid = typeof o.grid === "number" ? [o.grid, o.grid] : o.grid,
  9585. gridX = (grid[0] || 1),
  9586. gridY = (grid[1] || 1),
  9587. ox = Math.round((cs.width - os.width) / gridX) * gridX,
  9588. oy = Math.round((cs.height - os.height) / gridY) * gridY,
  9589. newWidth = os.width + ox,
  9590. newHeight = os.height + oy,
  9591. isMaxWidth = o.maxWidth && (o.maxWidth < newWidth),
  9592. isMaxHeight = o.maxHeight && (o.maxHeight < newHeight),
  9593. isMinWidth = o.minWidth && (o.minWidth > newWidth),
  9594. isMinHeight = o.minHeight && (o.minHeight > newHeight);
  9595. o.grid = grid;
  9596. if (isMinWidth) {
  9597. newWidth = newWidth + gridX;
  9598. }
  9599. if (isMinHeight) {
  9600. newHeight = newHeight + gridY;
  9601. }
  9602. if (isMaxWidth) {
  9603. newWidth = newWidth - gridX;
  9604. }
  9605. if (isMaxHeight) {
  9606. newHeight = newHeight - gridY;
  9607. }
  9608. if (/^(se|s|e)$/.test(a)) {
  9609. that.size.width = newWidth;
  9610. that.size.height = newHeight;
  9611. } else if (/^(ne)$/.test(a)) {
  9612. that.size.width = newWidth;
  9613. that.size.height = newHeight;
  9614. that.position.top = op.top - oy;
  9615. } else if (/^(sw)$/.test(a)) {
  9616. that.size.width = newWidth;
  9617. that.size.height = newHeight;
  9618. that.position.left = op.left - ox;
  9619. } else {
  9620. if (newHeight - gridY > 0) {
  9621. that.size.height = newHeight;
  9622. that.position.top = op.top - oy;
  9623. } else {
  9624. that.size.height = gridY;
  9625. that.position.top = op.top + os.height - gridY;
  9626. }
  9627. if (newWidth - gridX > 0) {
  9628. that.size.width = newWidth;
  9629. that.position.left = op.left - ox;
  9630. } else {
  9631. that.size.width = gridX;
  9632. that.position.left = op.left + os.width - gridX;
  9633. }
  9634. }
  9635. }
  9636. });
  9637. })(jQuery);
  9638. (function ($, undefined) {
  9639. $.widget("ui.selectable", $.ui.mouse, {
  9640. version: "1.10.4",
  9641. options: {
  9642. appendTo: "body",
  9643. autoRefresh: true,
  9644. distance: 0,
  9645. filter: "*",
  9646. tolerance: "touch",
  9647. // callbacks
  9648. selected: null,
  9649. selecting: null,
  9650. start: null,
  9651. stop: null,
  9652. unselected: null,
  9653. unselecting: null
  9654. },
  9655. _create: function () {
  9656. var selectees,
  9657. that = this;
  9658. this.element.addClass("ui-selectable");
  9659. this.dragged = false;
  9660. // cache selectee children based on filter
  9661. this.refresh = function () {
  9662. selectees = $(that.options.filter, that.element[0]);
  9663. selectees.addClass("ui-selectee");
  9664. selectees.each(function () {
  9665. var $this = $(this),
  9666. pos = $this.offset();
  9667. $.data(this, "selectable-item", {
  9668. element: this,
  9669. $element: $this,
  9670. left: pos.left,
  9671. top: pos.top,
  9672. right: pos.left + $this.outerWidth(),
  9673. bottom: pos.top + $this.outerHeight(),
  9674. startselected: false,
  9675. selected: $this.hasClass("ui-selected"),
  9676. selecting: $this.hasClass("ui-selecting"),
  9677. unselecting: $this.hasClass("ui-unselecting")
  9678. });
  9679. });
  9680. };
  9681. this.refresh();
  9682. this.selectees = selectees.addClass("ui-selectee");
  9683. this._mouseInit();
  9684. this.helper = $("<div class='ui-selectable-helper'></div>");
  9685. },
  9686. _destroy: function () {
  9687. this.selectees
  9688. .removeClass("ui-selectee")
  9689. .removeData("selectable-item");
  9690. this.element
  9691. .removeClass("ui-selectable ui-selectable-disabled");
  9692. this._mouseDestroy();
  9693. },
  9694. _mouseStart: function (event) {
  9695. var that = this,
  9696. options = this.options;
  9697. this.opos = [event.pageX, event.pageY];
  9698. if (this.options.disabled) {
  9699. return;
  9700. }
  9701. this.selectees = $(options.filter, this.element[0]);
  9702. this._trigger("start", event);
  9703. $(options.appendTo).append(this.helper);
  9704. // position helper (lasso)
  9705. this.helper.css({
  9706. "left": event.pageX,
  9707. "top": event.pageY,
  9708. "width": 0,
  9709. "height": 0
  9710. });
  9711. if (options.autoRefresh) {
  9712. this.refresh();
  9713. }
  9714. this.selectees.filter(".ui-selected").each(function () {
  9715. var selectee = $.data(this, "selectable-item");
  9716. selectee.startselected = true;
  9717. if (!event.metaKey && !event.ctrlKey) {
  9718. selectee.$element.removeClass("ui-selected");
  9719. selectee.selected = false;
  9720. selectee.$element.addClass("ui-unselecting");
  9721. selectee.unselecting = true;
  9722. // selectable UNSELECTING callback
  9723. that._trigger("unselecting", event, {
  9724. unselecting: selectee.element
  9725. });
  9726. }
  9727. });
  9728. $(event.target).parents().addBack().each(function () {
  9729. var doSelect,
  9730. selectee = $.data(this, "selectable-item");
  9731. if (selectee) {
  9732. doSelect = (!event.metaKey && !event.ctrlKey) || !selectee.$element.hasClass("ui-selected");
  9733. selectee.$element
  9734. .removeClass(doSelect ? "ui-unselecting" : "ui-selected")
  9735. .addClass(doSelect ? "ui-selecting" : "ui-unselecting");
  9736. selectee.unselecting = !doSelect;
  9737. selectee.selecting = doSelect;
  9738. selectee.selected = doSelect;
  9739. // selectable (UN)SELECTING callback
  9740. if (doSelect) {
  9741. that._trigger("selecting", event, {
  9742. selecting: selectee.element
  9743. });
  9744. } else {
  9745. that._trigger("unselecting", event, {
  9746. unselecting: selectee.element
  9747. });
  9748. }
  9749. return false;
  9750. }
  9751. });
  9752. },
  9753. _mouseDrag: function (event) {
  9754. this.dragged = true;
  9755. if (this.options.disabled) {
  9756. return;
  9757. }
  9758. var tmp,
  9759. that = this,
  9760. options = this.options,
  9761. x1 = this.opos[0],
  9762. y1 = this.opos[1],
  9763. x2 = event.pageX,
  9764. y2 = event.pageY;
  9765. if (x1 > x2) { tmp = x2; x2 = x1; x1 = tmp; }
  9766. if (y1 > y2) { tmp = y2; y2 = y1; y1 = tmp; }
  9767. this.helper.css({ left: x1, top: y1, width: x2 - x1, height: y2 - y1 });
  9768. this.selectees.each(function () {
  9769. var selectee = $.data(this, "selectable-item"),
  9770. hit = false;
  9771. //prevent helper from being selected if appendTo: selectable
  9772. if (!selectee || selectee.element === that.element[0]) {
  9773. return;
  9774. }
  9775. if (options.tolerance === "touch") {
  9776. hit = (!(selectee.left > x2 || selectee.right < x1 || selectee.top > y2 || selectee.bottom < y1));
  9777. } else if (options.tolerance === "fit") {
  9778. hit = (selectee.left > x1 && selectee.right < x2 && selectee.top > y1 && selectee.bottom < y2);
  9779. }
  9780. if (hit) {
  9781. // SELECT
  9782. if (selectee.selected) {
  9783. selectee.$element.removeClass("ui-selected");
  9784. selectee.selected = false;
  9785. }
  9786. if (selectee.unselecting) {
  9787. selectee.$element.removeClass("ui-unselecting");
  9788. selectee.unselecting = false;
  9789. }
  9790. if (!selectee.selecting) {
  9791. selectee.$element.addClass("ui-selecting");
  9792. selectee.selecting = true;
  9793. // selectable SELECTING callback
  9794. that._trigger("selecting", event, {
  9795. selecting: selectee.element
  9796. });
  9797. }
  9798. } else {
  9799. // UNSELECT
  9800. if (selectee.selecting) {
  9801. if ((event.metaKey || event.ctrlKey) && selectee.startselected) {
  9802. selectee.$element.removeClass("ui-selecting");
  9803. selectee.selecting = false;
  9804. selectee.$element.addClass("ui-selected");
  9805. selectee.selected = true;
  9806. } else {
  9807. selectee.$element.removeClass("ui-selecting");
  9808. selectee.selecting = false;
  9809. if (selectee.startselected) {
  9810. selectee.$element.addClass("ui-unselecting");
  9811. selectee.unselecting = true;
  9812. }
  9813. // selectable UNSELECTING callback
  9814. that._trigger("unselecting", event, {
  9815. unselecting: selectee.element
  9816. });
  9817. }
  9818. }
  9819. if (selectee.selected) {
  9820. if (!event.metaKey && !event.ctrlKey && !selectee.startselected) {
  9821. selectee.$element.removeClass("ui-selected");
  9822. selectee.selected = false;
  9823. selectee.$element.addClass("ui-unselecting");
  9824. selectee.unselecting = true;
  9825. // selectable UNSELECTING callback
  9826. that._trigger("unselecting", event, {
  9827. unselecting: selectee.element
  9828. });
  9829. }
  9830. }
  9831. }
  9832. });
  9833. return false;
  9834. },
  9835. _mouseStop: function (event) {
  9836. var that = this;
  9837. this.dragged = false;
  9838. $(".ui-unselecting", this.element[0]).each(function () {
  9839. var selectee = $.data(this, "selectable-item");
  9840. selectee.$element.removeClass("ui-unselecting");
  9841. selectee.unselecting = false;
  9842. selectee.startselected = false;
  9843. that._trigger("unselected", event, {
  9844. unselected: selectee.element
  9845. });
  9846. });
  9847. $(".ui-selecting", this.element[0]).each(function () {
  9848. var selectee = $.data(this, "selectable-item");
  9849. selectee.$element.removeClass("ui-selecting").addClass("ui-selected");
  9850. selectee.selecting = false;
  9851. selectee.selected = true;
  9852. selectee.startselected = true;
  9853. that._trigger("selected", event, {
  9854. selected: selectee.element
  9855. });
  9856. });
  9857. this._trigger("stop", event);
  9858. this.helper.remove();
  9859. return false;
  9860. }
  9861. });
  9862. })(jQuery);
  9863. (function ($, undefined) {
  9864. // number of pages in a slider
  9865. // (how many times can you page up/down to go through the whole range)
  9866. var numPages = 5;
  9867. $.widget("ui.slider", $.ui.mouse, {
  9868. version: "1.10.4",
  9869. widgetEventPrefix: "slide",
  9870. options: {
  9871. animate: false,
  9872. distance: 0,
  9873. max: 100,
  9874. min: 0,
  9875. orientation: "horizontal",
  9876. range: false,
  9877. step: 1,
  9878. value: 0,
  9879. values: null,
  9880. // callbacks
  9881. change: null,
  9882. slide: null,
  9883. start: null,
  9884. stop: null
  9885. },
  9886. _create: function () {
  9887. this._keySliding = false;
  9888. this._mouseSliding = false;
  9889. this._animateOff = true;
  9890. this._handleIndex = null;
  9891. this._detectOrientation();
  9892. this._mouseInit();
  9893. this.element
  9894. .addClass("ui-slider" +
  9895. " ui-slider-" + this.orientation +
  9896. " ui-widget" +
  9897. " ui-widget-content" +
  9898. " ui-corner-all");
  9899. this._refresh();
  9900. this._setOption("disabled", this.options.disabled);
  9901. this._animateOff = false;
  9902. },
  9903. _refresh: function () {
  9904. this._createRange();
  9905. this._createHandles();
  9906. this._setupEvents();
  9907. this._refreshValue();
  9908. },
  9909. _createHandles: function () {
  9910. var i, handleCount,
  9911. options = this.options,
  9912. existingHandles = this.element.find(".ui-slider-handle").addClass("ui-state-default ui-corner-all"),
  9913. handle = "<a class='ui-slider-handle ui-state-default ui-corner-all' href='#'></a>",
  9914. handles = [];
  9915. handleCount = (options.values && options.values.length) || 1;
  9916. if (existingHandles.length > handleCount) {
  9917. existingHandles.slice(handleCount).remove();
  9918. existingHandles = existingHandles.slice(0, handleCount);
  9919. }
  9920. for (i = existingHandles.length; i < handleCount; i++) {
  9921. handles.push(handle);
  9922. }
  9923. this.handles = existingHandles.add($(handles.join("")).appendTo(this.element));
  9924. this.handle = this.handles.eq(0);
  9925. this.handles.each(function (i) {
  9926. $(this).data("ui-slider-handle-index", i);
  9927. });
  9928. },
  9929. _createRange: function () {
  9930. var options = this.options,
  9931. classes = "";
  9932. if (options.range) {
  9933. if (options.range === true) {
  9934. if (!options.values) {
  9935. options.values = [this._valueMin(), this._valueMin()];
  9936. } else if (options.values.length && options.values.length !== 2) {
  9937. options.values = [options.values[0], options.values[0]];
  9938. } else if ($.isArray(options.values)) {
  9939. options.values = options.values.slice(0);
  9940. }
  9941. }
  9942. if (!this.range || !this.range.length) {
  9943. this.range = $("<div></div>")
  9944. .appendTo(this.element);
  9945. classes = "ui-slider-range" +
  9946. // note: this isn't the most fittingly semantic framework class for this element,
  9947. // but worked best visually with a variety of themes
  9948. " ui-widget-header ui-corner-all";
  9949. } else {
  9950. this.range.removeClass("ui-slider-range-min ui-slider-range-max")
  9951. // Handle range switching from true to min/max
  9952. .css({
  9953. "left": "",
  9954. "bottom": ""
  9955. });
  9956. }
  9957. this.range.addClass(classes +
  9958. ((options.range === "min" || options.range === "max") ? " ui-slider-range-" + options.range : ""));
  9959. } else {
  9960. if (this.range) {
  9961. this.range.remove();
  9962. }
  9963. this.range = null;
  9964. }
  9965. },
  9966. _setupEvents: function () {
  9967. var elements = this.handles.add(this.range).filter("a");
  9968. this._off(elements);
  9969. this._on(elements, this._handleEvents);
  9970. this._hoverable(elements);
  9971. this._focusable(elements);
  9972. },
  9973. _destroy: function () {
  9974. this.handles.remove();
  9975. if (this.range) {
  9976. this.range.remove();
  9977. }
  9978. this.element
  9979. .removeClass("ui-slider" +
  9980. " ui-slider-horizontal" +
  9981. " ui-slider-vertical" +
  9982. " ui-widget" +
  9983. " ui-widget-content" +
  9984. " ui-corner-all");
  9985. this._mouseDestroy();
  9986. },
  9987. _mouseCapture: function (event) {
  9988. var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
  9989. that = this,
  9990. o = this.options;
  9991. if (o.disabled) {
  9992. return false;
  9993. }
  9994. this.elementSize = {
  9995. width: this.element.outerWidth(),
  9996. height: this.element.outerHeight()
  9997. };
  9998. this.elementOffset = this.element.offset();
  9999. position = { x: event.pageX, y: event.pageY };
  10000. normValue = this._normValueFromMouse(position);
  10001. distance = this._valueMax() - this._valueMin() + 1;
  10002. this.handles.each(function (i) {
  10003. var thisDistance = Math.abs(normValue - that.values(i));
  10004. if ((distance > thisDistance) ||
  10005. (distance === thisDistance &&
  10006. (i === that._lastChangedValue || that.values(i) === o.min))) {
  10007. distance = thisDistance;
  10008. closestHandle = $(this);
  10009. index = i;
  10010. }
  10011. });
  10012. allowed = this._start(event, index);
  10013. if (allowed === false) {
  10014. return false;
  10015. }
  10016. this._mouseSliding = true;
  10017. this._handleIndex = index;
  10018. closestHandle
  10019. .addClass("ui-state-active")
  10020. .focus();
  10021. offset = closestHandle.offset();
  10022. mouseOverHandle = !$(event.target).parents().addBack().is(".ui-slider-handle");
  10023. this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
  10024. left: event.pageX - offset.left - (closestHandle.width() / 2),
  10025. top: event.pageY - offset.top -
  10026. (closestHandle.height() / 2) -
  10027. (parseInt(closestHandle.css("borderTopWidth"), 10) || 0) -
  10028. (parseInt(closestHandle.css("borderBottomWidth"), 10) || 0) +
  10029. (parseInt(closestHandle.css("marginTop"), 10) || 0)
  10030. };
  10031. if (!this.handles.hasClass("ui-state-hover")) {
  10032. this._slide(event, index, normValue);
  10033. }
  10034. this._animateOff = true;
  10035. return true;
  10036. },
  10037. _mouseStart: function () {
  10038. return true;
  10039. },
  10040. _mouseDrag: function (event) {
  10041. var position = { x: event.pageX, y: event.pageY },
  10042. normValue = this._normValueFromMouse(position);
  10043. this._slide(event, this._handleIndex, normValue);
  10044. return false;
  10045. },
  10046. _mouseStop: function (event) {
  10047. this.handles.removeClass("ui-state-active");
  10048. this._mouseSliding = false;
  10049. this._stop(event, this._handleIndex);
  10050. this._change(event, this._handleIndex);
  10051. this._handleIndex = null;
  10052. this._clickOffset = null;
  10053. this._animateOff = false;
  10054. return false;
  10055. },
  10056. _detectOrientation: function () {
  10057. this.orientation = (this.options.orientation === "vertical") ? "vertical" : "horizontal";
  10058. },
  10059. _normValueFromMouse: function (position) {
  10060. var pixelTotal,
  10061. pixelMouse,
  10062. percentMouse,
  10063. valueTotal,
  10064. valueMouse;
  10065. if (this.orientation === "horizontal") {
  10066. pixelTotal = this.elementSize.width;
  10067. pixelMouse = position.x - this.elementOffset.left - (this._clickOffset ? this._clickOffset.left : 0);
  10068. } else {
  10069. pixelTotal = this.elementSize.height;
  10070. pixelMouse = position.y - this.elementOffset.top - (this._clickOffset ? this._clickOffset.top : 0);
  10071. }
  10072. percentMouse = (pixelMouse / pixelTotal);
  10073. if (percentMouse > 1) {
  10074. percentMouse = 1;
  10075. }
  10076. if (percentMouse < 0) {
  10077. percentMouse = 0;
  10078. }
  10079. if (this.orientation === "vertical") {
  10080. percentMouse = 1 - percentMouse;
  10081. }
  10082. valueTotal = this._valueMax() - this._valueMin();
  10083. valueMouse = this._valueMin() + percentMouse * valueTotal;
  10084. return this._trimAlignValue(valueMouse);
  10085. },
  10086. _start: function (event, index) {
  10087. var uiHash = {
  10088. handle: this.handles[index],
  10089. value: this.value()
  10090. };
  10091. if (this.options.values && this.options.values.length) {
  10092. uiHash.value = this.values(index);
  10093. uiHash.values = this.values();
  10094. }
  10095. return this._trigger("start", event, uiHash);
  10096. },
  10097. _slide: function (event, index, newVal) {
  10098. var otherVal,
  10099. newValues,
  10100. allowed;
  10101. if (this.options.values && this.options.values.length) {
  10102. otherVal = this.values(index ? 0 : 1);
  10103. if ((this.options.values.length === 2 && this.options.range === true) &&
  10104. ((index === 0 && newVal > otherVal) || (index === 1 && newVal < otherVal))
  10105. ) {
  10106. newVal = otherVal;
  10107. }
  10108. if (newVal !== this.values(index)) {
  10109. newValues = this.values();
  10110. newValues[index] = newVal;
  10111. // A slide can be canceled by returning false from the slide callback
  10112. allowed = this._trigger("slide", event, {
  10113. handle: this.handles[index],
  10114. value: newVal,
  10115. values: newValues
  10116. });
  10117. otherVal = this.values(index ? 0 : 1);
  10118. if (allowed !== false) {
  10119. this.values(index, newVal);
  10120. }
  10121. }
  10122. } else {
  10123. if (newVal !== this.value()) {
  10124. // A slide can be canceled by returning false from the slide callback
  10125. allowed = this._trigger("slide", event, {
  10126. handle: this.handles[index],
  10127. value: newVal
  10128. });
  10129. if (allowed !== false) {
  10130. this.value(newVal);
  10131. }
  10132. }
  10133. }
  10134. },
  10135. _stop: function (event, index) {
  10136. var uiHash = {
  10137. handle: this.handles[index],
  10138. value: this.value()
  10139. };
  10140. if (this.options.values && this.options.values.length) {
  10141. uiHash.value = this.values(index);
  10142. uiHash.values = this.values();
  10143. }
  10144. this._trigger("stop", event, uiHash);
  10145. },
  10146. _change: function (event, index) {
  10147. if (!this._keySliding && !this._mouseSliding) {
  10148. var uiHash = {
  10149. handle: this.handles[index],
  10150. value: this.value()
  10151. };
  10152. if (this.options.values && this.options.values.length) {
  10153. uiHash.value = this.values(index);
  10154. uiHash.values = this.values();
  10155. }
  10156. //store the last changed value index for reference when handles overlap
  10157. this._lastChangedValue = index;
  10158. this._trigger("change", event, uiHash);
  10159. }
  10160. },
  10161. value: function (newValue) {
  10162. if (arguments.length) {
  10163. this.options.value = this._trimAlignValue(newValue);
  10164. this._refreshValue();
  10165. this._change(null, 0);
  10166. return;
  10167. }
  10168. return this._value();
  10169. },
  10170. values: function (index, newValue) {
  10171. var vals,
  10172. newValues,
  10173. i;
  10174. if (arguments.length > 1) {
  10175. this.options.values[index] = this._trimAlignValue(newValue);
  10176. this._refreshValue();
  10177. this._change(null, index);
  10178. return;
  10179. }
  10180. if (arguments.length) {
  10181. if ($.isArray(arguments[0])) {
  10182. vals = this.options.values;
  10183. newValues = arguments[0];
  10184. for (i = 0; i < vals.length; i += 1) {
  10185. vals[i] = this._trimAlignValue(newValues[i]);
  10186. this._change(null, i);
  10187. }
  10188. this._refreshValue();
  10189. } else {
  10190. if (this.options.values && this.options.values.length) {
  10191. return this._values(index);
  10192. } else {
  10193. return this.value();
  10194. }
  10195. }
  10196. } else {
  10197. return this._values();
  10198. }
  10199. },
  10200. _setOption: function (key, value) {
  10201. var i,
  10202. valsLength = 0;
  10203. if (key === "range" && this.options.range === true) {
  10204. if (value === "min") {
  10205. this.options.value = this._values(0);
  10206. this.options.values = null;
  10207. } else if (value === "max") {
  10208. this.options.value = this._values(this.options.values.length - 1);
  10209. this.options.values = null;
  10210. }
  10211. }
  10212. if ($.isArray(this.options.values)) {
  10213. valsLength = this.options.values.length;
  10214. }
  10215. $.Widget.prototype._setOption.apply(this, arguments);
  10216. switch (key) {
  10217. case "orientation":
  10218. this._detectOrientation();
  10219. this.element
  10220. .removeClass("ui-slider-horizontal ui-slider-vertical")
  10221. .addClass("ui-slider-" + this.orientation);
  10222. this._refreshValue();
  10223. break;
  10224. case "value":
  10225. this._animateOff = true;
  10226. this._refreshValue();
  10227. this._change(null, 0);
  10228. this._animateOff = false;
  10229. break;
  10230. case "values":
  10231. this._animateOff = true;
  10232. this._refreshValue();
  10233. for (i = 0; i < valsLength; i += 1) {
  10234. this._change(null, i);
  10235. }
  10236. this._animateOff = false;
  10237. break;
  10238. case "min":
  10239. case "max":
  10240. this._animateOff = true;
  10241. this._refreshValue();
  10242. this._animateOff = false;
  10243. break;
  10244. case "range":
  10245. this._animateOff = true;
  10246. this._refresh();
  10247. this._animateOff = false;
  10248. break;
  10249. }
  10250. },
  10251. //internal value getter
  10252. // _value() returns value trimmed by min and max, aligned by step
  10253. _value: function () {
  10254. var val = this.options.value;
  10255. val = this._trimAlignValue(val);
  10256. return val;
  10257. },
  10258. //internal values getter
  10259. // _values() returns array of values trimmed by min and max, aligned by step
  10260. // _values( index ) returns single value trimmed by min and max, aligned by step
  10261. _values: function (index) {
  10262. var val,
  10263. vals,
  10264. i;
  10265. if (arguments.length) {
  10266. val = this.options.values[index];
  10267. val = this._trimAlignValue(val);
  10268. return val;
  10269. } else if (this.options.values && this.options.values.length) {
  10270. // .slice() creates a copy of the array
  10271. // this copy gets trimmed by min and max and then returned
  10272. vals = this.options.values.slice();
  10273. for (i = 0; i < vals.length; i += 1) {
  10274. vals[i] = this._trimAlignValue(vals[i]);
  10275. }
  10276. return vals;
  10277. } else {
  10278. return [];
  10279. }
  10280. },
  10281. // returns the step-aligned value that val is closest to, between (inclusive) min and max
  10282. _trimAlignValue: function (val) {
  10283. if (val <= this._valueMin()) {
  10284. return this._valueMin();
  10285. }
  10286. if (val >= this._valueMax()) {
  10287. return this._valueMax();
  10288. }
  10289. var step = (this.options.step > 0) ? this.options.step : 1,
  10290. valModStep = (val - this._valueMin()) % step,
  10291. alignValue = val - valModStep;
  10292. if (Math.abs(valModStep) * 2 >= step) {
  10293. alignValue += (valModStep > 0) ? step : (-step);
  10294. }
  10295. // Since JavaScript has problems with large floats, round
  10296. // the final value to 5 digits after the decimal point (see #4124)
  10297. return parseFloat(alignValue.toFixed(5));
  10298. },
  10299. _valueMin: function () {
  10300. return this.options.min;
  10301. },
  10302. _valueMax: function () {
  10303. return this.options.max;
  10304. },
  10305. _refreshValue: function () {
  10306. var lastValPercent, valPercent, value, valueMin, valueMax,
  10307. oRange = this.options.range,
  10308. o = this.options,
  10309. that = this,
  10310. animate = (!this._animateOff) ? o.animate : false,
  10311. _set = {};
  10312. if (this.options.values && this.options.values.length) {
  10313. this.handles.each(function (i) {
  10314. valPercent = (that.values(i) - that._valueMin()) / (that._valueMax() - that._valueMin()) * 100;
  10315. _set[that.orientation === "horizontal" ? "left" : "bottom"] = valPercent + "%";
  10316. $(this).stop(1, 1)[animate ? "animate" : "css"](_set, o.animate);
  10317. if (that.options.range === true) {
  10318. if (that.orientation === "horizontal") {
  10319. if (i === 0) {
  10320. that.range.stop(1, 1)[animate ? "animate" : "css"]({ left: valPercent + "%" }, o.animate);
  10321. }
  10322. if (i === 1) {
  10323. that.range[animate ? "animate" : "css"]({ width: (valPercent - lastValPercent) + "%" }, { queue: false, duration: o.animate });
  10324. }
  10325. } else {
  10326. if (i === 0) {
  10327. that.range.stop(1, 1)[animate ? "animate" : "css"]({ bottom: (valPercent) + "%" }, o.animate);
  10328. }
  10329. if (i === 1) {
  10330. that.range[animate ? "animate" : "css"]({ height: (valPercent - lastValPercent) + "%" }, { queue: false, duration: o.animate });
  10331. }
  10332. }
  10333. }
  10334. lastValPercent = valPercent;
  10335. });
  10336. } else {
  10337. value = this.value();
  10338. valueMin = this._valueMin();
  10339. valueMax = this._valueMax();
  10340. valPercent = (valueMax !== valueMin) ?
  10341. (value - valueMin) / (valueMax - valueMin) * 100 :
  10342. 0;
  10343. _set[this.orientation === "horizontal" ? "left" : "bottom"] = valPercent + "%";
  10344. this.handle.stop(1, 1)[animate ? "animate" : "css"](_set, o.animate);
  10345. if (oRange === "min" && this.orientation === "horizontal") {
  10346. this.range.stop(1, 1)[animate ? "animate" : "css"]({ width: valPercent + "%" }, o.animate);
  10347. }
  10348. if (oRange === "max" && this.orientation === "horizontal") {
  10349. this.range[animate ? "animate" : "css"]({ width: (100 - valPercent) + "%" }, { queue: false, duration: o.animate });
  10350. }
  10351. if (oRange === "min" && this.orientation === "vertical") {
  10352. this.range.stop(1, 1)[animate ? "animate" : "css"]({ height: valPercent + "%" }, o.animate);
  10353. }
  10354. if (oRange === "max" && this.orientation === "vertical") {
  10355. this.range[animate ? "animate" : "css"]({ height: (100 - valPercent) + "%" }, { queue: false, duration: o.animate });
  10356. }
  10357. }
  10358. },
  10359. _handleEvents: {
  10360. keydown: function (event) {
  10361. var allowed, curVal, newVal, step,
  10362. index = $(event.target).data("ui-slider-handle-index");
  10363. switch (event.keyCode) {
  10364. case $.ui.keyCode.HOME:
  10365. case $.ui.keyCode.END:
  10366. case $.ui.keyCode.PAGE_UP:
  10367. case $.ui.keyCode.PAGE_DOWN:
  10368. case $.ui.keyCode.UP:
  10369. case $.ui.keyCode.RIGHT:
  10370. case $.ui.keyCode.DOWN:
  10371. case $.ui.keyCode.LEFT:
  10372. event.preventDefault();
  10373. if (!this._keySliding) {
  10374. this._keySliding = true;
  10375. $(event.target).addClass("ui-state-active");
  10376. allowed = this._start(event, index);
  10377. if (allowed === false) {
  10378. return;
  10379. }
  10380. }
  10381. break;
  10382. }
  10383. step = this.options.step;
  10384. if (this.options.values && this.options.values.length) {
  10385. curVal = newVal = this.values(index);
  10386. } else {
  10387. curVal = newVal = this.value();
  10388. }
  10389. switch (event.keyCode) {
  10390. case $.ui.keyCode.HOME:
  10391. newVal = this._valueMin();
  10392. break;
  10393. case $.ui.keyCode.END:
  10394. newVal = this._valueMax();
  10395. break;
  10396. case $.ui.keyCode.PAGE_UP:
  10397. newVal = this._trimAlignValue(curVal + ((this._valueMax() - this._valueMin()) / numPages));
  10398. break;
  10399. case $.ui.keyCode.PAGE_DOWN:
  10400. newVal = this._trimAlignValue(curVal - ((this._valueMax() - this._valueMin()) / numPages));
  10401. break;
  10402. case $.ui.keyCode.UP:
  10403. case $.ui.keyCode.RIGHT:
  10404. if (curVal === this._valueMax()) {
  10405. return;
  10406. }
  10407. newVal = this._trimAlignValue(curVal + step);
  10408. break;
  10409. case $.ui.keyCode.DOWN:
  10410. case $.ui.keyCode.LEFT:
  10411. if (curVal === this._valueMin()) {
  10412. return;
  10413. }
  10414. newVal = this._trimAlignValue(curVal - step);
  10415. break;
  10416. }
  10417. this._slide(event, index, newVal);
  10418. },
  10419. click: function (event) {
  10420. event.preventDefault();
  10421. },
  10422. keyup: function (event) {
  10423. var index = $(event.target).data("ui-slider-handle-index");
  10424. if (this._keySliding) {
  10425. this._keySliding = false;
  10426. this._stop(event, index);
  10427. this._change(event, index);
  10428. $(event.target).removeClass("ui-state-active");
  10429. }
  10430. }
  10431. }
  10432. });
  10433. }(jQuery));
  10434. (function ($, undefined) {
  10435. function isOverAxis(x, reference, size) {
  10436. return (x > reference) && (x < (reference + size));
  10437. }
  10438. function isFloating(item) {
  10439. return (/left|right/).test(item.css("float")) || (/inline|table-cell/).test(item.css("display"));
  10440. }
  10441. $.widget("ui.sortable", $.ui.mouse, {
  10442. version: "1.10.4",
  10443. widgetEventPrefix: "sort",
  10444. ready: false,
  10445. options: {
  10446. appendTo: "parent",
  10447. axis: false,
  10448. connectWith: false,
  10449. containment: false,
  10450. cursor: "auto",
  10451. cursorAt: false,
  10452. dropOnEmpty: true,
  10453. forcePlaceholderSize: false,
  10454. forceHelperSize: false,
  10455. grid: false,
  10456. handle: false,
  10457. helper: "original",
  10458. items: "> *",
  10459. opacity: false,
  10460. placeholder: false,
  10461. revert: false,
  10462. scroll: true,
  10463. scrollSensitivity: 20,
  10464. scrollSpeed: 20,
  10465. scope: "default",
  10466. tolerance: "intersect",
  10467. zIndex: 1000,
  10468. // callbacks
  10469. activate: null,
  10470. beforeStop: null,
  10471. change: null,
  10472. deactivate: null,
  10473. out: null,
  10474. over: null,
  10475. receive: null,
  10476. remove: null,
  10477. sort: null,
  10478. start: null,
  10479. stop: null,
  10480. update: null
  10481. },
  10482. _create: function () {
  10483. var o = this.options;
  10484. this.containerCache = {};
  10485. this.element.addClass("ui-sortable");
  10486. //Get the items
  10487. this.refresh();
  10488. //Let's determine if the items are being displayed horizontally
  10489. this.floating = this.items.length ? o.axis === "x" || isFloating(this.items[0].item) : false;
  10490. //Let's determine the parent's offset
  10491. this.offset = this.element.offset();
  10492. //Initialize mouse events for interaction
  10493. this._mouseInit();
  10494. //We're ready to go
  10495. this.ready = true;
  10496. },
  10497. _destroy: function () {
  10498. this.element
  10499. .removeClass("ui-sortable ui-sortable-disabled");
  10500. this._mouseDestroy();
  10501. for (var i = this.items.length - 1; i >= 0; i--) {
  10502. this.items[i].item.removeData(this.widgetName + "-item");
  10503. }
  10504. return this;
  10505. },
  10506. _setOption: function (key, value) {
  10507. if (key === "disabled") {
  10508. this.options[key] = value;
  10509. this.widget().toggleClass("ui-sortable-disabled", !!value);
  10510. } else {
  10511. // Don't call widget base _setOption for disable as it adds ui-state-disabled class
  10512. $.Widget.prototype._setOption.apply(this, arguments);
  10513. }
  10514. },
  10515. _mouseCapture: function (event, overrideHandle) {
  10516. var currentItem = null,
  10517. validHandle = false,
  10518. that = this;
  10519. if (this.reverting) {
  10520. return false;
  10521. }
  10522. if (this.options.disabled || this.options.type === "static") {
  10523. return false;
  10524. }
  10525. //We have to refresh the items data once first
  10526. this._refreshItems(event);
  10527. //Find out if the clicked node (or one of its parents) is a actual item in this.items
  10528. $(event.target).parents().each(function () {
  10529. if ($.data(this, that.widgetName + "-item") === that) {
  10530. currentItem = $(this);
  10531. return false;
  10532. }
  10533. });
  10534. if ($.data(event.target, that.widgetName + "-item") === that) {
  10535. currentItem = $(event.target);
  10536. }
  10537. if (!currentItem) {
  10538. return false;
  10539. }
  10540. if (this.options.handle && !overrideHandle) {
  10541. $(this.options.handle, currentItem).find("*").addBack().each(function () {
  10542. if (this === event.target) {
  10543. validHandle = true;
  10544. }
  10545. });
  10546. if (!validHandle) {
  10547. return false;
  10548. }
  10549. }
  10550. this.currentItem = currentItem;
  10551. this._removeCurrentsFromItems();
  10552. return true;
  10553. },
  10554. _mouseStart: function (event, overrideHandle, noActivation) {
  10555. var i, body,
  10556. o = this.options;
  10557. this.currentContainer = this;
  10558. //We only need to call refreshPositions, because the refreshItems call has been moved to mouseCapture
  10559. this.refreshPositions();
  10560. //Create and append the visible helper
  10561. this.helper = this._createHelper(event);
  10562. //Cache the helper size
  10563. this._cacheHelperProportions();
  10564. /*
  10565. * - Position generation -
  10566. * This block generates everything position related - it's the core of draggables.
  10567. */
  10568. //Cache the margins of the original element
  10569. this._cacheMargins();
  10570. //Get the next scrolling parent
  10571. this.scrollParent = this.helper.scrollParent();
  10572. //The element's absolute position on the page minus margins
  10573. this.offset = this.currentItem.offset();
  10574. this.offset = {
  10575. top: this.offset.top - this.margins.top,
  10576. left: this.offset.left - this.margins.left
  10577. };
  10578. $.extend(this.offset, {
  10579. click: { //Where the click happened, relative to the element
  10580. left: event.pageX - this.offset.left,
  10581. top: event.pageY - this.offset.top
  10582. },
  10583. parent: this._getParentOffset(),
  10584. relative: this._getRelativeOffset() //This is a relative to absolute position minus the actual position calculation - only used for relative positioned helper
  10585. });
  10586. // Only after we got the offset, we can change the helper's position to absolute
  10587. // TODO: Still need to figure out a way to make relative sorting possible
  10588. this.helper.css("position", "absolute");
  10589. this.cssPosition = this.helper.css("position");
  10590. //Generate the original position
  10591. this.originalPosition = this._generatePosition(event);
  10592. this.originalPageX = event.pageX;
  10593. this.originalPageY = event.pageY;
  10594. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  10595. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  10596. //Cache the former DOM position
  10597. this.domPosition = { prev: this.currentItem.prev()[0], parent: this.currentItem.parent()[0] };
  10598. //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
  10599. if (this.helper[0] !== this.currentItem[0]) {
  10600. this.currentItem.hide();
  10601. }
  10602. //Create the placeholder
  10603. this._createPlaceholder();
  10604. //Set a containment if given in the options
  10605. if (o.containment) {
  10606. this._setContainment();
  10607. }
  10608. if (o.cursor && o.cursor !== "auto") { // cursor option
  10609. body = this.document.find("body");
  10610. // support: IE
  10611. this.storedCursor = body.css("cursor");
  10612. body.css("cursor", o.cursor);
  10613. this.storedStylesheet = $("<style>*{ cursor: " + o.cursor + " !important; }</style>").appendTo(body);
  10614. }
  10615. if (o.opacity) { // opacity option
  10616. if (this.helper.css("opacity")) {
  10617. this._storedOpacity = this.helper.css("opacity");
  10618. }
  10619. this.helper.css("opacity", o.opacity);
  10620. }
  10621. if (o.zIndex) { // zIndex option
  10622. if (this.helper.css("zIndex")) {
  10623. this._storedZIndex = this.helper.css("zIndex");
  10624. }
  10625. this.helper.css("zIndex", o.zIndex);
  10626. }
  10627. //Prepare scrolling
  10628. if (this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
  10629. this.overflowOffset = this.scrollParent.offset();
  10630. }
  10631. //Call callbacks
  10632. this._trigger("start", event, this._uiHash());
  10633. //Recache the helper size
  10634. if (!this._preserveHelperProportions) {
  10635. this._cacheHelperProportions();
  10636. }
  10637. //Post "activate" events to possible containers
  10638. if (!noActivation) {
  10639. for (i = this.containers.length - 1; i >= 0; i--) {
  10640. this.containers[i]._trigger("activate", event, this._uiHash(this));
  10641. }
  10642. }
  10643. //Prepare possible droppables
  10644. if ($.ui.ddmanager) {
  10645. $.ui.ddmanager.current = this;
  10646. }
  10647. if ($.ui.ddmanager && !o.dropBehaviour) {
  10648. $.ui.ddmanager.prepareOffsets(this, event);
  10649. }
  10650. this.dragging = true;
  10651. this.helper.addClass("ui-sortable-helper");
  10652. this._mouseDrag(event); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  10653. return true;
  10654. },
  10655. _mouseDrag: function (event) {
  10656. var i, item, itemElement, intersection,
  10657. o = this.options,
  10658. scrolled = false;
  10659. //Compute the helpers position
  10660. this.position = this._generatePosition(event);
  10661. this.positionAbs = this._convertPositionTo("absolute");
  10662. if (!this.lastPositionAbs) {
  10663. this.lastPositionAbs = this.positionAbs;
  10664. }
  10665. //Do scrolling
  10666. if (this.options.scroll) {
  10667. if (this.scrollParent[0] !== document && this.scrollParent[0].tagName !== "HTML") {
  10668. if ((this.overflowOffset.top + this.scrollParent[0].offsetHeight) - event.pageY < o.scrollSensitivity) {
  10669. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop + o.scrollSpeed;
  10670. } else if (event.pageY - this.overflowOffset.top < o.scrollSensitivity) {
  10671. this.scrollParent[0].scrollTop = scrolled = this.scrollParent[0].scrollTop - o.scrollSpeed;
  10672. }
  10673. if ((this.overflowOffset.left + this.scrollParent[0].offsetWidth) - event.pageX < o.scrollSensitivity) {
  10674. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft + o.scrollSpeed;
  10675. } else if (event.pageX - this.overflowOffset.left < o.scrollSensitivity) {
  10676. this.scrollParent[0].scrollLeft = scrolled = this.scrollParent[0].scrollLeft - o.scrollSpeed;
  10677. }
  10678. } else {
  10679. if (event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
  10680. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  10681. } else if ($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
  10682. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  10683. }
  10684. if (event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
  10685. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  10686. } else if ($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
  10687. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  10688. }
  10689. }
  10690. if (scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  10691. $.ui.ddmanager.prepareOffsets(this, event);
  10692. }
  10693. }
  10694. //Regenerate the absolute position used for position checks
  10695. this.positionAbs = this._convertPositionTo("absolute");
  10696. //Set the helper position
  10697. if (!this.options.axis || this.options.axis !== "y") {
  10698. this.helper[0].style.left = this.position.left + "px";
  10699. }
  10700. if (!this.options.axis || this.options.axis !== "x") {
  10701. this.helper[0].style.top = this.position.top + "px";
  10702. }
  10703. //Rearrange
  10704. for (i = this.items.length - 1; i >= 0; i--) {
  10705. //Cache variables and intersection, continue if no intersection
  10706. item = this.items[i];
  10707. itemElement = item.item[0];
  10708. intersection = this._intersectsWithPointer(item);
  10709. if (!intersection) {
  10710. continue;
  10711. }
  10712. // Only put the placeholder inside the current Container, skip all
  10713. // items from other containers. This works because when moving
  10714. // an item from one container to another the
  10715. // currentContainer is switched before the placeholder is moved.
  10716. //
  10717. // Without this, moving items in "sub-sortables" can cause
  10718. // the placeholder to jitter beetween the outer and inner container.
  10719. if (item.instance !== this.currentContainer) {
  10720. continue;
  10721. }
  10722. // cannot intersect with itself
  10723. // no useless actions that have been done before
  10724. // no action if the item moved is the parent of the item checked
  10725. if (itemElement !== this.currentItem[0] &&
  10726. this.placeholder[intersection === 1 ? "next" : "prev"]()[0] !== itemElement &&
  10727. !$.contains(this.placeholder[0], itemElement) &&
  10728. (this.options.type === "semi-dynamic" ? !$.contains(this.element[0], itemElement) : true)
  10729. ) {
  10730. this.direction = intersection === 1 ? "down" : "up";
  10731. if (this.options.tolerance === "pointer" || this._intersectsWithSides(item)) {
  10732. this._rearrange(event, item);
  10733. } else {
  10734. break;
  10735. }
  10736. this._trigger("change", event, this._uiHash());
  10737. break;
  10738. }
  10739. }
  10740. //Post events to containers
  10741. this._contactContainers(event);
  10742. //Interconnect with droppables
  10743. if ($.ui.ddmanager) {
  10744. $.ui.ddmanager.drag(this, event);
  10745. }
  10746. //Call callbacks
  10747. this._trigger("sort", event, this._uiHash());
  10748. this.lastPositionAbs = this.positionAbs;
  10749. return false;
  10750. },
  10751. _mouseStop: function (event, noPropagation) {
  10752. if (!event) {
  10753. return;
  10754. }
  10755. //If we are using droppables, inform the manager about the drop
  10756. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  10757. $.ui.ddmanager.drop(this, event);
  10758. }
  10759. if (this.options.revert) {
  10760. var that = this,
  10761. cur = this.placeholder.offset(),
  10762. axis = this.options.axis,
  10763. animation = {};
  10764. if (!axis || axis === "x") {
  10765. animation.left = cur.left - this.offset.parent.left - this.margins.left + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollLeft);
  10766. }
  10767. if (!axis || axis === "y") {
  10768. animation.top = cur.top - this.offset.parent.top - this.margins.top + (this.offsetParent[0] === document.body ? 0 : this.offsetParent[0].scrollTop);
  10769. }
  10770. this.reverting = true;
  10771. $(this.helper).animate(animation, parseInt(this.options.revert, 10) || 500, function () {
  10772. that._clear(event);
  10773. });
  10774. } else {
  10775. this._clear(event, noPropagation);
  10776. }
  10777. return false;
  10778. },
  10779. cancel: function () {
  10780. if (this.dragging) {
  10781. this._mouseUp({ target: null });
  10782. if (this.options.helper === "original") {
  10783. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  10784. } else {
  10785. this.currentItem.show();
  10786. }
  10787. //Post deactivating events to containers
  10788. for (var i = this.containers.length - 1; i >= 0; i--) {
  10789. this.containers[i]._trigger("deactivate", null, this._uiHash(this));
  10790. if (this.containers[i].containerCache.over) {
  10791. this.containers[i]._trigger("out", null, this._uiHash(this));
  10792. this.containers[i].containerCache.over = 0;
  10793. }
  10794. }
  10795. }
  10796. if (this.placeholder) {
  10797. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  10798. if (this.placeholder[0].parentNode) {
  10799. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  10800. }
  10801. if (this.options.helper !== "original" && this.helper && this.helper[0].parentNode) {
  10802. this.helper.remove();
  10803. }
  10804. $.extend(this, {
  10805. helper: null,
  10806. dragging: false,
  10807. reverting: false,
  10808. _noFinalSort: null
  10809. });
  10810. if (this.domPosition.prev) {
  10811. $(this.domPosition.prev).after(this.currentItem);
  10812. } else {
  10813. $(this.domPosition.parent).prepend(this.currentItem);
  10814. }
  10815. }
  10816. return this;
  10817. },
  10818. serialize: function (o) {
  10819. var items = this._getItemsAsjQuery(o && o.connected),
  10820. str = [];
  10821. o = o || {};
  10822. $(items).each(function () {
  10823. var res = ($(o.item || this).attr(o.attribute || "id") || "").match(o.expression || (/(.+)[\-=_](.+)/));
  10824. if (res) {
  10825. str.push((o.key || res[1] + "[]") + "=" + (o.key && o.expression ? res[1] : res[2]));
  10826. }
  10827. });
  10828. if (!str.length && o.key) {
  10829. str.push(o.key + "=");
  10830. }
  10831. return str.join("&");
  10832. },
  10833. toArray: function (o) {
  10834. var items = this._getItemsAsjQuery(o && o.connected),
  10835. ret = [];
  10836. o = o || {};
  10837. items.each(function () { ret.push($(o.item || this).attr(o.attribute || "id") || ""); });
  10838. return ret;
  10839. },
  10840. /* Be careful with the following core functions */
  10841. _intersectsWith: function (item) {
  10842. var x1 = this.positionAbs.left,
  10843. x2 = x1 + this.helperProportions.width,
  10844. y1 = this.positionAbs.top,
  10845. y2 = y1 + this.helperProportions.height,
  10846. l = item.left,
  10847. r = l + item.width,
  10848. t = item.top,
  10849. b = t + item.height,
  10850. dyClick = this.offset.click.top,
  10851. dxClick = this.offset.click.left,
  10852. isOverElementHeight = (this.options.axis === "x") || ((y1 + dyClick) > t && (y1 + dyClick) < b),
  10853. isOverElementWidth = (this.options.axis === "y") || ((x1 + dxClick) > l && (x1 + dxClick) < r),
  10854. isOverElement = isOverElementHeight && isOverElementWidth;
  10855. if (this.options.tolerance === "pointer" ||
  10856. this.options.forcePointerForContainers ||
  10857. (this.options.tolerance !== "pointer" && this.helperProportions[this.floating ? "width" : "height"] > item[this.floating ? "width" : "height"])
  10858. ) {
  10859. return isOverElement;
  10860. } else {
  10861. return (l < x1 + (this.helperProportions.width / 2) && // Right Half
  10862. x2 - (this.helperProportions.width / 2) < r && // Left Half
  10863. t < y1 + (this.helperProportions.height / 2) && // Bottom Half
  10864. y2 - (this.helperProportions.height / 2) < b); // Top Half
  10865. }
  10866. },
  10867. _intersectsWithPointer: function (item) {
  10868. var isOverElementHeight = (this.options.axis === "x") || isOverAxis(this.positionAbs.top + this.offset.click.top, item.top, item.height),
  10869. isOverElementWidth = (this.options.axis === "y") || isOverAxis(this.positionAbs.left + this.offset.click.left, item.left, item.width),
  10870. isOverElement = isOverElementHeight && isOverElementWidth,
  10871. verticalDirection = this._getDragVerticalDirection(),
  10872. horizontalDirection = this._getDragHorizontalDirection();
  10873. if (!isOverElement) {
  10874. return false;
  10875. }
  10876. return this.floating ?
  10877. (((horizontalDirection && horizontalDirection === "right") || verticalDirection === "down") ? 2 : 1)
  10878. : (verticalDirection && (verticalDirection === "down" ? 2 : 1));
  10879. },
  10880. _intersectsWithSides: function (item) {
  10881. var isOverBottomHalf = isOverAxis(this.positionAbs.top + this.offset.click.top, item.top + (item.height / 2), item.height),
  10882. isOverRightHalf = isOverAxis(this.positionAbs.left + this.offset.click.left, item.left + (item.width / 2), item.width),
  10883. verticalDirection = this._getDragVerticalDirection(),
  10884. horizontalDirection = this._getDragHorizontalDirection();
  10885. if (this.floating && horizontalDirection) {
  10886. return ((horizontalDirection === "right" && isOverRightHalf) || (horizontalDirection === "left" && !isOverRightHalf));
  10887. } else {
  10888. return verticalDirection && ((verticalDirection === "down" && isOverBottomHalf) || (verticalDirection === "up" && !isOverBottomHalf));
  10889. }
  10890. },
  10891. _getDragVerticalDirection: function () {
  10892. var delta = this.positionAbs.top - this.lastPositionAbs.top;
  10893. return delta !== 0 && (delta > 0 ? "down" : "up");
  10894. },
  10895. _getDragHorizontalDirection: function () {
  10896. var delta = this.positionAbs.left - this.lastPositionAbs.left;
  10897. return delta !== 0 && (delta > 0 ? "right" : "left");
  10898. },
  10899. refresh: function (event) {
  10900. this._refreshItems(event);
  10901. this.refreshPositions();
  10902. return this;
  10903. },
  10904. _connectWith: function () {
  10905. var options = this.options;
  10906. return options.connectWith.constructor === String ? [options.connectWith] : options.connectWith;
  10907. },
  10908. _getItemsAsjQuery: function (connected) {
  10909. var i, j, cur, inst,
  10910. items = [],
  10911. queries = [],
  10912. connectWith = this._connectWith();
  10913. if (connectWith && connected) {
  10914. for (i = connectWith.length - 1; i >= 0; i--) {
  10915. cur = $(connectWith[i]);
  10916. for (j = cur.length - 1; j >= 0; j--) {
  10917. inst = $.data(cur[j], this.widgetFullName);
  10918. if (inst && inst !== this && !inst.options.disabled) {
  10919. 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]);
  10920. }
  10921. }
  10922. }
  10923. }
  10924. 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]);
  10925. function addItems() {
  10926. items.push(this);
  10927. }
  10928. for (i = queries.length - 1; i >= 0; i--) {
  10929. queries[i][0].each(addItems);
  10930. }
  10931. return $(items);
  10932. },
  10933. _removeCurrentsFromItems: function () {
  10934. var list = this.currentItem.find(":data(" + this.widgetName + "-item)");
  10935. this.items = $.grep(this.items, function (item) {
  10936. for (var j = 0; j < list.length; j++) {
  10937. if (list[j] === item.item[0]) {
  10938. return false;
  10939. }
  10940. }
  10941. return true;
  10942. });
  10943. },
  10944. _refreshItems: function (event) {
  10945. this.items = [];
  10946. this.containers = [this];
  10947. var i, j, cur, inst, targetData, _queries, item, queriesLength,
  10948. items = this.items,
  10949. queries = [[$.isFunction(this.options.items) ? this.options.items.call(this.element[0], event, { item: this.currentItem }) : $(this.options.items, this.element), this]],
  10950. connectWith = this._connectWith();
  10951. if (connectWith && this.ready) { //Shouldn't be run the first time through due to massive slow-down
  10952. for (i = connectWith.length - 1; i >= 0; i--) {
  10953. cur = $(connectWith[i]);
  10954. for (j = cur.length - 1; j >= 0; j--) {
  10955. inst = $.data(cur[j], this.widgetFullName);
  10956. if (inst && inst !== this && !inst.options.disabled) {
  10957. queries.push([$.isFunction(inst.options.items) ? inst.options.items.call(inst.element[0], event, { item: this.currentItem }) : $(inst.options.items, inst.element), inst]);
  10958. this.containers.push(inst);
  10959. }
  10960. }
  10961. }
  10962. }
  10963. for (i = queries.length - 1; i >= 0; i--) {
  10964. targetData = queries[i][1];
  10965. _queries = queries[i][0];
  10966. for (j = 0, queriesLength = _queries.length; j < queriesLength; j++) {
  10967. item = $(_queries[j]);
  10968. item.data(this.widgetName + "-item", targetData); // Data for target checking (mouse manager)
  10969. items.push({
  10970. item: item,
  10971. instance: targetData,
  10972. width: 0, height: 0,
  10973. left: 0, top: 0
  10974. });
  10975. }
  10976. }
  10977. },
  10978. refreshPositions: function (fast) {
  10979. //This has to be redone because due to the item being moved out/into the offsetParent, the offsetParent's position will change
  10980. if (this.offsetParent && this.helper) {
  10981. this.offset.parent = this._getParentOffset();
  10982. }
  10983. var i, item, t, p;
  10984. for (i = this.items.length - 1; i >= 0; i--) {
  10985. item = this.items[i];
  10986. //We ignore calculating positions of all connected containers when we're not over them
  10987. if (item.instance !== this.currentContainer && this.currentContainer && item.item[0] !== this.currentItem[0]) {
  10988. continue;
  10989. }
  10990. t = this.options.toleranceElement ? $(this.options.toleranceElement, item.item) : item.item;
  10991. if (!fast) {
  10992. item.width = t.outerWidth();
  10993. item.height = t.outerHeight();
  10994. }
  10995. p = t.offset();
  10996. item.left = p.left;
  10997. item.top = p.top;
  10998. }
  10999. if (this.options.custom && this.options.custom.refreshContainers) {
  11000. this.options.custom.refreshContainers.call(this);
  11001. } else {
  11002. for (i = this.containers.length - 1; i >= 0; i--) {
  11003. p = this.containers[i].element.offset();
  11004. this.containers[i].containerCache.left = p.left;
  11005. this.containers[i].containerCache.top = p.top;
  11006. this.containers[i].containerCache.width = this.containers[i].element.outerWidth();
  11007. this.containers[i].containerCache.height = this.containers[i].element.outerHeight();
  11008. }
  11009. }
  11010. return this;
  11011. },
  11012. _createPlaceholder: function (that) {
  11013. that = that || this;
  11014. var className,
  11015. o = that.options;
  11016. if (!o.placeholder || o.placeholder.constructor === String) {
  11017. className = o.placeholder;
  11018. o.placeholder = {
  11019. element: function () {
  11020. var nodeName = that.currentItem[0].nodeName.toLowerCase(),
  11021. element = $("<" + nodeName + ">", that.document[0])
  11022. .addClass(className || that.currentItem[0].className + " ui-sortable-placeholder")
  11023. .removeClass("ui-sortable-helper");
  11024. if (nodeName === "tr") {
  11025. that.currentItem.children().each(function () {
  11026. $("<td>&#160;</td>", that.document[0])
  11027. .attr("colspan", $(this).attr("colspan") || 1)
  11028. .appendTo(element);
  11029. });
  11030. } else if (nodeName === "img") {
  11031. element.attr("src", that.currentItem.attr("src"));
  11032. }
  11033. if (!className) {
  11034. element.css("visibility", "hidden");
  11035. }
  11036. return element;
  11037. },
  11038. update: function (container, p) {
  11039. // 1. If a className is set as 'placeholder option, we don't force sizes - the class is responsible for that
  11040. // 2. The option 'forcePlaceholderSize can be enabled to force it even if a class name is specified
  11041. if (className && !o.forcePlaceholderSize) {
  11042. return;
  11043. }
  11044. //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
  11045. if (!p.height()) { p.height(that.currentItem.innerHeight() - parseInt(that.currentItem.css("paddingTop") || 0, 10) - parseInt(that.currentItem.css("paddingBottom") || 0, 10)); }
  11046. if (!p.width()) { p.width(that.currentItem.innerWidth() - parseInt(that.currentItem.css("paddingLeft") || 0, 10) - parseInt(that.currentItem.css("paddingRight") || 0, 10)); }
  11047. }
  11048. };
  11049. }
  11050. //Create the placeholder
  11051. that.placeholder = $(o.placeholder.element.call(that.element, that.currentItem));
  11052. //Append it after the actual current item
  11053. that.currentItem.after(that.placeholder);
  11054. //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
  11055. o.placeholder.update(that, that.placeholder);
  11056. },
  11057. _contactContainers: function (event) {
  11058. var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, base, cur, nearBottom, floating,
  11059. innermostContainer = null,
  11060. innermostIndex = null;
  11061. // get innermost container that intersects with item
  11062. for (i = this.containers.length - 1; i >= 0; i--) {
  11063. // never consider a container that's located within the item itself
  11064. if ($.contains(this.currentItem[0], this.containers[i].element[0])) {
  11065. continue;
  11066. }
  11067. if (this._intersectsWith(this.containers[i].containerCache)) {
  11068. // if we've already found a container and it's more "inner" than this, then continue
  11069. if (innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0])) {
  11070. continue;
  11071. }
  11072. innermostContainer = this.containers[i];
  11073. innermostIndex = i;
  11074. } else {
  11075. // container doesn't intersect. trigger "out" event if necessary
  11076. if (this.containers[i].containerCache.over) {
  11077. this.containers[i]._trigger("out", event, this._uiHash(this));
  11078. this.containers[i].containerCache.over = 0;
  11079. }
  11080. }
  11081. }
  11082. // if no intersecting containers found, return
  11083. if (!innermostContainer) {
  11084. return;
  11085. }
  11086. // move the item into the container if it's not there already
  11087. if (this.containers.length === 1) {
  11088. if (!this.containers[innermostIndex].containerCache.over) {
  11089. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  11090. this.containers[innermostIndex].containerCache.over = 1;
  11091. }
  11092. } else {
  11093. //When entering a new container, we will find the item with the least distance and append our item near it
  11094. dist = 10000;
  11095. itemWithLeastDistance = null;
  11096. floating = innermostContainer.floating || isFloating(this.currentItem);
  11097. posProperty = floating ? "left" : "top";
  11098. sizeProperty = floating ? "width" : "height";
  11099. base = this.positionAbs[posProperty] + this.offset.click[posProperty];
  11100. for (j = this.items.length - 1; j >= 0; j--) {
  11101. if (!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) {
  11102. continue;
  11103. }
  11104. if (this.items[j].item[0] === this.currentItem[0]) {
  11105. continue;
  11106. }
  11107. if (floating && !isOverAxis(this.positionAbs.top + this.offset.click.top, this.items[j].top, this.items[j].height)) {
  11108. continue;
  11109. }
  11110. cur = this.items[j].item.offset()[posProperty];
  11111. nearBottom = false;
  11112. if (Math.abs(cur - base) > Math.abs(cur + this.items[j][sizeProperty] - base)) {
  11113. nearBottom = true;
  11114. cur += this.items[j][sizeProperty];
  11115. }
  11116. if (Math.abs(cur - base) < dist) {
  11117. dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
  11118. this.direction = nearBottom ? "up" : "down";
  11119. }
  11120. }
  11121. //Check if dropOnEmpty is enabled
  11122. if (!itemWithLeastDistance && !this.options.dropOnEmpty) {
  11123. return;
  11124. }
  11125. if (this.currentContainer === this.containers[innermostIndex]) {
  11126. return;
  11127. }
  11128. itemWithLeastDistance ? this._rearrange(event, itemWithLeastDistance, null, true) : this._rearrange(event, null, this.containers[innermostIndex].element, true);
  11129. this._trigger("change", event, this._uiHash());
  11130. this.containers[innermostIndex]._trigger("change", event, this._uiHash(this));
  11131. this.currentContainer = this.containers[innermostIndex];
  11132. //Update the placeholder
  11133. this.options.placeholder.update(this.currentContainer, this.placeholder);
  11134. this.containers[innermostIndex]._trigger("over", event, this._uiHash(this));
  11135. this.containers[innermostIndex].containerCache.over = 1;
  11136. }
  11137. },
  11138. _createHelper: function (event) {
  11139. var o = this.options,
  11140. helper = $.isFunction(o.helper) ? $(o.helper.apply(this.element[0], [event, this.currentItem])) : (o.helper === "clone" ? this.currentItem.clone() : this.currentItem);
  11141. //Add the helper to the DOM if that didn't happen already
  11142. if (!helper.parents("body").length) {
  11143. $(o.appendTo !== "parent" ? o.appendTo : this.currentItem[0].parentNode)[0].appendChild(helper[0]);
  11144. }
  11145. if (helper[0] === this.currentItem[0]) {
  11146. 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") };
  11147. }
  11148. if (!helper[0].style.width || o.forceHelperSize) {
  11149. helper.width(this.currentItem.width());
  11150. }
  11151. if (!helper[0].style.height || o.forceHelperSize) {
  11152. helper.height(this.currentItem.height());
  11153. }
  11154. return helper;
  11155. },
  11156. _adjustOffsetFromHelper: function (obj) {
  11157. if (typeof obj === "string") {
  11158. obj = obj.split(" ");
  11159. }
  11160. if ($.isArray(obj)) {
  11161. obj = { left: +obj[0], top: +obj[1] || 0 };
  11162. }
  11163. if ("left" in obj) {
  11164. this.offset.click.left = obj.left + this.margins.left;
  11165. }
  11166. if ("right" in obj) {
  11167. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  11168. }
  11169. if ("top" in obj) {
  11170. this.offset.click.top = obj.top + this.margins.top;
  11171. }
  11172. if ("bottom" in obj) {
  11173. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  11174. }
  11175. },
  11176. _getParentOffset: function () {
  11177. //Get the offsetParent and cache its position
  11178. this.offsetParent = this.helper.offsetParent();
  11179. var po = this.offsetParent.offset();
  11180. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  11181. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  11182. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  11183. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  11184. if (this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  11185. po.left += this.scrollParent.scrollLeft();
  11186. po.top += this.scrollParent.scrollTop();
  11187. }
  11188. // This needs to be actually done for all browsers, since pageX/pageY includes this information
  11189. // with an ugly IE fix
  11190. if (this.offsetParent[0] === document.body || (this.offsetParent[0].tagName && this.offsetParent[0].tagName.toLowerCase() === "html" && $.ui.ie)) {
  11191. po = { top: 0, left: 0 };
  11192. }
  11193. return {
  11194. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"), 10) || 0),
  11195. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"), 10) || 0)
  11196. };
  11197. },
  11198. _getRelativeOffset: function () {
  11199. if (this.cssPosition === "relative") {
  11200. var p = this.currentItem.position();
  11201. return {
  11202. top: p.top - (parseInt(this.helper.css("top"), 10) || 0) + this.scrollParent.scrollTop(),
  11203. left: p.left - (parseInt(this.helper.css("left"), 10) || 0) + this.scrollParent.scrollLeft()
  11204. };
  11205. } else {
  11206. return { top: 0, left: 0 };
  11207. }
  11208. },
  11209. _cacheMargins: function () {
  11210. this.margins = {
  11211. left: (parseInt(this.currentItem.css("marginLeft"), 10) || 0),
  11212. top: (parseInt(this.currentItem.css("marginTop"), 10) || 0)
  11213. };
  11214. },
  11215. _cacheHelperProportions: function () {
  11216. this.helperProportions = {
  11217. width: this.helper.outerWidth(),
  11218. height: this.helper.outerHeight()
  11219. };
  11220. },
  11221. _setContainment: function () {
  11222. var ce, co, over,
  11223. o = this.options;
  11224. if (o.containment === "parent") {
  11225. o.containment = this.helper[0].parentNode;
  11226. }
  11227. if (o.containment === "document" || o.containment === "window") {
  11228. this.containment = [
  11229. 0 - this.offset.relative.left - this.offset.parent.left,
  11230. 0 - this.offset.relative.top - this.offset.parent.top,
  11231. $(o.containment === "document" ? document : window).width() - this.helperProportions.width - this.margins.left,
  11232. ($(o.containment === "document" ? document : window).height() || document.body.parentNode.scrollHeight) - this.helperProportions.height - this.margins.top
  11233. ];
  11234. }
  11235. if (!(/^(document|window|parent)$/).test(o.containment)) {
  11236. ce = $(o.containment)[0];
  11237. co = $(o.containment).offset();
  11238. over = ($(ce).css("overflow") !== "hidden");
  11239. this.containment = [
  11240. co.left + (parseInt($(ce).css("borderLeftWidth"), 10) || 0) + (parseInt($(ce).css("paddingLeft"), 10) || 0) - this.margins.left,
  11241. co.top + (parseInt($(ce).css("borderTopWidth"), 10) || 0) + (parseInt($(ce).css("paddingTop"), 10) || 0) - this.margins.top,
  11242. 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,
  11243. 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
  11244. ];
  11245. }
  11246. },
  11247. _convertPositionTo: function (d, pos) {
  11248. if (!pos) {
  11249. pos = this.position;
  11250. }
  11251. var mod = d === "absolute" ? 1 : -1,
  11252. scroll = this.cssPosition === "absolute" && !(this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent,
  11253. scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
  11254. return {
  11255. top: (
  11256. pos.top + // The absolute mouse position
  11257. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  11258. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  11259. ((this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : (scrollIsRootNode ? 0 : scroll.scrollTop())) * mod)
  11260. ),
  11261. left: (
  11262. pos.left + // The absolute mouse position
  11263. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  11264. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  11265. ((this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft()) * mod)
  11266. )
  11267. };
  11268. },
  11269. _generatePosition: function (event) {
  11270. var top, left,
  11271. o = this.options,
  11272. pageX = event.pageX,
  11273. pageY = event.pageY,
  11274. 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);
  11275. // This is another very weird special case that only happens for relative elements:
  11276. // 1. If the css position is relative
  11277. // 2. and the scroll parent is the document or similar to the offset parent
  11278. // we have to refresh the relative offset during the scroll so there are no jumps
  11279. if (this.cssPosition === "relative" && !(this.scrollParent[0] !== document && this.scrollParent[0] !== this.offsetParent[0])) {
  11280. this.offset.relative = this._getRelativeOffset();
  11281. }
  11282. /*
  11283. * - Position constraining -
  11284. * Constrain the position to a mix of grid, containment.
  11285. */
  11286. if (this.originalPosition) { //If we are not dragging yet, we won't check for options
  11287. if (this.containment) {
  11288. if (event.pageX - this.offset.click.left < this.containment[0]) {
  11289. pageX = this.containment[0] + this.offset.click.left;
  11290. }
  11291. if (event.pageY - this.offset.click.top < this.containment[1]) {
  11292. pageY = this.containment[1] + this.offset.click.top;
  11293. }
  11294. if (event.pageX - this.offset.click.left > this.containment[2]) {
  11295. pageX = this.containment[2] + this.offset.click.left;
  11296. }
  11297. if (event.pageY - this.offset.click.top > this.containment[3]) {
  11298. pageY = this.containment[3] + this.offset.click.top;
  11299. }
  11300. }
  11301. if (o.grid) {
  11302. top = this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1];
  11303. 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;
  11304. left = this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0];
  11305. 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;
  11306. }
  11307. }
  11308. return {
  11309. top: (
  11310. pageY - // The absolute mouse position
  11311. this.offset.click.top - // Click offset (relative to the element)
  11312. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  11313. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  11314. ((this.cssPosition === "fixed" ? -this.scrollParent.scrollTop() : (scrollIsRootNode ? 0 : scroll.scrollTop())))
  11315. ),
  11316. left: (
  11317. pageX - // The absolute mouse position
  11318. this.offset.click.left - // Click offset (relative to the element)
  11319. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  11320. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  11321. ((this.cssPosition === "fixed" ? -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 : scroll.scrollLeft()))
  11322. )
  11323. };
  11324. },
  11325. _rearrange: function (event, i, a, hardRefresh) {
  11326. 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));
  11327. //Various things done here to improve the performance:
  11328. // 1. we create a setTimeout, that calls refreshPositions
  11329. // 2. on the instance, we have a counter variable, that get's higher after every append
  11330. // 3. on the local scope, we copy the counter variable, and check in the timeout, if it's still the same
  11331. // 4. this lets only the last addition to the timeout stack through
  11332. this.counter = this.counter ? ++this.counter : 1;
  11333. var counter = this.counter;
  11334. this._delay(function () {
  11335. if (counter === this.counter) {
  11336. this.refreshPositions(!hardRefresh); //Precompute after each DOM insertion, NOT on mousemove
  11337. }
  11338. });
  11339. },
  11340. _clear: function (event, noPropagation) {
  11341. this.reverting = false;
  11342. // We delay all events that have to be triggered to after the point where the placeholder has been removed and
  11343. // everything else normalized again
  11344. var i,
  11345. delayedTriggers = [];
  11346. // We first have to update the dom position of the actual currentItem
  11347. // Note: don't do it if the current item is already removed (by a user), or it gets reappended (see #4088)
  11348. if (!this._noFinalSort && this.currentItem.parent().length) {
  11349. this.placeholder.before(this.currentItem);
  11350. }
  11351. this._noFinalSort = null;
  11352. if (this.helper[0] === this.currentItem[0]) {
  11353. for (i in this._storedCSS) {
  11354. if (this._storedCSS[i] === "auto" || this._storedCSS[i] === "static") {
  11355. this._storedCSS[i] = "";
  11356. }
  11357. }
  11358. this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper");
  11359. } else {
  11360. this.currentItem.show();
  11361. }
  11362. if (this.fromOutside && !noPropagation) {
  11363. delayedTriggers.push(function (event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
  11364. }
  11365. if ((this.fromOutside || this.domPosition.prev !== this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent !== this.currentItem.parent()[0]) && !noPropagation) {
  11366. delayedTriggers.push(function (event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
  11367. }
  11368. // Check if the items Container has Changed and trigger appropriate
  11369. // events.
  11370. if (this !== this.currentContainer) {
  11371. if (!noPropagation) {
  11372. delayedTriggers.push(function (event) { this._trigger("remove", event, this._uiHash()); });
  11373. delayedTriggers.push((function (c) { return function (event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  11374. delayedTriggers.push((function (c) { return function (event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.currentContainer));
  11375. }
  11376. }
  11377. //Post events to containers
  11378. function delayEvent(type, instance, container) {
  11379. return function (event) {
  11380. container._trigger(type, event, instance._uiHash(instance));
  11381. };
  11382. }
  11383. for (i = this.containers.length - 1; i >= 0; i--) {
  11384. if (!noPropagation) {
  11385. delayedTriggers.push(delayEvent("deactivate", this, this.containers[i]));
  11386. }
  11387. if (this.containers[i].containerCache.over) {
  11388. delayedTriggers.push(delayEvent("out", this, this.containers[i]));
  11389. this.containers[i].containerCache.over = 0;
  11390. }
  11391. }
  11392. //Do what was originally in plugins
  11393. if (this.storedCursor) {
  11394. this.document.find("body").css("cursor", this.storedCursor);
  11395. this.storedStylesheet.remove();
  11396. }
  11397. if (this._storedOpacity) {
  11398. this.helper.css("opacity", this._storedOpacity);
  11399. }
  11400. if (this._storedZIndex) {
  11401. this.helper.css("zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex);
  11402. }
  11403. this.dragging = false;
  11404. if (this.cancelHelperRemoval) {
  11405. if (!noPropagation) {
  11406. this._trigger("beforeStop", event, this._uiHash());
  11407. for (i = 0; i < delayedTriggers.length; i++) {
  11408. delayedTriggers[i].call(this, event);
  11409. } //Trigger all delayed events
  11410. this._trigger("stop", event, this._uiHash());
  11411. }
  11412. this.fromOutside = false;
  11413. return false;
  11414. }
  11415. if (!noPropagation) {
  11416. this._trigger("beforeStop", event, this._uiHash());
  11417. }
  11418. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately, it unbinds ALL events from the original node!
  11419. this.placeholder[0].parentNode.removeChild(this.placeholder[0]);
  11420. if (this.helper[0] !== this.currentItem[0]) {
  11421. this.helper.remove();
  11422. }
  11423. this.helper = null;
  11424. if (!noPropagation) {
  11425. for (i = 0; i < delayedTriggers.length; i++) {
  11426. delayedTriggers[i].call(this, event);
  11427. } //Trigger all delayed events
  11428. this._trigger("stop", event, this._uiHash());
  11429. }
  11430. this.fromOutside = false;
  11431. return true;
  11432. },
  11433. _trigger: function () {
  11434. if ($.Widget.prototype._trigger.apply(this, arguments) === false) {
  11435. this.cancel();
  11436. }
  11437. },
  11438. _uiHash: function (_inst) {
  11439. var inst = _inst || this;
  11440. return {
  11441. helper: inst.helper,
  11442. placeholder: inst.placeholder || $([]),
  11443. position: inst.position,
  11444. originalPosition: inst.originalPosition,
  11445. offset: inst.positionAbs,
  11446. item: inst.currentItem,
  11447. sender: _inst ? _inst.element : null
  11448. };
  11449. }
  11450. });
  11451. })(jQuery);
  11452. (function ($) {
  11453. function modifier(fn) {
  11454. return function () {
  11455. var previous = this.element.val();
  11456. fn.apply(this, arguments);
  11457. this._refresh();
  11458. if (previous !== this.element.val()) {
  11459. this._trigger("change");
  11460. }
  11461. };
  11462. }
  11463. $.widget("ui.spinner", {
  11464. version: "1.10.4",
  11465. defaultElement: "<input>",
  11466. widgetEventPrefix: "spin",
  11467. options: {
  11468. culture: null,
  11469. icons: {
  11470. down: "ui-icon-triangle-1-s",
  11471. up: "ui-icon-triangle-1-n"
  11472. },
  11473. incremental: true,
  11474. max: null,
  11475. min: null,
  11476. numberFormat: null,
  11477. page: 10,
  11478. step: 1,
  11479. change: null,
  11480. spin: null,
  11481. start: null,
  11482. stop: null
  11483. },
  11484. _create: function () {
  11485. // handle string values that need to be parsed
  11486. this._setOption("max", this.options.max);
  11487. this._setOption("min", this.options.min);
  11488. this._setOption("step", this.options.step);
  11489. // Only format if there is a value, prevents the field from being marked
  11490. // as invalid in Firefox, see #9573.
  11491. if (this.value() !== "") {
  11492. // Format the value, but don't constrain.
  11493. this._value(this.element.val(), true);
  11494. }
  11495. this._draw();
  11496. this._on(this._events);
  11497. this._refresh();
  11498. // turning off autocomplete prevents the browser from remembering the
  11499. // value when navigating through history, so we re-enable autocomplete
  11500. // if the page is unloaded before the widget is destroyed. #7790
  11501. this._on(this.window, {
  11502. beforeunload: function () {
  11503. this.element.removeAttr("autocomplete");
  11504. }
  11505. });
  11506. },
  11507. _getCreateOptions: function () {
  11508. var options = {},
  11509. element = this.element;
  11510. $.each(["min", "max", "step"], function (i, option) {
  11511. var value = element.attr(option);
  11512. if (value !== undefined && value.length) {
  11513. options[option] = value;
  11514. }
  11515. });
  11516. return options;
  11517. },
  11518. _events: {
  11519. keydown: function (event) {
  11520. if (this._start(event) && this._keydown(event)) {
  11521. event.preventDefault();
  11522. }
  11523. },
  11524. keyup: "_stop",
  11525. focus: function () {
  11526. this.previous = this.element.val();
  11527. },
  11528. blur: function (event) {
  11529. if (this.cancelBlur) {
  11530. delete this.cancelBlur;
  11531. return;
  11532. }
  11533. this._stop();
  11534. this._refresh();
  11535. if (this.previous !== this.element.val()) {
  11536. this._trigger("change", event);
  11537. }
  11538. },
  11539. mousewheel: function (event, delta) {
  11540. if (!delta) {
  11541. return;
  11542. }
  11543. if (!this.spinning && !this._start(event)) {
  11544. return false;
  11545. }
  11546. this._spin((delta > 0 ? 1 : -1) * this.options.step, event);
  11547. clearTimeout(this.mousewheelTimer);
  11548. this.mousewheelTimer = this._delay(function () {
  11549. if (this.spinning) {
  11550. this._stop(event);
  11551. }
  11552. }, 100);
  11553. event.preventDefault();
  11554. },
  11555. "mousedown .ui-spinner-button": function (event) {
  11556. var previous;
  11557. // We never want the buttons to have focus; whenever the user is
  11558. // interacting with the spinner, the focus should be on the input.
  11559. // If the input is focused then this.previous is properly set from
  11560. // when the input first received focus. If the input is not focused
  11561. // then we need to set this.previous based on the value before spinning.
  11562. previous = this.element[0] === this.document[0].activeElement ?
  11563. this.previous : this.element.val();
  11564. function checkFocus() {
  11565. var isActive = this.element[0] === this.document[0].activeElement;
  11566. if (!isActive) {
  11567. this.element.focus();
  11568. this.previous = previous;
  11569. // support: IE
  11570. // IE sets focus asynchronously, so we need to check if focus
  11571. // moved off of the input because the user clicked on the button.
  11572. this._delay(function () {
  11573. this.previous = previous;
  11574. });
  11575. }
  11576. }
  11577. // ensure focus is on (or stays on) the text field
  11578. event.preventDefault();
  11579. checkFocus.call(this);
  11580. // support: IE
  11581. // IE doesn't prevent moving focus even with event.preventDefault()
  11582. // so we set a flag to know when we should ignore the blur event
  11583. // and check (again) if focus moved off of the input.
  11584. this.cancelBlur = true;
  11585. this._delay(function () {
  11586. delete this.cancelBlur;
  11587. checkFocus.call(this);
  11588. });
  11589. if (this._start(event) === false) {
  11590. return;
  11591. }
  11592. this._repeat(null, $(event.currentTarget).hasClass("ui-spinner-up") ? 1 : -1, event);
  11593. },
  11594. "mouseup .ui-spinner-button": "_stop",
  11595. "mouseenter .ui-spinner-button": function (event) {
  11596. // button will add ui-state-active if mouse was down while mouseleave and kept down
  11597. if (!$(event.currentTarget).hasClass("ui-state-active")) {
  11598. return;
  11599. }
  11600. if (this._start(event) === false) {
  11601. return false;
  11602. }
  11603. this._repeat(null, $(event.currentTarget).hasClass("ui-spinner-up") ? 1 : -1, event);
  11604. },
  11605. // TODO: do we really want to consider this a stop?
  11606. // shouldn't we just stop the repeater and wait until mouseup before
  11607. // we trigger the stop event?
  11608. "mouseleave .ui-spinner-button": "_stop"
  11609. },
  11610. _draw: function () {
  11611. var uiSpinner = this.uiSpinner = this.element
  11612. .addClass("ui-spinner-input")
  11613. .attr("autocomplete", "off")
  11614. .wrap(this._uiSpinnerHtml())
  11615. .parent()
  11616. // add buttons
  11617. .append(this._buttonHtml());
  11618. this.element.attr("role", "spinbutton");
  11619. // button bindings
  11620. this.buttons = uiSpinner.find(".ui-spinner-button")
  11621. .attr("tabIndex", -1)
  11622. .button()
  11623. .removeClass("ui-corner-all");
  11624. // IE 6 doesn't understand height: 50% for the buttons
  11625. // unless the wrapper has an explicit height
  11626. if (this.buttons.height() > Math.ceil(uiSpinner.height() * 0.5) &&
  11627. uiSpinner.height() > 0) {
  11628. uiSpinner.height(uiSpinner.height());
  11629. }
  11630. // disable spinner if element was already disabled
  11631. if (this.options.disabled) {
  11632. this.disable();
  11633. }
  11634. },
  11635. _keydown: function (event) {
  11636. var options = this.options,
  11637. keyCode = $.ui.keyCode;
  11638. switch (event.keyCode) {
  11639. case keyCode.UP:
  11640. this._repeat(null, 1, event);
  11641. return true;
  11642. case keyCode.DOWN:
  11643. this._repeat(null, -1, event);
  11644. return true;
  11645. case keyCode.PAGE_UP:
  11646. this._repeat(null, options.page, event);
  11647. return true;
  11648. case keyCode.PAGE_DOWN:
  11649. this._repeat(null, -options.page, event);
  11650. return true;
  11651. }
  11652. return false;
  11653. },
  11654. _uiSpinnerHtml: function () {
  11655. return "<span class='ui-spinner ui-widget ui-widget-content ui-corner-all'></span>";
  11656. },
  11657. _buttonHtml: function () {
  11658. return "" +
  11659. "<a class='ui-spinner-button ui-spinner-up ui-corner-tr'>" +
  11660. "<span class='ui-icon " + this.options.icons.up + "'>&#9650;</span>" +
  11661. "</a>" +
  11662. "<a class='ui-spinner-button ui-spinner-down ui-corner-br'>" +
  11663. "<span class='ui-icon " + this.options.icons.down + "'>&#9660;</span>" +
  11664. "</a>";
  11665. },
  11666. _start: function (event) {
  11667. if (!this.spinning && this._trigger("start", event) === false) {
  11668. return false;
  11669. }
  11670. if (!this.counter) {
  11671. this.counter = 1;
  11672. }
  11673. this.spinning = true;
  11674. return true;
  11675. },
  11676. _repeat: function (i, steps, event) {
  11677. i = i || 500;
  11678. clearTimeout(this.timer);
  11679. this.timer = this._delay(function () {
  11680. this._repeat(40, steps, event);
  11681. }, i);
  11682. this._spin(steps * this.options.step, event);
  11683. },
  11684. _spin: function (step, event) {
  11685. var value = this.value() || 0;
  11686. if (!this.counter) {
  11687. this.counter = 1;
  11688. }
  11689. value = this._adjustValue(value + step * this._increment(this.counter));
  11690. if (!this.spinning || this._trigger("spin", event, { value: value }) !== false) {
  11691. this._value(value);
  11692. this.counter++;
  11693. }
  11694. },
  11695. _increment: function (i) {
  11696. var incremental = this.options.incremental;
  11697. if (incremental) {
  11698. return $.isFunction(incremental) ?
  11699. incremental(i) :
  11700. Math.floor(i * i * i / 50000 - i * i / 500 + 17 * i / 200 + 1);
  11701. }
  11702. return 1;
  11703. },
  11704. _precision: function () {
  11705. var precision = this._precisionOf(this.options.step);
  11706. if (this.options.min !== null) {
  11707. precision = Math.max(precision, this._precisionOf(this.options.min));
  11708. }
  11709. return precision;
  11710. },
  11711. _precisionOf: function (num) {
  11712. var str = num.toString(),
  11713. decimal = str.indexOf(".");
  11714. return decimal === -1 ? 0 : str.length - decimal - 1;
  11715. },
  11716. _adjustValue: function (value) {
  11717. var base, aboveMin,
  11718. options = this.options;
  11719. // make sure we're at a valid step
  11720. // - find out where we are relative to the base (min or 0)
  11721. base = options.min !== null ? options.min : 0;
  11722. aboveMin = value - base;
  11723. // - round to the nearest step
  11724. aboveMin = Math.round(aboveMin / options.step) * options.step;
  11725. // - rounding is based on 0, so adjust back to our base
  11726. value = base + aboveMin;
  11727. // fix precision from bad JS floating point math
  11728. value = parseFloat(value.toFixed(this._precision()));
  11729. // clamp the value
  11730. if (options.max !== null && value > options.max) {
  11731. return options.max;
  11732. }
  11733. if (options.min !== null && value < options.min) {
  11734. return options.min;
  11735. }
  11736. return value;
  11737. },
  11738. _stop: function (event) {
  11739. if (!this.spinning) {
  11740. return;
  11741. }
  11742. clearTimeout(this.timer);
  11743. clearTimeout(this.mousewheelTimer);
  11744. this.counter = 0;
  11745. this.spinning = false;
  11746. this._trigger("stop", event);
  11747. },
  11748. _setOption: function (key, value) {
  11749. if (key === "culture" || key === "numberFormat") {
  11750. var prevValue = this._parse(this.element.val());
  11751. this.options[key] = value;
  11752. this.element.val(this._format(prevValue));
  11753. return;
  11754. }
  11755. if (key === "max" || key === "min" || key === "step") {
  11756. if (typeof value === "string") {
  11757. value = this._parse(value);
  11758. }
  11759. }
  11760. if (key === "icons") {
  11761. this.buttons.first().find(".ui-icon")
  11762. .removeClass(this.options.icons.up)
  11763. .addClass(value.up);
  11764. this.buttons.last().find(".ui-icon")
  11765. .removeClass(this.options.icons.down)
  11766. .addClass(value.down);
  11767. }
  11768. this._super(key, value);
  11769. if (key === "disabled") {
  11770. if (value) {
  11771. this.element.prop("disabled", true);
  11772. this.buttons.button("disable");
  11773. } else {
  11774. this.element.prop("disabled", false);
  11775. this.buttons.button("enable");
  11776. }
  11777. }
  11778. },
  11779. _setOptions: modifier(function (options) {
  11780. this._super(options);
  11781. this._value(this.element.val());
  11782. }),
  11783. _parse: function (val) {
  11784. if (typeof val === "string" && val !== "") {
  11785. val = window.Globalize && this.options.numberFormat ?
  11786. Globalize.parseFloat(val, 10, this.options.culture) : +val;
  11787. }
  11788. return val === "" || isNaN(val) ? null : val;
  11789. },
  11790. _format: function (value) {
  11791. if (value === "") {
  11792. return "";
  11793. }
  11794. return window.Globalize && this.options.numberFormat ?
  11795. Globalize.format(value, this.options.numberFormat, this.options.culture) :
  11796. value;
  11797. },
  11798. _refresh: function () {
  11799. this.element.attr({
  11800. "aria-valuemin": this.options.min,
  11801. "aria-valuemax": this.options.max,
  11802. // TODO: what should we do with values that can't be parsed?
  11803. "aria-valuenow": this._parse(this.element.val())
  11804. });
  11805. },
  11806. // update the value without triggering change
  11807. _value: function (value, allowAny) {
  11808. var parsed;
  11809. if (value !== "") {
  11810. parsed = this._parse(value);
  11811. if (parsed !== null) {
  11812. if (!allowAny) {
  11813. parsed = this._adjustValue(parsed);
  11814. }
  11815. value = this._format(parsed);
  11816. }
  11817. }
  11818. this.element.val(value);
  11819. this._refresh();
  11820. },
  11821. _destroy: function () {
  11822. this.element
  11823. .removeClass("ui-spinner-input")
  11824. .prop("disabled", false)
  11825. .removeAttr("autocomplete")
  11826. .removeAttr("role")
  11827. .removeAttr("aria-valuemin")
  11828. .removeAttr("aria-valuemax")
  11829. .removeAttr("aria-valuenow");
  11830. this.uiSpinner.replaceWith(this.element);
  11831. },
  11832. stepUp: modifier(function (steps) {
  11833. this._stepUp(steps);
  11834. }),
  11835. _stepUp: function (steps) {
  11836. if (this._start()) {
  11837. this._spin((steps || 1) * this.options.step);
  11838. this._stop();
  11839. }
  11840. },
  11841. stepDown: modifier(function (steps) {
  11842. this._stepDown(steps);
  11843. }),
  11844. _stepDown: function (steps) {
  11845. if (this._start()) {
  11846. this._spin((steps || 1) * -this.options.step);
  11847. this._stop();
  11848. }
  11849. },
  11850. pageUp: modifier(function (pages) {
  11851. this._stepUp((pages || 1) * this.options.page);
  11852. }),
  11853. pageDown: modifier(function (pages) {
  11854. this._stepDown((pages || 1) * this.options.page);
  11855. }),
  11856. value: function (newVal) {
  11857. if (!arguments.length) {
  11858. return this._parse(this.element.val());
  11859. }
  11860. modifier(this._value).call(this, newVal);
  11861. },
  11862. widget: function () {
  11863. return this.uiSpinner;
  11864. }
  11865. });
  11866. }(jQuery));
  11867. (function ($, undefined) {
  11868. var tabId = 0,
  11869. rhash = /#.*$/;
  11870. function getNextTabId() {
  11871. return ++tabId;
  11872. }
  11873. function isLocal(anchor) {
  11874. // support: IE7
  11875. // IE7 doesn't normalize the href property when set via script (#9317)
  11876. anchor = anchor.cloneNode(false);
  11877. return anchor.hash.length > 1 &&
  11878. decodeURIComponent(anchor.href.replace(rhash, "")) ===
  11879. decodeURIComponent(location.href.replace(rhash, ""));
  11880. }
  11881. $.widget("ui.tabs", {
  11882. version: "1.10.4",
  11883. delay: 300,
  11884. options: {
  11885. active: null,
  11886. collapsible: false,
  11887. event: "click",
  11888. heightStyle: "content",
  11889. hide: null,
  11890. show: null,
  11891. // callbacks
  11892. activate: null,
  11893. beforeActivate: null,
  11894. beforeLoad: null,
  11895. load: null
  11896. },
  11897. _create: function () {
  11898. var that = this,
  11899. options = this.options;
  11900. this.running = false;
  11901. this.element
  11902. .addClass("ui-tabs ui-widget ui-widget-content ui-corner-all")
  11903. .toggleClass("ui-tabs-collapsible", options.collapsible)
  11904. // Prevent users from focusing disabled tabs via click
  11905. .delegate(".ui-tabs-nav > li", "mousedown" + this.eventNamespace, function (event) {
  11906. if ($(this).is(".ui-state-disabled")) {
  11907. event.preventDefault();
  11908. }
  11909. })
  11910. // support: IE <9
  11911. // Preventing the default action in mousedown doesn't prevent IE
  11912. // from focusing the element, so if the anchor gets focused, blur.
  11913. // We don't have to worry about focusing the previously focused
  11914. // element since clicking on a non-focusable element should focus
  11915. // the body anyway.
  11916. .delegate(".ui-tabs-anchor", "focus" + this.eventNamespace, function () {
  11917. if ($(this).closest("li").is(".ui-state-disabled")) {
  11918. this.blur();
  11919. }
  11920. });
  11921. this._processTabs();
  11922. options.active = this._initialActive();
  11923. // Take disabling tabs via class attribute from HTML
  11924. // into account and update option properly.
  11925. if ($.isArray(options.disabled)) {
  11926. options.disabled = $.unique(options.disabled.concat(
  11927. $.map(this.tabs.filter(".ui-state-disabled"), function (li) {
  11928. return that.tabs.index(li);
  11929. })
  11930. )).sort();
  11931. }
  11932. // check for length avoids error when initializing empty list
  11933. if (this.options.active !== false && this.anchors.length) {
  11934. this.active = this._findActive(options.active);
  11935. } else {
  11936. this.active = $();
  11937. }
  11938. this._refresh();
  11939. if (this.active.length) {
  11940. this.load(options.active);
  11941. }
  11942. },
  11943. _initialActive: function () {
  11944. var active = this.options.active,
  11945. collapsible = this.options.collapsible,
  11946. locationHash = location.hash.substring(1);
  11947. if (active === null) {
  11948. // check the fragment identifier in the URL
  11949. if (locationHash) {
  11950. this.tabs.each(function (i, tab) {
  11951. if ($(tab).attr("aria-controls") === locationHash) {
  11952. active = i;
  11953. return false;
  11954. }
  11955. });
  11956. }
  11957. // check for a tab marked active via a class
  11958. if (active === null) {
  11959. active = this.tabs.index(this.tabs.filter(".ui-tabs-active"));
  11960. }
  11961. // no active tab, set to false
  11962. if (active === null || active === -1) {
  11963. active = this.tabs.length ? 0 : false;
  11964. }
  11965. }
  11966. // handle numbers: negative, out of range
  11967. if (active !== false) {
  11968. active = this.tabs.index(this.tabs.eq(active));
  11969. if (active === -1) {
  11970. active = collapsible ? false : 0;
  11971. }
  11972. }
  11973. // don't allow collapsible: false and active: false
  11974. if (!collapsible && active === false && this.anchors.length) {
  11975. active = 0;
  11976. }
  11977. return active;
  11978. },
  11979. _getCreateEventData: function () {
  11980. return {
  11981. tab: this.active,
  11982. panel: !this.active.length ? $() : this._getPanelForTab(this.active)
  11983. };
  11984. },
  11985. _tabKeydown: function (event) {
  11986. var focusedTab = $(this.document[0].activeElement).closest("li"),
  11987. selectedIndex = this.tabs.index(focusedTab),
  11988. goingForward = true;
  11989. if (this._handlePageNav(event)) {
  11990. return;
  11991. }
  11992. switch (event.keyCode) {
  11993. case $.ui.keyCode.RIGHT:
  11994. case $.ui.keyCode.DOWN:
  11995. selectedIndex++;
  11996. break;
  11997. case $.ui.keyCode.UP:
  11998. case $.ui.keyCode.LEFT:
  11999. goingForward = false;
  12000. selectedIndex--;
  12001. break;
  12002. case $.ui.keyCode.END:
  12003. selectedIndex = this.anchors.length - 1;
  12004. break;
  12005. case $.ui.keyCode.HOME:
  12006. selectedIndex = 0;
  12007. break;
  12008. case $.ui.keyCode.SPACE:
  12009. // Activate only, no collapsing
  12010. event.preventDefault();
  12011. clearTimeout(this.activating);
  12012. this._activate(selectedIndex);
  12013. return;
  12014. case $.ui.keyCode.ENTER:
  12015. // Toggle (cancel delayed activation, allow collapsing)
  12016. event.preventDefault();
  12017. clearTimeout(this.activating);
  12018. // Determine if we should collapse or activate
  12019. this._activate(selectedIndex === this.options.active ? false : selectedIndex);
  12020. return;
  12021. default:
  12022. return;
  12023. }
  12024. // Focus the appropriate tab, based on which key was pressed
  12025. event.preventDefault();
  12026. clearTimeout(this.activating);
  12027. selectedIndex = this._focusNextTab(selectedIndex, goingForward);
  12028. // Navigating with control key will prevent automatic activation
  12029. if (!event.ctrlKey) {
  12030. // Update aria-selected immediately so that AT think the tab is already selected.
  12031. // Otherwise AT may confuse the user by stating that they need to activate the tab,
  12032. // but the tab will already be activated by the time the announcement finishes.
  12033. focusedTab.attr("aria-selected", "false");
  12034. this.tabs.eq(selectedIndex).attr("aria-selected", "true");
  12035. this.activating = this._delay(function () {
  12036. this.option("active", selectedIndex);
  12037. }, this.delay);
  12038. }
  12039. },
  12040. _panelKeydown: function (event) {
  12041. if (this._handlePageNav(event)) {
  12042. return;
  12043. }
  12044. // Ctrl+up moves focus to the current tab
  12045. if (event.ctrlKey && event.keyCode === $.ui.keyCode.UP) {
  12046. event.preventDefault();
  12047. this.active.focus();
  12048. }
  12049. },
  12050. // Alt+page up/down moves focus to the previous/next tab (and activates)
  12051. _handlePageNav: function (event) {
  12052. if (event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP) {
  12053. this._activate(this._focusNextTab(this.options.active - 1, false));
  12054. return true;
  12055. }
  12056. if (event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN) {
  12057. this._activate(this._focusNextTab(this.options.active + 1, true));
  12058. return true;
  12059. }
  12060. },
  12061. _findNextTab: function (index, goingForward) {
  12062. var lastTabIndex = this.tabs.length - 1;
  12063. function constrain() {
  12064. if (index > lastTabIndex) {
  12065. index = 0;
  12066. }
  12067. if (index < 0) {
  12068. index = lastTabIndex;
  12069. }
  12070. return index;
  12071. }
  12072. while ($.inArray(constrain(), this.options.disabled) !== -1) {
  12073. index = goingForward ? index + 1 : index - 1;
  12074. }
  12075. return index;
  12076. },
  12077. _focusNextTab: function (index, goingForward) {
  12078. index = this._findNextTab(index, goingForward);
  12079. this.tabs.eq(index).focus();
  12080. return index;
  12081. },
  12082. _setOption: function (key, value) {
  12083. if (key === "active") {
  12084. // _activate() will handle invalid values and update this.options
  12085. this._activate(value);
  12086. return;
  12087. }
  12088. if (key === "disabled") {
  12089. // don't use the widget factory's disabled handling
  12090. this._setupDisabled(value);
  12091. return;
  12092. }
  12093. this._super(key, value);
  12094. if (key === "collapsible") {
  12095. this.element.toggleClass("ui-tabs-collapsible", value);
  12096. // Setting collapsible: false while collapsed; open first panel
  12097. if (!value && this.options.active === false) {
  12098. this._activate(0);
  12099. }
  12100. }
  12101. if (key === "event") {
  12102. this._setupEvents(value);
  12103. }
  12104. if (key === "heightStyle") {
  12105. this._setupHeightStyle(value);
  12106. }
  12107. },
  12108. _tabId: function (tab) {
  12109. return tab.attr("aria-controls") || "ui-tabs-" + getNextTabId();
  12110. },
  12111. _sanitizeSelector: function (hash) {
  12112. return hash ? hash.replace(/[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&") : "";
  12113. },
  12114. refresh: function () {
  12115. var options = this.options,
  12116. lis = this.tablist.children(":has(a[href])");
  12117. // get disabled tabs from class attribute from HTML
  12118. // this will get converted to a boolean if needed in _refresh()
  12119. options.disabled = $.map(lis.filter(".ui-state-disabled"), function (tab) {
  12120. return lis.index(tab);
  12121. });
  12122. this._processTabs();
  12123. // was collapsed or no tabs
  12124. if (options.active === false || !this.anchors.length) {
  12125. options.active = false;
  12126. this.active = $();
  12127. // was active, but active tab is gone
  12128. } else if (this.active.length && !$.contains(this.tablist[0], this.active[0])) {
  12129. // all remaining tabs are disabled
  12130. if (this.tabs.length === options.disabled.length) {
  12131. options.active = false;
  12132. this.active = $();
  12133. // activate previous tab
  12134. } else {
  12135. this._activate(this._findNextTab(Math.max(0, options.active - 1), false));
  12136. }
  12137. // was active, active tab still exists
  12138. } else {
  12139. // make sure active index is correct
  12140. options.active = this.tabs.index(this.active);
  12141. }
  12142. this._refresh();
  12143. },
  12144. _refresh: function () {
  12145. this._setupDisabled(this.options.disabled);
  12146. this._setupEvents(this.options.event);
  12147. this._setupHeightStyle(this.options.heightStyle);
  12148. this.tabs.not(this.active).attr({
  12149. "aria-selected": "false",
  12150. tabIndex: -1
  12151. });
  12152. this.panels.not(this._getPanelForTab(this.active))
  12153. .hide()
  12154. .attr({
  12155. "aria-expanded": "false",
  12156. "aria-hidden": "true"
  12157. });
  12158. // Make sure one tab is in the tab order
  12159. if (!this.active.length) {
  12160. this.tabs.eq(0).attr("tabIndex", 0);
  12161. } else {
  12162. this.active
  12163. .addClass("ui-tabs-active ui-state-active")
  12164. .attr({
  12165. "aria-selected": "true",
  12166. tabIndex: 0
  12167. });
  12168. this._getPanelForTab(this.active)
  12169. .show()
  12170. .attr({
  12171. "aria-expanded": "true",
  12172. "aria-hidden": "false"
  12173. });
  12174. }
  12175. },
  12176. _processTabs: function () {
  12177. var that = this;
  12178. this.tablist = this._getList()
  12179. .addClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all")
  12180. .attr("role", "tablist");
  12181. this.tabs = this.tablist.find("> li:has(a[href])")
  12182. .addClass("ui-state-default ui-corner-top")
  12183. .attr({
  12184. role: "tab",
  12185. tabIndex: -1
  12186. });
  12187. this.anchors = this.tabs.map(function () {
  12188. return $("a", this)[0];
  12189. })
  12190. .addClass("ui-tabs-anchor")
  12191. .attr({
  12192. role: "presentation",
  12193. tabIndex: -1
  12194. });
  12195. this.panels = $();
  12196. this.anchors.each(function (i, anchor) {
  12197. var selector, panel, panelId,
  12198. anchorId = $(anchor).uniqueId().attr("id"),
  12199. tab = $(anchor).closest("li"),
  12200. originalAriaControls = tab.attr("aria-controls");
  12201. // inline tab
  12202. if (isLocal(anchor)) {
  12203. selector = anchor.hash;
  12204. panel = that.element.find(that._sanitizeSelector(selector));
  12205. // remote tab
  12206. } else {
  12207. panelId = that._tabId(tab);
  12208. selector = "#" + panelId;
  12209. panel = that.element.find(selector);
  12210. if (!panel.length) {
  12211. panel = that._createPanel(panelId);
  12212. panel.insertAfter(that.panels[i - 1] || that.tablist);
  12213. }
  12214. panel.attr("aria-live", "polite");
  12215. }
  12216. if (panel.length) {
  12217. that.panels = that.panels.add(panel);
  12218. }
  12219. if (originalAriaControls) {
  12220. tab.data("ui-tabs-aria-controls", originalAriaControls);
  12221. }
  12222. tab.attr({
  12223. "aria-controls": selector.substring(1),
  12224. "aria-labelledby": anchorId
  12225. });
  12226. panel.attr("aria-labelledby", anchorId);
  12227. });
  12228. this.panels
  12229. .addClass("ui-tabs-panel ui-widget-content ui-corner-bottom")
  12230. .attr("role", "tabpanel");
  12231. },
  12232. // allow overriding how to find the list for rare usage scenarios (#7715)
  12233. _getList: function () {
  12234. return this.tablist || this.element.find("ol,ul").eq(0);
  12235. },
  12236. _createPanel: function (id) {
  12237. return $("<div>")
  12238. .attr("id", id)
  12239. .addClass("ui-tabs-panel ui-widget-content ui-corner-bottom")
  12240. .data("ui-tabs-destroy", true);
  12241. },
  12242. _setupDisabled: function (disabled) {
  12243. if ($.isArray(disabled)) {
  12244. if (!disabled.length) {
  12245. disabled = false;
  12246. } else if (disabled.length === this.anchors.length) {
  12247. disabled = true;
  12248. }
  12249. }
  12250. // disable tabs
  12251. for (var i = 0, li; (li = this.tabs[i]); i++) {
  12252. if (disabled === true || $.inArray(i, disabled) !== -1) {
  12253. $(li)
  12254. .addClass("ui-state-disabled")
  12255. .attr("aria-disabled", "true");
  12256. } else {
  12257. $(li)
  12258. .removeClass("ui-state-disabled")
  12259. .removeAttr("aria-disabled");
  12260. }
  12261. }
  12262. this.options.disabled = disabled;
  12263. },
  12264. _setupEvents: function (event) {
  12265. var events = {
  12266. click: function (event) {
  12267. event.preventDefault();
  12268. }
  12269. };
  12270. if (event) {
  12271. $.each(event.split(" "), function (index, eventName) {
  12272. events[eventName] = "_eventHandler";
  12273. });
  12274. }
  12275. this._off(this.anchors.add(this.tabs).add(this.panels));
  12276. this._on(this.anchors, events);
  12277. this._on(this.tabs, { keydown: "_tabKeydown" });
  12278. this._on(this.panels, { keydown: "_panelKeydown" });
  12279. this._focusable(this.tabs);
  12280. this._hoverable(this.tabs);
  12281. },
  12282. _setupHeightStyle: function (heightStyle) {
  12283. var maxHeight,
  12284. parent = this.element.parent();
  12285. if (heightStyle === "fill") {
  12286. maxHeight = parent.height();
  12287. maxHeight -= this.element.outerHeight() - this.element.height();
  12288. this.element.siblings(":visible").each(function () {
  12289. var elem = $(this),
  12290. position = elem.css("position");
  12291. if (position === "absolute" || position === "fixed") {
  12292. return;
  12293. }
  12294. maxHeight -= elem.outerHeight(true);
  12295. });
  12296. this.element.children().not(this.panels).each(function () {
  12297. maxHeight -= $(this).outerHeight(true);
  12298. });
  12299. this.panels.each(function () {
  12300. $(this).height(Math.max(0, maxHeight -
  12301. $(this).innerHeight() + $(this).height()));
  12302. })
  12303. .css("overflow", "auto");
  12304. } else if (heightStyle === "auto") {
  12305. maxHeight = 0;
  12306. this.panels.each(function () {
  12307. maxHeight = Math.max(maxHeight, $(this).height("").height());
  12308. }).height(maxHeight);
  12309. }
  12310. },
  12311. _eventHandler: function (event) {
  12312. var options = this.options,
  12313. active = this.active,
  12314. anchor = $(event.currentTarget),
  12315. tab = anchor.closest("li"),
  12316. clickedIsActive = tab[0] === active[0],
  12317. collapsing = clickedIsActive && options.collapsible,
  12318. toShow = collapsing ? $() : this._getPanelForTab(tab),
  12319. toHide = !active.length ? $() : this._getPanelForTab(active),
  12320. eventData = {
  12321. oldTab: active,
  12322. oldPanel: toHide,
  12323. newTab: collapsing ? $() : tab,
  12324. newPanel: toShow
  12325. };
  12326. event.preventDefault();
  12327. if (tab.hasClass("ui-state-disabled") ||
  12328. // tab is already loading
  12329. tab.hasClass("ui-tabs-loading") ||
  12330. // can't switch durning an animation
  12331. this.running ||
  12332. // click on active header, but not collapsible
  12333. (clickedIsActive && !options.collapsible) ||
  12334. // allow canceling activation
  12335. (this._trigger("beforeActivate", event, eventData) === false)) {
  12336. return;
  12337. }
  12338. options.active = collapsing ? false : this.tabs.index(tab);
  12339. this.active = clickedIsActive ? $() : tab;
  12340. if (this.xhr) {
  12341. this.xhr.abort();
  12342. }
  12343. if (!toHide.length && !toShow.length) {
  12344. $.error("jQuery UI Tabs: Mismatching fragment identifier.");
  12345. }
  12346. if (toShow.length) {
  12347. this.load(this.tabs.index(tab), event);
  12348. }
  12349. this._toggle(event, eventData);
  12350. },
  12351. // handles show/hide for selecting tabs
  12352. _toggle: function (event, eventData) {
  12353. var that = this,
  12354. toShow = eventData.newPanel,
  12355. toHide = eventData.oldPanel;
  12356. this.running = true;
  12357. function complete() {
  12358. that.running = false;
  12359. that._trigger("activate", event, eventData);
  12360. }
  12361. function show() {
  12362. eventData.newTab.closest("li").addClass("ui-tabs-active ui-state-active");
  12363. if (toShow.length && that.options.show) {
  12364. that._show(toShow, that.options.show, complete);
  12365. } else {
  12366. toShow.show();
  12367. complete();
  12368. }
  12369. }
  12370. // start out by hiding, then showing, then completing
  12371. if (toHide.length && this.options.hide) {
  12372. this._hide(toHide, this.options.hide, function () {
  12373. eventData.oldTab.closest("li").removeClass("ui-tabs-active ui-state-active");
  12374. show();
  12375. });
  12376. } else {
  12377. eventData.oldTab.closest("li").removeClass("ui-tabs-active ui-state-active");
  12378. toHide.hide();
  12379. show();
  12380. }
  12381. toHide.attr({
  12382. "aria-expanded": "false",
  12383. "aria-hidden": "true"
  12384. });
  12385. eventData.oldTab.attr("aria-selected", "false");
  12386. // If we're switching tabs, remove the old tab from the tab order.
  12387. // If we're opening from collapsed state, remove the previous tab from the tab order.
  12388. // If we're collapsing, then keep the collapsing tab in the tab order.
  12389. if (toShow.length && toHide.length) {
  12390. eventData.oldTab.attr("tabIndex", -1);
  12391. } else if (toShow.length) {
  12392. this.tabs.filter(function () {
  12393. return $(this).attr("tabIndex") === 0;
  12394. })
  12395. .attr("tabIndex", -1);
  12396. }
  12397. toShow.attr({
  12398. "aria-expanded": "true",
  12399. "aria-hidden": "false"
  12400. });
  12401. eventData.newTab.attr({
  12402. "aria-selected": "true",
  12403. tabIndex: 0
  12404. });
  12405. },
  12406. _activate: function (index) {
  12407. var anchor,
  12408. active = this._findActive(index);
  12409. // trying to activate the already active panel
  12410. if (active[0] === this.active[0]) {
  12411. return;
  12412. }
  12413. // trying to collapse, simulate a click on the current active header
  12414. if (!active.length) {
  12415. active = this.active;
  12416. }
  12417. anchor = active.find(".ui-tabs-anchor")[0];
  12418. this._eventHandler({
  12419. target: anchor,
  12420. currentTarget: anchor,
  12421. preventDefault: $.noop
  12422. });
  12423. },
  12424. _findActive: function (index) {
  12425. return index === false ? $() : this.tabs.eq(index);
  12426. },
  12427. _getIndex: function (index) {
  12428. // meta-function to give users option to provide a href string instead of a numerical index.
  12429. if (typeof index === "string") {
  12430. index = this.anchors.index(this.anchors.filter("[href$='" + index + "']"));
  12431. }
  12432. return index;
  12433. },
  12434. _destroy: function () {
  12435. if (this.xhr) {
  12436. this.xhr.abort();
  12437. }
  12438. this.element.removeClass("ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible");
  12439. this.tablist
  12440. .removeClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all")
  12441. .removeAttr("role");
  12442. this.anchors
  12443. .removeClass("ui-tabs-anchor")
  12444. .removeAttr("role")
  12445. .removeAttr("tabIndex")
  12446. .removeUniqueId();
  12447. this.tabs.add(this.panels).each(function () {
  12448. if ($.data(this, "ui-tabs-destroy")) {
  12449. $(this).remove();
  12450. } else {
  12451. $(this)
  12452. .removeClass("ui-state-default ui-state-active ui-state-disabled " +
  12453. "ui-corner-top ui-corner-bottom ui-widget-content ui-tabs-active ui-tabs-panel")
  12454. .removeAttr("tabIndex")
  12455. .removeAttr("aria-live")
  12456. .removeAttr("aria-busy")
  12457. .removeAttr("aria-selected")
  12458. .removeAttr("aria-labelledby")
  12459. .removeAttr("aria-hidden")
  12460. .removeAttr("aria-expanded")
  12461. .removeAttr("role");
  12462. }
  12463. });
  12464. this.tabs.each(function () {
  12465. var li = $(this),
  12466. prev = li.data("ui-tabs-aria-controls");
  12467. if (prev) {
  12468. li
  12469. .attr("aria-controls", prev)
  12470. .removeData("ui-tabs-aria-controls");
  12471. } else {
  12472. li.removeAttr("aria-controls");
  12473. }
  12474. });
  12475. this.panels.show();
  12476. if (this.options.heightStyle !== "content") {
  12477. this.panels.css("height", "");
  12478. }
  12479. },
  12480. enable: function (index) {
  12481. var disabled = this.options.disabled;
  12482. if (disabled === false) {
  12483. return;
  12484. }
  12485. if (index === undefined) {
  12486. disabled = false;
  12487. } else {
  12488. index = this._getIndex(index);
  12489. if ($.isArray(disabled)) {
  12490. disabled = $.map(disabled, function (num) {
  12491. return num !== index ? num : null;
  12492. });
  12493. } else {
  12494. disabled = $.map(this.tabs, function (li, num) {
  12495. return num !== index ? num : null;
  12496. });
  12497. }
  12498. }
  12499. this._setupDisabled(disabled);
  12500. },
  12501. disable: function (index) {
  12502. var disabled = this.options.disabled;
  12503. if (disabled === true) {
  12504. return;
  12505. }
  12506. if (index === undefined) {
  12507. disabled = true;
  12508. } else {
  12509. index = this._getIndex(index);
  12510. if ($.inArray(index, disabled) !== -1) {
  12511. return;
  12512. }
  12513. if ($.isArray(disabled)) {
  12514. disabled = $.merge([index], disabled).sort();
  12515. } else {
  12516. disabled = [index];
  12517. }
  12518. }
  12519. this._setupDisabled(disabled);
  12520. },
  12521. load: function (index, event) {
  12522. index = this._getIndex(index);
  12523. var that = this,
  12524. tab = this.tabs.eq(index),
  12525. anchor = tab.find(".ui-tabs-anchor"),
  12526. panel = this._getPanelForTab(tab),
  12527. eventData = {
  12528. tab: tab,
  12529. panel: panel
  12530. };
  12531. // not remote
  12532. if (isLocal(anchor[0])) {
  12533. return;
  12534. }
  12535. this.xhr = $.ajax(this._ajaxSettings(anchor, event, eventData));
  12536. // support: jQuery <1.8
  12537. // jQuery <1.8 returns false if the request is canceled in beforeSend,
  12538. // but as of 1.8, $.ajax() always returns a jqXHR object.
  12539. if (this.xhr && this.xhr.statusText !== "canceled") {
  12540. tab.addClass("ui-tabs-loading");
  12541. panel.attr("aria-busy", "true");
  12542. this.xhr
  12543. .success(function (response) {
  12544. // support: jQuery <1.8
  12545. // http://bugs.jquery.com/ticket/11778
  12546. setTimeout(function () {
  12547. panel.html(response);
  12548. that._trigger("load", event, eventData);
  12549. }, 1);
  12550. })
  12551. .complete(function (jqXHR, status) {
  12552. // support: jQuery <1.8
  12553. // http://bugs.jquery.com/ticket/11778
  12554. setTimeout(function () {
  12555. if (status === "abort") {
  12556. that.panels.stop(false, true);
  12557. }
  12558. tab.removeClass("ui-tabs-loading");
  12559. panel.removeAttr("aria-busy");
  12560. if (jqXHR === that.xhr) {
  12561. delete that.xhr;
  12562. }
  12563. }, 1);
  12564. });
  12565. }
  12566. },
  12567. _ajaxSettings: function (anchor, event, eventData) {
  12568. var that = this;
  12569. return {
  12570. url: anchor.attr("href"),
  12571. beforeSend: function (jqXHR, settings) {
  12572. return that._trigger("beforeLoad", event,
  12573. $.extend({ jqXHR: jqXHR, ajaxSettings: settings }, eventData));
  12574. }
  12575. };
  12576. },
  12577. _getPanelForTab: function (tab) {
  12578. var id = $(tab).attr("aria-controls");
  12579. return this.element.find(this._sanitizeSelector("#" + id));
  12580. }
  12581. });
  12582. })(jQuery);
  12583. (function ($) {
  12584. var increments = 0;
  12585. function addDescribedBy(elem, id) {
  12586. var describedby = (elem.attr("aria-describedby") || "").split(/\s+/);
  12587. describedby.push(id);
  12588. elem
  12589. .data("ui-tooltip-id", id)
  12590. .attr("aria-describedby", $.trim(describedby.join(" ")));
  12591. }
  12592. function removeDescribedBy(elem) {
  12593. var id = elem.data("ui-tooltip-id"),
  12594. describedby = (elem.attr("aria-describedby") || "").split(/\s+/),
  12595. index = $.inArray(id, describedby);
  12596. if (index !== -1) {
  12597. describedby.splice(index, 1);
  12598. }
  12599. elem.removeData("ui-tooltip-id");
  12600. describedby = $.trim(describedby.join(" "));
  12601. if (describedby) {
  12602. elem.attr("aria-describedby", describedby);
  12603. } else {
  12604. elem.removeAttr("aria-describedby");
  12605. }
  12606. }
  12607. $.widget("ui.tooltip", {
  12608. version: "1.10.4",
  12609. options: {
  12610. content: function () {
  12611. // support: IE<9, Opera in jQuery <1.7
  12612. // .text() can't accept undefined, so coerce to a string
  12613. var title = $(this).attr("title") || "";
  12614. // Escape title, since we're going from an attribute to raw HTML
  12615. return $("<a>").text(title).html();
  12616. },
  12617. hide: true,
  12618. // Disabled elements have inconsistent behavior across browsers (#8661)
  12619. items: "[title]:not([disabled])",
  12620. position: {
  12621. my: "left top+15",
  12622. at: "left bottom",
  12623. collision: "flipfit flip"
  12624. },
  12625. show: true,
  12626. tooltipClass: null,
  12627. track: false,
  12628. // callbacks
  12629. close: null,
  12630. open: null
  12631. },
  12632. _create: function () {
  12633. this._on({
  12634. mouseover: "open",
  12635. focusin: "open"
  12636. });
  12637. // IDs of generated tooltips, needed for destroy
  12638. this.tooltips = {};
  12639. // IDs of parent tooltips where we removed the title attribute
  12640. this.parents = {};
  12641. if (this.options.disabled) {
  12642. this._disable();
  12643. }
  12644. },
  12645. _setOption: function (key, value) {
  12646. var that = this;
  12647. if (key === "disabled") {
  12648. this[value ? "_disable" : "_enable"]();
  12649. this.options[key] = value;
  12650. // disable element style changes
  12651. return;
  12652. }
  12653. this._super(key, value);
  12654. if (key === "content") {
  12655. $.each(this.tooltips, function (id, element) {
  12656. that._updateContent(element);
  12657. });
  12658. }
  12659. },
  12660. _disable: function () {
  12661. var that = this;
  12662. // close open tooltips
  12663. $.each(this.tooltips, function (id, element) {
  12664. var event = $.Event("blur");
  12665. event.target = event.currentTarget = element[0];
  12666. that.close(event, true);
  12667. });
  12668. // remove title attributes to prevent native tooltips
  12669. this.element.find(this.options.items).addBack().each(function () {
  12670. var element = $(this);
  12671. if (element.is("[title]")) {
  12672. element
  12673. .data("ui-tooltip-title", element.attr("title"))
  12674. .attr("title", "");
  12675. }
  12676. });
  12677. },
  12678. _enable: function () {
  12679. // restore title attributes
  12680. this.element.find(this.options.items).addBack().each(function () {
  12681. var element = $(this);
  12682. if (element.data("ui-tooltip-title")) {
  12683. element.attr("title", element.data("ui-tooltip-title"));
  12684. }
  12685. });
  12686. },
  12687. open: function (event) {
  12688. var that = this,
  12689. target = $(event ? event.target : this.element)
  12690. // we need closest here due to mouseover bubbling,
  12691. // but always pointing at the same event target
  12692. .closest(this.options.items);
  12693. // No element to show a tooltip for or the tooltip is already open
  12694. if (!target.length || target.data("ui-tooltip-id")) {
  12695. return;
  12696. }
  12697. if (target.attr("title")) {
  12698. target.data("ui-tooltip-title", target.attr("title"));
  12699. }
  12700. target.data("ui-tooltip-open", true);
  12701. // kill parent tooltips, custom or native, for hover
  12702. if (event && event.type === "mouseover") {
  12703. target.parents().each(function () {
  12704. var parent = $(this),
  12705. blurEvent;
  12706. if (parent.data("ui-tooltip-open")) {
  12707. blurEvent = $.Event("blur");
  12708. blurEvent.target = blurEvent.currentTarget = this;
  12709. that.close(blurEvent, true);
  12710. }
  12711. if (parent.attr("title")) {
  12712. parent.uniqueId();
  12713. that.parents[this.id] = {
  12714. element: this,
  12715. title: parent.attr("title")
  12716. };
  12717. parent.attr("title", "");
  12718. }
  12719. });
  12720. }
  12721. this._updateContent(target, event);
  12722. },
  12723. _updateContent: function (target, event) {
  12724. var content,
  12725. contentOption = this.options.content,
  12726. that = this,
  12727. eventType = event ? event.type : null;
  12728. if (typeof contentOption === "string") {
  12729. return this._open(event, target, contentOption);
  12730. }
  12731. content = contentOption.call(target[0], function (response) {
  12732. // ignore async response if tooltip was closed already
  12733. if (!target.data("ui-tooltip-open")) {
  12734. return;
  12735. }
  12736. // IE may instantly serve a cached response for ajax requests
  12737. // delay this call to _open so the other call to _open runs first
  12738. that._delay(function () {
  12739. // jQuery creates a special event for focusin when it doesn't
  12740. // exist natively. To improve performance, the native event
  12741. // object is reused and the type is changed. Therefore, we can't
  12742. // rely on the type being correct after the event finished
  12743. // bubbling, so we set it back to the previous value. (#8740)
  12744. if (event) {
  12745. event.type = eventType;
  12746. }
  12747. this._open(event, target, response);
  12748. });
  12749. });
  12750. if (content) {
  12751. this._open(event, target, content);
  12752. }
  12753. },
  12754. _open: function (event, target, content) {
  12755. var tooltip, events, delayedShow,
  12756. positionOption = $.extend({}, this.options.position);
  12757. if (!content) {
  12758. return;
  12759. }
  12760. // Content can be updated multiple times. If the tooltip already
  12761. // exists, then just update the content and bail.
  12762. tooltip = this._find(target);
  12763. if (tooltip.length) {
  12764. tooltip.find(".ui-tooltip-content").html(content);
  12765. return;
  12766. }
  12767. // if we have a title, clear it to prevent the native tooltip
  12768. // we have to check first to avoid defining a title if none exists
  12769. // (we don't want to cause an element to start matching [title])
  12770. //
  12771. // We use removeAttr only for key events, to allow IE to export the correct
  12772. // accessible attributes. For mouse events, set to empty string to avoid
  12773. // native tooltip showing up (happens only when removing inside mouseover).
  12774. if (target.is("[title]")) {
  12775. if (event && event.type === "mouseover") {
  12776. target.attr("title", "");
  12777. } else {
  12778. target.removeAttr("title");
  12779. }
  12780. }
  12781. tooltip = this._tooltip(target);
  12782. addDescribedBy(target, tooltip.attr("id"));
  12783. tooltip.find(".ui-tooltip-content").html(content);
  12784. function position(event) {
  12785. positionOption.of = event;
  12786. if (tooltip.is(":hidden")) {
  12787. return;
  12788. }
  12789. tooltip.position(positionOption);
  12790. }
  12791. if (this.options.track && event && /^mouse/.test(event.type)) {
  12792. this._on(this.document, {
  12793. mousemove: position
  12794. });
  12795. // trigger once to override element-relative positioning
  12796. position(event);
  12797. } else {
  12798. tooltip.position($.extend({
  12799. of: target
  12800. }, this.options.position));
  12801. }
  12802. tooltip.hide();
  12803. this._show(tooltip, this.options.show);
  12804. // Handle tracking tooltips that are shown with a delay (#8644). As soon
  12805. // as the tooltip is visible, position the tooltip using the most recent
  12806. // event.
  12807. if (this.options.show && this.options.show.delay) {
  12808. delayedShow = this.delayedShow = setInterval(function () {
  12809. if (tooltip.is(":visible")) {
  12810. position(positionOption.of);
  12811. clearInterval(delayedShow);
  12812. }
  12813. }, $.fx.interval);
  12814. }
  12815. this._trigger("open", event, { tooltip: tooltip });
  12816. events = {
  12817. keyup: function (event) {
  12818. if (event.keyCode === $.ui.keyCode.ESCAPE) {
  12819. var fakeEvent = $.Event(event);
  12820. fakeEvent.currentTarget = target[0];
  12821. this.close(fakeEvent, true);
  12822. }
  12823. },
  12824. remove: function () {
  12825. this._removeTooltip(tooltip);
  12826. }
  12827. };
  12828. if (!event || event.type === "mouseover") {
  12829. events.mouseleave = "close";
  12830. }
  12831. if (!event || event.type === "focusin") {
  12832. events.focusout = "close";
  12833. }
  12834. this._on(true, target, events);
  12835. },
  12836. close: function (event) {
  12837. var that = this,
  12838. target = $(event ? event.currentTarget : this.element),
  12839. tooltip = this._find(target);
  12840. // disabling closes the tooltip, so we need to track when we're closing
  12841. // to avoid an infinite loop in case the tooltip becomes disabled on close
  12842. if (this.closing) {
  12843. return;
  12844. }
  12845. // Clear the interval for delayed tracking tooltips
  12846. clearInterval(this.delayedShow);
  12847. // only set title if we had one before (see comment in _open())
  12848. if (target.data("ui-tooltip-title")) {
  12849. target.attr("title", target.data("ui-tooltip-title"));
  12850. }
  12851. removeDescribedBy(target);
  12852. tooltip.stop(true);
  12853. this._hide(tooltip, this.options.hide, function () {
  12854. that._removeTooltip($(this));
  12855. });
  12856. target.removeData("ui-tooltip-open");
  12857. this._off(target, "mouseleave focusout keyup");
  12858. // Remove 'remove' binding only on delegated targets
  12859. if (target[0] !== this.element[0]) {
  12860. this._off(target, "remove");
  12861. }
  12862. this._off(this.document, "mousemove");
  12863. if (event && event.type === "mouseleave") {
  12864. $.each(this.parents, function (id, parent) {
  12865. $(parent.element).attr("title", parent.title);
  12866. delete that.parents[id];
  12867. });
  12868. }
  12869. this.closing = true;
  12870. this._trigger("close", event, { tooltip: tooltip });
  12871. this.closing = false;
  12872. },
  12873. _tooltip: function (element) {
  12874. var id = "ui-tooltip-" + increments++,
  12875. tooltip = $("<div>")
  12876. .attr({
  12877. id: id,
  12878. role: "tooltip"
  12879. })
  12880. .addClass("ui-tooltip ui-widget ui-corner-all ui-widget-content " +
  12881. (this.options.tooltipClass || ""));
  12882. $("<div>")
  12883. .addClass("ui-tooltip-content")
  12884. .appendTo(tooltip);
  12885. tooltip.appendTo(this.document[0].body);
  12886. this.tooltips[id] = element;
  12887. return tooltip;
  12888. },
  12889. _find: function (target) {
  12890. var id = target.data("ui-tooltip-id");
  12891. return id ? $("#" + id) : $();
  12892. },
  12893. _removeTooltip: function (tooltip) {
  12894. tooltip.remove();
  12895. delete this.tooltips[tooltip.attr("id")];
  12896. },
  12897. _destroy: function () {
  12898. var that = this;
  12899. // close open tooltips
  12900. $.each(this.tooltips, function (id, element) {
  12901. // Delegate to close method to handle common cleanup
  12902. var event = $.Event("blur");
  12903. event.target = event.currentTarget = element[0];
  12904. that.close(event, true);
  12905. // Remove immediately; destroying an open tooltip doesn't use the
  12906. // hide animation
  12907. $("#" + id).remove();
  12908. // Restore the title
  12909. if (element.data("ui-tooltip-title")) {
  12910. element.attr("title", element.data("ui-tooltip-title"));
  12911. element.removeData("ui-tooltip-title");
  12912. }
  12913. });
  12914. }
  12915. });
  12916. }(jQuery));