Нема описа

jquery-ui.js 516KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046
  1. /*! jQuery UI - v1.13.0 - 2021-12-26
  2. * http://jqueryui.com
  3. * Includes: widget.js, position.js, data.js, disable-selection.js, focusable.js, form-reset-mixin.js, jquery-patch.js, keycode.js, labels.js, scroll-parent.js, tabbable.js, unique-id.js, widgets/draggable.js, widgets/droppable.js, widgets/resizable.js, widgets/selectable.js, widgets/sortable.js, widgets/accordion.js, widgets/autocomplete.js, widgets/button.js, widgets/checkboxradio.js, widgets/controlgroup.js, widgets/datepicker.js, widgets/dialog.js, widgets/menu.js, widgets/mouse.js, widgets/progressbar.js, widgets/selectmenu.js, widgets/slider.js, widgets/spinner.js, widgets/tabs.js, widgets/tooltip.js, effect.js, effects/effect-blind.js, effects/effect-bounce.js, effects/effect-clip.js, effects/effect-drop.js, effects/effect-explode.js, effects/effect-fade.js, effects/effect-fold.js, effects/effect-highlight.js, effects/effect-puff.js, effects/effect-pulsate.js, effects/effect-scale.js, effects/effect-shake.js, effects/effect-size.js, effects/effect-slide.js, effects/effect-transfer.js
  4. * Copyright jQuery Foundation and other contributors; Licensed MIT */
  5. ( function( factory ) {
  6. "use strict";
  7. if ( typeof define === "function" && define.amd ) {
  8. // AMD. Register as an anonymous module.
  9. define( [ "jquery" ], factory );
  10. } else {
  11. // Browser globals
  12. factory( jQuery );
  13. }
  14. } )( function( $ ) {
  15. "use strict";
  16. $.ui = $.ui || {};
  17. var version = $.ui.version = "1.13.0";
  18. /*!
  19. * jQuery UI Widget 1.13.0
  20. * http://jqueryui.com
  21. *
  22. * Copyright jQuery Foundation and other contributors
  23. * Released under the MIT license.
  24. * http://jquery.org/license
  25. */
  26. //>>label: Widget
  27. //>>group: Core
  28. //>>description: Provides a factory for creating stateful widgets with a common API.
  29. //>>docs: http://api.jqueryui.com/jQuery.widget/
  30. //>>demos: http://jqueryui.com/widget/
  31. var widgetUuid = 0;
  32. var widgetHasOwnProperty = Array.prototype.hasOwnProperty;
  33. var widgetSlice = Array.prototype.slice;
  34. $.cleanData = ( function( orig ) {
  35. return function( elems ) {
  36. var events, elem, i;
  37. for ( i = 0; ( elem = elems[ i ] ) != null; i++ ) {
  38. // Only trigger remove when necessary to save time
  39. events = $._data( elem, "events" );
  40. if ( events && events.remove ) {
  41. $( elem ).triggerHandler( "remove" );
  42. }
  43. }
  44. orig( elems );
  45. };
  46. } )( $.cleanData );
  47. $.widget = function( name, base, prototype ) {
  48. var existingConstructor, constructor, basePrototype;
  49. // ProxiedPrototype allows the provided prototype to remain unmodified
  50. // so that it can be used as a mixin for multiple widgets (#8876)
  51. var proxiedPrototype = {};
  52. var namespace = name.split( "." )[ 0 ];
  53. name = name.split( "." )[ 1 ];
  54. var fullName = namespace + "-" + name;
  55. if ( !prototype ) {
  56. prototype = base;
  57. base = $.Widget;
  58. }
  59. if ( Array.isArray( prototype ) ) {
  60. prototype = $.extend.apply( null, [ {} ].concat( prototype ) );
  61. }
  62. // Create selector for plugin
  63. $.expr.pseudos[ fullName.toLowerCase() ] = function( elem ) {
  64. return !!$.data( elem, fullName );
  65. };
  66. $[ namespace ] = $[ namespace ] || {};
  67. existingConstructor = $[ namespace ][ name ];
  68. constructor = $[ namespace ][ name ] = function( options, element ) {
  69. // Allow instantiation without "new" keyword
  70. if ( !this._createWidget ) {
  71. return new constructor( options, element );
  72. }
  73. // Allow instantiation without initializing for simple inheritance
  74. // must use "new" keyword (the code above always passes args)
  75. if ( arguments.length ) {
  76. this._createWidget( options, element );
  77. }
  78. };
  79. // Extend with the existing constructor to carry over any static properties
  80. $.extend( constructor, existingConstructor, {
  81. version: prototype.version,
  82. // Copy the object used to create the prototype in case we need to
  83. // redefine the widget later
  84. _proto: $.extend( {}, prototype ),
  85. // Track widgets that inherit from this widget in case this widget is
  86. // redefined after a widget inherits from it
  87. _childConstructors: []
  88. } );
  89. basePrototype = new base();
  90. // We need to make the options hash a property directly on the new instance
  91. // otherwise we'll modify the options hash on the prototype that we're
  92. // inheriting from
  93. basePrototype.options = $.widget.extend( {}, basePrototype.options );
  94. $.each( prototype, function( prop, value ) {
  95. if ( typeof value !== "function" ) {
  96. proxiedPrototype[ prop ] = value;
  97. return;
  98. }
  99. proxiedPrototype[ prop ] = ( function() {
  100. function _super() {
  101. return base.prototype[ prop ].apply( this, arguments );
  102. }
  103. function _superApply( args ) {
  104. return base.prototype[ prop ].apply( this, args );
  105. }
  106. return function() {
  107. var __super = this._super;
  108. var __superApply = this._superApply;
  109. var returnValue;
  110. this._super = _super;
  111. this._superApply = _superApply;
  112. returnValue = value.apply( this, arguments );
  113. this._super = __super;
  114. this._superApply = __superApply;
  115. return returnValue;
  116. };
  117. } )();
  118. } );
  119. constructor.prototype = $.widget.extend( basePrototype, {
  120. // TODO: remove support for widgetEventPrefix
  121. // always use the name + a colon as the prefix, e.g., draggable:start
  122. // don't prefix for widgets that aren't DOM-based
  123. widgetEventPrefix: existingConstructor ? ( basePrototype.widgetEventPrefix || name ) : name
  124. }, proxiedPrototype, {
  125. constructor: constructor,
  126. namespace: namespace,
  127. widgetName: name,
  128. widgetFullName: fullName
  129. } );
  130. // If this widget is being redefined then we need to find all widgets that
  131. // are inheriting from it and redefine all of them so that they inherit from
  132. // the new version of this widget. We're essentially trying to replace one
  133. // level in the prototype chain.
  134. if ( existingConstructor ) {
  135. $.each( existingConstructor._childConstructors, function( i, child ) {
  136. var childPrototype = child.prototype;
  137. // Redefine the child widget using the same prototype that was
  138. // originally used, but inherit from the new version of the base
  139. $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor,
  140. child._proto );
  141. } );
  142. // Remove the list of existing child constructors from the old constructor
  143. // so the old child constructors can be garbage collected
  144. delete existingConstructor._childConstructors;
  145. } else {
  146. base._childConstructors.push( constructor );
  147. }
  148. $.widget.bridge( name, constructor );
  149. return constructor;
  150. };
  151. $.widget.extend = function( target ) {
  152. var input = widgetSlice.call( arguments, 1 );
  153. var inputIndex = 0;
  154. var inputLength = input.length;
  155. var key;
  156. var value;
  157. for ( ; inputIndex < inputLength; inputIndex++ ) {
  158. for ( key in input[ inputIndex ] ) {
  159. value = input[ inputIndex ][ key ];
  160. if ( widgetHasOwnProperty.call( input[ inputIndex ], key ) && value !== undefined ) {
  161. // Clone objects
  162. if ( $.isPlainObject( value ) ) {
  163. target[ key ] = $.isPlainObject( target[ key ] ) ?
  164. $.widget.extend( {}, target[ key ], value ) :
  165. // Don't extend strings, arrays, etc. with objects
  166. $.widget.extend( {}, value );
  167. // Copy everything else by reference
  168. } else {
  169. target[ key ] = value;
  170. }
  171. }
  172. }
  173. }
  174. return target;
  175. };
  176. $.widget.bridge = function( name, object ) {
  177. var fullName = object.prototype.widgetFullName || name;
  178. $.fn[ name ] = function( options ) {
  179. var isMethodCall = typeof options === "string";
  180. var args = widgetSlice.call( arguments, 1 );
  181. var returnValue = this;
  182. if ( isMethodCall ) {
  183. // If this is an empty collection, we need to have the instance method
  184. // return undefined instead of the jQuery instance
  185. if ( !this.length && options === "instance" ) {
  186. returnValue = undefined;
  187. } else {
  188. this.each( function() {
  189. var methodValue;
  190. var instance = $.data( this, fullName );
  191. if ( options === "instance" ) {
  192. returnValue = instance;
  193. return false;
  194. }
  195. if ( !instance ) {
  196. return $.error( "cannot call methods on " + name +
  197. " prior to initialization; " +
  198. "attempted to call method '" + options + "'" );
  199. }
  200. if ( typeof instance[ options ] !== "function" ||
  201. options.charAt( 0 ) === "_" ) {
  202. return $.error( "no such method '" + options + "' for " + name +
  203. " widget instance" );
  204. }
  205. methodValue = instance[ options ].apply( instance, args );
  206. if ( methodValue !== instance && methodValue !== undefined ) {
  207. returnValue = methodValue && methodValue.jquery ?
  208. returnValue.pushStack( methodValue.get() ) :
  209. methodValue;
  210. return false;
  211. }
  212. } );
  213. }
  214. } else {
  215. // Allow multiple hashes to be passed on init
  216. if ( args.length ) {
  217. options = $.widget.extend.apply( null, [ options ].concat( args ) );
  218. }
  219. this.each( function() {
  220. var instance = $.data( this, fullName );
  221. if ( instance ) {
  222. instance.option( options || {} );
  223. if ( instance._init ) {
  224. instance._init();
  225. }
  226. } else {
  227. $.data( this, fullName, new object( options, this ) );
  228. }
  229. } );
  230. }
  231. return returnValue;
  232. };
  233. };
  234. $.Widget = function( /* options, element */ ) {};
  235. $.Widget._childConstructors = [];
  236. $.Widget.prototype = {
  237. widgetName: "widget",
  238. widgetEventPrefix: "",
  239. defaultElement: "<div>",
  240. options: {
  241. classes: {},
  242. disabled: false,
  243. // Callbacks
  244. create: null
  245. },
  246. _createWidget: function( options, element ) {
  247. element = $( element || this.defaultElement || this )[ 0 ];
  248. this.element = $( element );
  249. this.uuid = widgetUuid++;
  250. this.eventNamespace = "." + this.widgetName + this.uuid;
  251. this.bindings = $();
  252. this.hoverable = $();
  253. this.focusable = $();
  254. this.classesElementLookup = {};
  255. if ( element !== this ) {
  256. $.data( element, this.widgetFullName, this );
  257. this._on( true, this.element, {
  258. remove: function( event ) {
  259. if ( event.target === element ) {
  260. this.destroy();
  261. }
  262. }
  263. } );
  264. this.document = $( element.style ?
  265. // Element within the document
  266. element.ownerDocument :
  267. // Element is window or document
  268. element.document || element );
  269. this.window = $( this.document[ 0 ].defaultView || this.document[ 0 ].parentWindow );
  270. }
  271. this.options = $.widget.extend( {},
  272. this.options,
  273. this._getCreateOptions(),
  274. options );
  275. this._create();
  276. if ( this.options.disabled ) {
  277. this._setOptionDisabled( this.options.disabled );
  278. }
  279. this._trigger( "create", null, this._getCreateEventData() );
  280. this._init();
  281. },
  282. _getCreateOptions: function() {
  283. return {};
  284. },
  285. _getCreateEventData: $.noop,
  286. _create: $.noop,
  287. _init: $.noop,
  288. destroy: function() {
  289. var that = this;
  290. this._destroy();
  291. $.each( this.classesElementLookup, function( key, value ) {
  292. that._removeClass( value, key );
  293. } );
  294. // We can probably remove the unbind calls in 2.0
  295. // all event bindings should go through this._on()
  296. this.element
  297. .off( this.eventNamespace )
  298. .removeData( this.widgetFullName );
  299. this.widget()
  300. .off( this.eventNamespace )
  301. .removeAttr( "aria-disabled" );
  302. // Clean up events and states
  303. this.bindings.off( this.eventNamespace );
  304. },
  305. _destroy: $.noop,
  306. widget: function() {
  307. return this.element;
  308. },
  309. option: function( key, value ) {
  310. var options = key;
  311. var parts;
  312. var curOption;
  313. var i;
  314. if ( arguments.length === 0 ) {
  315. // Don't return a reference to the internal hash
  316. return $.widget.extend( {}, this.options );
  317. }
  318. if ( typeof key === "string" ) {
  319. // Handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
  320. options = {};
  321. parts = key.split( "." );
  322. key = parts.shift();
  323. if ( parts.length ) {
  324. curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
  325. for ( i = 0; i < parts.length - 1; i++ ) {
  326. curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
  327. curOption = curOption[ parts[ i ] ];
  328. }
  329. key = parts.pop();
  330. if ( arguments.length === 1 ) {
  331. return curOption[ key ] === undefined ? null : curOption[ key ];
  332. }
  333. curOption[ key ] = value;
  334. } else {
  335. if ( arguments.length === 1 ) {
  336. return this.options[ key ] === undefined ? null : this.options[ key ];
  337. }
  338. options[ key ] = value;
  339. }
  340. }
  341. this._setOptions( options );
  342. return this;
  343. },
  344. _setOptions: function( options ) {
  345. var key;
  346. for ( key in options ) {
  347. this._setOption( key, options[ key ] );
  348. }
  349. return this;
  350. },
  351. _setOption: function( key, value ) {
  352. if ( key === "classes" ) {
  353. this._setOptionClasses( value );
  354. }
  355. this.options[ key ] = value;
  356. if ( key === "disabled" ) {
  357. this._setOptionDisabled( value );
  358. }
  359. return this;
  360. },
  361. _setOptionClasses: function( value ) {
  362. var classKey, elements, currentElements;
  363. for ( classKey in value ) {
  364. currentElements = this.classesElementLookup[ classKey ];
  365. if ( value[ classKey ] === this.options.classes[ classKey ] ||
  366. !currentElements ||
  367. !currentElements.length ) {
  368. continue;
  369. }
  370. // We are doing this to create a new jQuery object because the _removeClass() call
  371. // on the next line is going to destroy the reference to the current elements being
  372. // tracked. We need to save a copy of this collection so that we can add the new classes
  373. // below.
  374. elements = $( currentElements.get() );
  375. this._removeClass( currentElements, classKey );
  376. // We don't use _addClass() here, because that uses this.options.classes
  377. // for generating the string of classes. We want to use the value passed in from
  378. // _setOption(), this is the new value of the classes option which was passed to
  379. // _setOption(). We pass this value directly to _classes().
  380. elements.addClass( this._classes( {
  381. element: elements,
  382. keys: classKey,
  383. classes: value,
  384. add: true
  385. } ) );
  386. }
  387. },
  388. _setOptionDisabled: function( value ) {
  389. this._toggleClass( this.widget(), this.widgetFullName + "-disabled", null, !!value );
  390. // If the widget is becoming disabled, then nothing is interactive
  391. if ( value ) {
  392. this._removeClass( this.hoverable, null, "ui-state-hover" );
  393. this._removeClass( this.focusable, null, "ui-state-focus" );
  394. }
  395. },
  396. enable: function() {
  397. return this._setOptions( { disabled: false } );
  398. },
  399. disable: function() {
  400. return this._setOptions( { disabled: true } );
  401. },
  402. _classes: function( options ) {
  403. var full = [];
  404. var that = this;
  405. options = $.extend( {
  406. element: this.element,
  407. classes: this.options.classes || {}
  408. }, options );
  409. function bindRemoveEvent() {
  410. options.element.each( function( _, element ) {
  411. var isTracked = $.map( that.classesElementLookup, function( elements ) {
  412. return elements;
  413. } )
  414. .some( function( elements ) {
  415. return elements.is( element );
  416. } );
  417. if ( !isTracked ) {
  418. that._on( $( element ), {
  419. remove: "_untrackClassesElement"
  420. } );
  421. }
  422. } );
  423. }
  424. function processClassString( classes, checkOption ) {
  425. var current, i;
  426. for ( i = 0; i < classes.length; i++ ) {
  427. current = that.classesElementLookup[ classes[ i ] ] || $();
  428. if ( options.add ) {
  429. bindRemoveEvent();
  430. current = $( $.uniqueSort( current.get().concat( options.element.get() ) ) );
  431. } else {
  432. current = $( current.not( options.element ).get() );
  433. }
  434. that.classesElementLookup[ classes[ i ] ] = current;
  435. full.push( classes[ i ] );
  436. if ( checkOption && options.classes[ classes[ i ] ] ) {
  437. full.push( options.classes[ classes[ i ] ] );
  438. }
  439. }
  440. }
  441. if ( options.keys ) {
  442. processClassString( options.keys.match( /\S+/g ) || [], true );
  443. }
  444. if ( options.extra ) {
  445. processClassString( options.extra.match( /\S+/g ) || [] );
  446. }
  447. return full.join( " " );
  448. },
  449. _untrackClassesElement: function( event ) {
  450. var that = this;
  451. $.each( that.classesElementLookup, function( key, value ) {
  452. if ( $.inArray( event.target, value ) !== -1 ) {
  453. that.classesElementLookup[ key ] = $( value.not( event.target ).get() );
  454. }
  455. } );
  456. this._off( $( event.target ) );
  457. },
  458. _removeClass: function( element, keys, extra ) {
  459. return this._toggleClass( element, keys, extra, false );
  460. },
  461. _addClass: function( element, keys, extra ) {
  462. return this._toggleClass( element, keys, extra, true );
  463. },
  464. _toggleClass: function( element, keys, extra, add ) {
  465. add = ( typeof add === "boolean" ) ? add : extra;
  466. var shift = ( typeof element === "string" || element === null ),
  467. options = {
  468. extra: shift ? keys : extra,
  469. keys: shift ? element : keys,
  470. element: shift ? this.element : element,
  471. add: add
  472. };
  473. options.element.toggleClass( this._classes( options ), add );
  474. return this;
  475. },
  476. _on: function( suppressDisabledCheck, element, handlers ) {
  477. var delegateElement;
  478. var instance = this;
  479. // No suppressDisabledCheck flag, shuffle arguments
  480. if ( typeof suppressDisabledCheck !== "boolean" ) {
  481. handlers = element;
  482. element = suppressDisabledCheck;
  483. suppressDisabledCheck = false;
  484. }
  485. // No element argument, shuffle and use this.element
  486. if ( !handlers ) {
  487. handlers = element;
  488. element = this.element;
  489. delegateElement = this.widget();
  490. } else {
  491. element = delegateElement = $( element );
  492. this.bindings = this.bindings.add( element );
  493. }
  494. $.each( handlers, function( event, handler ) {
  495. function handlerProxy() {
  496. // Allow widgets to customize the disabled handling
  497. // - disabled as an array instead of boolean
  498. // - disabled class as method for disabling individual parts
  499. if ( !suppressDisabledCheck &&
  500. ( instance.options.disabled === true ||
  501. $( this ).hasClass( "ui-state-disabled" ) ) ) {
  502. return;
  503. }
  504. return ( typeof handler === "string" ? instance[ handler ] : handler )
  505. .apply( instance, arguments );
  506. }
  507. // Copy the guid so direct unbinding works
  508. if ( typeof handler !== "string" ) {
  509. handlerProxy.guid = handler.guid =
  510. handler.guid || handlerProxy.guid || $.guid++;
  511. }
  512. var match = event.match( /^([\w:-]*)\s*(.*)$/ );
  513. var eventName = match[ 1 ] + instance.eventNamespace;
  514. var selector = match[ 2 ];
  515. if ( selector ) {
  516. delegateElement.on( eventName, selector, handlerProxy );
  517. } else {
  518. element.on( eventName, handlerProxy );
  519. }
  520. } );
  521. },
  522. _off: function( element, eventName ) {
  523. eventName = ( eventName || "" ).split( " " ).join( this.eventNamespace + " " ) +
  524. this.eventNamespace;
  525. element.off( eventName );
  526. // Clear the stack to avoid memory leaks (#10056)
  527. this.bindings = $( this.bindings.not( element ).get() );
  528. this.focusable = $( this.focusable.not( element ).get() );
  529. this.hoverable = $( this.hoverable.not( element ).get() );
  530. },
  531. _delay: function( handler, delay ) {
  532. function handlerProxy() {
  533. return ( typeof handler === "string" ? instance[ handler ] : handler )
  534. .apply( instance, arguments );
  535. }
  536. var instance = this;
  537. return setTimeout( handlerProxy, delay || 0 );
  538. },
  539. _hoverable: function( element ) {
  540. this.hoverable = this.hoverable.add( element );
  541. this._on( element, {
  542. mouseenter: function( event ) {
  543. this._addClass( $( event.currentTarget ), null, "ui-state-hover" );
  544. },
  545. mouseleave: function( event ) {
  546. this._removeClass( $( event.currentTarget ), null, "ui-state-hover" );
  547. }
  548. } );
  549. },
  550. _focusable: function( element ) {
  551. this.focusable = this.focusable.add( element );
  552. this._on( element, {
  553. focusin: function( event ) {
  554. this._addClass( $( event.currentTarget ), null, "ui-state-focus" );
  555. },
  556. focusout: function( event ) {
  557. this._removeClass( $( event.currentTarget ), null, "ui-state-focus" );
  558. }
  559. } );
  560. },
  561. _trigger: function( type, event, data ) {
  562. var prop, orig;
  563. var callback = this.options[ type ];
  564. data = data || {};
  565. event = $.Event( event );
  566. event.type = ( type === this.widgetEventPrefix ?
  567. type :
  568. this.widgetEventPrefix + type ).toLowerCase();
  569. // The original event may come from any element
  570. // so we need to reset the target on the new event
  571. event.target = this.element[ 0 ];
  572. // Copy original event properties over to the new event
  573. orig = event.originalEvent;
  574. if ( orig ) {
  575. for ( prop in orig ) {
  576. if ( !( prop in event ) ) {
  577. event[ prop ] = orig[ prop ];
  578. }
  579. }
  580. }
  581. this.element.trigger( event, data );
  582. return !( typeof callback === "function" &&
  583. callback.apply( this.element[ 0 ], [ event ].concat( data ) ) === false ||
  584. event.isDefaultPrevented() );
  585. }
  586. };
  587. $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
  588. $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
  589. if ( typeof options === "string" ) {
  590. options = { effect: options };
  591. }
  592. var hasOptions;
  593. var effectName = !options ?
  594. method :
  595. options === true || typeof options === "number" ?
  596. defaultEffect :
  597. options.effect || defaultEffect;
  598. options = options || {};
  599. if ( typeof options === "number" ) {
  600. options = { duration: options };
  601. } else if ( options === true ) {
  602. options = {};
  603. }
  604. hasOptions = !$.isEmptyObject( options );
  605. options.complete = callback;
  606. if ( options.delay ) {
  607. element.delay( options.delay );
  608. }
  609. if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
  610. element[ method ]( options );
  611. } else if ( effectName !== method && element[ effectName ] ) {
  612. element[ effectName ]( options.duration, options.easing, callback );
  613. } else {
  614. element.queue( function( next ) {
  615. $( this )[ method ]();
  616. if ( callback ) {
  617. callback.call( element[ 0 ] );
  618. }
  619. next();
  620. } );
  621. }
  622. };
  623. } );
  624. var widget = $.widget;
  625. /*!
  626. * jQuery UI Position 1.13.0
  627. * http://jqueryui.com
  628. *
  629. * Copyright jQuery Foundation and other contributors
  630. * Released under the MIT license.
  631. * http://jquery.org/license
  632. *
  633. * http://api.jqueryui.com/position/
  634. */
  635. //>>label: Position
  636. //>>group: Core
  637. //>>description: Positions elements relative to other elements.
  638. //>>docs: http://api.jqueryui.com/position/
  639. //>>demos: http://jqueryui.com/position/
  640. ( function() {
  641. var cachedScrollbarWidth,
  642. max = Math.max,
  643. abs = Math.abs,
  644. rhorizontal = /left|center|right/,
  645. rvertical = /top|center|bottom/,
  646. roffset = /[\+\-]\d+(\.[\d]+)?%?/,
  647. rposition = /^\w+/,
  648. rpercent = /%$/,
  649. _position = $.fn.position;
  650. function getOffsets( offsets, width, height ) {
  651. return [
  652. parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ),
  653. parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
  654. ];
  655. }
  656. function parseCss( element, property ) {
  657. return parseInt( $.css( element, property ), 10 ) || 0;
  658. }
  659. function isWindow( obj ) {
  660. return obj != null && obj === obj.window;
  661. }
  662. function getDimensions( elem ) {
  663. var raw = elem[ 0 ];
  664. if ( raw.nodeType === 9 ) {
  665. return {
  666. width: elem.width(),
  667. height: elem.height(),
  668. offset: { top: 0, left: 0 }
  669. };
  670. }
  671. if ( isWindow( raw ) ) {
  672. return {
  673. width: elem.width(),
  674. height: elem.height(),
  675. offset: { top: elem.scrollTop(), left: elem.scrollLeft() }
  676. };
  677. }
  678. if ( raw.preventDefault ) {
  679. return {
  680. width: 0,
  681. height: 0,
  682. offset: { top: raw.pageY, left: raw.pageX }
  683. };
  684. }
  685. return {
  686. width: elem.outerWidth(),
  687. height: elem.outerHeight(),
  688. offset: elem.offset()
  689. };
  690. }
  691. $.position = {
  692. scrollbarWidth: function() {
  693. if ( cachedScrollbarWidth !== undefined ) {
  694. return cachedScrollbarWidth;
  695. }
  696. var w1, w2,
  697. div = $( "<div style=" +
  698. "'display:block;position:absolute;width:200px;height:200px;overflow:hidden;'>" +
  699. "<div style='height:300px;width:auto;'></div></div>" ),
  700. innerDiv = div.children()[ 0 ];
  701. $( "body" ).append( div );
  702. w1 = innerDiv.offsetWidth;
  703. div.css( "overflow", "scroll" );
  704. w2 = innerDiv.offsetWidth;
  705. if ( w1 === w2 ) {
  706. w2 = div[ 0 ].clientWidth;
  707. }
  708. div.remove();
  709. return ( cachedScrollbarWidth = w1 - w2 );
  710. },
  711. getScrollInfo: function( within ) {
  712. var overflowX = within.isWindow || within.isDocument ? "" :
  713. within.element.css( "overflow-x" ),
  714. overflowY = within.isWindow || within.isDocument ? "" :
  715. within.element.css( "overflow-y" ),
  716. hasOverflowX = overflowX === "scroll" ||
  717. ( overflowX === "auto" && within.width < within.element[ 0 ].scrollWidth ),
  718. hasOverflowY = overflowY === "scroll" ||
  719. ( overflowY === "auto" && within.height < within.element[ 0 ].scrollHeight );
  720. return {
  721. width: hasOverflowY ? $.position.scrollbarWidth() : 0,
  722. height: hasOverflowX ? $.position.scrollbarWidth() : 0
  723. };
  724. },
  725. getWithinInfo: function( element ) {
  726. var withinElement = $( element || window ),
  727. isElemWindow = isWindow( withinElement[ 0 ] ),
  728. isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9,
  729. hasOffset = !isElemWindow && !isDocument;
  730. return {
  731. element: withinElement,
  732. isWindow: isElemWindow,
  733. isDocument: isDocument,
  734. offset: hasOffset ? $( element ).offset() : { left: 0, top: 0 },
  735. scrollLeft: withinElement.scrollLeft(),
  736. scrollTop: withinElement.scrollTop(),
  737. width: withinElement.outerWidth(),
  738. height: withinElement.outerHeight()
  739. };
  740. }
  741. };
  742. $.fn.position = function( options ) {
  743. if ( !options || !options.of ) {
  744. return _position.apply( this, arguments );
  745. }
  746. // Make a copy, we don't want to modify arguments
  747. options = $.extend( {}, options );
  748. var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
  749. // Make sure string options are treated as CSS selectors
  750. target = typeof options.of === "string" ?
  751. $( document ).find( options.of ) :
  752. $( options.of ),
  753. within = $.position.getWithinInfo( options.within ),
  754. scrollInfo = $.position.getScrollInfo( within ),
  755. collision = ( options.collision || "flip" ).split( " " ),
  756. offsets = {};
  757. dimensions = getDimensions( target );
  758. if ( target[ 0 ].preventDefault ) {
  759. // Force left top to allow flipping
  760. options.at = "left top";
  761. }
  762. targetWidth = dimensions.width;
  763. targetHeight = dimensions.height;
  764. targetOffset = dimensions.offset;
  765. // Clone to reuse original targetOffset later
  766. basePosition = $.extend( {}, targetOffset );
  767. // Force my and at to have valid horizontal and vertical positions
  768. // if a value is missing or invalid, it will be converted to center
  769. $.each( [ "my", "at" ], function() {
  770. var pos = ( options[ this ] || "" ).split( " " ),
  771. horizontalOffset,
  772. verticalOffset;
  773. if ( pos.length === 1 ) {
  774. pos = rhorizontal.test( pos[ 0 ] ) ?
  775. pos.concat( [ "center" ] ) :
  776. rvertical.test( pos[ 0 ] ) ?
  777. [ "center" ].concat( pos ) :
  778. [ "center", "center" ];
  779. }
  780. pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center";
  781. pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center";
  782. // Calculate offsets
  783. horizontalOffset = roffset.exec( pos[ 0 ] );
  784. verticalOffset = roffset.exec( pos[ 1 ] );
  785. offsets[ this ] = [
  786. horizontalOffset ? horizontalOffset[ 0 ] : 0,
  787. verticalOffset ? verticalOffset[ 0 ] : 0
  788. ];
  789. // Reduce to just the positions without the offsets
  790. options[ this ] = [
  791. rposition.exec( pos[ 0 ] )[ 0 ],
  792. rposition.exec( pos[ 1 ] )[ 0 ]
  793. ];
  794. } );
  795. // Normalize collision option
  796. if ( collision.length === 1 ) {
  797. collision[ 1 ] = collision[ 0 ];
  798. }
  799. if ( options.at[ 0 ] === "right" ) {
  800. basePosition.left += targetWidth;
  801. } else if ( options.at[ 0 ] === "center" ) {
  802. basePosition.left += targetWidth / 2;
  803. }
  804. if ( options.at[ 1 ] === "bottom" ) {
  805. basePosition.top += targetHeight;
  806. } else if ( options.at[ 1 ] === "center" ) {
  807. basePosition.top += targetHeight / 2;
  808. }
  809. atOffset = getOffsets( offsets.at, targetWidth, targetHeight );
  810. basePosition.left += atOffset[ 0 ];
  811. basePosition.top += atOffset[ 1 ];
  812. return this.each( function() {
  813. var collisionPosition, using,
  814. elem = $( this ),
  815. elemWidth = elem.outerWidth(),
  816. elemHeight = elem.outerHeight(),
  817. marginLeft = parseCss( this, "marginLeft" ),
  818. marginTop = parseCss( this, "marginTop" ),
  819. collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) +
  820. scrollInfo.width,
  821. collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) +
  822. scrollInfo.height,
  823. position = $.extend( {}, basePosition ),
  824. myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() );
  825. if ( options.my[ 0 ] === "right" ) {
  826. position.left -= elemWidth;
  827. } else if ( options.my[ 0 ] === "center" ) {
  828. position.left -= elemWidth / 2;
  829. }
  830. if ( options.my[ 1 ] === "bottom" ) {
  831. position.top -= elemHeight;
  832. } else if ( options.my[ 1 ] === "center" ) {
  833. position.top -= elemHeight / 2;
  834. }
  835. position.left += myOffset[ 0 ];
  836. position.top += myOffset[ 1 ];
  837. collisionPosition = {
  838. marginLeft: marginLeft,
  839. marginTop: marginTop
  840. };
  841. $.each( [ "left", "top" ], function( i, dir ) {
  842. if ( $.ui.position[ collision[ i ] ] ) {
  843. $.ui.position[ collision[ i ] ][ dir ]( position, {
  844. targetWidth: targetWidth,
  845. targetHeight: targetHeight,
  846. elemWidth: elemWidth,
  847. elemHeight: elemHeight,
  848. collisionPosition: collisionPosition,
  849. collisionWidth: collisionWidth,
  850. collisionHeight: collisionHeight,
  851. offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
  852. my: options.my,
  853. at: options.at,
  854. within: within,
  855. elem: elem
  856. } );
  857. }
  858. } );
  859. if ( options.using ) {
  860. // Adds feedback as second argument to using callback, if present
  861. using = function( props ) {
  862. var left = targetOffset.left - position.left,
  863. right = left + targetWidth - elemWidth,
  864. top = targetOffset.top - position.top,
  865. bottom = top + targetHeight - elemHeight,
  866. feedback = {
  867. target: {
  868. element: target,
  869. left: targetOffset.left,
  870. top: targetOffset.top,
  871. width: targetWidth,
  872. height: targetHeight
  873. },
  874. element: {
  875. element: elem,
  876. left: position.left,
  877. top: position.top,
  878. width: elemWidth,
  879. height: elemHeight
  880. },
  881. horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
  882. vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
  883. };
  884. if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
  885. feedback.horizontal = "center";
  886. }
  887. if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
  888. feedback.vertical = "middle";
  889. }
  890. if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
  891. feedback.important = "horizontal";
  892. } else {
  893. feedback.important = "vertical";
  894. }
  895. options.using.call( this, props, feedback );
  896. };
  897. }
  898. elem.offset( $.extend( position, { using: using } ) );
  899. } );
  900. };
  901. $.ui.position = {
  902. fit: {
  903. left: function( position, data ) {
  904. var within = data.within,
  905. withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
  906. outerWidth = within.width,
  907. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  908. overLeft = withinOffset - collisionPosLeft,
  909. overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
  910. newOverRight;
  911. // Element is wider than within
  912. if ( data.collisionWidth > outerWidth ) {
  913. // Element is initially over the left side of within
  914. if ( overLeft > 0 && overRight <= 0 ) {
  915. newOverRight = position.left + overLeft + data.collisionWidth - outerWidth -
  916. withinOffset;
  917. position.left += overLeft - newOverRight;
  918. // Element is initially over right side of within
  919. } else if ( overRight > 0 && overLeft <= 0 ) {
  920. position.left = withinOffset;
  921. // Element is initially over both left and right sides of within
  922. } else {
  923. if ( overLeft > overRight ) {
  924. position.left = withinOffset + outerWidth - data.collisionWidth;
  925. } else {
  926. position.left = withinOffset;
  927. }
  928. }
  929. // Too far left -> align with left edge
  930. } else if ( overLeft > 0 ) {
  931. position.left += overLeft;
  932. // Too far right -> align with right edge
  933. } else if ( overRight > 0 ) {
  934. position.left -= overRight;
  935. // Adjust based on position and margin
  936. } else {
  937. position.left = max( position.left - collisionPosLeft, position.left );
  938. }
  939. },
  940. top: function( position, data ) {
  941. var within = data.within,
  942. withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
  943. outerHeight = data.within.height,
  944. collisionPosTop = position.top - data.collisionPosition.marginTop,
  945. overTop = withinOffset - collisionPosTop,
  946. overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
  947. newOverBottom;
  948. // Element is taller than within
  949. if ( data.collisionHeight > outerHeight ) {
  950. // Element is initially over the top of within
  951. if ( overTop > 0 && overBottom <= 0 ) {
  952. newOverBottom = position.top + overTop + data.collisionHeight - outerHeight -
  953. withinOffset;
  954. position.top += overTop - newOverBottom;
  955. // Element is initially over bottom of within
  956. } else if ( overBottom > 0 && overTop <= 0 ) {
  957. position.top = withinOffset;
  958. // Element is initially over both top and bottom of within
  959. } else {
  960. if ( overTop > overBottom ) {
  961. position.top = withinOffset + outerHeight - data.collisionHeight;
  962. } else {
  963. position.top = withinOffset;
  964. }
  965. }
  966. // Too far up -> align with top
  967. } else if ( overTop > 0 ) {
  968. position.top += overTop;
  969. // Too far down -> align with bottom edge
  970. } else if ( overBottom > 0 ) {
  971. position.top -= overBottom;
  972. // Adjust based on position and margin
  973. } else {
  974. position.top = max( position.top - collisionPosTop, position.top );
  975. }
  976. }
  977. },
  978. flip: {
  979. left: function( position, data ) {
  980. var within = data.within,
  981. withinOffset = within.offset.left + within.scrollLeft,
  982. outerWidth = within.width,
  983. offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
  984. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  985. overLeft = collisionPosLeft - offsetLeft,
  986. overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
  987. myOffset = data.my[ 0 ] === "left" ?
  988. -data.elemWidth :
  989. data.my[ 0 ] === "right" ?
  990. data.elemWidth :
  991. 0,
  992. atOffset = data.at[ 0 ] === "left" ?
  993. data.targetWidth :
  994. data.at[ 0 ] === "right" ?
  995. -data.targetWidth :
  996. 0,
  997. offset = -2 * data.offset[ 0 ],
  998. newOverRight,
  999. newOverLeft;
  1000. if ( overLeft < 0 ) {
  1001. newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth -
  1002. outerWidth - withinOffset;
  1003. if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
  1004. position.left += myOffset + atOffset + offset;
  1005. }
  1006. } else if ( overRight > 0 ) {
  1007. newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset +
  1008. atOffset + offset - offsetLeft;
  1009. if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
  1010. position.left += myOffset + atOffset + offset;
  1011. }
  1012. }
  1013. },
  1014. top: function( position, data ) {
  1015. var within = data.within,
  1016. withinOffset = within.offset.top + within.scrollTop,
  1017. outerHeight = within.height,
  1018. offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
  1019. collisionPosTop = position.top - data.collisionPosition.marginTop,
  1020. overTop = collisionPosTop - offsetTop,
  1021. overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
  1022. top = data.my[ 1 ] === "top",
  1023. myOffset = top ?
  1024. -data.elemHeight :
  1025. data.my[ 1 ] === "bottom" ?
  1026. data.elemHeight :
  1027. 0,
  1028. atOffset = data.at[ 1 ] === "top" ?
  1029. data.targetHeight :
  1030. data.at[ 1 ] === "bottom" ?
  1031. -data.targetHeight :
  1032. 0,
  1033. offset = -2 * data.offset[ 1 ],
  1034. newOverTop,
  1035. newOverBottom;
  1036. if ( overTop < 0 ) {
  1037. newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight -
  1038. outerHeight - withinOffset;
  1039. if ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) {
  1040. position.top += myOffset + atOffset + offset;
  1041. }
  1042. } else if ( overBottom > 0 ) {
  1043. newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset +
  1044. offset - offsetTop;
  1045. if ( newOverTop > 0 || abs( newOverTop ) < overBottom ) {
  1046. position.top += myOffset + atOffset + offset;
  1047. }
  1048. }
  1049. }
  1050. },
  1051. flipfit: {
  1052. left: function() {
  1053. $.ui.position.flip.left.apply( this, arguments );
  1054. $.ui.position.fit.left.apply( this, arguments );
  1055. },
  1056. top: function() {
  1057. $.ui.position.flip.top.apply( this, arguments );
  1058. $.ui.position.fit.top.apply( this, arguments );
  1059. }
  1060. }
  1061. };
  1062. } )();
  1063. var position = $.ui.position;
  1064. /*!
  1065. * jQuery UI :data 1.13.0
  1066. * http://jqueryui.com
  1067. *
  1068. * Copyright jQuery Foundation and other contributors
  1069. * Released under the MIT license.
  1070. * http://jquery.org/license
  1071. */
  1072. //>>label: :data Selector
  1073. //>>group: Core
  1074. //>>description: Selects elements which have data stored under the specified key.
  1075. //>>docs: http://api.jqueryui.com/data-selector/
  1076. var data = $.extend( $.expr.pseudos, {
  1077. data: $.expr.createPseudo ?
  1078. $.expr.createPseudo( function( dataName ) {
  1079. return function( elem ) {
  1080. return !!$.data( elem, dataName );
  1081. };
  1082. } ) :
  1083. // Support: jQuery <1.8
  1084. function( elem, i, match ) {
  1085. return !!$.data( elem, match[ 3 ] );
  1086. }
  1087. } );
  1088. /*!
  1089. * jQuery UI Disable Selection 1.13.0
  1090. * http://jqueryui.com
  1091. *
  1092. * Copyright jQuery Foundation and other contributors
  1093. * Released under the MIT license.
  1094. * http://jquery.org/license
  1095. */
  1096. //>>label: disableSelection
  1097. //>>group: Core
  1098. //>>description: Disable selection of text content within the set of matched elements.
  1099. //>>docs: http://api.jqueryui.com/disableSelection/
  1100. // This file is deprecated
  1101. var disableSelection = $.fn.extend( {
  1102. disableSelection: ( function() {
  1103. var eventType = "onselectstart" in document.createElement( "div" ) ?
  1104. "selectstart" :
  1105. "mousedown";
  1106. return function() {
  1107. return this.on( eventType + ".ui-disableSelection", function( event ) {
  1108. event.preventDefault();
  1109. } );
  1110. };
  1111. } )(),
  1112. enableSelection: function() {
  1113. return this.off( ".ui-disableSelection" );
  1114. }
  1115. } );
  1116. /*!
  1117. * jQuery UI Focusable 1.13.0
  1118. * http://jqueryui.com
  1119. *
  1120. * Copyright jQuery Foundation and other contributors
  1121. * Released under the MIT license.
  1122. * http://jquery.org/license
  1123. */
  1124. //>>label: :focusable Selector
  1125. //>>group: Core
  1126. //>>description: Selects elements which can be focused.
  1127. //>>docs: http://api.jqueryui.com/focusable-selector/
  1128. // Selectors
  1129. $.ui.focusable = function( element, hasTabindex ) {
  1130. var map, mapName, img, focusableIfVisible, fieldset,
  1131. nodeName = element.nodeName.toLowerCase();
  1132. if ( "area" === nodeName ) {
  1133. map = element.parentNode;
  1134. mapName = map.name;
  1135. if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
  1136. return false;
  1137. }
  1138. img = $( "img[usemap='#" + mapName + "']" );
  1139. return img.length > 0 && img.is( ":visible" );
  1140. }
  1141. if ( /^(input|select|textarea|button|object)$/.test( nodeName ) ) {
  1142. focusableIfVisible = !element.disabled;
  1143. if ( focusableIfVisible ) {
  1144. // Form controls within a disabled fieldset are disabled.
  1145. // However, controls within the fieldset's legend do not get disabled.
  1146. // Since controls generally aren't placed inside legends, we skip
  1147. // this portion of the check.
  1148. fieldset = $( element ).closest( "fieldset" )[ 0 ];
  1149. if ( fieldset ) {
  1150. focusableIfVisible = !fieldset.disabled;
  1151. }
  1152. }
  1153. } else if ( "a" === nodeName ) {
  1154. focusableIfVisible = element.href || hasTabindex;
  1155. } else {
  1156. focusableIfVisible = hasTabindex;
  1157. }
  1158. return focusableIfVisible && $( element ).is( ":visible" ) && visible( $( element ) );
  1159. };
  1160. // Support: IE 8 only
  1161. // IE 8 doesn't resolve inherit to visible/hidden for computed values
  1162. function visible( element ) {
  1163. var visibility = element.css( "visibility" );
  1164. while ( visibility === "inherit" ) {
  1165. element = element.parent();
  1166. visibility = element.css( "visibility" );
  1167. }
  1168. return visibility === "visible";
  1169. }
  1170. $.extend( $.expr.pseudos, {
  1171. focusable: function( element ) {
  1172. return $.ui.focusable( element, $.attr( element, "tabindex" ) != null );
  1173. }
  1174. } );
  1175. var focusable = $.ui.focusable;
  1176. // Support: IE8 Only
  1177. // IE8 does not support the form attribute and when it is supplied. It overwrites the form prop
  1178. // with a string, so we need to find the proper form.
  1179. var form = $.fn._form = function() {
  1180. return typeof this[ 0 ].form === "string" ? this.closest( "form" ) : $( this[ 0 ].form );
  1181. };
  1182. /*!
  1183. * jQuery UI Form Reset Mixin 1.13.0
  1184. * http://jqueryui.com
  1185. *
  1186. * Copyright jQuery Foundation and other contributors
  1187. * Released under the MIT license.
  1188. * http://jquery.org/license
  1189. */
  1190. //>>label: Form Reset Mixin
  1191. //>>group: Core
  1192. //>>description: Refresh input widgets when their form is reset
  1193. //>>docs: http://api.jqueryui.com/form-reset-mixin/
  1194. var formResetMixin = $.ui.formResetMixin = {
  1195. _formResetHandler: function() {
  1196. var form = $( this );
  1197. // Wait for the form reset to actually happen before refreshing
  1198. setTimeout( function() {
  1199. var instances = form.data( "ui-form-reset-instances" );
  1200. $.each( instances, function() {
  1201. this.refresh();
  1202. } );
  1203. } );
  1204. },
  1205. _bindFormResetHandler: function() {
  1206. this.form = this.element._form();
  1207. if ( !this.form.length ) {
  1208. return;
  1209. }
  1210. var instances = this.form.data( "ui-form-reset-instances" ) || [];
  1211. if ( !instances.length ) {
  1212. // We don't use _on() here because we use a single event handler per form
  1213. this.form.on( "reset.ui-form-reset", this._formResetHandler );
  1214. }
  1215. instances.push( this );
  1216. this.form.data( "ui-form-reset-instances", instances );
  1217. },
  1218. _unbindFormResetHandler: function() {
  1219. if ( !this.form.length ) {
  1220. return;
  1221. }
  1222. var instances = this.form.data( "ui-form-reset-instances" );
  1223. instances.splice( $.inArray( this, instances ), 1 );
  1224. if ( instances.length ) {
  1225. this.form.data( "ui-form-reset-instances", instances );
  1226. } else {
  1227. this.form
  1228. .removeData( "ui-form-reset-instances" )
  1229. .off( "reset.ui-form-reset" );
  1230. }
  1231. }
  1232. };
  1233. /*!
  1234. * jQuery UI Support for jQuery core 1.8.x and newer 1.13.0
  1235. * http://jqueryui.com
  1236. *
  1237. * Copyright jQuery Foundation and other contributors
  1238. * Released under the MIT license.
  1239. * http://jquery.org/license
  1240. *
  1241. */
  1242. //>>label: jQuery 1.8+ Support
  1243. //>>group: Core
  1244. //>>description: Support version 1.8.x and newer of jQuery core
  1245. // Support: jQuery 1.9.x or older
  1246. // $.expr[ ":" ] is deprecated.
  1247. if ( !$.expr.pseudos ) {
  1248. $.expr.pseudos = $.expr[ ":" ];
  1249. }
  1250. // Support: jQuery 1.11.x or older
  1251. // $.unique has been renamed to $.uniqueSort
  1252. if ( !$.uniqueSort ) {
  1253. $.uniqueSort = $.unique;
  1254. }
  1255. // Support: jQuery 2.2.x or older.
  1256. // This method has been defined in jQuery 3.0.0.
  1257. // Code from https://github.com/jquery/jquery/blob/e539bac79e666bba95bba86d690b4e609dca2286/src/selector/escapeSelector.js
  1258. if ( !$.escapeSelector ) {
  1259. // CSS string/identifier serialization
  1260. // https://drafts.csswg.org/cssom/#common-serializing-idioms
  1261. var rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\x80-\uFFFF\w-]/g;
  1262. var fcssescape = function( ch, asCodePoint ) {
  1263. if ( asCodePoint ) {
  1264. // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
  1265. if ( ch === "\0" ) {
  1266. return "\uFFFD";
  1267. }
  1268. // Control characters and (dependent upon position) numbers get escaped as code points
  1269. return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " ";
  1270. }
  1271. // Other potentially-special ASCII characters get backslash-escaped
  1272. return "\\" + ch;
  1273. };
  1274. $.escapeSelector = function( sel ) {
  1275. return ( sel + "" ).replace( rcssescape, fcssescape );
  1276. };
  1277. }
  1278. // Support: jQuery 3.4.x or older
  1279. // These methods have been defined in jQuery 3.5.0.
  1280. if ( !$.fn.even || !$.fn.odd ) {
  1281. $.fn.extend( {
  1282. even: function() {
  1283. return this.filter( function( i ) {
  1284. return i % 2 === 0;
  1285. } );
  1286. },
  1287. odd: function() {
  1288. return this.filter( function( i ) {
  1289. return i % 2 === 1;
  1290. } );
  1291. }
  1292. } );
  1293. }
  1294. ;
  1295. /*!
  1296. * jQuery UI Keycode 1.13.0
  1297. * http://jqueryui.com
  1298. *
  1299. * Copyright jQuery Foundation and other contributors
  1300. * Released under the MIT license.
  1301. * http://jquery.org/license
  1302. */
  1303. //>>label: Keycode
  1304. //>>group: Core
  1305. //>>description: Provide keycodes as keynames
  1306. //>>docs: http://api.jqueryui.com/jQuery.ui.keyCode/
  1307. var keycode = $.ui.keyCode = {
  1308. BACKSPACE: 8,
  1309. COMMA: 188,
  1310. DELETE: 46,
  1311. DOWN: 40,
  1312. END: 35,
  1313. ENTER: 13,
  1314. ESCAPE: 27,
  1315. HOME: 36,
  1316. LEFT: 37,
  1317. PAGE_DOWN: 34,
  1318. PAGE_UP: 33,
  1319. PERIOD: 190,
  1320. RIGHT: 39,
  1321. SPACE: 32,
  1322. TAB: 9,
  1323. UP: 38
  1324. };
  1325. /*!
  1326. * jQuery UI Labels 1.13.0
  1327. * http://jqueryui.com
  1328. *
  1329. * Copyright jQuery Foundation and other contributors
  1330. * Released under the MIT license.
  1331. * http://jquery.org/license
  1332. */
  1333. //>>label: labels
  1334. //>>group: Core
  1335. //>>description: Find all the labels associated with a given input
  1336. //>>docs: http://api.jqueryui.com/labels/
  1337. var labels = $.fn.labels = function() {
  1338. var ancestor, selector, id, labels, ancestors;
  1339. if ( !this.length ) {
  1340. return this.pushStack( [] );
  1341. }
  1342. // Check control.labels first
  1343. if ( this[ 0 ].labels && this[ 0 ].labels.length ) {
  1344. return this.pushStack( this[ 0 ].labels );
  1345. }
  1346. // Support: IE <= 11, FF <= 37, Android <= 2.3 only
  1347. // Above browsers do not support control.labels. Everything below is to support them
  1348. // as well as document fragments. control.labels does not work on document fragments
  1349. labels = this.eq( 0 ).parents( "label" );
  1350. // Look for the label based on the id
  1351. id = this.attr( "id" );
  1352. if ( id ) {
  1353. // We don't search against the document in case the element
  1354. // is disconnected from the DOM
  1355. ancestor = this.eq( 0 ).parents().last();
  1356. // Get a full set of top level ancestors
  1357. ancestors = ancestor.add( ancestor.length ? ancestor.siblings() : this.siblings() );
  1358. // Create a selector for the label based on the id
  1359. selector = "label[for='" + $.escapeSelector( id ) + "']";
  1360. labels = labels.add( ancestors.find( selector ).addBack( selector ) );
  1361. }
  1362. // Return whatever we have found for labels
  1363. return this.pushStack( labels );
  1364. };
  1365. /*!
  1366. * jQuery UI Scroll Parent 1.13.0
  1367. * http://jqueryui.com
  1368. *
  1369. * Copyright jQuery Foundation and other contributors
  1370. * Released under the MIT license.
  1371. * http://jquery.org/license
  1372. */
  1373. //>>label: scrollParent
  1374. //>>group: Core
  1375. //>>description: Get the closest ancestor element that is scrollable.
  1376. //>>docs: http://api.jqueryui.com/scrollParent/
  1377. var scrollParent = $.fn.scrollParent = function( includeHidden ) {
  1378. var position = this.css( "position" ),
  1379. excludeStaticParent = position === "absolute",
  1380. overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/,
  1381. scrollParent = this.parents().filter( function() {
  1382. var parent = $( this );
  1383. if ( excludeStaticParent && parent.css( "position" ) === "static" ) {
  1384. return false;
  1385. }
  1386. return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) +
  1387. parent.css( "overflow-x" ) );
  1388. } ).eq( 0 );
  1389. return position === "fixed" || !scrollParent.length ?
  1390. $( this[ 0 ].ownerDocument || document ) :
  1391. scrollParent;
  1392. };
  1393. /*!
  1394. * jQuery UI Tabbable 1.13.0
  1395. * http://jqueryui.com
  1396. *
  1397. * Copyright jQuery Foundation and other contributors
  1398. * Released under the MIT license.
  1399. * http://jquery.org/license
  1400. */
  1401. //>>label: :tabbable Selector
  1402. //>>group: Core
  1403. //>>description: Selects elements which can be tabbed to.
  1404. //>>docs: http://api.jqueryui.com/tabbable-selector/
  1405. var tabbable = $.extend( $.expr.pseudos, {
  1406. tabbable: function( element ) {
  1407. var tabIndex = $.attr( element, "tabindex" ),
  1408. hasTabindex = tabIndex != null;
  1409. return ( !hasTabindex || tabIndex >= 0 ) && $.ui.focusable( element, hasTabindex );
  1410. }
  1411. } );
  1412. /*!
  1413. * jQuery UI Unique ID 1.13.0
  1414. * http://jqueryui.com
  1415. *
  1416. * Copyright jQuery Foundation and other contributors
  1417. * Released under the MIT license.
  1418. * http://jquery.org/license
  1419. */
  1420. //>>label: uniqueId
  1421. //>>group: Core
  1422. //>>description: Functions to generate and remove uniqueId's
  1423. //>>docs: http://api.jqueryui.com/uniqueId/
  1424. var uniqueId = $.fn.extend( {
  1425. uniqueId: ( function() {
  1426. var uuid = 0;
  1427. return function() {
  1428. return this.each( function() {
  1429. if ( !this.id ) {
  1430. this.id = "ui-id-" + ( ++uuid );
  1431. }
  1432. } );
  1433. };
  1434. } )(),
  1435. removeUniqueId: function() {
  1436. return this.each( function() {
  1437. if ( /^ui-id-\d+$/.test( this.id ) ) {
  1438. $( this ).removeAttr( "id" );
  1439. }
  1440. } );
  1441. }
  1442. } );
  1443. // This file is deprecated
  1444. var ie = $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
  1445. /*!
  1446. * jQuery UI Mouse 1.13.0
  1447. * http://jqueryui.com
  1448. *
  1449. * Copyright jQuery Foundation and other contributors
  1450. * Released under the MIT license.
  1451. * http://jquery.org/license
  1452. */
  1453. //>>label: Mouse
  1454. //>>group: Widgets
  1455. //>>description: Abstracts mouse-based interactions to assist in creating certain widgets.
  1456. //>>docs: http://api.jqueryui.com/mouse/
  1457. var mouseHandled = false;
  1458. $( document ).on( "mouseup", function() {
  1459. mouseHandled = false;
  1460. } );
  1461. var widgetsMouse = $.widget( "ui.mouse", {
  1462. version: "1.13.0",
  1463. options: {
  1464. cancel: "input, textarea, button, select, option",
  1465. distance: 1,
  1466. delay: 0
  1467. },
  1468. _mouseInit: function() {
  1469. var that = this;
  1470. this.element
  1471. .on( "mousedown." + this.widgetName, function( event ) {
  1472. return that._mouseDown( event );
  1473. } )
  1474. .on( "click." + this.widgetName, function( event ) {
  1475. if ( true === $.data( event.target, that.widgetName + ".preventClickEvent" ) ) {
  1476. $.removeData( event.target, that.widgetName + ".preventClickEvent" );
  1477. event.stopImmediatePropagation();
  1478. return false;
  1479. }
  1480. } );
  1481. this.started = false;
  1482. },
  1483. // TODO: make sure destroying one instance of mouse doesn't mess with
  1484. // other instances of mouse
  1485. _mouseDestroy: function() {
  1486. this.element.off( "." + this.widgetName );
  1487. if ( this._mouseMoveDelegate ) {
  1488. this.document
  1489. .off( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  1490. .off( "mouseup." + this.widgetName, this._mouseUpDelegate );
  1491. }
  1492. },
  1493. _mouseDown: function( event ) {
  1494. // don't let more than one widget handle mouseStart
  1495. if ( mouseHandled ) {
  1496. return;
  1497. }
  1498. this._mouseMoved = false;
  1499. // We may have missed mouseup (out of window)
  1500. if ( this._mouseStarted ) {
  1501. this._mouseUp( event );
  1502. }
  1503. this._mouseDownEvent = event;
  1504. var that = this,
  1505. btnIsLeft = ( event.which === 1 ),
  1506. // event.target.nodeName works around a bug in IE 8 with
  1507. // disabled inputs (#7620)
  1508. elIsCancel = ( typeof this.options.cancel === "string" && event.target.nodeName ?
  1509. $( event.target ).closest( this.options.cancel ).length : false );
  1510. if ( !btnIsLeft || elIsCancel || !this._mouseCapture( event ) ) {
  1511. return true;
  1512. }
  1513. this.mouseDelayMet = !this.options.delay;
  1514. if ( !this.mouseDelayMet ) {
  1515. this._mouseDelayTimer = setTimeout( function() {
  1516. that.mouseDelayMet = true;
  1517. }, this.options.delay );
  1518. }
  1519. if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) {
  1520. this._mouseStarted = ( this._mouseStart( event ) !== false );
  1521. if ( !this._mouseStarted ) {
  1522. event.preventDefault();
  1523. return true;
  1524. }
  1525. }
  1526. // Click event may never have fired (Gecko & Opera)
  1527. if ( true === $.data( event.target, this.widgetName + ".preventClickEvent" ) ) {
  1528. $.removeData( event.target, this.widgetName + ".preventClickEvent" );
  1529. }
  1530. // These delegates are required to keep context
  1531. this._mouseMoveDelegate = function( event ) {
  1532. return that._mouseMove( event );
  1533. };
  1534. this._mouseUpDelegate = function( event ) {
  1535. return that._mouseUp( event );
  1536. };
  1537. this.document
  1538. .on( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  1539. .on( "mouseup." + this.widgetName, this._mouseUpDelegate );
  1540. event.preventDefault();
  1541. mouseHandled = true;
  1542. return true;
  1543. },
  1544. _mouseMove: function( event ) {
  1545. // Only check for mouseups outside the document if you've moved inside the document
  1546. // at least once. This prevents the firing of mouseup in the case of IE<9, which will
  1547. // fire a mousemove event if content is placed under the cursor. See #7778
  1548. // Support: IE <9
  1549. if ( this._mouseMoved ) {
  1550. // IE mouseup check - mouseup happened when mouse was out of window
  1551. if ( $.ui.ie && ( !document.documentMode || document.documentMode < 9 ) &&
  1552. !event.button ) {
  1553. return this._mouseUp( event );
  1554. // Iframe mouseup check - mouseup occurred in another document
  1555. } else if ( !event.which ) {
  1556. // Support: Safari <=8 - 9
  1557. // Safari sets which to 0 if you press any of the following keys
  1558. // during a drag (#14461)
  1559. if ( event.originalEvent.altKey || event.originalEvent.ctrlKey ||
  1560. event.originalEvent.metaKey || event.originalEvent.shiftKey ) {
  1561. this.ignoreMissingWhich = true;
  1562. } else if ( !this.ignoreMissingWhich ) {
  1563. return this._mouseUp( event );
  1564. }
  1565. }
  1566. }
  1567. if ( event.which || event.button ) {
  1568. this._mouseMoved = true;
  1569. }
  1570. if ( this._mouseStarted ) {
  1571. this._mouseDrag( event );
  1572. return event.preventDefault();
  1573. }
  1574. if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) {
  1575. this._mouseStarted =
  1576. ( this._mouseStart( this._mouseDownEvent, event ) !== false );
  1577. if ( this._mouseStarted ) {
  1578. this._mouseDrag( event );
  1579. } else {
  1580. this._mouseUp( event );
  1581. }
  1582. }
  1583. return !this._mouseStarted;
  1584. },
  1585. _mouseUp: function( event ) {
  1586. this.document
  1587. .off( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  1588. .off( "mouseup." + this.widgetName, this._mouseUpDelegate );
  1589. if ( this._mouseStarted ) {
  1590. this._mouseStarted = false;
  1591. if ( event.target === this._mouseDownEvent.target ) {
  1592. $.data( event.target, this.widgetName + ".preventClickEvent", true );
  1593. }
  1594. this._mouseStop( event );
  1595. }
  1596. if ( this._mouseDelayTimer ) {
  1597. clearTimeout( this._mouseDelayTimer );
  1598. delete this._mouseDelayTimer;
  1599. }
  1600. this.ignoreMissingWhich = false;
  1601. mouseHandled = false;
  1602. event.preventDefault();
  1603. },
  1604. _mouseDistanceMet: function( event ) {
  1605. return ( Math.max(
  1606. Math.abs( this._mouseDownEvent.pageX - event.pageX ),
  1607. Math.abs( this._mouseDownEvent.pageY - event.pageY )
  1608. ) >= this.options.distance
  1609. );
  1610. },
  1611. _mouseDelayMet: function( /* event */ ) {
  1612. return this.mouseDelayMet;
  1613. },
  1614. // These are placeholder methods, to be overriden by extending plugin
  1615. _mouseStart: function( /* event */ ) {},
  1616. _mouseDrag: function( /* event */ ) {},
  1617. _mouseStop: function( /* event */ ) {},
  1618. _mouseCapture: function( /* event */ ) {
  1619. return true;
  1620. }
  1621. } );
  1622. // $.ui.plugin is deprecated. Use $.widget() extensions instead.
  1623. var plugin = $.ui.plugin = {
  1624. add: function( module, option, set ) {
  1625. var i,
  1626. proto = $.ui[ module ].prototype;
  1627. for ( i in set ) {
  1628. proto.plugins[ i ] = proto.plugins[ i ] || [];
  1629. proto.plugins[ i ].push( [ option, set[ i ] ] );
  1630. }
  1631. },
  1632. call: function( instance, name, args, allowDisconnected ) {
  1633. var i,
  1634. set = instance.plugins[ name ];
  1635. if ( !set ) {
  1636. return;
  1637. }
  1638. if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode ||
  1639. instance.element[ 0 ].parentNode.nodeType === 11 ) ) {
  1640. return;
  1641. }
  1642. for ( i = 0; i < set.length; i++ ) {
  1643. if ( instance.options[ set[ i ][ 0 ] ] ) {
  1644. set[ i ][ 1 ].apply( instance.element, args );
  1645. }
  1646. }
  1647. }
  1648. };
  1649. var safeActiveElement = $.ui.safeActiveElement = function( document ) {
  1650. var activeElement;
  1651. // Support: IE 9 only
  1652. // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
  1653. try {
  1654. activeElement = document.activeElement;
  1655. } catch ( error ) {
  1656. activeElement = document.body;
  1657. }
  1658. // Support: IE 9 - 11 only
  1659. // IE may return null instead of an element
  1660. // Interestingly, this only seems to occur when NOT in an iframe
  1661. if ( !activeElement ) {
  1662. activeElement = document.body;
  1663. }
  1664. // Support: IE 11 only
  1665. // IE11 returns a seemingly empty object in some cases when accessing
  1666. // document.activeElement from an <iframe>
  1667. if ( !activeElement.nodeName ) {
  1668. activeElement = document.body;
  1669. }
  1670. return activeElement;
  1671. };
  1672. var safeBlur = $.ui.safeBlur = function( element ) {
  1673. // Support: IE9 - 10 only
  1674. // If the <body> is blurred, IE will switch windows, see #9420
  1675. if ( element && element.nodeName.toLowerCase() !== "body" ) {
  1676. $( element ).trigger( "blur" );
  1677. }
  1678. };
  1679. /*!
  1680. * jQuery UI Draggable 1.13.0
  1681. * http://jqueryui.com
  1682. *
  1683. * Copyright jQuery Foundation and other contributors
  1684. * Released under the MIT license.
  1685. * http://jquery.org/license
  1686. */
  1687. //>>label: Draggable
  1688. //>>group: Interactions
  1689. //>>description: Enables dragging functionality for any element.
  1690. //>>docs: http://api.jqueryui.com/draggable/
  1691. //>>demos: http://jqueryui.com/draggable/
  1692. //>>css.structure: ../../themes/base/draggable.css
  1693. $.widget( "ui.draggable", $.ui.mouse, {
  1694. version: "1.13.0",
  1695. widgetEventPrefix: "drag",
  1696. options: {
  1697. addClasses: true,
  1698. appendTo: "parent",
  1699. axis: false,
  1700. connectToSortable: false,
  1701. containment: false,
  1702. cursor: "auto",
  1703. cursorAt: false,
  1704. grid: false,
  1705. handle: false,
  1706. helper: "original",
  1707. iframeFix: false,
  1708. opacity: false,
  1709. refreshPositions: false,
  1710. revert: false,
  1711. revertDuration: 500,
  1712. scope: "default",
  1713. scroll: true,
  1714. scrollSensitivity: 20,
  1715. scrollSpeed: 20,
  1716. snap: false,
  1717. snapMode: "both",
  1718. snapTolerance: 20,
  1719. stack: false,
  1720. zIndex: false,
  1721. // Callbacks
  1722. drag: null,
  1723. start: null,
  1724. stop: null
  1725. },
  1726. _create: function() {
  1727. if ( this.options.helper === "original" ) {
  1728. this._setPositionRelative();
  1729. }
  1730. if ( this.options.addClasses ) {
  1731. this._addClass( "ui-draggable" );
  1732. }
  1733. this._setHandleClassName();
  1734. this._mouseInit();
  1735. },
  1736. _setOption: function( key, value ) {
  1737. this._super( key, value );
  1738. if ( key === "handle" ) {
  1739. this._removeHandleClassName();
  1740. this._setHandleClassName();
  1741. }
  1742. },
  1743. _destroy: function() {
  1744. if ( ( this.helper || this.element ).is( ".ui-draggable-dragging" ) ) {
  1745. this.destroyOnClear = true;
  1746. return;
  1747. }
  1748. this._removeHandleClassName();
  1749. this._mouseDestroy();
  1750. },
  1751. _mouseCapture: function( event ) {
  1752. var o = this.options;
  1753. // Among others, prevent a drag on a resizable-handle
  1754. if ( this.helper || o.disabled ||
  1755. $( event.target ).closest( ".ui-resizable-handle" ).length > 0 ) {
  1756. return false;
  1757. }
  1758. //Quit if we're not on a valid handle
  1759. this.handle = this._getHandle( event );
  1760. if ( !this.handle ) {
  1761. return false;
  1762. }
  1763. this._blurActiveElement( event );
  1764. this._blockFrames( o.iframeFix === true ? "iframe" : o.iframeFix );
  1765. return true;
  1766. },
  1767. _blockFrames: function( selector ) {
  1768. this.iframeBlocks = this.document.find( selector ).map( function() {
  1769. var iframe = $( this );
  1770. return $( "<div>" )
  1771. .css( "position", "absolute" )
  1772. .appendTo( iframe.parent() )
  1773. .outerWidth( iframe.outerWidth() )
  1774. .outerHeight( iframe.outerHeight() )
  1775. .offset( iframe.offset() )[ 0 ];
  1776. } );
  1777. },
  1778. _unblockFrames: function() {
  1779. if ( this.iframeBlocks ) {
  1780. this.iframeBlocks.remove();
  1781. delete this.iframeBlocks;
  1782. }
  1783. },
  1784. _blurActiveElement: function( event ) {
  1785. var activeElement = $.ui.safeActiveElement( this.document[ 0 ] ),
  1786. target = $( event.target );
  1787. // Don't blur if the event occurred on an element that is within
  1788. // the currently focused element
  1789. // See #10527, #12472
  1790. if ( target.closest( activeElement ).length ) {
  1791. return;
  1792. }
  1793. // Blur any element that currently has focus, see #4261
  1794. $.ui.safeBlur( activeElement );
  1795. },
  1796. _mouseStart: function( event ) {
  1797. var o = this.options;
  1798. //Create and append the visible helper
  1799. this.helper = this._createHelper( event );
  1800. this._addClass( this.helper, "ui-draggable-dragging" );
  1801. //Cache the helper size
  1802. this._cacheHelperProportions();
  1803. //If ddmanager is used for droppables, set the global draggable
  1804. if ( $.ui.ddmanager ) {
  1805. $.ui.ddmanager.current = this;
  1806. }
  1807. /*
  1808. * - Position generation -
  1809. * This block generates everything position related - it's the core of draggables.
  1810. */
  1811. //Cache the margins of the original element
  1812. this._cacheMargins();
  1813. //Store the helper's css position
  1814. this.cssPosition = this.helper.css( "position" );
  1815. this.scrollParent = this.helper.scrollParent( true );
  1816. this.offsetParent = this.helper.offsetParent();
  1817. this.hasFixedAncestor = this.helper.parents().filter( function() {
  1818. return $( this ).css( "position" ) === "fixed";
  1819. } ).length > 0;
  1820. //The element's absolute position on the page minus margins
  1821. this.positionAbs = this.element.offset();
  1822. this._refreshOffsets( event );
  1823. //Generate the original position
  1824. this.originalPosition = this.position = this._generatePosition( event, false );
  1825. this.originalPageX = event.pageX;
  1826. this.originalPageY = event.pageY;
  1827. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  1828. if ( o.cursorAt ) {
  1829. this._adjustOffsetFromHelper( o.cursorAt );
  1830. }
  1831. //Set a containment if given in the options
  1832. this._setContainment();
  1833. //Trigger event + callbacks
  1834. if ( this._trigger( "start", event ) === false ) {
  1835. this._clear();
  1836. return false;
  1837. }
  1838. //Recache the helper size
  1839. this._cacheHelperProportions();
  1840. //Prepare the droppable offsets
  1841. if ( $.ui.ddmanager && !o.dropBehaviour ) {
  1842. $.ui.ddmanager.prepareOffsets( this, event );
  1843. }
  1844. // Execute the drag once - this causes the helper not to be visible before getting its
  1845. // correct position
  1846. this._mouseDrag( event, true );
  1847. // If the ddmanager is used for droppables, inform the manager that dragging has started
  1848. // (see #5003)
  1849. if ( $.ui.ddmanager ) {
  1850. $.ui.ddmanager.dragStart( this, event );
  1851. }
  1852. return true;
  1853. },
  1854. _refreshOffsets: function( event ) {
  1855. this.offset = {
  1856. top: this.positionAbs.top - this.margins.top,
  1857. left: this.positionAbs.left - this.margins.left,
  1858. scroll: false,
  1859. parent: this._getParentOffset(),
  1860. relative: this._getRelativeOffset()
  1861. };
  1862. this.offset.click = {
  1863. left: event.pageX - this.offset.left,
  1864. top: event.pageY - this.offset.top
  1865. };
  1866. },
  1867. _mouseDrag: function( event, noPropagation ) {
  1868. // reset any necessary cached properties (see #5009)
  1869. if ( this.hasFixedAncestor ) {
  1870. this.offset.parent = this._getParentOffset();
  1871. }
  1872. //Compute the helpers position
  1873. this.position = this._generatePosition( event, true );
  1874. this.positionAbs = this._convertPositionTo( "absolute" );
  1875. //Call plugins and callbacks and use the resulting position if something is returned
  1876. if ( !noPropagation ) {
  1877. var ui = this._uiHash();
  1878. if ( this._trigger( "drag", event, ui ) === false ) {
  1879. this._mouseUp( new $.Event( "mouseup", event ) );
  1880. return false;
  1881. }
  1882. this.position = ui.position;
  1883. }
  1884. this.helper[ 0 ].style.left = this.position.left + "px";
  1885. this.helper[ 0 ].style.top = this.position.top + "px";
  1886. if ( $.ui.ddmanager ) {
  1887. $.ui.ddmanager.drag( this, event );
  1888. }
  1889. return false;
  1890. },
  1891. _mouseStop: function( event ) {
  1892. //If we are using droppables, inform the manager about the drop
  1893. var that = this,
  1894. dropped = false;
  1895. if ( $.ui.ddmanager && !this.options.dropBehaviour ) {
  1896. dropped = $.ui.ddmanager.drop( this, event );
  1897. }
  1898. //if a drop comes from outside (a sortable)
  1899. if ( this.dropped ) {
  1900. dropped = this.dropped;
  1901. this.dropped = false;
  1902. }
  1903. if ( ( this.options.revert === "invalid" && !dropped ) ||
  1904. ( this.options.revert === "valid" && dropped ) ||
  1905. this.options.revert === true || ( typeof this.options.revert === "function" &&
  1906. this.options.revert.call( this.element, dropped ) )
  1907. ) {
  1908. $( this.helper ).animate(
  1909. this.originalPosition,
  1910. parseInt( this.options.revertDuration, 10 ),
  1911. function() {
  1912. if ( that._trigger( "stop", event ) !== false ) {
  1913. that._clear();
  1914. }
  1915. }
  1916. );
  1917. } else {
  1918. if ( this._trigger( "stop", event ) !== false ) {
  1919. this._clear();
  1920. }
  1921. }
  1922. return false;
  1923. },
  1924. _mouseUp: function( event ) {
  1925. this._unblockFrames();
  1926. // If the ddmanager is used for droppables, inform the manager that dragging has stopped
  1927. // (see #5003)
  1928. if ( $.ui.ddmanager ) {
  1929. $.ui.ddmanager.dragStop( this, event );
  1930. }
  1931. // Only need to focus if the event occurred on the draggable itself, see #10527
  1932. if ( this.handleElement.is( event.target ) ) {
  1933. // The interaction is over; whether or not the click resulted in a drag,
  1934. // focus the element
  1935. this.element.trigger( "focus" );
  1936. }
  1937. return $.ui.mouse.prototype._mouseUp.call( this, event );
  1938. },
  1939. cancel: function() {
  1940. if ( this.helper.is( ".ui-draggable-dragging" ) ) {
  1941. this._mouseUp( new $.Event( "mouseup", { target: this.element[ 0 ] } ) );
  1942. } else {
  1943. this._clear();
  1944. }
  1945. return this;
  1946. },
  1947. _getHandle: function( event ) {
  1948. return this.options.handle ?
  1949. !!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
  1950. true;
  1951. },
  1952. _setHandleClassName: function() {
  1953. this.handleElement = this.options.handle ?
  1954. this.element.find( this.options.handle ) : this.element;
  1955. this._addClass( this.handleElement, "ui-draggable-handle" );
  1956. },
  1957. _removeHandleClassName: function() {
  1958. this._removeClass( this.handleElement, "ui-draggable-handle" );
  1959. },
  1960. _createHelper: function( event ) {
  1961. var o = this.options,
  1962. helperIsFunction = typeof o.helper === "function",
  1963. helper = helperIsFunction ?
  1964. $( o.helper.apply( this.element[ 0 ], [ event ] ) ) :
  1965. ( o.helper === "clone" ?
  1966. this.element.clone().removeAttr( "id" ) :
  1967. this.element );
  1968. if ( !helper.parents( "body" ).length ) {
  1969. helper.appendTo( ( o.appendTo === "parent" ?
  1970. this.element[ 0 ].parentNode :
  1971. o.appendTo ) );
  1972. }
  1973. // Http://bugs.jqueryui.com/ticket/9446
  1974. // a helper function can return the original element
  1975. // which wouldn't have been set to relative in _create
  1976. if ( helperIsFunction && helper[ 0 ] === this.element[ 0 ] ) {
  1977. this._setPositionRelative();
  1978. }
  1979. if ( helper[ 0 ] !== this.element[ 0 ] &&
  1980. !( /(fixed|absolute)/ ).test( helper.css( "position" ) ) ) {
  1981. helper.css( "position", "absolute" );
  1982. }
  1983. return helper;
  1984. },
  1985. _setPositionRelative: function() {
  1986. if ( !( /^(?:r|a|f)/ ).test( this.element.css( "position" ) ) ) {
  1987. this.element[ 0 ].style.position = "relative";
  1988. }
  1989. },
  1990. _adjustOffsetFromHelper: function( obj ) {
  1991. if ( typeof obj === "string" ) {
  1992. obj = obj.split( " " );
  1993. }
  1994. if ( Array.isArray( obj ) ) {
  1995. obj = { left: +obj[ 0 ], top: +obj[ 1 ] || 0 };
  1996. }
  1997. if ( "left" in obj ) {
  1998. this.offset.click.left = obj.left + this.margins.left;
  1999. }
  2000. if ( "right" in obj ) {
  2001. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  2002. }
  2003. if ( "top" in obj ) {
  2004. this.offset.click.top = obj.top + this.margins.top;
  2005. }
  2006. if ( "bottom" in obj ) {
  2007. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  2008. }
  2009. },
  2010. _isRootNode: function( element ) {
  2011. return ( /(html|body)/i ).test( element.tagName ) || element === this.document[ 0 ];
  2012. },
  2013. _getParentOffset: function() {
  2014. //Get the offsetParent and cache its position
  2015. var po = this.offsetParent.offset(),
  2016. document = this.document[ 0 ];
  2017. // This is a special case where we need to modify a offset calculated on start, since the
  2018. // following happened:
  2019. // 1. The position of the helper is absolute, so it's position is calculated based on the
  2020. // next positioned parent
  2021. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't
  2022. // the document, which means that the scroll is included in the initial calculation of the
  2023. // offset of the parent, and never recalculated upon drag
  2024. if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== document &&
  2025. $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) {
  2026. po.left += this.scrollParent.scrollLeft();
  2027. po.top += this.scrollParent.scrollTop();
  2028. }
  2029. if ( this._isRootNode( this.offsetParent[ 0 ] ) ) {
  2030. po = { top: 0, left: 0 };
  2031. }
  2032. return {
  2033. top: po.top + ( parseInt( this.offsetParent.css( "borderTopWidth" ), 10 ) || 0 ),
  2034. left: po.left + ( parseInt( this.offsetParent.css( "borderLeftWidth" ), 10 ) || 0 )
  2035. };
  2036. },
  2037. _getRelativeOffset: function() {
  2038. if ( this.cssPosition !== "relative" ) {
  2039. return { top: 0, left: 0 };
  2040. }
  2041. var p = this.element.position(),
  2042. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
  2043. return {
  2044. top: p.top - ( parseInt( this.helper.css( "top" ), 10 ) || 0 ) +
  2045. ( !scrollIsRootNode ? this.scrollParent.scrollTop() : 0 ),
  2046. left: p.left - ( parseInt( this.helper.css( "left" ), 10 ) || 0 ) +
  2047. ( !scrollIsRootNode ? this.scrollParent.scrollLeft() : 0 )
  2048. };
  2049. },
  2050. _cacheMargins: function() {
  2051. this.margins = {
  2052. left: ( parseInt( this.element.css( "marginLeft" ), 10 ) || 0 ),
  2053. top: ( parseInt( this.element.css( "marginTop" ), 10 ) || 0 ),
  2054. right: ( parseInt( this.element.css( "marginRight" ), 10 ) || 0 ),
  2055. bottom: ( parseInt( this.element.css( "marginBottom" ), 10 ) || 0 )
  2056. };
  2057. },
  2058. _cacheHelperProportions: function() {
  2059. this.helperProportions = {
  2060. width: this.helper.outerWidth(),
  2061. height: this.helper.outerHeight()
  2062. };
  2063. },
  2064. _setContainment: function() {
  2065. var isUserScrollable, c, ce,
  2066. o = this.options,
  2067. document = this.document[ 0 ];
  2068. this.relativeContainer = null;
  2069. if ( !o.containment ) {
  2070. this.containment = null;
  2071. return;
  2072. }
  2073. if ( o.containment === "window" ) {
  2074. this.containment = [
  2075. $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
  2076. $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top,
  2077. $( window ).scrollLeft() + $( window ).width() -
  2078. this.helperProportions.width - this.margins.left,
  2079. $( window ).scrollTop() +
  2080. ( $( window ).height() || document.body.parentNode.scrollHeight ) -
  2081. this.helperProportions.height - this.margins.top
  2082. ];
  2083. return;
  2084. }
  2085. if ( o.containment === "document" ) {
  2086. this.containment = [
  2087. 0,
  2088. 0,
  2089. $( document ).width() - this.helperProportions.width - this.margins.left,
  2090. ( $( document ).height() || document.body.parentNode.scrollHeight ) -
  2091. this.helperProportions.height - this.margins.top
  2092. ];
  2093. return;
  2094. }
  2095. if ( o.containment.constructor === Array ) {
  2096. this.containment = o.containment;
  2097. return;
  2098. }
  2099. if ( o.containment === "parent" ) {
  2100. o.containment = this.helper[ 0 ].parentNode;
  2101. }
  2102. c = $( o.containment );
  2103. ce = c[ 0 ];
  2104. if ( !ce ) {
  2105. return;
  2106. }
  2107. isUserScrollable = /(scroll|auto)/.test( c.css( "overflow" ) );
  2108. this.containment = [
  2109. ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) +
  2110. ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ),
  2111. ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) +
  2112. ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ),
  2113. ( isUserScrollable ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) -
  2114. ( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) -
  2115. ( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) -
  2116. this.helperProportions.width -
  2117. this.margins.left -
  2118. this.margins.right,
  2119. ( isUserScrollable ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) -
  2120. ( parseInt( c.css( "borderBottomWidth" ), 10 ) || 0 ) -
  2121. ( parseInt( c.css( "paddingBottom" ), 10 ) || 0 ) -
  2122. this.helperProportions.height -
  2123. this.margins.top -
  2124. this.margins.bottom
  2125. ];
  2126. this.relativeContainer = c;
  2127. },
  2128. _convertPositionTo: function( d, pos ) {
  2129. if ( !pos ) {
  2130. pos = this.position;
  2131. }
  2132. var mod = d === "absolute" ? 1 : -1,
  2133. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
  2134. return {
  2135. top: (
  2136. // The absolute mouse position
  2137. pos.top +
  2138. // Only for relative positioned nodes: Relative offset from element to offset parent
  2139. this.offset.relative.top * mod +
  2140. // The offsetParent's offset without borders (offset + border)
  2141. this.offset.parent.top * mod -
  2142. ( ( this.cssPosition === "fixed" ?
  2143. -this.offset.scroll.top :
  2144. ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) * mod )
  2145. ),
  2146. left: (
  2147. // The absolute mouse position
  2148. pos.left +
  2149. // Only for relative positioned nodes: Relative offset from element to offset parent
  2150. this.offset.relative.left * mod +
  2151. // The offsetParent's offset without borders (offset + border)
  2152. this.offset.parent.left * mod -
  2153. ( ( this.cssPosition === "fixed" ?
  2154. -this.offset.scroll.left :
  2155. ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) * mod )
  2156. )
  2157. };
  2158. },
  2159. _generatePosition: function( event, constrainPosition ) {
  2160. var containment, co, top, left,
  2161. o = this.options,
  2162. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] ),
  2163. pageX = event.pageX,
  2164. pageY = event.pageY;
  2165. // Cache the scroll
  2166. if ( !scrollIsRootNode || !this.offset.scroll ) {
  2167. this.offset.scroll = {
  2168. top: this.scrollParent.scrollTop(),
  2169. left: this.scrollParent.scrollLeft()
  2170. };
  2171. }
  2172. /*
  2173. * - Position constraining -
  2174. * Constrain the position to a mix of grid, containment.
  2175. */
  2176. // If we are not dragging yet, we won't check for options
  2177. if ( constrainPosition ) {
  2178. if ( this.containment ) {
  2179. if ( this.relativeContainer ) {
  2180. co = this.relativeContainer.offset();
  2181. containment = [
  2182. this.containment[ 0 ] + co.left,
  2183. this.containment[ 1 ] + co.top,
  2184. this.containment[ 2 ] + co.left,
  2185. this.containment[ 3 ] + co.top
  2186. ];
  2187. } else {
  2188. containment = this.containment;
  2189. }
  2190. if ( event.pageX - this.offset.click.left < containment[ 0 ] ) {
  2191. pageX = containment[ 0 ] + this.offset.click.left;
  2192. }
  2193. if ( event.pageY - this.offset.click.top < containment[ 1 ] ) {
  2194. pageY = containment[ 1 ] + this.offset.click.top;
  2195. }
  2196. if ( event.pageX - this.offset.click.left > containment[ 2 ] ) {
  2197. pageX = containment[ 2 ] + this.offset.click.left;
  2198. }
  2199. if ( event.pageY - this.offset.click.top > containment[ 3 ] ) {
  2200. pageY = containment[ 3 ] + this.offset.click.top;
  2201. }
  2202. }
  2203. if ( o.grid ) {
  2204. //Check for grid elements set to 0 to prevent divide by 0 error causing invalid
  2205. // argument errors in IE (see ticket #6950)
  2206. top = o.grid[ 1 ] ? this.originalPageY + Math.round( ( pageY -
  2207. this.originalPageY ) / o.grid[ 1 ] ) * o.grid[ 1 ] : this.originalPageY;
  2208. pageY = containment ? ( ( top - this.offset.click.top >= containment[ 1 ] ||
  2209. top - this.offset.click.top > containment[ 3 ] ) ?
  2210. top :
  2211. ( ( top - this.offset.click.top >= containment[ 1 ] ) ?
  2212. top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) : top;
  2213. left = o.grid[ 0 ] ? this.originalPageX +
  2214. Math.round( ( pageX - this.originalPageX ) / o.grid[ 0 ] ) * o.grid[ 0 ] :
  2215. this.originalPageX;
  2216. pageX = containment ? ( ( left - this.offset.click.left >= containment[ 0 ] ||
  2217. left - this.offset.click.left > containment[ 2 ] ) ?
  2218. left :
  2219. ( ( left - this.offset.click.left >= containment[ 0 ] ) ?
  2220. left - o.grid[ 0 ] : left + o.grid[ 0 ] ) ) : left;
  2221. }
  2222. if ( o.axis === "y" ) {
  2223. pageX = this.originalPageX;
  2224. }
  2225. if ( o.axis === "x" ) {
  2226. pageY = this.originalPageY;
  2227. }
  2228. }
  2229. return {
  2230. top: (
  2231. // The absolute mouse position
  2232. pageY -
  2233. // Click offset (relative to the element)
  2234. this.offset.click.top -
  2235. // Only for relative positioned nodes: Relative offset from element to offset parent
  2236. this.offset.relative.top -
  2237. // The offsetParent's offset without borders (offset + border)
  2238. this.offset.parent.top +
  2239. ( this.cssPosition === "fixed" ?
  2240. -this.offset.scroll.top :
  2241. ( scrollIsRootNode ? 0 : this.offset.scroll.top ) )
  2242. ),
  2243. left: (
  2244. // The absolute mouse position
  2245. pageX -
  2246. // Click offset (relative to the element)
  2247. this.offset.click.left -
  2248. // Only for relative positioned nodes: Relative offset from element to offset parent
  2249. this.offset.relative.left -
  2250. // The offsetParent's offset without borders (offset + border)
  2251. this.offset.parent.left +
  2252. ( this.cssPosition === "fixed" ?
  2253. -this.offset.scroll.left :
  2254. ( scrollIsRootNode ? 0 : this.offset.scroll.left ) )
  2255. )
  2256. };
  2257. },
  2258. _clear: function() {
  2259. this._removeClass( this.helper, "ui-draggable-dragging" );
  2260. if ( this.helper[ 0 ] !== this.element[ 0 ] && !this.cancelHelperRemoval ) {
  2261. this.helper.remove();
  2262. }
  2263. this.helper = null;
  2264. this.cancelHelperRemoval = false;
  2265. if ( this.destroyOnClear ) {
  2266. this.destroy();
  2267. }
  2268. },
  2269. // From now on bulk stuff - mainly helpers
  2270. _trigger: function( type, event, ui ) {
  2271. ui = ui || this._uiHash();
  2272. $.ui.plugin.call( this, type, [ event, ui, this ], true );
  2273. // Absolute position and offset (see #6884 ) have to be recalculated after plugins
  2274. if ( /^(drag|start|stop)/.test( type ) ) {
  2275. this.positionAbs = this._convertPositionTo( "absolute" );
  2276. ui.offset = this.positionAbs;
  2277. }
  2278. return $.Widget.prototype._trigger.call( this, type, event, ui );
  2279. },
  2280. plugins: {},
  2281. _uiHash: function() {
  2282. return {
  2283. helper: this.helper,
  2284. position: this.position,
  2285. originalPosition: this.originalPosition,
  2286. offset: this.positionAbs
  2287. };
  2288. }
  2289. } );
  2290. $.ui.plugin.add( "draggable", "connectToSortable", {
  2291. start: function( event, ui, draggable ) {
  2292. var uiSortable = $.extend( {}, ui, {
  2293. item: draggable.element
  2294. } );
  2295. draggable.sortables = [];
  2296. $( draggable.options.connectToSortable ).each( function() {
  2297. var sortable = $( this ).sortable( "instance" );
  2298. if ( sortable && !sortable.options.disabled ) {
  2299. draggable.sortables.push( sortable );
  2300. // RefreshPositions is called at drag start to refresh the containerCache
  2301. // which is used in drag. This ensures it's initialized and synchronized
  2302. // with any changes that might have happened on the page since initialization.
  2303. sortable.refreshPositions();
  2304. sortable._trigger( "activate", event, uiSortable );
  2305. }
  2306. } );
  2307. },
  2308. stop: function( event, ui, draggable ) {
  2309. var uiSortable = $.extend( {}, ui, {
  2310. item: draggable.element
  2311. } );
  2312. draggable.cancelHelperRemoval = false;
  2313. $.each( draggable.sortables, function() {
  2314. var sortable = this;
  2315. if ( sortable.isOver ) {
  2316. sortable.isOver = 0;
  2317. // Allow this sortable to handle removing the helper
  2318. draggable.cancelHelperRemoval = true;
  2319. sortable.cancelHelperRemoval = false;
  2320. // Use _storedCSS To restore properties in the sortable,
  2321. // as this also handles revert (#9675) since the draggable
  2322. // may have modified them in unexpected ways (#8809)
  2323. sortable._storedCSS = {
  2324. position: sortable.placeholder.css( "position" ),
  2325. top: sortable.placeholder.css( "top" ),
  2326. left: sortable.placeholder.css( "left" )
  2327. };
  2328. sortable._mouseStop( event );
  2329. // Once drag has ended, the sortable should return to using
  2330. // its original helper, not the shared helper from draggable
  2331. sortable.options.helper = sortable.options._helper;
  2332. } else {
  2333. // Prevent this Sortable from removing the helper.
  2334. // However, don't set the draggable to remove the helper
  2335. // either as another connected Sortable may yet handle the removal.
  2336. sortable.cancelHelperRemoval = true;
  2337. sortable._trigger( "deactivate", event, uiSortable );
  2338. }
  2339. } );
  2340. },
  2341. drag: function( event, ui, draggable ) {
  2342. $.each( draggable.sortables, function() {
  2343. var innermostIntersecting = false,
  2344. sortable = this;
  2345. // Copy over variables that sortable's _intersectsWith uses
  2346. sortable.positionAbs = draggable.positionAbs;
  2347. sortable.helperProportions = draggable.helperProportions;
  2348. sortable.offset.click = draggable.offset.click;
  2349. if ( sortable._intersectsWith( sortable.containerCache ) ) {
  2350. innermostIntersecting = true;
  2351. $.each( draggable.sortables, function() {
  2352. // Copy over variables that sortable's _intersectsWith uses
  2353. this.positionAbs = draggable.positionAbs;
  2354. this.helperProportions = draggable.helperProportions;
  2355. this.offset.click = draggable.offset.click;
  2356. if ( this !== sortable &&
  2357. this._intersectsWith( this.containerCache ) &&
  2358. $.contains( sortable.element[ 0 ], this.element[ 0 ] ) ) {
  2359. innermostIntersecting = false;
  2360. }
  2361. return innermostIntersecting;
  2362. } );
  2363. }
  2364. if ( innermostIntersecting ) {
  2365. // If it intersects, we use a little isOver variable and set it once,
  2366. // so that the move-in stuff gets fired only once.
  2367. if ( !sortable.isOver ) {
  2368. sortable.isOver = 1;
  2369. // Store draggable's parent in case we need to reappend to it later.
  2370. draggable._parent = ui.helper.parent();
  2371. sortable.currentItem = ui.helper
  2372. .appendTo( sortable.element )
  2373. .data( "ui-sortable-item", true );
  2374. // Store helper option to later restore it
  2375. sortable.options._helper = sortable.options.helper;
  2376. sortable.options.helper = function() {
  2377. return ui.helper[ 0 ];
  2378. };
  2379. // Fire the start events of the sortable with our passed browser event,
  2380. // and our own helper (so it doesn't create a new one)
  2381. event.target = sortable.currentItem[ 0 ];
  2382. sortable._mouseCapture( event, true );
  2383. sortable._mouseStart( event, true, true );
  2384. // Because the browser event is way off the new appended portlet,
  2385. // modify necessary variables to reflect the changes
  2386. sortable.offset.click.top = draggable.offset.click.top;
  2387. sortable.offset.click.left = draggable.offset.click.left;
  2388. sortable.offset.parent.left -= draggable.offset.parent.left -
  2389. sortable.offset.parent.left;
  2390. sortable.offset.parent.top -= draggable.offset.parent.top -
  2391. sortable.offset.parent.top;
  2392. draggable._trigger( "toSortable", event );
  2393. // Inform draggable that the helper is in a valid drop zone,
  2394. // used solely in the revert option to handle "valid/invalid".
  2395. draggable.dropped = sortable.element;
  2396. // Need to refreshPositions of all sortables in the case that
  2397. // adding to one sortable changes the location of the other sortables (#9675)
  2398. $.each( draggable.sortables, function() {
  2399. this.refreshPositions();
  2400. } );
  2401. // Hack so receive/update callbacks work (mostly)
  2402. draggable.currentItem = draggable.element;
  2403. sortable.fromOutside = draggable;
  2404. }
  2405. if ( sortable.currentItem ) {
  2406. sortable._mouseDrag( event );
  2407. // Copy the sortable's position because the draggable's can potentially reflect
  2408. // a relative position, while sortable is always absolute, which the dragged
  2409. // element has now become. (#8809)
  2410. ui.position = sortable.position;
  2411. }
  2412. } else {
  2413. // If it doesn't intersect with the sortable, and it intersected before,
  2414. // we fake the drag stop of the sortable, but make sure it doesn't remove
  2415. // the helper by using cancelHelperRemoval.
  2416. if ( sortable.isOver ) {
  2417. sortable.isOver = 0;
  2418. sortable.cancelHelperRemoval = true;
  2419. // Calling sortable's mouseStop would trigger a revert,
  2420. // so revert must be temporarily false until after mouseStop is called.
  2421. sortable.options._revert = sortable.options.revert;
  2422. sortable.options.revert = false;
  2423. sortable._trigger( "out", event, sortable._uiHash( sortable ) );
  2424. sortable._mouseStop( event, true );
  2425. // Restore sortable behaviors that were modfied
  2426. // when the draggable entered the sortable area (#9481)
  2427. sortable.options.revert = sortable.options._revert;
  2428. sortable.options.helper = sortable.options._helper;
  2429. if ( sortable.placeholder ) {
  2430. sortable.placeholder.remove();
  2431. }
  2432. // Restore and recalculate the draggable's offset considering the sortable
  2433. // may have modified them in unexpected ways. (#8809, #10669)
  2434. ui.helper.appendTo( draggable._parent );
  2435. draggable._refreshOffsets( event );
  2436. ui.position = draggable._generatePosition( event, true );
  2437. draggable._trigger( "fromSortable", event );
  2438. // Inform draggable that the helper is no longer in a valid drop zone
  2439. draggable.dropped = false;
  2440. // Need to refreshPositions of all sortables just in case removing
  2441. // from one sortable changes the location of other sortables (#9675)
  2442. $.each( draggable.sortables, function() {
  2443. this.refreshPositions();
  2444. } );
  2445. }
  2446. }
  2447. } );
  2448. }
  2449. } );
  2450. $.ui.plugin.add( "draggable", "cursor", {
  2451. start: function( event, ui, instance ) {
  2452. var t = $( "body" ),
  2453. o = instance.options;
  2454. if ( t.css( "cursor" ) ) {
  2455. o._cursor = t.css( "cursor" );
  2456. }
  2457. t.css( "cursor", o.cursor );
  2458. },
  2459. stop: function( event, ui, instance ) {
  2460. var o = instance.options;
  2461. if ( o._cursor ) {
  2462. $( "body" ).css( "cursor", o._cursor );
  2463. }
  2464. }
  2465. } );
  2466. $.ui.plugin.add( "draggable", "opacity", {
  2467. start: function( event, ui, instance ) {
  2468. var t = $( ui.helper ),
  2469. o = instance.options;
  2470. if ( t.css( "opacity" ) ) {
  2471. o._opacity = t.css( "opacity" );
  2472. }
  2473. t.css( "opacity", o.opacity );
  2474. },
  2475. stop: function( event, ui, instance ) {
  2476. var o = instance.options;
  2477. if ( o._opacity ) {
  2478. $( ui.helper ).css( "opacity", o._opacity );
  2479. }
  2480. }
  2481. } );
  2482. $.ui.plugin.add( "draggable", "scroll", {
  2483. start: function( event, ui, i ) {
  2484. if ( !i.scrollParentNotHidden ) {
  2485. i.scrollParentNotHidden = i.helper.scrollParent( false );
  2486. }
  2487. if ( i.scrollParentNotHidden[ 0 ] !== i.document[ 0 ] &&
  2488. i.scrollParentNotHidden[ 0 ].tagName !== "HTML" ) {
  2489. i.overflowOffset = i.scrollParentNotHidden.offset();
  2490. }
  2491. },
  2492. drag: function( event, ui, i ) {
  2493. var o = i.options,
  2494. scrolled = false,
  2495. scrollParent = i.scrollParentNotHidden[ 0 ],
  2496. document = i.document[ 0 ];
  2497. if ( scrollParent !== document && scrollParent.tagName !== "HTML" ) {
  2498. if ( !o.axis || o.axis !== "x" ) {
  2499. if ( ( i.overflowOffset.top + scrollParent.offsetHeight ) - event.pageY <
  2500. o.scrollSensitivity ) {
  2501. scrollParent.scrollTop = scrolled = scrollParent.scrollTop + o.scrollSpeed;
  2502. } else if ( event.pageY - i.overflowOffset.top < o.scrollSensitivity ) {
  2503. scrollParent.scrollTop = scrolled = scrollParent.scrollTop - o.scrollSpeed;
  2504. }
  2505. }
  2506. if ( !o.axis || o.axis !== "y" ) {
  2507. if ( ( i.overflowOffset.left + scrollParent.offsetWidth ) - event.pageX <
  2508. o.scrollSensitivity ) {
  2509. scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft + o.scrollSpeed;
  2510. } else if ( event.pageX - i.overflowOffset.left < o.scrollSensitivity ) {
  2511. scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft - o.scrollSpeed;
  2512. }
  2513. }
  2514. } else {
  2515. if ( !o.axis || o.axis !== "x" ) {
  2516. if ( event.pageY - $( document ).scrollTop() < o.scrollSensitivity ) {
  2517. scrolled = $( document ).scrollTop( $( document ).scrollTop() - o.scrollSpeed );
  2518. } else if ( $( window ).height() - ( event.pageY - $( document ).scrollTop() ) <
  2519. o.scrollSensitivity ) {
  2520. scrolled = $( document ).scrollTop( $( document ).scrollTop() + o.scrollSpeed );
  2521. }
  2522. }
  2523. if ( !o.axis || o.axis !== "y" ) {
  2524. if ( event.pageX - $( document ).scrollLeft() < o.scrollSensitivity ) {
  2525. scrolled = $( document ).scrollLeft(
  2526. $( document ).scrollLeft() - o.scrollSpeed
  2527. );
  2528. } else if ( $( window ).width() - ( event.pageX - $( document ).scrollLeft() ) <
  2529. o.scrollSensitivity ) {
  2530. scrolled = $( document ).scrollLeft(
  2531. $( document ).scrollLeft() + o.scrollSpeed
  2532. );
  2533. }
  2534. }
  2535. }
  2536. if ( scrolled !== false && $.ui.ddmanager && !o.dropBehaviour ) {
  2537. $.ui.ddmanager.prepareOffsets( i, event );
  2538. }
  2539. }
  2540. } );
  2541. $.ui.plugin.add( "draggable", "snap", {
  2542. start: function( event, ui, i ) {
  2543. var o = i.options;
  2544. i.snapElements = [];
  2545. $( o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap )
  2546. .each( function() {
  2547. var $t = $( this ),
  2548. $o = $t.offset();
  2549. if ( this !== i.element[ 0 ] ) {
  2550. i.snapElements.push( {
  2551. item: this,
  2552. width: $t.outerWidth(), height: $t.outerHeight(),
  2553. top: $o.top, left: $o.left
  2554. } );
  2555. }
  2556. } );
  2557. },
  2558. drag: function( event, ui, inst ) {
  2559. var ts, bs, ls, rs, l, r, t, b, i, first,
  2560. o = inst.options,
  2561. d = o.snapTolerance,
  2562. x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
  2563. y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
  2564. for ( i = inst.snapElements.length - 1; i >= 0; i-- ) {
  2565. l = inst.snapElements[ i ].left - inst.margins.left;
  2566. r = l + inst.snapElements[ i ].width;
  2567. t = inst.snapElements[ i ].top - inst.margins.top;
  2568. b = t + inst.snapElements[ i ].height;
  2569. if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d ||
  2570. !$.contains( inst.snapElements[ i ].item.ownerDocument,
  2571. inst.snapElements[ i ].item ) ) {
  2572. if ( inst.snapElements[ i ].snapping ) {
  2573. if ( inst.options.snap.release ) {
  2574. inst.options.snap.release.call(
  2575. inst.element,
  2576. event,
  2577. $.extend( inst._uiHash(), { snapItem: inst.snapElements[ i ].item } )
  2578. );
  2579. }
  2580. }
  2581. inst.snapElements[ i ].snapping = false;
  2582. continue;
  2583. }
  2584. if ( o.snapMode !== "inner" ) {
  2585. ts = Math.abs( t - y2 ) <= d;
  2586. bs = Math.abs( b - y1 ) <= d;
  2587. ls = Math.abs( l - x2 ) <= d;
  2588. rs = Math.abs( r - x1 ) <= d;
  2589. if ( ts ) {
  2590. ui.position.top = inst._convertPositionTo( "relative", {
  2591. top: t - inst.helperProportions.height,
  2592. left: 0
  2593. } ).top;
  2594. }
  2595. if ( bs ) {
  2596. ui.position.top = inst._convertPositionTo( "relative", {
  2597. top: b,
  2598. left: 0
  2599. } ).top;
  2600. }
  2601. if ( ls ) {
  2602. ui.position.left = inst._convertPositionTo( "relative", {
  2603. top: 0,
  2604. left: l - inst.helperProportions.width
  2605. } ).left;
  2606. }
  2607. if ( rs ) {
  2608. ui.position.left = inst._convertPositionTo( "relative", {
  2609. top: 0,
  2610. left: r
  2611. } ).left;
  2612. }
  2613. }
  2614. first = ( ts || bs || ls || rs );
  2615. if ( o.snapMode !== "outer" ) {
  2616. ts = Math.abs( t - y1 ) <= d;
  2617. bs = Math.abs( b - y2 ) <= d;
  2618. ls = Math.abs( l - x1 ) <= d;
  2619. rs = Math.abs( r - x2 ) <= d;
  2620. if ( ts ) {
  2621. ui.position.top = inst._convertPositionTo( "relative", {
  2622. top: t,
  2623. left: 0
  2624. } ).top;
  2625. }
  2626. if ( bs ) {
  2627. ui.position.top = inst._convertPositionTo( "relative", {
  2628. top: b - inst.helperProportions.height,
  2629. left: 0
  2630. } ).top;
  2631. }
  2632. if ( ls ) {
  2633. ui.position.left = inst._convertPositionTo( "relative", {
  2634. top: 0,
  2635. left: l
  2636. } ).left;
  2637. }
  2638. if ( rs ) {
  2639. ui.position.left = inst._convertPositionTo( "relative", {
  2640. top: 0,
  2641. left: r - inst.helperProportions.width
  2642. } ).left;
  2643. }
  2644. }
  2645. if ( !inst.snapElements[ i ].snapping && ( ts || bs || ls || rs || first ) ) {
  2646. if ( inst.options.snap.snap ) {
  2647. inst.options.snap.snap.call(
  2648. inst.element,
  2649. event,
  2650. $.extend( inst._uiHash(), {
  2651. snapItem: inst.snapElements[ i ].item
  2652. } ) );
  2653. }
  2654. }
  2655. inst.snapElements[ i ].snapping = ( ts || bs || ls || rs || first );
  2656. }
  2657. }
  2658. } );
  2659. $.ui.plugin.add( "draggable", "stack", {
  2660. start: function( event, ui, instance ) {
  2661. var min,
  2662. o = instance.options,
  2663. group = $.makeArray( $( o.stack ) ).sort( function( a, b ) {
  2664. return ( parseInt( $( a ).css( "zIndex" ), 10 ) || 0 ) -
  2665. ( parseInt( $( b ).css( "zIndex" ), 10 ) || 0 );
  2666. } );
  2667. if ( !group.length ) {
  2668. return;
  2669. }
  2670. min = parseInt( $( group[ 0 ] ).css( "zIndex" ), 10 ) || 0;
  2671. $( group ).each( function( i ) {
  2672. $( this ).css( "zIndex", min + i );
  2673. } );
  2674. this.css( "zIndex", ( min + group.length ) );
  2675. }
  2676. } );
  2677. $.ui.plugin.add( "draggable", "zIndex", {
  2678. start: function( event, ui, instance ) {
  2679. var t = $( ui.helper ),
  2680. o = instance.options;
  2681. if ( t.css( "zIndex" ) ) {
  2682. o._zIndex = t.css( "zIndex" );
  2683. }
  2684. t.css( "zIndex", o.zIndex );
  2685. },
  2686. stop: function( event, ui, instance ) {
  2687. var o = instance.options;
  2688. if ( o._zIndex ) {
  2689. $( ui.helper ).css( "zIndex", o._zIndex );
  2690. }
  2691. }
  2692. } );
  2693. var widgetsDraggable = $.ui.draggable;
  2694. /*!
  2695. * jQuery UI Droppable 1.13.0
  2696. * http://jqueryui.com
  2697. *
  2698. * Copyright jQuery Foundation and other contributors
  2699. * Released under the MIT license.
  2700. * http://jquery.org/license
  2701. */
  2702. //>>label: Droppable
  2703. //>>group: Interactions
  2704. //>>description: Enables drop targets for draggable elements.
  2705. //>>docs: http://api.jqueryui.com/droppable/
  2706. //>>demos: http://jqueryui.com/droppable/
  2707. $.widget( "ui.droppable", {
  2708. version: "1.13.0",
  2709. widgetEventPrefix: "drop",
  2710. options: {
  2711. accept: "*",
  2712. addClasses: true,
  2713. greedy: false,
  2714. scope: "default",
  2715. tolerance: "intersect",
  2716. // Callbacks
  2717. activate: null,
  2718. deactivate: null,
  2719. drop: null,
  2720. out: null,
  2721. over: null
  2722. },
  2723. _create: function() {
  2724. var proportions,
  2725. o = this.options,
  2726. accept = o.accept;
  2727. this.isover = false;
  2728. this.isout = true;
  2729. this.accept = typeof accept === "function" ? accept : function( d ) {
  2730. return d.is( accept );
  2731. };
  2732. this.proportions = function( /* valueToWrite */ ) {
  2733. if ( arguments.length ) {
  2734. // Store the droppable's proportions
  2735. proportions = arguments[ 0 ];
  2736. } else {
  2737. // Retrieve or derive the droppable's proportions
  2738. return proportions ?
  2739. proportions :
  2740. proportions = {
  2741. width: this.element[ 0 ].offsetWidth,
  2742. height: this.element[ 0 ].offsetHeight
  2743. };
  2744. }
  2745. };
  2746. this._addToManager( o.scope );
  2747. if ( o.addClasses ) {
  2748. this._addClass( "ui-droppable" );
  2749. }
  2750. },
  2751. _addToManager: function( scope ) {
  2752. // Add the reference and positions to the manager
  2753. $.ui.ddmanager.droppables[ scope ] = $.ui.ddmanager.droppables[ scope ] || [];
  2754. $.ui.ddmanager.droppables[ scope ].push( this );
  2755. },
  2756. _splice: function( drop ) {
  2757. var i = 0;
  2758. for ( ; i < drop.length; i++ ) {
  2759. if ( drop[ i ] === this ) {
  2760. drop.splice( i, 1 );
  2761. }
  2762. }
  2763. },
  2764. _destroy: function() {
  2765. var drop = $.ui.ddmanager.droppables[ this.options.scope ];
  2766. this._splice( drop );
  2767. },
  2768. _setOption: function( key, value ) {
  2769. if ( key === "accept" ) {
  2770. this.accept = typeof value === "function" ? value : function( d ) {
  2771. return d.is( value );
  2772. };
  2773. } else if ( key === "scope" ) {
  2774. var drop = $.ui.ddmanager.droppables[ this.options.scope ];
  2775. this._splice( drop );
  2776. this._addToManager( value );
  2777. }
  2778. this._super( key, value );
  2779. },
  2780. _activate: function( event ) {
  2781. var draggable = $.ui.ddmanager.current;
  2782. this._addActiveClass();
  2783. if ( draggable ) {
  2784. this._trigger( "activate", event, this.ui( draggable ) );
  2785. }
  2786. },
  2787. _deactivate: function( event ) {
  2788. var draggable = $.ui.ddmanager.current;
  2789. this._removeActiveClass();
  2790. if ( draggable ) {
  2791. this._trigger( "deactivate", event, this.ui( draggable ) );
  2792. }
  2793. },
  2794. _over: function( event ) {
  2795. var draggable = $.ui.ddmanager.current;
  2796. // Bail if draggable and droppable are same element
  2797. if ( !draggable || ( draggable.currentItem ||
  2798. draggable.element )[ 0 ] === this.element[ 0 ] ) {
  2799. return;
  2800. }
  2801. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem ||
  2802. draggable.element ) ) ) {
  2803. this._addHoverClass();
  2804. this._trigger( "over", event, this.ui( draggable ) );
  2805. }
  2806. },
  2807. _out: function( event ) {
  2808. var draggable = $.ui.ddmanager.current;
  2809. // Bail if draggable and droppable are same element
  2810. if ( !draggable || ( draggable.currentItem ||
  2811. draggable.element )[ 0 ] === this.element[ 0 ] ) {
  2812. return;
  2813. }
  2814. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem ||
  2815. draggable.element ) ) ) {
  2816. this._removeHoverClass();
  2817. this._trigger( "out", event, this.ui( draggable ) );
  2818. }
  2819. },
  2820. _drop: function( event, custom ) {
  2821. var draggable = custom || $.ui.ddmanager.current,
  2822. childrenIntersection = false;
  2823. // Bail if draggable and droppable are same element
  2824. if ( !draggable || ( draggable.currentItem ||
  2825. draggable.element )[ 0 ] === this.element[ 0 ] ) {
  2826. return false;
  2827. }
  2828. this.element
  2829. .find( ":data(ui-droppable)" )
  2830. .not( ".ui-draggable-dragging" )
  2831. .each( function() {
  2832. var inst = $( this ).droppable( "instance" );
  2833. if (
  2834. inst.options.greedy &&
  2835. !inst.options.disabled &&
  2836. inst.options.scope === draggable.options.scope &&
  2837. inst.accept.call(
  2838. inst.element[ 0 ], ( draggable.currentItem || draggable.element )
  2839. ) &&
  2840. $.ui.intersect(
  2841. draggable,
  2842. $.extend( inst, { offset: inst.element.offset() } ),
  2843. inst.options.tolerance, event
  2844. )
  2845. ) {
  2846. childrenIntersection = true;
  2847. return false;
  2848. }
  2849. } );
  2850. if ( childrenIntersection ) {
  2851. return false;
  2852. }
  2853. if ( this.accept.call( this.element[ 0 ],
  2854. ( draggable.currentItem || draggable.element ) ) ) {
  2855. this._removeActiveClass();
  2856. this._removeHoverClass();
  2857. this._trigger( "drop", event, this.ui( draggable ) );
  2858. return this.element;
  2859. }
  2860. return false;
  2861. },
  2862. ui: function( c ) {
  2863. return {
  2864. draggable: ( c.currentItem || c.element ),
  2865. helper: c.helper,
  2866. position: c.position,
  2867. offset: c.positionAbs
  2868. };
  2869. },
  2870. // Extension points just to make backcompat sane and avoid duplicating logic
  2871. // TODO: Remove in 1.14 along with call to it below
  2872. _addHoverClass: function() {
  2873. this._addClass( "ui-droppable-hover" );
  2874. },
  2875. _removeHoverClass: function() {
  2876. this._removeClass( "ui-droppable-hover" );
  2877. },
  2878. _addActiveClass: function() {
  2879. this._addClass( "ui-droppable-active" );
  2880. },
  2881. _removeActiveClass: function() {
  2882. this._removeClass( "ui-droppable-active" );
  2883. }
  2884. } );
  2885. $.ui.intersect = ( function() {
  2886. function isOverAxis( x, reference, size ) {
  2887. return ( x >= reference ) && ( x < ( reference + size ) );
  2888. }
  2889. return function( draggable, droppable, toleranceMode, event ) {
  2890. if ( !droppable.offset ) {
  2891. return false;
  2892. }
  2893. var x1 = ( draggable.positionAbs ||
  2894. draggable.position.absolute ).left + draggable.margins.left,
  2895. y1 = ( draggable.positionAbs ||
  2896. draggable.position.absolute ).top + draggable.margins.top,
  2897. x2 = x1 + draggable.helperProportions.width,
  2898. y2 = y1 + draggable.helperProportions.height,
  2899. l = droppable.offset.left,
  2900. t = droppable.offset.top,
  2901. r = l + droppable.proportions().width,
  2902. b = t + droppable.proportions().height;
  2903. switch ( toleranceMode ) {
  2904. case "fit":
  2905. return ( l <= x1 && x2 <= r && t <= y1 && y2 <= b );
  2906. case "intersect":
  2907. return ( l < x1 + ( draggable.helperProportions.width / 2 ) && // Right Half
  2908. x2 - ( draggable.helperProportions.width / 2 ) < r && // Left Half
  2909. t < y1 + ( draggable.helperProportions.height / 2 ) && // Bottom Half
  2910. y2 - ( draggable.helperProportions.height / 2 ) < b ); // Top Half
  2911. case "pointer":
  2912. return isOverAxis( event.pageY, t, droppable.proportions().height ) &&
  2913. isOverAxis( event.pageX, l, droppable.proportions().width );
  2914. case "touch":
  2915. return (
  2916. ( y1 >= t && y1 <= b ) || // Top edge touching
  2917. ( y2 >= t && y2 <= b ) || // Bottom edge touching
  2918. ( y1 < t && y2 > b ) // Surrounded vertically
  2919. ) && (
  2920. ( x1 >= l && x1 <= r ) || // Left edge touching
  2921. ( x2 >= l && x2 <= r ) || // Right edge touching
  2922. ( x1 < l && x2 > r ) // Surrounded horizontally
  2923. );
  2924. default:
  2925. return false;
  2926. }
  2927. };
  2928. } )();
  2929. /*
  2930. This manager tracks offsets of draggables and droppables
  2931. */
  2932. $.ui.ddmanager = {
  2933. current: null,
  2934. droppables: { "default": [] },
  2935. prepareOffsets: function( t, event ) {
  2936. var i, j,
  2937. m = $.ui.ddmanager.droppables[ t.options.scope ] || [],
  2938. type = event ? event.type : null, // workaround for #2317
  2939. list = ( t.currentItem || t.element ).find( ":data(ui-droppable)" ).addBack();
  2940. droppablesLoop: for ( i = 0; i < m.length; i++ ) {
  2941. // No disabled and non-accepted
  2942. if ( m[ i ].options.disabled || ( t && !m[ i ].accept.call( m[ i ].element[ 0 ],
  2943. ( t.currentItem || t.element ) ) ) ) {
  2944. continue;
  2945. }
  2946. // Filter out elements in the current dragged item
  2947. for ( j = 0; j < list.length; j++ ) {
  2948. if ( list[ j ] === m[ i ].element[ 0 ] ) {
  2949. m[ i ].proportions().height = 0;
  2950. continue droppablesLoop;
  2951. }
  2952. }
  2953. m[ i ].visible = m[ i ].element.css( "display" ) !== "none";
  2954. if ( !m[ i ].visible ) {
  2955. continue;
  2956. }
  2957. // Activate the droppable if used directly from draggables
  2958. if ( type === "mousedown" ) {
  2959. m[ i ]._activate.call( m[ i ], event );
  2960. }
  2961. m[ i ].offset = m[ i ].element.offset();
  2962. m[ i ].proportions( {
  2963. width: m[ i ].element[ 0 ].offsetWidth,
  2964. height: m[ i ].element[ 0 ].offsetHeight
  2965. } );
  2966. }
  2967. },
  2968. drop: function( draggable, event ) {
  2969. var dropped = false;
  2970. // Create a copy of the droppables in case the list changes during the drop (#9116)
  2971. $.each( ( $.ui.ddmanager.droppables[ draggable.options.scope ] || [] ).slice(), function() {
  2972. if ( !this.options ) {
  2973. return;
  2974. }
  2975. if ( !this.options.disabled && this.visible &&
  2976. $.ui.intersect( draggable, this, this.options.tolerance, event ) ) {
  2977. dropped = this._drop.call( this, event ) || dropped;
  2978. }
  2979. if ( !this.options.disabled && this.visible && this.accept.call( this.element[ 0 ],
  2980. ( draggable.currentItem || draggable.element ) ) ) {
  2981. this.isout = true;
  2982. this.isover = false;
  2983. this._deactivate.call( this, event );
  2984. }
  2985. } );
  2986. return dropped;
  2987. },
  2988. dragStart: function( draggable, event ) {
  2989. // Listen for scrolling so that if the dragging causes scrolling the position of the
  2990. // droppables can be recalculated (see #5003)
  2991. draggable.element.parentsUntil( "body" ).on( "scroll.droppable", function() {
  2992. if ( !draggable.options.refreshPositions ) {
  2993. $.ui.ddmanager.prepareOffsets( draggable, event );
  2994. }
  2995. } );
  2996. },
  2997. drag: function( draggable, event ) {
  2998. // If you have a highly dynamic page, you might try this option. It renders positions
  2999. // every time you move the mouse.
  3000. if ( draggable.options.refreshPositions ) {
  3001. $.ui.ddmanager.prepareOffsets( draggable, event );
  3002. }
  3003. // Run through all droppables and check their positions based on specific tolerance options
  3004. $.each( $.ui.ddmanager.droppables[ draggable.options.scope ] || [], function() {
  3005. if ( this.options.disabled || this.greedyChild || !this.visible ) {
  3006. return;
  3007. }
  3008. var parentInstance, scope, parent,
  3009. intersects = $.ui.intersect( draggable, this, this.options.tolerance, event ),
  3010. c = !intersects && this.isover ?
  3011. "isout" :
  3012. ( intersects && !this.isover ? "isover" : null );
  3013. if ( !c ) {
  3014. return;
  3015. }
  3016. if ( this.options.greedy ) {
  3017. // find droppable parents with same scope
  3018. scope = this.options.scope;
  3019. parent = this.element.parents( ":data(ui-droppable)" ).filter( function() {
  3020. return $( this ).droppable( "instance" ).options.scope === scope;
  3021. } );
  3022. if ( parent.length ) {
  3023. parentInstance = $( parent[ 0 ] ).droppable( "instance" );
  3024. parentInstance.greedyChild = ( c === "isover" );
  3025. }
  3026. }
  3027. // We just moved into a greedy child
  3028. if ( parentInstance && c === "isover" ) {
  3029. parentInstance.isover = false;
  3030. parentInstance.isout = true;
  3031. parentInstance._out.call( parentInstance, event );
  3032. }
  3033. this[ c ] = true;
  3034. this[ c === "isout" ? "isover" : "isout" ] = false;
  3035. this[ c === "isover" ? "_over" : "_out" ].call( this, event );
  3036. // We just moved out of a greedy child
  3037. if ( parentInstance && c === "isout" ) {
  3038. parentInstance.isout = false;
  3039. parentInstance.isover = true;
  3040. parentInstance._over.call( parentInstance, event );
  3041. }
  3042. } );
  3043. },
  3044. dragStop: function( draggable, event ) {
  3045. draggable.element.parentsUntil( "body" ).off( "scroll.droppable" );
  3046. // Call prepareOffsets one final time since IE does not fire return scroll events when
  3047. // overflow was caused by drag (see #5003)
  3048. if ( !draggable.options.refreshPositions ) {
  3049. $.ui.ddmanager.prepareOffsets( draggable, event );
  3050. }
  3051. }
  3052. };
  3053. // DEPRECATED
  3054. // TODO: switch return back to widget declaration at top of file when this is removed
  3055. if ( $.uiBackCompat !== false ) {
  3056. // Backcompat for activeClass and hoverClass options
  3057. $.widget( "ui.droppable", $.ui.droppable, {
  3058. options: {
  3059. hoverClass: false,
  3060. activeClass: false
  3061. },
  3062. _addActiveClass: function() {
  3063. this._super();
  3064. if ( this.options.activeClass ) {
  3065. this.element.addClass( this.options.activeClass );
  3066. }
  3067. },
  3068. _removeActiveClass: function() {
  3069. this._super();
  3070. if ( this.options.activeClass ) {
  3071. this.element.removeClass( this.options.activeClass );
  3072. }
  3073. },
  3074. _addHoverClass: function() {
  3075. this._super();
  3076. if ( this.options.hoverClass ) {
  3077. this.element.addClass( this.options.hoverClass );
  3078. }
  3079. },
  3080. _removeHoverClass: function() {
  3081. this._super();
  3082. if ( this.options.hoverClass ) {
  3083. this.element.removeClass( this.options.hoverClass );
  3084. }
  3085. }
  3086. } );
  3087. }
  3088. var widgetsDroppable = $.ui.droppable;
  3089. /*!
  3090. * jQuery UI Resizable 1.13.0
  3091. * http://jqueryui.com
  3092. *
  3093. * Copyright jQuery Foundation and other contributors
  3094. * Released under the MIT license.
  3095. * http://jquery.org/license
  3096. */
  3097. //>>label: Resizable
  3098. //>>group: Interactions
  3099. //>>description: Enables resize functionality for any element.
  3100. //>>docs: http://api.jqueryui.com/resizable/
  3101. //>>demos: http://jqueryui.com/resizable/
  3102. //>>css.structure: ../../themes/base/core.css
  3103. //>>css.structure: ../../themes/base/resizable.css
  3104. //>>css.theme: ../../themes/base/theme.css
  3105. $.widget( "ui.resizable", $.ui.mouse, {
  3106. version: "1.13.0",
  3107. widgetEventPrefix: "resize",
  3108. options: {
  3109. alsoResize: false,
  3110. animate: false,
  3111. animateDuration: "slow",
  3112. animateEasing: "swing",
  3113. aspectRatio: false,
  3114. autoHide: false,
  3115. classes: {
  3116. "ui-resizable-se": "ui-icon ui-icon-gripsmall-diagonal-se"
  3117. },
  3118. containment: false,
  3119. ghost: false,
  3120. grid: false,
  3121. handles: "e,s,se",
  3122. helper: false,
  3123. maxHeight: null,
  3124. maxWidth: null,
  3125. minHeight: 10,
  3126. minWidth: 10,
  3127. // See #7960
  3128. zIndex: 90,
  3129. // Callbacks
  3130. resize: null,
  3131. start: null,
  3132. stop: null
  3133. },
  3134. _num: function( value ) {
  3135. return parseFloat( value ) || 0;
  3136. },
  3137. _isNumber: function( value ) {
  3138. return !isNaN( parseFloat( value ) );
  3139. },
  3140. _hasScroll: function( el, a ) {
  3141. if ( $( el ).css( "overflow" ) === "hidden" ) {
  3142. return false;
  3143. }
  3144. var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
  3145. has = false;
  3146. if ( el[ scroll ] > 0 ) {
  3147. return true;
  3148. }
  3149. // TODO: determine which cases actually cause this to happen
  3150. // if the element doesn't have the scroll set, see if it's possible to
  3151. // set the scroll
  3152. try {
  3153. el[ scroll ] = 1;
  3154. has = ( el[ scroll ] > 0 );
  3155. el[ scroll ] = 0;
  3156. } catch ( e ) {
  3157. // `el` might be a string, then setting `scroll` will throw
  3158. // an error in strict mode; ignore it.
  3159. }
  3160. return has;
  3161. },
  3162. _create: function() {
  3163. var margins,
  3164. o = this.options,
  3165. that = this;
  3166. this._addClass( "ui-resizable" );
  3167. $.extend( this, {
  3168. _aspectRatio: !!( o.aspectRatio ),
  3169. aspectRatio: o.aspectRatio,
  3170. originalElement: this.element,
  3171. _proportionallyResizeElements: [],
  3172. _helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
  3173. } );
  3174. // Wrap the element if it cannot hold child nodes
  3175. if ( this.element[ 0 ].nodeName.match( /^(canvas|textarea|input|select|button|img)$/i ) ) {
  3176. this.element.wrap(
  3177. $( "<div class='ui-wrapper'></div>" ).css( {
  3178. overflow: "hidden",
  3179. position: this.element.css( "position" ),
  3180. width: this.element.outerWidth(),
  3181. height: this.element.outerHeight(),
  3182. top: this.element.css( "top" ),
  3183. left: this.element.css( "left" )
  3184. } )
  3185. );
  3186. this.element = this.element.parent().data(
  3187. "ui-resizable", this.element.resizable( "instance" )
  3188. );
  3189. this.elementIsWrapper = true;
  3190. margins = {
  3191. marginTop: this.originalElement.css( "marginTop" ),
  3192. marginRight: this.originalElement.css( "marginRight" ),
  3193. marginBottom: this.originalElement.css( "marginBottom" ),
  3194. marginLeft: this.originalElement.css( "marginLeft" )
  3195. };
  3196. this.element.css( margins );
  3197. this.originalElement.css( "margin", 0 );
  3198. // support: Safari
  3199. // Prevent Safari textarea resize
  3200. this.originalResizeStyle = this.originalElement.css( "resize" );
  3201. this.originalElement.css( "resize", "none" );
  3202. this._proportionallyResizeElements.push( this.originalElement.css( {
  3203. position: "static",
  3204. zoom: 1,
  3205. display: "block"
  3206. } ) );
  3207. // Support: IE9
  3208. // avoid IE jump (hard set the margin)
  3209. this.originalElement.css( margins );
  3210. this._proportionallyResize();
  3211. }
  3212. this._setupHandles();
  3213. if ( o.autoHide ) {
  3214. $( this.element )
  3215. .on( "mouseenter", function() {
  3216. if ( o.disabled ) {
  3217. return;
  3218. }
  3219. that._removeClass( "ui-resizable-autohide" );
  3220. that._handles.show();
  3221. } )
  3222. .on( "mouseleave", function() {
  3223. if ( o.disabled ) {
  3224. return;
  3225. }
  3226. if ( !that.resizing ) {
  3227. that._addClass( "ui-resizable-autohide" );
  3228. that._handles.hide();
  3229. }
  3230. } );
  3231. }
  3232. this._mouseInit();
  3233. },
  3234. _destroy: function() {
  3235. this._mouseDestroy();
  3236. this._addedHandles.remove();
  3237. var wrapper,
  3238. _destroy = function( exp ) {
  3239. $( exp )
  3240. .removeData( "resizable" )
  3241. .removeData( "ui-resizable" )
  3242. .off( ".resizable" );
  3243. };
  3244. // TODO: Unwrap at same DOM position
  3245. if ( this.elementIsWrapper ) {
  3246. _destroy( this.element );
  3247. wrapper = this.element;
  3248. this.originalElement.css( {
  3249. position: wrapper.css( "position" ),
  3250. width: wrapper.outerWidth(),
  3251. height: wrapper.outerHeight(),
  3252. top: wrapper.css( "top" ),
  3253. left: wrapper.css( "left" )
  3254. } ).insertAfter( wrapper );
  3255. wrapper.remove();
  3256. }
  3257. this.originalElement.css( "resize", this.originalResizeStyle );
  3258. _destroy( this.originalElement );
  3259. return this;
  3260. },
  3261. _setOption: function( key, value ) {
  3262. this._super( key, value );
  3263. switch ( key ) {
  3264. case "handles":
  3265. this._removeHandles();
  3266. this._setupHandles();
  3267. break;
  3268. case "aspectRatio":
  3269. this._aspectRatio = !!value;
  3270. break;
  3271. default:
  3272. break;
  3273. }
  3274. },
  3275. _setupHandles: function() {
  3276. var o = this.options, handle, i, n, hname, axis, that = this;
  3277. this.handles = o.handles ||
  3278. ( !$( ".ui-resizable-handle", this.element ).length ?
  3279. "e,s,se" : {
  3280. n: ".ui-resizable-n",
  3281. e: ".ui-resizable-e",
  3282. s: ".ui-resizable-s",
  3283. w: ".ui-resizable-w",
  3284. se: ".ui-resizable-se",
  3285. sw: ".ui-resizable-sw",
  3286. ne: ".ui-resizable-ne",
  3287. nw: ".ui-resizable-nw"
  3288. } );
  3289. this._handles = $();
  3290. this._addedHandles = $();
  3291. if ( this.handles.constructor === String ) {
  3292. if ( this.handles === "all" ) {
  3293. this.handles = "n,e,s,w,se,sw,ne,nw";
  3294. }
  3295. n = this.handles.split( "," );
  3296. this.handles = {};
  3297. for ( i = 0; i < n.length; i++ ) {
  3298. handle = String.prototype.trim.call( n[ i ] );
  3299. hname = "ui-resizable-" + handle;
  3300. axis = $( "<div>" );
  3301. this._addClass( axis, "ui-resizable-handle " + hname );
  3302. axis.css( { zIndex: o.zIndex } );
  3303. this.handles[ handle ] = ".ui-resizable-" + handle;
  3304. if ( !this.element.children( this.handles[ handle ] ).length ) {
  3305. this.element.append( axis );
  3306. this._addedHandles = this._addedHandles.add( axis );
  3307. }
  3308. }
  3309. }
  3310. this._renderAxis = function( target ) {
  3311. var i, axis, padPos, padWrapper;
  3312. target = target || this.element;
  3313. for ( i in this.handles ) {
  3314. if ( this.handles[ i ].constructor === String ) {
  3315. this.handles[ i ] = this.element.children( this.handles[ i ] ).first().show();
  3316. } else if ( this.handles[ i ].jquery || this.handles[ i ].nodeType ) {
  3317. this.handles[ i ] = $( this.handles[ i ] );
  3318. this._on( this.handles[ i ], { "mousedown": that._mouseDown } );
  3319. }
  3320. if ( this.elementIsWrapper &&
  3321. this.originalElement[ 0 ]
  3322. .nodeName
  3323. .match( /^(textarea|input|select|button)$/i ) ) {
  3324. axis = $( this.handles[ i ], this.element );
  3325. padWrapper = /sw|ne|nw|se|n|s/.test( i ) ?
  3326. axis.outerHeight() :
  3327. axis.outerWidth();
  3328. padPos = [ "padding",
  3329. /ne|nw|n/.test( i ) ? "Top" :
  3330. /se|sw|s/.test( i ) ? "Bottom" :
  3331. /^e$/.test( i ) ? "Right" : "Left" ].join( "" );
  3332. target.css( padPos, padWrapper );
  3333. this._proportionallyResize();
  3334. }
  3335. this._handles = this._handles.add( this.handles[ i ] );
  3336. }
  3337. };
  3338. // TODO: make renderAxis a prototype function
  3339. this._renderAxis( this.element );
  3340. this._handles = this._handles.add( this.element.find( ".ui-resizable-handle" ) );
  3341. this._handles.disableSelection();
  3342. this._handles.on( "mouseover", function() {
  3343. if ( !that.resizing ) {
  3344. if ( this.className ) {
  3345. axis = this.className.match( /ui-resizable-(se|sw|ne|nw|n|e|s|w)/i );
  3346. }
  3347. that.axis = axis && axis[ 1 ] ? axis[ 1 ] : "se";
  3348. }
  3349. } );
  3350. if ( o.autoHide ) {
  3351. this._handles.hide();
  3352. this._addClass( "ui-resizable-autohide" );
  3353. }
  3354. },
  3355. _removeHandles: function() {
  3356. this._addedHandles.remove();
  3357. },
  3358. _mouseCapture: function( event ) {
  3359. var i, handle,
  3360. capture = false;
  3361. for ( i in this.handles ) {
  3362. handle = $( this.handles[ i ] )[ 0 ];
  3363. if ( handle === event.target || $.contains( handle, event.target ) ) {
  3364. capture = true;
  3365. }
  3366. }
  3367. return !this.options.disabled && capture;
  3368. },
  3369. _mouseStart: function( event ) {
  3370. var curleft, curtop, cursor,
  3371. o = this.options,
  3372. el = this.element;
  3373. this.resizing = true;
  3374. this._renderProxy();
  3375. curleft = this._num( this.helper.css( "left" ) );
  3376. curtop = this._num( this.helper.css( "top" ) );
  3377. if ( o.containment ) {
  3378. curleft += $( o.containment ).scrollLeft() || 0;
  3379. curtop += $( o.containment ).scrollTop() || 0;
  3380. }
  3381. this.offset = this.helper.offset();
  3382. this.position = { left: curleft, top: curtop };
  3383. this.size = this._helper ? {
  3384. width: this.helper.width(),
  3385. height: this.helper.height()
  3386. } : {
  3387. width: el.width(),
  3388. height: el.height()
  3389. };
  3390. this.originalSize = this._helper ? {
  3391. width: el.outerWidth(),
  3392. height: el.outerHeight()
  3393. } : {
  3394. width: el.width(),
  3395. height: el.height()
  3396. };
  3397. this.sizeDiff = {
  3398. width: el.outerWidth() - el.width(),
  3399. height: el.outerHeight() - el.height()
  3400. };
  3401. this.originalPosition = { left: curleft, top: curtop };
  3402. this.originalMousePosition = { left: event.pageX, top: event.pageY };
  3403. this.aspectRatio = ( typeof o.aspectRatio === "number" ) ?
  3404. o.aspectRatio :
  3405. ( ( this.originalSize.width / this.originalSize.height ) || 1 );
  3406. cursor = $( ".ui-resizable-" + this.axis ).css( "cursor" );
  3407. $( "body" ).css( "cursor", cursor === "auto" ? this.axis + "-resize" : cursor );
  3408. this._addClass( "ui-resizable-resizing" );
  3409. this._propagate( "start", event );
  3410. return true;
  3411. },
  3412. _mouseDrag: function( event ) {
  3413. var data, props,
  3414. smp = this.originalMousePosition,
  3415. a = this.axis,
  3416. dx = ( event.pageX - smp.left ) || 0,
  3417. dy = ( event.pageY - smp.top ) || 0,
  3418. trigger = this._change[ a ];
  3419. this._updatePrevProperties();
  3420. if ( !trigger ) {
  3421. return false;
  3422. }
  3423. data = trigger.apply( this, [ event, dx, dy ] );
  3424. this._updateVirtualBoundaries( event.shiftKey );
  3425. if ( this._aspectRatio || event.shiftKey ) {
  3426. data = this._updateRatio( data, event );
  3427. }
  3428. data = this._respectSize( data, event );
  3429. this._updateCache( data );
  3430. this._propagate( "resize", event );
  3431. props = this._applyChanges();
  3432. if ( !this._helper && this._proportionallyResizeElements.length ) {
  3433. this._proportionallyResize();
  3434. }
  3435. if ( !$.isEmptyObject( props ) ) {
  3436. this._updatePrevProperties();
  3437. this._trigger( "resize", event, this.ui() );
  3438. this._applyChanges();
  3439. }
  3440. return false;
  3441. },
  3442. _mouseStop: function( event ) {
  3443. this.resizing = false;
  3444. var pr, ista, soffseth, soffsetw, s, left, top,
  3445. o = this.options, that = this;
  3446. if ( this._helper ) {
  3447. pr = this._proportionallyResizeElements;
  3448. ista = pr.length && ( /textarea/i ).test( pr[ 0 ].nodeName );
  3449. soffseth = ista && this._hasScroll( pr[ 0 ], "left" ) ? 0 : that.sizeDiff.height;
  3450. soffsetw = ista ? 0 : that.sizeDiff.width;
  3451. s = {
  3452. width: ( that.helper.width() - soffsetw ),
  3453. height: ( that.helper.height() - soffseth )
  3454. };
  3455. left = ( parseFloat( that.element.css( "left" ) ) +
  3456. ( that.position.left - that.originalPosition.left ) ) || null;
  3457. top = ( parseFloat( that.element.css( "top" ) ) +
  3458. ( that.position.top - that.originalPosition.top ) ) || null;
  3459. if ( !o.animate ) {
  3460. this.element.css( $.extend( s, { top: top, left: left } ) );
  3461. }
  3462. that.helper.height( that.size.height );
  3463. that.helper.width( that.size.width );
  3464. if ( this._helper && !o.animate ) {
  3465. this._proportionallyResize();
  3466. }
  3467. }
  3468. $( "body" ).css( "cursor", "auto" );
  3469. this._removeClass( "ui-resizable-resizing" );
  3470. this._propagate( "stop", event );
  3471. if ( this._helper ) {
  3472. this.helper.remove();
  3473. }
  3474. return false;
  3475. },
  3476. _updatePrevProperties: function() {
  3477. this.prevPosition = {
  3478. top: this.position.top,
  3479. left: this.position.left
  3480. };
  3481. this.prevSize = {
  3482. width: this.size.width,
  3483. height: this.size.height
  3484. };
  3485. },
  3486. _applyChanges: function() {
  3487. var props = {};
  3488. if ( this.position.top !== this.prevPosition.top ) {
  3489. props.top = this.position.top + "px";
  3490. }
  3491. if ( this.position.left !== this.prevPosition.left ) {
  3492. props.left = this.position.left + "px";
  3493. }
  3494. if ( this.size.width !== this.prevSize.width ) {
  3495. props.width = this.size.width + "px";
  3496. }
  3497. if ( this.size.height !== this.prevSize.height ) {
  3498. props.height = this.size.height + "px";
  3499. }
  3500. this.helper.css( props );
  3501. return props;
  3502. },
  3503. _updateVirtualBoundaries: function( forceAspectRatio ) {
  3504. var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b,
  3505. o = this.options;
  3506. b = {
  3507. minWidth: this._isNumber( o.minWidth ) ? o.minWidth : 0,
  3508. maxWidth: this._isNumber( o.maxWidth ) ? o.maxWidth : Infinity,
  3509. minHeight: this._isNumber( o.minHeight ) ? o.minHeight : 0,
  3510. maxHeight: this._isNumber( o.maxHeight ) ? o.maxHeight : Infinity
  3511. };
  3512. if ( this._aspectRatio || forceAspectRatio ) {
  3513. pMinWidth = b.minHeight * this.aspectRatio;
  3514. pMinHeight = b.minWidth / this.aspectRatio;
  3515. pMaxWidth = b.maxHeight * this.aspectRatio;
  3516. pMaxHeight = b.maxWidth / this.aspectRatio;
  3517. if ( pMinWidth > b.minWidth ) {
  3518. b.minWidth = pMinWidth;
  3519. }
  3520. if ( pMinHeight > b.minHeight ) {
  3521. b.minHeight = pMinHeight;
  3522. }
  3523. if ( pMaxWidth < b.maxWidth ) {
  3524. b.maxWidth = pMaxWidth;
  3525. }
  3526. if ( pMaxHeight < b.maxHeight ) {
  3527. b.maxHeight = pMaxHeight;
  3528. }
  3529. }
  3530. this._vBoundaries = b;
  3531. },
  3532. _updateCache: function( data ) {
  3533. this.offset = this.helper.offset();
  3534. if ( this._isNumber( data.left ) ) {
  3535. this.position.left = data.left;
  3536. }
  3537. if ( this._isNumber( data.top ) ) {
  3538. this.position.top = data.top;
  3539. }
  3540. if ( this._isNumber( data.height ) ) {
  3541. this.size.height = data.height;
  3542. }
  3543. if ( this._isNumber( data.width ) ) {
  3544. this.size.width = data.width;
  3545. }
  3546. },
  3547. _updateRatio: function( data ) {
  3548. var cpos = this.position,
  3549. csize = this.size,
  3550. a = this.axis;
  3551. if ( this._isNumber( data.height ) ) {
  3552. data.width = ( data.height * this.aspectRatio );
  3553. } else if ( this._isNumber( data.width ) ) {
  3554. data.height = ( data.width / this.aspectRatio );
  3555. }
  3556. if ( a === "sw" ) {
  3557. data.left = cpos.left + ( csize.width - data.width );
  3558. data.top = null;
  3559. }
  3560. if ( a === "nw" ) {
  3561. data.top = cpos.top + ( csize.height - data.height );
  3562. data.left = cpos.left + ( csize.width - data.width );
  3563. }
  3564. return data;
  3565. },
  3566. _respectSize: function( data ) {
  3567. var o = this._vBoundaries,
  3568. a = this.axis,
  3569. ismaxw = this._isNumber( data.width ) && o.maxWidth && ( o.maxWidth < data.width ),
  3570. ismaxh = this._isNumber( data.height ) && o.maxHeight && ( o.maxHeight < data.height ),
  3571. isminw = this._isNumber( data.width ) && o.minWidth && ( o.minWidth > data.width ),
  3572. isminh = this._isNumber( data.height ) && o.minHeight && ( o.minHeight > data.height ),
  3573. dw = this.originalPosition.left + this.originalSize.width,
  3574. dh = this.originalPosition.top + this.originalSize.height,
  3575. cw = /sw|nw|w/.test( a ), ch = /nw|ne|n/.test( a );
  3576. if ( isminw ) {
  3577. data.width = o.minWidth;
  3578. }
  3579. if ( isminh ) {
  3580. data.height = o.minHeight;
  3581. }
  3582. if ( ismaxw ) {
  3583. data.width = o.maxWidth;
  3584. }
  3585. if ( ismaxh ) {
  3586. data.height = o.maxHeight;
  3587. }
  3588. if ( isminw && cw ) {
  3589. data.left = dw - o.minWidth;
  3590. }
  3591. if ( ismaxw && cw ) {
  3592. data.left = dw - o.maxWidth;
  3593. }
  3594. if ( isminh && ch ) {
  3595. data.top = dh - o.minHeight;
  3596. }
  3597. if ( ismaxh && ch ) {
  3598. data.top = dh - o.maxHeight;
  3599. }
  3600. // Fixing jump error on top/left - bug #2330
  3601. if ( !data.width && !data.height && !data.left && data.top ) {
  3602. data.top = null;
  3603. } else if ( !data.width && !data.height && !data.top && data.left ) {
  3604. data.left = null;
  3605. }
  3606. return data;
  3607. },
  3608. _getPaddingPlusBorderDimensions: function( element ) {
  3609. var i = 0,
  3610. widths = [],
  3611. borders = [
  3612. element.css( "borderTopWidth" ),
  3613. element.css( "borderRightWidth" ),
  3614. element.css( "borderBottomWidth" ),
  3615. element.css( "borderLeftWidth" )
  3616. ],
  3617. paddings = [
  3618. element.css( "paddingTop" ),
  3619. element.css( "paddingRight" ),
  3620. element.css( "paddingBottom" ),
  3621. element.css( "paddingLeft" )
  3622. ];
  3623. for ( ; i < 4; i++ ) {
  3624. widths[ i ] = ( parseFloat( borders[ i ] ) || 0 );
  3625. widths[ i ] += ( parseFloat( paddings[ i ] ) || 0 );
  3626. }
  3627. return {
  3628. height: widths[ 0 ] + widths[ 2 ],
  3629. width: widths[ 1 ] + widths[ 3 ]
  3630. };
  3631. },
  3632. _proportionallyResize: function() {
  3633. if ( !this._proportionallyResizeElements.length ) {
  3634. return;
  3635. }
  3636. var prel,
  3637. i = 0,
  3638. element = this.helper || this.element;
  3639. for ( ; i < this._proportionallyResizeElements.length; i++ ) {
  3640. prel = this._proportionallyResizeElements[ i ];
  3641. // TODO: Seems like a bug to cache this.outerDimensions
  3642. // considering that we are in a loop.
  3643. if ( !this.outerDimensions ) {
  3644. this.outerDimensions = this._getPaddingPlusBorderDimensions( prel );
  3645. }
  3646. prel.css( {
  3647. height: ( element.height() - this.outerDimensions.height ) || 0,
  3648. width: ( element.width() - this.outerDimensions.width ) || 0
  3649. } );
  3650. }
  3651. },
  3652. _renderProxy: function() {
  3653. var el = this.element, o = this.options;
  3654. this.elementOffset = el.offset();
  3655. if ( this._helper ) {
  3656. this.helper = this.helper || $( "<div></div>" ).css( { overflow: "hidden" } );
  3657. this._addClass( this.helper, this._helper );
  3658. this.helper.css( {
  3659. width: this.element.outerWidth(),
  3660. height: this.element.outerHeight(),
  3661. position: "absolute",
  3662. left: this.elementOffset.left + "px",
  3663. top: this.elementOffset.top + "px",
  3664. zIndex: ++o.zIndex //TODO: Don't modify option
  3665. } );
  3666. this.helper
  3667. .appendTo( "body" )
  3668. .disableSelection();
  3669. } else {
  3670. this.helper = this.element;
  3671. }
  3672. },
  3673. _change: {
  3674. e: function( event, dx ) {
  3675. return { width: this.originalSize.width + dx };
  3676. },
  3677. w: function( event, dx ) {
  3678. var cs = this.originalSize, sp = this.originalPosition;
  3679. return { left: sp.left + dx, width: cs.width - dx };
  3680. },
  3681. n: function( event, dx, dy ) {
  3682. var cs = this.originalSize, sp = this.originalPosition;
  3683. return { top: sp.top + dy, height: cs.height - dy };
  3684. },
  3685. s: function( event, dx, dy ) {
  3686. return { height: this.originalSize.height + dy };
  3687. },
  3688. se: function( event, dx, dy ) {
  3689. return $.extend( this._change.s.apply( this, arguments ),
  3690. this._change.e.apply( this, [ event, dx, dy ] ) );
  3691. },
  3692. sw: function( event, dx, dy ) {
  3693. return $.extend( this._change.s.apply( this, arguments ),
  3694. this._change.w.apply( this, [ event, dx, dy ] ) );
  3695. },
  3696. ne: function( event, dx, dy ) {
  3697. return $.extend( this._change.n.apply( this, arguments ),
  3698. this._change.e.apply( this, [ event, dx, dy ] ) );
  3699. },
  3700. nw: function( event, dx, dy ) {
  3701. return $.extend( this._change.n.apply( this, arguments ),
  3702. this._change.w.apply( this, [ event, dx, dy ] ) );
  3703. }
  3704. },
  3705. _propagate: function( n, event ) {
  3706. $.ui.plugin.call( this, n, [ event, this.ui() ] );
  3707. if ( n !== "resize" ) {
  3708. this._trigger( n, event, this.ui() );
  3709. }
  3710. },
  3711. plugins: {},
  3712. ui: function() {
  3713. return {
  3714. originalElement: this.originalElement,
  3715. element: this.element,
  3716. helper: this.helper,
  3717. position: this.position,
  3718. size: this.size,
  3719. originalSize: this.originalSize,
  3720. originalPosition: this.originalPosition
  3721. };
  3722. }
  3723. } );
  3724. /*
  3725. * Resizable Extensions
  3726. */
  3727. $.ui.plugin.add( "resizable", "animate", {
  3728. stop: function( event ) {
  3729. var that = $( this ).resizable( "instance" ),
  3730. o = that.options,
  3731. pr = that._proportionallyResizeElements,
  3732. ista = pr.length && ( /textarea/i ).test( pr[ 0 ].nodeName ),
  3733. soffseth = ista && that._hasScroll( pr[ 0 ], "left" ) ? 0 : that.sizeDiff.height,
  3734. soffsetw = ista ? 0 : that.sizeDiff.width,
  3735. style = {
  3736. width: ( that.size.width - soffsetw ),
  3737. height: ( that.size.height - soffseth )
  3738. },
  3739. left = ( parseFloat( that.element.css( "left" ) ) +
  3740. ( that.position.left - that.originalPosition.left ) ) || null,
  3741. top = ( parseFloat( that.element.css( "top" ) ) +
  3742. ( that.position.top - that.originalPosition.top ) ) || null;
  3743. that.element.animate(
  3744. $.extend( style, top && left ? { top: top, left: left } : {} ), {
  3745. duration: o.animateDuration,
  3746. easing: o.animateEasing,
  3747. step: function() {
  3748. var data = {
  3749. width: parseFloat( that.element.css( "width" ) ),
  3750. height: parseFloat( that.element.css( "height" ) ),
  3751. top: parseFloat( that.element.css( "top" ) ),
  3752. left: parseFloat( that.element.css( "left" ) )
  3753. };
  3754. if ( pr && pr.length ) {
  3755. $( pr[ 0 ] ).css( { width: data.width, height: data.height } );
  3756. }
  3757. // Propagating resize, and updating values for each animation step
  3758. that._updateCache( data );
  3759. that._propagate( "resize", event );
  3760. }
  3761. }
  3762. );
  3763. }
  3764. } );
  3765. $.ui.plugin.add( "resizable", "containment", {
  3766. start: function() {
  3767. var element, p, co, ch, cw, width, height,
  3768. that = $( this ).resizable( "instance" ),
  3769. o = that.options,
  3770. el = that.element,
  3771. oc = o.containment,
  3772. ce = ( oc instanceof $ ) ?
  3773. oc.get( 0 ) :
  3774. ( /parent/.test( oc ) ) ? el.parent().get( 0 ) : oc;
  3775. if ( !ce ) {
  3776. return;
  3777. }
  3778. that.containerElement = $( ce );
  3779. if ( /document/.test( oc ) || oc === document ) {
  3780. that.containerOffset = {
  3781. left: 0,
  3782. top: 0
  3783. };
  3784. that.containerPosition = {
  3785. left: 0,
  3786. top: 0
  3787. };
  3788. that.parentData = {
  3789. element: $( document ),
  3790. left: 0,
  3791. top: 0,
  3792. width: $( document ).width(),
  3793. height: $( document ).height() || document.body.parentNode.scrollHeight
  3794. };
  3795. } else {
  3796. element = $( ce );
  3797. p = [];
  3798. $( [ "Top", "Right", "Left", "Bottom" ] ).each( function( i, name ) {
  3799. p[ i ] = that._num( element.css( "padding" + name ) );
  3800. } );
  3801. that.containerOffset = element.offset();
  3802. that.containerPosition = element.position();
  3803. that.containerSize = {
  3804. height: ( element.innerHeight() - p[ 3 ] ),
  3805. width: ( element.innerWidth() - p[ 1 ] )
  3806. };
  3807. co = that.containerOffset;
  3808. ch = that.containerSize.height;
  3809. cw = that.containerSize.width;
  3810. width = ( that._hasScroll( ce, "left" ) ? ce.scrollWidth : cw );
  3811. height = ( that._hasScroll( ce ) ? ce.scrollHeight : ch );
  3812. that.parentData = {
  3813. element: ce,
  3814. left: co.left,
  3815. top: co.top,
  3816. width: width,
  3817. height: height
  3818. };
  3819. }
  3820. },
  3821. resize: function( event ) {
  3822. var woset, hoset, isParent, isOffsetRelative,
  3823. that = $( this ).resizable( "instance" ),
  3824. o = that.options,
  3825. co = that.containerOffset,
  3826. cp = that.position,
  3827. pRatio = that._aspectRatio || event.shiftKey,
  3828. cop = {
  3829. top: 0,
  3830. left: 0
  3831. },
  3832. ce = that.containerElement,
  3833. continueResize = true;
  3834. if ( ce[ 0 ] !== document && ( /static/ ).test( ce.css( "position" ) ) ) {
  3835. cop = co;
  3836. }
  3837. if ( cp.left < ( that._helper ? co.left : 0 ) ) {
  3838. that.size.width = that.size.width +
  3839. ( that._helper ?
  3840. ( that.position.left - co.left ) :
  3841. ( that.position.left - cop.left ) );
  3842. if ( pRatio ) {
  3843. that.size.height = that.size.width / that.aspectRatio;
  3844. continueResize = false;
  3845. }
  3846. that.position.left = o.helper ? co.left : 0;
  3847. }
  3848. if ( cp.top < ( that._helper ? co.top : 0 ) ) {
  3849. that.size.height = that.size.height +
  3850. ( that._helper ?
  3851. ( that.position.top - co.top ) :
  3852. that.position.top );
  3853. if ( pRatio ) {
  3854. that.size.width = that.size.height * that.aspectRatio;
  3855. continueResize = false;
  3856. }
  3857. that.position.top = that._helper ? co.top : 0;
  3858. }
  3859. isParent = that.containerElement.get( 0 ) === that.element.parent().get( 0 );
  3860. isOffsetRelative = /relative|absolute/.test( that.containerElement.css( "position" ) );
  3861. if ( isParent && isOffsetRelative ) {
  3862. that.offset.left = that.parentData.left + that.position.left;
  3863. that.offset.top = that.parentData.top + that.position.top;
  3864. } else {
  3865. that.offset.left = that.element.offset().left;
  3866. that.offset.top = that.element.offset().top;
  3867. }
  3868. woset = Math.abs( that.sizeDiff.width +
  3869. ( that._helper ?
  3870. that.offset.left - cop.left :
  3871. ( that.offset.left - co.left ) ) );
  3872. hoset = Math.abs( that.sizeDiff.height +
  3873. ( that._helper ?
  3874. that.offset.top - cop.top :
  3875. ( that.offset.top - co.top ) ) );
  3876. if ( woset + that.size.width >= that.parentData.width ) {
  3877. that.size.width = that.parentData.width - woset;
  3878. if ( pRatio ) {
  3879. that.size.height = that.size.width / that.aspectRatio;
  3880. continueResize = false;
  3881. }
  3882. }
  3883. if ( hoset + that.size.height >= that.parentData.height ) {
  3884. that.size.height = that.parentData.height - hoset;
  3885. if ( pRatio ) {
  3886. that.size.width = that.size.height * that.aspectRatio;
  3887. continueResize = false;
  3888. }
  3889. }
  3890. if ( !continueResize ) {
  3891. that.position.left = that.prevPosition.left;
  3892. that.position.top = that.prevPosition.top;
  3893. that.size.width = that.prevSize.width;
  3894. that.size.height = that.prevSize.height;
  3895. }
  3896. },
  3897. stop: function() {
  3898. var that = $( this ).resizable( "instance" ),
  3899. o = that.options,
  3900. co = that.containerOffset,
  3901. cop = that.containerPosition,
  3902. ce = that.containerElement,
  3903. helper = $( that.helper ),
  3904. ho = helper.offset(),
  3905. w = helper.outerWidth() - that.sizeDiff.width,
  3906. h = helper.outerHeight() - that.sizeDiff.height;
  3907. if ( that._helper && !o.animate && ( /relative/ ).test( ce.css( "position" ) ) ) {
  3908. $( this ).css( {
  3909. left: ho.left - cop.left - co.left,
  3910. width: w,
  3911. height: h
  3912. } );
  3913. }
  3914. if ( that._helper && !o.animate && ( /static/ ).test( ce.css( "position" ) ) ) {
  3915. $( this ).css( {
  3916. left: ho.left - cop.left - co.left,
  3917. width: w,
  3918. height: h
  3919. } );
  3920. }
  3921. }
  3922. } );
  3923. $.ui.plugin.add( "resizable", "alsoResize", {
  3924. start: function() {
  3925. var that = $( this ).resizable( "instance" ),
  3926. o = that.options;
  3927. $( o.alsoResize ).each( function() {
  3928. var el = $( this );
  3929. el.data( "ui-resizable-alsoresize", {
  3930. width: parseFloat( el.width() ), height: parseFloat( el.height() ),
  3931. left: parseFloat( el.css( "left" ) ), top: parseFloat( el.css( "top" ) )
  3932. } );
  3933. } );
  3934. },
  3935. resize: function( event, ui ) {
  3936. var that = $( this ).resizable( "instance" ),
  3937. o = that.options,
  3938. os = that.originalSize,
  3939. op = that.originalPosition,
  3940. delta = {
  3941. height: ( that.size.height - os.height ) || 0,
  3942. width: ( that.size.width - os.width ) || 0,
  3943. top: ( that.position.top - op.top ) || 0,
  3944. left: ( that.position.left - op.left ) || 0
  3945. };
  3946. $( o.alsoResize ).each( function() {
  3947. var el = $( this ), start = $( this ).data( "ui-resizable-alsoresize" ), style = {},
  3948. css = el.parents( ui.originalElement[ 0 ] ).length ?
  3949. [ "width", "height" ] :
  3950. [ "width", "height", "top", "left" ];
  3951. $.each( css, function( i, prop ) {
  3952. var sum = ( start[ prop ] || 0 ) + ( delta[ prop ] || 0 );
  3953. if ( sum && sum >= 0 ) {
  3954. style[ prop ] = sum || null;
  3955. }
  3956. } );
  3957. el.css( style );
  3958. } );
  3959. },
  3960. stop: function() {
  3961. $( this ).removeData( "ui-resizable-alsoresize" );
  3962. }
  3963. } );
  3964. $.ui.plugin.add( "resizable", "ghost", {
  3965. start: function() {
  3966. var that = $( this ).resizable( "instance" ), cs = that.size;
  3967. that.ghost = that.originalElement.clone();
  3968. that.ghost.css( {
  3969. opacity: 0.25,
  3970. display: "block",
  3971. position: "relative",
  3972. height: cs.height,
  3973. width: cs.width,
  3974. margin: 0,
  3975. left: 0,
  3976. top: 0
  3977. } );
  3978. that._addClass( that.ghost, "ui-resizable-ghost" );
  3979. // DEPRECATED
  3980. // TODO: remove after 1.12
  3981. if ( $.uiBackCompat !== false && typeof that.options.ghost === "string" ) {
  3982. // Ghost option
  3983. that.ghost.addClass( this.options.ghost );
  3984. }
  3985. that.ghost.appendTo( that.helper );
  3986. },
  3987. resize: function() {
  3988. var that = $( this ).resizable( "instance" );
  3989. if ( that.ghost ) {
  3990. that.ghost.css( {
  3991. position: "relative",
  3992. height: that.size.height,
  3993. width: that.size.width
  3994. } );
  3995. }
  3996. },
  3997. stop: function() {
  3998. var that = $( this ).resizable( "instance" );
  3999. if ( that.ghost && that.helper ) {
  4000. that.helper.get( 0 ).removeChild( that.ghost.get( 0 ) );
  4001. }
  4002. }
  4003. } );
  4004. $.ui.plugin.add( "resizable", "grid", {
  4005. resize: function() {
  4006. var outerDimensions,
  4007. that = $( this ).resizable( "instance" ),
  4008. o = that.options,
  4009. cs = that.size,
  4010. os = that.originalSize,
  4011. op = that.originalPosition,
  4012. a = that.axis,
  4013. grid = typeof o.grid === "number" ? [ o.grid, o.grid ] : o.grid,
  4014. gridX = ( grid[ 0 ] || 1 ),
  4015. gridY = ( grid[ 1 ] || 1 ),
  4016. ox = Math.round( ( cs.width - os.width ) / gridX ) * gridX,
  4017. oy = Math.round( ( cs.height - os.height ) / gridY ) * gridY,
  4018. newWidth = os.width + ox,
  4019. newHeight = os.height + oy,
  4020. isMaxWidth = o.maxWidth && ( o.maxWidth < newWidth ),
  4021. isMaxHeight = o.maxHeight && ( o.maxHeight < newHeight ),
  4022. isMinWidth = o.minWidth && ( o.minWidth > newWidth ),
  4023. isMinHeight = o.minHeight && ( o.minHeight > newHeight );
  4024. o.grid = grid;
  4025. if ( isMinWidth ) {
  4026. newWidth += gridX;
  4027. }
  4028. if ( isMinHeight ) {
  4029. newHeight += gridY;
  4030. }
  4031. if ( isMaxWidth ) {
  4032. newWidth -= gridX;
  4033. }
  4034. if ( isMaxHeight ) {
  4035. newHeight -= gridY;
  4036. }
  4037. if ( /^(se|s|e)$/.test( a ) ) {
  4038. that.size.width = newWidth;
  4039. that.size.height = newHeight;
  4040. } else if ( /^(ne)$/.test( a ) ) {
  4041. that.size.width = newWidth;
  4042. that.size.height = newHeight;
  4043. that.position.top = op.top - oy;
  4044. } else if ( /^(sw)$/.test( a ) ) {
  4045. that.size.width = newWidth;
  4046. that.size.height = newHeight;
  4047. that.position.left = op.left - ox;
  4048. } else {
  4049. if ( newHeight - gridY <= 0 || newWidth - gridX <= 0 ) {
  4050. outerDimensions = that._getPaddingPlusBorderDimensions( this );
  4051. }
  4052. if ( newHeight - gridY > 0 ) {
  4053. that.size.height = newHeight;
  4054. that.position.top = op.top - oy;
  4055. } else {
  4056. newHeight = gridY - outerDimensions.height;
  4057. that.size.height = newHeight;
  4058. that.position.top = op.top + os.height - newHeight;
  4059. }
  4060. if ( newWidth - gridX > 0 ) {
  4061. that.size.width = newWidth;
  4062. that.position.left = op.left - ox;
  4063. } else {
  4064. newWidth = gridX - outerDimensions.width;
  4065. that.size.width = newWidth;
  4066. that.position.left = op.left + os.width - newWidth;
  4067. }
  4068. }
  4069. }
  4070. } );
  4071. var widgetsResizable = $.ui.resizable;
  4072. /*!
  4073. * jQuery UI Selectable 1.13.0
  4074. * http://jqueryui.com
  4075. *
  4076. * Copyright jQuery Foundation and other contributors
  4077. * Released under the MIT license.
  4078. * http://jquery.org/license
  4079. */
  4080. //>>label: Selectable
  4081. //>>group: Interactions
  4082. //>>description: Allows groups of elements to be selected with the mouse.
  4083. //>>docs: http://api.jqueryui.com/selectable/
  4084. //>>demos: http://jqueryui.com/selectable/
  4085. //>>css.structure: ../../themes/base/selectable.css
  4086. var widgetsSelectable = $.widget( "ui.selectable", $.ui.mouse, {
  4087. version: "1.13.0",
  4088. options: {
  4089. appendTo: "body",
  4090. autoRefresh: true,
  4091. distance: 0,
  4092. filter: "*",
  4093. tolerance: "touch",
  4094. // Callbacks
  4095. selected: null,
  4096. selecting: null,
  4097. start: null,
  4098. stop: null,
  4099. unselected: null,
  4100. unselecting: null
  4101. },
  4102. _create: function() {
  4103. var that = this;
  4104. this._addClass( "ui-selectable" );
  4105. this.dragged = false;
  4106. // Cache selectee children based on filter
  4107. this.refresh = function() {
  4108. that.elementPos = $( that.element[ 0 ] ).offset();
  4109. that.selectees = $( that.options.filter, that.element[ 0 ] );
  4110. that._addClass( that.selectees, "ui-selectee" );
  4111. that.selectees.each( function() {
  4112. var $this = $( this ),
  4113. selecteeOffset = $this.offset(),
  4114. pos = {
  4115. left: selecteeOffset.left - that.elementPos.left,
  4116. top: selecteeOffset.top - that.elementPos.top
  4117. };
  4118. $.data( this, "selectable-item", {
  4119. element: this,
  4120. $element: $this,
  4121. left: pos.left,
  4122. top: pos.top,
  4123. right: pos.left + $this.outerWidth(),
  4124. bottom: pos.top + $this.outerHeight(),
  4125. startselected: false,
  4126. selected: $this.hasClass( "ui-selected" ),
  4127. selecting: $this.hasClass( "ui-selecting" ),
  4128. unselecting: $this.hasClass( "ui-unselecting" )
  4129. } );
  4130. } );
  4131. };
  4132. this.refresh();
  4133. this._mouseInit();
  4134. this.helper = $( "<div>" );
  4135. this._addClass( this.helper, "ui-selectable-helper" );
  4136. },
  4137. _destroy: function() {
  4138. this.selectees.removeData( "selectable-item" );
  4139. this._mouseDestroy();
  4140. },
  4141. _mouseStart: function( event ) {
  4142. var that = this,
  4143. options = this.options;
  4144. this.opos = [ event.pageX, event.pageY ];
  4145. this.elementPos = $( this.element[ 0 ] ).offset();
  4146. if ( this.options.disabled ) {
  4147. return;
  4148. }
  4149. this.selectees = $( options.filter, this.element[ 0 ] );
  4150. this._trigger( "start", event );
  4151. $( options.appendTo ).append( this.helper );
  4152. // position helper (lasso)
  4153. this.helper.css( {
  4154. "left": event.pageX,
  4155. "top": event.pageY,
  4156. "width": 0,
  4157. "height": 0
  4158. } );
  4159. if ( options.autoRefresh ) {
  4160. this.refresh();
  4161. }
  4162. this.selectees.filter( ".ui-selected" ).each( function() {
  4163. var selectee = $.data( this, "selectable-item" );
  4164. selectee.startselected = true;
  4165. if ( !event.metaKey && !event.ctrlKey ) {
  4166. that._removeClass( selectee.$element, "ui-selected" );
  4167. selectee.selected = false;
  4168. that._addClass( selectee.$element, "ui-unselecting" );
  4169. selectee.unselecting = true;
  4170. // selectable UNSELECTING callback
  4171. that._trigger( "unselecting", event, {
  4172. unselecting: selectee.element
  4173. } );
  4174. }
  4175. } );
  4176. $( event.target ).parents().addBack().each( function() {
  4177. var doSelect,
  4178. selectee = $.data( this, "selectable-item" );
  4179. if ( selectee ) {
  4180. doSelect = ( !event.metaKey && !event.ctrlKey ) ||
  4181. !selectee.$element.hasClass( "ui-selected" );
  4182. that._removeClass( selectee.$element, doSelect ? "ui-unselecting" : "ui-selected" )
  4183. ._addClass( selectee.$element, doSelect ? "ui-selecting" : "ui-unselecting" );
  4184. selectee.unselecting = !doSelect;
  4185. selectee.selecting = doSelect;
  4186. selectee.selected = doSelect;
  4187. // selectable (UN)SELECTING callback
  4188. if ( doSelect ) {
  4189. that._trigger( "selecting", event, {
  4190. selecting: selectee.element
  4191. } );
  4192. } else {
  4193. that._trigger( "unselecting", event, {
  4194. unselecting: selectee.element
  4195. } );
  4196. }
  4197. return false;
  4198. }
  4199. } );
  4200. },
  4201. _mouseDrag: function( event ) {
  4202. this.dragged = true;
  4203. if ( this.options.disabled ) {
  4204. return;
  4205. }
  4206. var tmp,
  4207. that = this,
  4208. options = this.options,
  4209. x1 = this.opos[ 0 ],
  4210. y1 = this.opos[ 1 ],
  4211. x2 = event.pageX,
  4212. y2 = event.pageY;
  4213. if ( x1 > x2 ) {
  4214. tmp = x2; x2 = x1; x1 = tmp;
  4215. }
  4216. if ( y1 > y2 ) {
  4217. tmp = y2; y2 = y1; y1 = tmp;
  4218. }
  4219. this.helper.css( { left: x1, top: y1, width: x2 - x1, height: y2 - y1 } );
  4220. this.selectees.each( function() {
  4221. var selectee = $.data( this, "selectable-item" ),
  4222. hit = false,
  4223. offset = {};
  4224. //prevent helper from being selected if appendTo: selectable
  4225. if ( !selectee || selectee.element === that.element[ 0 ] ) {
  4226. return;
  4227. }
  4228. offset.left = selectee.left + that.elementPos.left;
  4229. offset.right = selectee.right + that.elementPos.left;
  4230. offset.top = selectee.top + that.elementPos.top;
  4231. offset.bottom = selectee.bottom + that.elementPos.top;
  4232. if ( options.tolerance === "touch" ) {
  4233. hit = ( !( offset.left > x2 || offset.right < x1 || offset.top > y2 ||
  4234. offset.bottom < y1 ) );
  4235. } else if ( options.tolerance === "fit" ) {
  4236. hit = ( offset.left > x1 && offset.right < x2 && offset.top > y1 &&
  4237. offset.bottom < y2 );
  4238. }
  4239. if ( hit ) {
  4240. // SELECT
  4241. if ( selectee.selected ) {
  4242. that._removeClass( selectee.$element, "ui-selected" );
  4243. selectee.selected = false;
  4244. }
  4245. if ( selectee.unselecting ) {
  4246. that._removeClass( selectee.$element, "ui-unselecting" );
  4247. selectee.unselecting = false;
  4248. }
  4249. if ( !selectee.selecting ) {
  4250. that._addClass( selectee.$element, "ui-selecting" );
  4251. selectee.selecting = true;
  4252. // selectable SELECTING callback
  4253. that._trigger( "selecting", event, {
  4254. selecting: selectee.element
  4255. } );
  4256. }
  4257. } else {
  4258. // UNSELECT
  4259. if ( selectee.selecting ) {
  4260. if ( ( event.metaKey || event.ctrlKey ) && selectee.startselected ) {
  4261. that._removeClass( selectee.$element, "ui-selecting" );
  4262. selectee.selecting = false;
  4263. that._addClass( selectee.$element, "ui-selected" );
  4264. selectee.selected = true;
  4265. } else {
  4266. that._removeClass( selectee.$element, "ui-selecting" );
  4267. selectee.selecting = false;
  4268. if ( selectee.startselected ) {
  4269. that._addClass( selectee.$element, "ui-unselecting" );
  4270. selectee.unselecting = true;
  4271. }
  4272. // selectable UNSELECTING callback
  4273. that._trigger( "unselecting", event, {
  4274. unselecting: selectee.element
  4275. } );
  4276. }
  4277. }
  4278. if ( selectee.selected ) {
  4279. if ( !event.metaKey && !event.ctrlKey && !selectee.startselected ) {
  4280. that._removeClass( selectee.$element, "ui-selected" );
  4281. selectee.selected = false;
  4282. that._addClass( selectee.$element, "ui-unselecting" );
  4283. selectee.unselecting = true;
  4284. // selectable UNSELECTING callback
  4285. that._trigger( "unselecting", event, {
  4286. unselecting: selectee.element
  4287. } );
  4288. }
  4289. }
  4290. }
  4291. } );
  4292. return false;
  4293. },
  4294. _mouseStop: function( event ) {
  4295. var that = this;
  4296. this.dragged = false;
  4297. $( ".ui-unselecting", this.element[ 0 ] ).each( function() {
  4298. var selectee = $.data( this, "selectable-item" );
  4299. that._removeClass( selectee.$element, "ui-unselecting" );
  4300. selectee.unselecting = false;
  4301. selectee.startselected = false;
  4302. that._trigger( "unselected", event, {
  4303. unselected: selectee.element
  4304. } );
  4305. } );
  4306. $( ".ui-selecting", this.element[ 0 ] ).each( function() {
  4307. var selectee = $.data( this, "selectable-item" );
  4308. that._removeClass( selectee.$element, "ui-selecting" )
  4309. ._addClass( selectee.$element, "ui-selected" );
  4310. selectee.selecting = false;
  4311. selectee.selected = true;
  4312. selectee.startselected = true;
  4313. that._trigger( "selected", event, {
  4314. selected: selectee.element
  4315. } );
  4316. } );
  4317. this._trigger( "stop", event );
  4318. this.helper.remove();
  4319. return false;
  4320. }
  4321. } );
  4322. /*!
  4323. * jQuery UI Sortable 1.13.0
  4324. * http://jqueryui.com
  4325. *
  4326. * Copyright jQuery Foundation and other contributors
  4327. * Released under the MIT license.
  4328. * http://jquery.org/license
  4329. */
  4330. //>>label: Sortable
  4331. //>>group: Interactions
  4332. //>>description: Enables items in a list to be sorted using the mouse.
  4333. //>>docs: http://api.jqueryui.com/sortable/
  4334. //>>demos: http://jqueryui.com/sortable/
  4335. //>>css.structure: ../../themes/base/sortable.css
  4336. var widgetsSortable = $.widget( "ui.sortable", $.ui.mouse, {
  4337. version: "1.13.0",
  4338. widgetEventPrefix: "sort",
  4339. ready: false,
  4340. options: {
  4341. appendTo: "parent",
  4342. axis: false,
  4343. connectWith: false,
  4344. containment: false,
  4345. cursor: "auto",
  4346. cursorAt: false,
  4347. dropOnEmpty: true,
  4348. forcePlaceholderSize: false,
  4349. forceHelperSize: false,
  4350. grid: false,
  4351. handle: false,
  4352. helper: "original",
  4353. items: "> *",
  4354. opacity: false,
  4355. placeholder: false,
  4356. revert: false,
  4357. scroll: true,
  4358. scrollSensitivity: 20,
  4359. scrollSpeed: 20,
  4360. scope: "default",
  4361. tolerance: "intersect",
  4362. zIndex: 1000,
  4363. // Callbacks
  4364. activate: null,
  4365. beforeStop: null,
  4366. change: null,
  4367. deactivate: null,
  4368. out: null,
  4369. over: null,
  4370. receive: null,
  4371. remove: null,
  4372. sort: null,
  4373. start: null,
  4374. stop: null,
  4375. update: null
  4376. },
  4377. _isOverAxis: function( x, reference, size ) {
  4378. return ( x >= reference ) && ( x < ( reference + size ) );
  4379. },
  4380. _isFloating: function( item ) {
  4381. return ( /left|right/ ).test( item.css( "float" ) ) ||
  4382. ( /inline|table-cell/ ).test( item.css( "display" ) );
  4383. },
  4384. _create: function() {
  4385. this.containerCache = {};
  4386. this._addClass( "ui-sortable" );
  4387. //Get the items
  4388. this.refresh();
  4389. //Let's determine the parent's offset
  4390. this.offset = this.element.offset();
  4391. //Initialize mouse events for interaction
  4392. this._mouseInit();
  4393. this._setHandleClassName();
  4394. //We're ready to go
  4395. this.ready = true;
  4396. },
  4397. _setOption: function( key, value ) {
  4398. this._super( key, value );
  4399. if ( key === "handle" ) {
  4400. this._setHandleClassName();
  4401. }
  4402. },
  4403. _setHandleClassName: function() {
  4404. var that = this;
  4405. this._removeClass( this.element.find( ".ui-sortable-handle" ), "ui-sortable-handle" );
  4406. $.each( this.items, function() {
  4407. that._addClass(
  4408. this.instance.options.handle ?
  4409. this.item.find( this.instance.options.handle ) :
  4410. this.item,
  4411. "ui-sortable-handle"
  4412. );
  4413. } );
  4414. },
  4415. _destroy: function() {
  4416. this._mouseDestroy();
  4417. for ( var i = this.items.length - 1; i >= 0; i-- ) {
  4418. this.items[ i ].item.removeData( this.widgetName + "-item" );
  4419. }
  4420. return this;
  4421. },
  4422. _mouseCapture: function( event, overrideHandle ) {
  4423. var currentItem = null,
  4424. validHandle = false,
  4425. that = this;
  4426. if ( this.reverting ) {
  4427. return false;
  4428. }
  4429. if ( this.options.disabled || this.options.type === "static" ) {
  4430. return false;
  4431. }
  4432. //We have to refresh the items data once first
  4433. this._refreshItems( event );
  4434. //Find out if the clicked node (or one of its parents) is a actual item in this.items
  4435. $( event.target ).parents().each( function() {
  4436. if ( $.data( this, that.widgetName + "-item" ) === that ) {
  4437. currentItem = $( this );
  4438. return false;
  4439. }
  4440. } );
  4441. if ( $.data( event.target, that.widgetName + "-item" ) === that ) {
  4442. currentItem = $( event.target );
  4443. }
  4444. if ( !currentItem ) {
  4445. return false;
  4446. }
  4447. if ( this.options.handle && !overrideHandle ) {
  4448. $( this.options.handle, currentItem ).find( "*" ).addBack().each( function() {
  4449. if ( this === event.target ) {
  4450. validHandle = true;
  4451. }
  4452. } );
  4453. if ( !validHandle ) {
  4454. return false;
  4455. }
  4456. }
  4457. this.currentItem = currentItem;
  4458. this._removeCurrentsFromItems();
  4459. return true;
  4460. },
  4461. _mouseStart: function( event, overrideHandle, noActivation ) {
  4462. var i, body,
  4463. o = this.options;
  4464. this.currentContainer = this;
  4465. //We only need to call refreshPositions, because the refreshItems call has been moved to
  4466. // mouseCapture
  4467. this.refreshPositions();
  4468. //Prepare the dragged items parent
  4469. this.appendTo = $( o.appendTo !== "parent" ?
  4470. o.appendTo :
  4471. this.currentItem.parent() );
  4472. //Create and append the visible helper
  4473. this.helper = this._createHelper( event );
  4474. //Cache the helper size
  4475. this._cacheHelperProportions();
  4476. /*
  4477. * - Position generation -
  4478. * This block generates everything position related - it's the core of draggables.
  4479. */
  4480. //Cache the margins of the original element
  4481. this._cacheMargins();
  4482. //The element's absolute position on the page minus margins
  4483. this.offset = this.currentItem.offset();
  4484. this.offset = {
  4485. top: this.offset.top - this.margins.top,
  4486. left: this.offset.left - this.margins.left
  4487. };
  4488. $.extend( this.offset, {
  4489. click: { //Where the click happened, relative to the element
  4490. left: event.pageX - this.offset.left,
  4491. top: event.pageY - this.offset.top
  4492. },
  4493. // This is a relative to absolute position minus the actual position calculation -
  4494. // only used for relative positioned helper
  4495. relative: this._getRelativeOffset()
  4496. } );
  4497. // After we get the helper offset, but before we get the parent offset we can
  4498. // change the helper's position to absolute
  4499. // TODO: Still need to figure out a way to make relative sorting possible
  4500. this.helper.css( "position", "absolute" );
  4501. this.cssPosition = this.helper.css( "position" );
  4502. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  4503. if ( o.cursorAt ) {
  4504. this._adjustOffsetFromHelper( o.cursorAt );
  4505. }
  4506. //Cache the former DOM position
  4507. this.domPosition = {
  4508. prev: this.currentItem.prev()[ 0 ],
  4509. parent: this.currentItem.parent()[ 0 ]
  4510. };
  4511. // If the helper is not the original, hide the original so it's not playing any role during
  4512. // the drag, won't cause anything bad this way
  4513. if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) {
  4514. this.currentItem.hide();
  4515. }
  4516. //Create the placeholder
  4517. this._createPlaceholder();
  4518. //Get the next scrolling parent
  4519. this.scrollParent = this.placeholder.scrollParent();
  4520. $.extend( this.offset, {
  4521. parent: this._getParentOffset()
  4522. } );
  4523. //Set a containment if given in the options
  4524. if ( o.containment ) {
  4525. this._setContainment();
  4526. }
  4527. if ( o.cursor && o.cursor !== "auto" ) { // cursor option
  4528. body = this.document.find( "body" );
  4529. // Support: IE
  4530. this.storedCursor = body.css( "cursor" );
  4531. body.css( "cursor", o.cursor );
  4532. this.storedStylesheet =
  4533. $( "<style>*{ cursor: " + o.cursor + " !important; }</style>" ).appendTo( body );
  4534. }
  4535. // We need to make sure to grab the zIndex before setting the
  4536. // opacity, because setting the opacity to anything lower than 1
  4537. // causes the zIndex to change from "auto" to 0.
  4538. if ( o.zIndex ) { // zIndex option
  4539. if ( this.helper.css( "zIndex" ) ) {
  4540. this._storedZIndex = this.helper.css( "zIndex" );
  4541. }
  4542. this.helper.css( "zIndex", o.zIndex );
  4543. }
  4544. if ( o.opacity ) { // opacity option
  4545. if ( this.helper.css( "opacity" ) ) {
  4546. this._storedOpacity = this.helper.css( "opacity" );
  4547. }
  4548. this.helper.css( "opacity", o.opacity );
  4549. }
  4550. //Prepare scrolling
  4551. if ( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  4552. this.scrollParent[ 0 ].tagName !== "HTML" ) {
  4553. this.overflowOffset = this.scrollParent.offset();
  4554. }
  4555. //Call callbacks
  4556. this._trigger( "start", event, this._uiHash() );
  4557. //Recache the helper size
  4558. if ( !this._preserveHelperProportions ) {
  4559. this._cacheHelperProportions();
  4560. }
  4561. //Post "activate" events to possible containers
  4562. if ( !noActivation ) {
  4563. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  4564. this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
  4565. }
  4566. }
  4567. //Prepare possible droppables
  4568. if ( $.ui.ddmanager ) {
  4569. $.ui.ddmanager.current = this;
  4570. }
  4571. if ( $.ui.ddmanager && !o.dropBehaviour ) {
  4572. $.ui.ddmanager.prepareOffsets( this, event );
  4573. }
  4574. this.dragging = true;
  4575. this._addClass( this.helper, "ui-sortable-helper" );
  4576. //Move the helper, if needed
  4577. if ( !this.helper.parent().is( this.appendTo ) ) {
  4578. this.helper.detach().appendTo( this.appendTo );
  4579. //Update position
  4580. this.offset.parent = this._getParentOffset();
  4581. }
  4582. //Generate the original position
  4583. this.position = this.originalPosition = this._generatePosition( event );
  4584. this.originalPageX = event.pageX;
  4585. this.originalPageY = event.pageY;
  4586. this.lastPositionAbs = this.positionAbs = this._convertPositionTo( "absolute" );
  4587. this._mouseDrag( event );
  4588. return true;
  4589. },
  4590. _scroll: function( event ) {
  4591. var o = this.options,
  4592. scrolled = false;
  4593. if ( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  4594. this.scrollParent[ 0 ].tagName !== "HTML" ) {
  4595. if ( ( this.overflowOffset.top + this.scrollParent[ 0 ].offsetHeight ) -
  4596. event.pageY < o.scrollSensitivity ) {
  4597. this.scrollParent[ 0 ].scrollTop =
  4598. scrolled = this.scrollParent[ 0 ].scrollTop + o.scrollSpeed;
  4599. } else if ( event.pageY - this.overflowOffset.top < o.scrollSensitivity ) {
  4600. this.scrollParent[ 0 ].scrollTop =
  4601. scrolled = this.scrollParent[ 0 ].scrollTop - o.scrollSpeed;
  4602. }
  4603. if ( ( this.overflowOffset.left + this.scrollParent[ 0 ].offsetWidth ) -
  4604. event.pageX < o.scrollSensitivity ) {
  4605. this.scrollParent[ 0 ].scrollLeft = scrolled =
  4606. this.scrollParent[ 0 ].scrollLeft + o.scrollSpeed;
  4607. } else if ( event.pageX - this.overflowOffset.left < o.scrollSensitivity ) {
  4608. this.scrollParent[ 0 ].scrollLeft = scrolled =
  4609. this.scrollParent[ 0 ].scrollLeft - o.scrollSpeed;
  4610. }
  4611. } else {
  4612. if ( event.pageY - this.document.scrollTop() < o.scrollSensitivity ) {
  4613. scrolled = this.document.scrollTop( this.document.scrollTop() - o.scrollSpeed );
  4614. } else if ( this.window.height() - ( event.pageY - this.document.scrollTop() ) <
  4615. o.scrollSensitivity ) {
  4616. scrolled = this.document.scrollTop( this.document.scrollTop() + o.scrollSpeed );
  4617. }
  4618. if ( event.pageX - this.document.scrollLeft() < o.scrollSensitivity ) {
  4619. scrolled = this.document.scrollLeft(
  4620. this.document.scrollLeft() - o.scrollSpeed
  4621. );
  4622. } else if ( this.window.width() - ( event.pageX - this.document.scrollLeft() ) <
  4623. o.scrollSensitivity ) {
  4624. scrolled = this.document.scrollLeft(
  4625. this.document.scrollLeft() + o.scrollSpeed
  4626. );
  4627. }
  4628. }
  4629. return scrolled;
  4630. },
  4631. _mouseDrag: function( event ) {
  4632. var i, item, itemElement, intersection,
  4633. o = this.options;
  4634. //Compute the helpers position
  4635. this.position = this._generatePosition( event );
  4636. this.positionAbs = this._convertPositionTo( "absolute" );
  4637. //Set the helper position
  4638. if ( !this.options.axis || this.options.axis !== "y" ) {
  4639. this.helper[ 0 ].style.left = this.position.left + "px";
  4640. }
  4641. if ( !this.options.axis || this.options.axis !== "x" ) {
  4642. this.helper[ 0 ].style.top = this.position.top + "px";
  4643. }
  4644. //Post events to containers
  4645. this._contactContainers( event );
  4646. if ( this.innermostContainer !== null ) {
  4647. //Do scrolling
  4648. if ( o.scroll ) {
  4649. if ( this._scroll( event ) !== false ) {
  4650. //Update item positions used in position checks
  4651. this._refreshItemPositions( true );
  4652. if ( $.ui.ddmanager && !o.dropBehaviour ) {
  4653. $.ui.ddmanager.prepareOffsets( this, event );
  4654. }
  4655. }
  4656. }
  4657. this.dragDirection = {
  4658. vertical: this._getDragVerticalDirection(),
  4659. horizontal: this._getDragHorizontalDirection()
  4660. };
  4661. //Rearrange
  4662. for ( i = this.items.length - 1; i >= 0; i-- ) {
  4663. //Cache variables and intersection, continue if no intersection
  4664. item = this.items[ i ];
  4665. itemElement = item.item[ 0 ];
  4666. intersection = this._intersectsWithPointer( item );
  4667. if ( !intersection ) {
  4668. continue;
  4669. }
  4670. // Only put the placeholder inside the current Container, skip all
  4671. // items from other containers. This works because when moving
  4672. // an item from one container to another the
  4673. // currentContainer is switched before the placeholder is moved.
  4674. //
  4675. // Without this, moving items in "sub-sortables" can cause
  4676. // the placeholder to jitter between the outer and inner container.
  4677. if ( item.instance !== this.currentContainer ) {
  4678. continue;
  4679. }
  4680. // Cannot intersect with itself
  4681. // no useless actions that have been done before
  4682. // no action if the item moved is the parent of the item checked
  4683. if ( itemElement !== this.currentItem[ 0 ] &&
  4684. this.placeholder[ intersection === 1 ?
  4685. "next" : "prev" ]()[ 0 ] !== itemElement &&
  4686. !$.contains( this.placeholder[ 0 ], itemElement ) &&
  4687. ( this.options.type === "semi-dynamic" ?
  4688. !$.contains( this.element[ 0 ], itemElement ) :
  4689. true
  4690. )
  4691. ) {
  4692. this.direction = intersection === 1 ? "down" : "up";
  4693. if ( this.options.tolerance === "pointer" ||
  4694. this._intersectsWithSides( item ) ) {
  4695. this._rearrange( event, item );
  4696. } else {
  4697. break;
  4698. }
  4699. this._trigger( "change", event, this._uiHash() );
  4700. break;
  4701. }
  4702. }
  4703. }
  4704. //Interconnect with droppables
  4705. if ( $.ui.ddmanager ) {
  4706. $.ui.ddmanager.drag( this, event );
  4707. }
  4708. //Call callbacks
  4709. this._trigger( "sort", event, this._uiHash() );
  4710. this.lastPositionAbs = this.positionAbs;
  4711. return false;
  4712. },
  4713. _mouseStop: function( event, noPropagation ) {
  4714. if ( !event ) {
  4715. return;
  4716. }
  4717. //If we are using droppables, inform the manager about the drop
  4718. if ( $.ui.ddmanager && !this.options.dropBehaviour ) {
  4719. $.ui.ddmanager.drop( this, event );
  4720. }
  4721. if ( this.options.revert ) {
  4722. var that = this,
  4723. cur = this.placeholder.offset(),
  4724. axis = this.options.axis,
  4725. animation = {};
  4726. if ( !axis || axis === "x" ) {
  4727. animation.left = cur.left - this.offset.parent.left - this.margins.left +
  4728. ( this.offsetParent[ 0 ] === this.document[ 0 ].body ?
  4729. 0 :
  4730. this.offsetParent[ 0 ].scrollLeft
  4731. );
  4732. }
  4733. if ( !axis || axis === "y" ) {
  4734. animation.top = cur.top - this.offset.parent.top - this.margins.top +
  4735. ( this.offsetParent[ 0 ] === this.document[ 0 ].body ?
  4736. 0 :
  4737. this.offsetParent[ 0 ].scrollTop
  4738. );
  4739. }
  4740. this.reverting = true;
  4741. $( this.helper ).animate(
  4742. animation,
  4743. parseInt( this.options.revert, 10 ) || 500,
  4744. function() {
  4745. that._clear( event );
  4746. }
  4747. );
  4748. } else {
  4749. this._clear( event, noPropagation );
  4750. }
  4751. return false;
  4752. },
  4753. cancel: function() {
  4754. if ( this.dragging ) {
  4755. this._mouseUp( new $.Event( "mouseup", { target: null } ) );
  4756. if ( this.options.helper === "original" ) {
  4757. this.currentItem.css( this._storedCSS );
  4758. this._removeClass( this.currentItem, "ui-sortable-helper" );
  4759. } else {
  4760. this.currentItem.show();
  4761. }
  4762. //Post deactivating events to containers
  4763. for ( var i = this.containers.length - 1; i >= 0; i-- ) {
  4764. this.containers[ i ]._trigger( "deactivate", null, this._uiHash( this ) );
  4765. if ( this.containers[ i ].containerCache.over ) {
  4766. this.containers[ i ]._trigger( "out", null, this._uiHash( this ) );
  4767. this.containers[ i ].containerCache.over = 0;
  4768. }
  4769. }
  4770. }
  4771. if ( this.placeholder ) {
  4772. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately,
  4773. // it unbinds ALL events from the original node!
  4774. if ( this.placeholder[ 0 ].parentNode ) {
  4775. this.placeholder[ 0 ].parentNode.removeChild( this.placeholder[ 0 ] );
  4776. }
  4777. if ( this.options.helper !== "original" && this.helper &&
  4778. this.helper[ 0 ].parentNode ) {
  4779. this.helper.remove();
  4780. }
  4781. $.extend( this, {
  4782. helper: null,
  4783. dragging: false,
  4784. reverting: false,
  4785. _noFinalSort: null
  4786. } );
  4787. if ( this.domPosition.prev ) {
  4788. $( this.domPosition.prev ).after( this.currentItem );
  4789. } else {
  4790. $( this.domPosition.parent ).prepend( this.currentItem );
  4791. }
  4792. }
  4793. return this;
  4794. },
  4795. serialize: function( o ) {
  4796. var items = this._getItemsAsjQuery( o && o.connected ),
  4797. str = [];
  4798. o = o || {};
  4799. $( items ).each( function() {
  4800. var res = ( $( o.item || this ).attr( o.attribute || "id" ) || "" )
  4801. .match( o.expression || ( /(.+)[\-=_](.+)/ ) );
  4802. if ( res ) {
  4803. str.push(
  4804. ( o.key || res[ 1 ] + "[]" ) +
  4805. "=" + ( o.key && o.expression ? res[ 1 ] : res[ 2 ] ) );
  4806. }
  4807. } );
  4808. if ( !str.length && o.key ) {
  4809. str.push( o.key + "=" );
  4810. }
  4811. return str.join( "&" );
  4812. },
  4813. toArray: function( o ) {
  4814. var items = this._getItemsAsjQuery( o && o.connected ),
  4815. ret = [];
  4816. o = o || {};
  4817. items.each( function() {
  4818. ret.push( $( o.item || this ).attr( o.attribute || "id" ) || "" );
  4819. } );
  4820. return ret;
  4821. },
  4822. /* Be careful with the following core functions */
  4823. _intersectsWith: function( item ) {
  4824. var x1 = this.positionAbs.left,
  4825. x2 = x1 + this.helperProportions.width,
  4826. y1 = this.positionAbs.top,
  4827. y2 = y1 + this.helperProportions.height,
  4828. l = item.left,
  4829. r = l + item.width,
  4830. t = item.top,
  4831. b = t + item.height,
  4832. dyClick = this.offset.click.top,
  4833. dxClick = this.offset.click.left,
  4834. isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t &&
  4835. ( y1 + dyClick ) < b ),
  4836. isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l &&
  4837. ( x1 + dxClick ) < r ),
  4838. isOverElement = isOverElementHeight && isOverElementWidth;
  4839. if ( this.options.tolerance === "pointer" ||
  4840. this.options.forcePointerForContainers ||
  4841. ( this.options.tolerance !== "pointer" &&
  4842. this.helperProportions[ this.floating ? "width" : "height" ] >
  4843. item[ this.floating ? "width" : "height" ] )
  4844. ) {
  4845. return isOverElement;
  4846. } else {
  4847. return ( l < x1 + ( this.helperProportions.width / 2 ) && // Right Half
  4848. x2 - ( this.helperProportions.width / 2 ) < r && // Left Half
  4849. t < y1 + ( this.helperProportions.height / 2 ) && // Bottom Half
  4850. y2 - ( this.helperProportions.height / 2 ) < b ); // Top Half
  4851. }
  4852. },
  4853. _intersectsWithPointer: function( item ) {
  4854. var verticalDirection, horizontalDirection,
  4855. isOverElementHeight = ( this.options.axis === "x" ) ||
  4856. this._isOverAxis(
  4857. this.positionAbs.top + this.offset.click.top, item.top, item.height ),
  4858. isOverElementWidth = ( this.options.axis === "y" ) ||
  4859. this._isOverAxis(
  4860. this.positionAbs.left + this.offset.click.left, item.left, item.width ),
  4861. isOverElement = isOverElementHeight && isOverElementWidth;
  4862. if ( !isOverElement ) {
  4863. return false;
  4864. }
  4865. verticalDirection = this.dragDirection.vertical;
  4866. horizontalDirection = this.dragDirection.horizontal;
  4867. return this.floating ?
  4868. ( ( horizontalDirection === "right" || verticalDirection === "down" ) ? 2 : 1 ) :
  4869. ( verticalDirection && ( verticalDirection === "down" ? 2 : 1 ) );
  4870. },
  4871. _intersectsWithSides: function( item ) {
  4872. var isOverBottomHalf = this._isOverAxis( this.positionAbs.top +
  4873. this.offset.click.top, item.top + ( item.height / 2 ), item.height ),
  4874. isOverRightHalf = this._isOverAxis( this.positionAbs.left +
  4875. this.offset.click.left, item.left + ( item.width / 2 ), item.width ),
  4876. verticalDirection = this.dragDirection.vertical,
  4877. horizontalDirection = this.dragDirection.horizontal;
  4878. if ( this.floating && horizontalDirection ) {
  4879. return ( ( horizontalDirection === "right" && isOverRightHalf ) ||
  4880. ( horizontalDirection === "left" && !isOverRightHalf ) );
  4881. } else {
  4882. return verticalDirection && ( ( verticalDirection === "down" && isOverBottomHalf ) ||
  4883. ( verticalDirection === "up" && !isOverBottomHalf ) );
  4884. }
  4885. },
  4886. _getDragVerticalDirection: function() {
  4887. var delta = this.positionAbs.top - this.lastPositionAbs.top;
  4888. return delta !== 0 && ( delta > 0 ? "down" : "up" );
  4889. },
  4890. _getDragHorizontalDirection: function() {
  4891. var delta = this.positionAbs.left - this.lastPositionAbs.left;
  4892. return delta !== 0 && ( delta > 0 ? "right" : "left" );
  4893. },
  4894. refresh: function( event ) {
  4895. this._refreshItems( event );
  4896. this._setHandleClassName();
  4897. this.refreshPositions();
  4898. return this;
  4899. },
  4900. _connectWith: function() {
  4901. var options = this.options;
  4902. return options.connectWith.constructor === String ?
  4903. [ options.connectWith ] :
  4904. options.connectWith;
  4905. },
  4906. _getItemsAsjQuery: function( connected ) {
  4907. var i, j, cur, inst,
  4908. items = [],
  4909. queries = [],
  4910. connectWith = this._connectWith();
  4911. if ( connectWith && connected ) {
  4912. for ( i = connectWith.length - 1; i >= 0; i-- ) {
  4913. cur = $( connectWith[ i ], this.document[ 0 ] );
  4914. for ( j = cur.length - 1; j >= 0; j-- ) {
  4915. inst = $.data( cur[ j ], this.widgetFullName );
  4916. if ( inst && inst !== this && !inst.options.disabled ) {
  4917. queries.push( [ typeof inst.options.items === "function" ?
  4918. inst.options.items.call( inst.element ) :
  4919. $( inst.options.items, inst.element )
  4920. .not( ".ui-sortable-helper" )
  4921. .not( ".ui-sortable-placeholder" ), inst ] );
  4922. }
  4923. }
  4924. }
  4925. }
  4926. queries.push( [ typeof this.options.items === "function" ?
  4927. this.options.items
  4928. .call( this.element, null, { options: this.options, item: this.currentItem } ) :
  4929. $( this.options.items, this.element )
  4930. .not( ".ui-sortable-helper" )
  4931. .not( ".ui-sortable-placeholder" ), this ] );
  4932. function addItems() {
  4933. items.push( this );
  4934. }
  4935. for ( i = queries.length - 1; i >= 0; i-- ) {
  4936. queries[ i ][ 0 ].each( addItems );
  4937. }
  4938. return $( items );
  4939. },
  4940. _removeCurrentsFromItems: function() {
  4941. var list = this.currentItem.find( ":data(" + this.widgetName + "-item)" );
  4942. this.items = $.grep( this.items, function( item ) {
  4943. for ( var j = 0; j < list.length; j++ ) {
  4944. if ( list[ j ] === item.item[ 0 ] ) {
  4945. return false;
  4946. }
  4947. }
  4948. return true;
  4949. } );
  4950. },
  4951. _refreshItems: function( event ) {
  4952. this.items = [];
  4953. this.containers = [ this ];
  4954. var i, j, cur, inst, targetData, _queries, item, queriesLength,
  4955. items = this.items,
  4956. queries = [ [ typeof this.options.items === "function" ?
  4957. this.options.items.call( this.element[ 0 ], event, { item: this.currentItem } ) :
  4958. $( this.options.items, this.element ), this ] ],
  4959. connectWith = this._connectWith();
  4960. //Shouldn't be run the first time through due to massive slow-down
  4961. if ( connectWith && this.ready ) {
  4962. for ( i = connectWith.length - 1; i >= 0; i-- ) {
  4963. cur = $( connectWith[ i ], this.document[ 0 ] );
  4964. for ( j = cur.length - 1; j >= 0; j-- ) {
  4965. inst = $.data( cur[ j ], this.widgetFullName );
  4966. if ( inst && inst !== this && !inst.options.disabled ) {
  4967. queries.push( [ typeof inst.options.items === "function" ?
  4968. inst.options.items
  4969. .call( inst.element[ 0 ], event, { item: this.currentItem } ) :
  4970. $( inst.options.items, inst.element ), inst ] );
  4971. this.containers.push( inst );
  4972. }
  4973. }
  4974. }
  4975. }
  4976. for ( i = queries.length - 1; i >= 0; i-- ) {
  4977. targetData = queries[ i ][ 1 ];
  4978. _queries = queries[ i ][ 0 ];
  4979. for ( j = 0, queriesLength = _queries.length; j < queriesLength; j++ ) {
  4980. item = $( _queries[ j ] );
  4981. // Data for target checking (mouse manager)
  4982. item.data( this.widgetName + "-item", targetData );
  4983. items.push( {
  4984. item: item,
  4985. instance: targetData,
  4986. width: 0, height: 0,
  4987. left: 0, top: 0
  4988. } );
  4989. }
  4990. }
  4991. },
  4992. _refreshItemPositions: function( fast ) {
  4993. var i, item, t, p;
  4994. for ( i = this.items.length - 1; i >= 0; i-- ) {
  4995. item = this.items[ i ];
  4996. //We ignore calculating positions of all connected containers when we're not over them
  4997. if ( this.currentContainer && item.instance !== this.currentContainer &&
  4998. item.item[ 0 ] !== this.currentItem[ 0 ] ) {
  4999. continue;
  5000. }
  5001. t = this.options.toleranceElement ?
  5002. $( this.options.toleranceElement, item.item ) :
  5003. item.item;
  5004. if ( !fast ) {
  5005. item.width = t.outerWidth();
  5006. item.height = t.outerHeight();
  5007. }
  5008. p = t.offset();
  5009. item.left = p.left;
  5010. item.top = p.top;
  5011. }
  5012. },
  5013. refreshPositions: function( fast ) {
  5014. // Determine whether items are being displayed horizontally
  5015. this.floating = this.items.length ?
  5016. this.options.axis === "x" || this._isFloating( this.items[ 0 ].item ) :
  5017. false;
  5018. if ( this.innermostContainer !== null ) {
  5019. this._refreshItemPositions( fast );
  5020. }
  5021. var i, p;
  5022. if ( this.options.custom && this.options.custom.refreshContainers ) {
  5023. this.options.custom.refreshContainers.call( this );
  5024. } else {
  5025. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  5026. p = this.containers[ i ].element.offset();
  5027. this.containers[ i ].containerCache.left = p.left;
  5028. this.containers[ i ].containerCache.top = p.top;
  5029. this.containers[ i ].containerCache.width =
  5030. this.containers[ i ].element.outerWidth();
  5031. this.containers[ i ].containerCache.height =
  5032. this.containers[ i ].element.outerHeight();
  5033. }
  5034. }
  5035. return this;
  5036. },
  5037. _createPlaceholder: function( that ) {
  5038. that = that || this;
  5039. var className, nodeName,
  5040. o = that.options;
  5041. if ( !o.placeholder || o.placeholder.constructor === String ) {
  5042. className = o.placeholder;
  5043. nodeName = that.currentItem[ 0 ].nodeName.toLowerCase();
  5044. o.placeholder = {
  5045. element: function() {
  5046. var element = $( "<" + nodeName + ">", that.document[ 0 ] );
  5047. that._addClass( element, "ui-sortable-placeholder",
  5048. className || that.currentItem[ 0 ].className )
  5049. ._removeClass( element, "ui-sortable-helper" );
  5050. if ( nodeName === "tbody" ) {
  5051. that._createTrPlaceholder(
  5052. that.currentItem.find( "tr" ).eq( 0 ),
  5053. $( "<tr>", that.document[ 0 ] ).appendTo( element )
  5054. );
  5055. } else if ( nodeName === "tr" ) {
  5056. that._createTrPlaceholder( that.currentItem, element );
  5057. } else if ( nodeName === "img" ) {
  5058. element.attr( "src", that.currentItem.attr( "src" ) );
  5059. }
  5060. if ( !className ) {
  5061. element.css( "visibility", "hidden" );
  5062. }
  5063. return element;
  5064. },
  5065. update: function( container, p ) {
  5066. // 1. If a className is set as 'placeholder option, we don't force sizes -
  5067. // the class is responsible for that
  5068. // 2. The option 'forcePlaceholderSize can be enabled to force it even if a
  5069. // class name is specified
  5070. if ( className && !o.forcePlaceholderSize ) {
  5071. return;
  5072. }
  5073. // If the element doesn't have a actual height or width by itself (without
  5074. // styles coming from a stylesheet), it receives the inline height and width
  5075. // from the dragged item. Or, if it's a tbody or tr, it's going to have a height
  5076. // anyway since we're populating them with <td>s above, but they're unlikely to
  5077. // be the correct height on their own if the row heights are dynamic, so we'll
  5078. // always assign the height of the dragged item given forcePlaceholderSize
  5079. // is true.
  5080. if ( !p.height() || ( o.forcePlaceholderSize &&
  5081. ( nodeName === "tbody" || nodeName === "tr" ) ) ) {
  5082. p.height(
  5083. that.currentItem.innerHeight() -
  5084. parseInt( that.currentItem.css( "paddingTop" ) || 0, 10 ) -
  5085. parseInt( that.currentItem.css( "paddingBottom" ) || 0, 10 ) );
  5086. }
  5087. if ( !p.width() ) {
  5088. p.width(
  5089. that.currentItem.innerWidth() -
  5090. parseInt( that.currentItem.css( "paddingLeft" ) || 0, 10 ) -
  5091. parseInt( that.currentItem.css( "paddingRight" ) || 0, 10 ) );
  5092. }
  5093. }
  5094. };
  5095. }
  5096. //Create the placeholder
  5097. that.placeholder = $( o.placeholder.element.call( that.element, that.currentItem ) );
  5098. //Append it after the actual current item
  5099. that.currentItem.after( that.placeholder );
  5100. //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
  5101. o.placeholder.update( that, that.placeholder );
  5102. },
  5103. _createTrPlaceholder: function( sourceTr, targetTr ) {
  5104. var that = this;
  5105. sourceTr.children().each( function() {
  5106. $( "<td>&#160;</td>", that.document[ 0 ] )
  5107. .attr( "colspan", $( this ).attr( "colspan" ) || 1 )
  5108. .appendTo( targetTr );
  5109. } );
  5110. },
  5111. _contactContainers: function( event ) {
  5112. var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, cur, nearBottom,
  5113. floating, axis,
  5114. innermostContainer = null,
  5115. innermostIndex = null;
  5116. // Get innermost container that intersects with item
  5117. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  5118. // Never consider a container that's located within the item itself
  5119. if ( $.contains( this.currentItem[ 0 ], this.containers[ i ].element[ 0 ] ) ) {
  5120. continue;
  5121. }
  5122. if ( this._intersectsWith( this.containers[ i ].containerCache ) ) {
  5123. // If we've already found a container and it's more "inner" than this, then continue
  5124. if ( innermostContainer &&
  5125. $.contains(
  5126. this.containers[ i ].element[ 0 ],
  5127. innermostContainer.element[ 0 ] ) ) {
  5128. continue;
  5129. }
  5130. innermostContainer = this.containers[ i ];
  5131. innermostIndex = i;
  5132. } else {
  5133. // container doesn't intersect. trigger "out" event if necessary
  5134. if ( this.containers[ i ].containerCache.over ) {
  5135. this.containers[ i ]._trigger( "out", event, this._uiHash( this ) );
  5136. this.containers[ i ].containerCache.over = 0;
  5137. }
  5138. }
  5139. }
  5140. this.innermostContainer = innermostContainer;
  5141. // If no intersecting containers found, return
  5142. if ( !innermostContainer ) {
  5143. return;
  5144. }
  5145. // Move the item into the container if it's not there already
  5146. if ( this.containers.length === 1 ) {
  5147. if ( !this.containers[ innermostIndex ].containerCache.over ) {
  5148. this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash( this ) );
  5149. this.containers[ innermostIndex ].containerCache.over = 1;
  5150. }
  5151. } else {
  5152. // When entering a new container, we will find the item with the least distance and
  5153. // append our item near it
  5154. dist = 10000;
  5155. itemWithLeastDistance = null;
  5156. floating = innermostContainer.floating || this._isFloating( this.currentItem );
  5157. posProperty = floating ? "left" : "top";
  5158. sizeProperty = floating ? "width" : "height";
  5159. axis = floating ? "pageX" : "pageY";
  5160. for ( j = this.items.length - 1; j >= 0; j-- ) {
  5161. if ( !$.contains(
  5162. this.containers[ innermostIndex ].element[ 0 ], this.items[ j ].item[ 0 ] )
  5163. ) {
  5164. continue;
  5165. }
  5166. if ( this.items[ j ].item[ 0 ] === this.currentItem[ 0 ] ) {
  5167. continue;
  5168. }
  5169. cur = this.items[ j ].item.offset()[ posProperty ];
  5170. nearBottom = false;
  5171. if ( event[ axis ] - cur > this.items[ j ][ sizeProperty ] / 2 ) {
  5172. nearBottom = true;
  5173. }
  5174. if ( Math.abs( event[ axis ] - cur ) < dist ) {
  5175. dist = Math.abs( event[ axis ] - cur );
  5176. itemWithLeastDistance = this.items[ j ];
  5177. this.direction = nearBottom ? "up" : "down";
  5178. }
  5179. }
  5180. //Check if dropOnEmpty is enabled
  5181. if ( !itemWithLeastDistance && !this.options.dropOnEmpty ) {
  5182. return;
  5183. }
  5184. if ( this.currentContainer === this.containers[ innermostIndex ] ) {
  5185. if ( !this.currentContainer.containerCache.over ) {
  5186. this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash() );
  5187. this.currentContainer.containerCache.over = 1;
  5188. }
  5189. return;
  5190. }
  5191. if ( itemWithLeastDistance ) {
  5192. this._rearrange( event, itemWithLeastDistance, null, true );
  5193. } else {
  5194. this._rearrange( event, null, this.containers[ innermostIndex ].element, true );
  5195. }
  5196. this._trigger( "change", event, this._uiHash() );
  5197. this.containers[ innermostIndex ]._trigger( "change", event, this._uiHash( this ) );
  5198. this.currentContainer = this.containers[ innermostIndex ];
  5199. //Update the placeholder
  5200. this.options.placeholder.update( this.currentContainer, this.placeholder );
  5201. //Update scrollParent
  5202. this.scrollParent = this.placeholder.scrollParent();
  5203. //Update overflowOffset
  5204. if ( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  5205. this.scrollParent[ 0 ].tagName !== "HTML" ) {
  5206. this.overflowOffset = this.scrollParent.offset();
  5207. }
  5208. this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash( this ) );
  5209. this.containers[ innermostIndex ].containerCache.over = 1;
  5210. }
  5211. },
  5212. _createHelper: function( event ) {
  5213. var o = this.options,
  5214. helper = typeof o.helper === "function" ?
  5215. $( o.helper.apply( this.element[ 0 ], [ event, this.currentItem ] ) ) :
  5216. ( o.helper === "clone" ? this.currentItem.clone() : this.currentItem );
  5217. //Add the helper to the DOM if that didn't happen already
  5218. if ( !helper.parents( "body" ).length ) {
  5219. this.appendTo[ 0 ].appendChild( helper[ 0 ] );
  5220. }
  5221. if ( helper[ 0 ] === this.currentItem[ 0 ] ) {
  5222. this._storedCSS = {
  5223. width: this.currentItem[ 0 ].style.width,
  5224. height: this.currentItem[ 0 ].style.height,
  5225. position: this.currentItem.css( "position" ),
  5226. top: this.currentItem.css( "top" ),
  5227. left: this.currentItem.css( "left" )
  5228. };
  5229. }
  5230. if ( !helper[ 0 ].style.width || o.forceHelperSize ) {
  5231. helper.width( this.currentItem.width() );
  5232. }
  5233. if ( !helper[ 0 ].style.height || o.forceHelperSize ) {
  5234. helper.height( this.currentItem.height() );
  5235. }
  5236. return helper;
  5237. },
  5238. _adjustOffsetFromHelper: function( obj ) {
  5239. if ( typeof obj === "string" ) {
  5240. obj = obj.split( " " );
  5241. }
  5242. if ( Array.isArray( obj ) ) {
  5243. obj = { left: +obj[ 0 ], top: +obj[ 1 ] || 0 };
  5244. }
  5245. if ( "left" in obj ) {
  5246. this.offset.click.left = obj.left + this.margins.left;
  5247. }
  5248. if ( "right" in obj ) {
  5249. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  5250. }
  5251. if ( "top" in obj ) {
  5252. this.offset.click.top = obj.top + this.margins.top;
  5253. }
  5254. if ( "bottom" in obj ) {
  5255. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  5256. }
  5257. },
  5258. _getParentOffset: function() {
  5259. //Get the offsetParent and cache its position
  5260. this.offsetParent = this.helper.offsetParent();
  5261. var po = this.offsetParent.offset();
  5262. // This is a special case where we need to modify a offset calculated on start, since the
  5263. // following happened:
  5264. // 1. The position of the helper is absolute, so it's position is calculated based on the
  5265. // next positioned parent
  5266. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't
  5267. // the document, which means that the scroll is included in the initial calculation of the
  5268. // offset of the parent, and never recalculated upon drag
  5269. if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  5270. $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) {
  5271. po.left += this.scrollParent.scrollLeft();
  5272. po.top += this.scrollParent.scrollTop();
  5273. }
  5274. // This needs to be actually done for all browsers, since pageX/pageY includes this
  5275. // information with an ugly IE fix
  5276. if ( this.offsetParent[ 0 ] === this.document[ 0 ].body ||
  5277. ( this.offsetParent[ 0 ].tagName &&
  5278. this.offsetParent[ 0 ].tagName.toLowerCase() === "html" && $.ui.ie ) ) {
  5279. po = { top: 0, left: 0 };
  5280. }
  5281. return {
  5282. top: po.top + ( parseInt( this.offsetParent.css( "borderTopWidth" ), 10 ) || 0 ),
  5283. left: po.left + ( parseInt( this.offsetParent.css( "borderLeftWidth" ), 10 ) || 0 )
  5284. };
  5285. },
  5286. _getRelativeOffset: function() {
  5287. if ( this.cssPosition === "relative" ) {
  5288. var p = this.currentItem.position();
  5289. return {
  5290. top: p.top - ( parseInt( this.helper.css( "top" ), 10 ) || 0 ) +
  5291. this.scrollParent.scrollTop(),
  5292. left: p.left - ( parseInt( this.helper.css( "left" ), 10 ) || 0 ) +
  5293. this.scrollParent.scrollLeft()
  5294. };
  5295. } else {
  5296. return { top: 0, left: 0 };
  5297. }
  5298. },
  5299. _cacheMargins: function() {
  5300. this.margins = {
  5301. left: ( parseInt( this.currentItem.css( "marginLeft" ), 10 ) || 0 ),
  5302. top: ( parseInt( this.currentItem.css( "marginTop" ), 10 ) || 0 )
  5303. };
  5304. },
  5305. _cacheHelperProportions: function() {
  5306. this.helperProportions = {
  5307. width: this.helper.outerWidth(),
  5308. height: this.helper.outerHeight()
  5309. };
  5310. },
  5311. _setContainment: function() {
  5312. var ce, co, over,
  5313. o = this.options;
  5314. if ( o.containment === "parent" ) {
  5315. o.containment = this.helper[ 0 ].parentNode;
  5316. }
  5317. if ( o.containment === "document" || o.containment === "window" ) {
  5318. this.containment = [
  5319. 0 - this.offset.relative.left - this.offset.parent.left,
  5320. 0 - this.offset.relative.top - this.offset.parent.top,
  5321. o.containment === "document" ?
  5322. this.document.width() :
  5323. this.window.width() - this.helperProportions.width - this.margins.left,
  5324. ( o.containment === "document" ?
  5325. ( this.document.height() || document.body.parentNode.scrollHeight ) :
  5326. this.window.height() || this.document[ 0 ].body.parentNode.scrollHeight
  5327. ) - this.helperProportions.height - this.margins.top
  5328. ];
  5329. }
  5330. if ( !( /^(document|window|parent)$/ ).test( o.containment ) ) {
  5331. ce = $( o.containment )[ 0 ];
  5332. co = $( o.containment ).offset();
  5333. over = ( $( ce ).css( "overflow" ) !== "hidden" );
  5334. this.containment = [
  5335. co.left + ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) +
  5336. ( parseInt( $( ce ).css( "paddingLeft" ), 10 ) || 0 ) - this.margins.left,
  5337. co.top + ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) +
  5338. ( parseInt( $( ce ).css( "paddingTop" ), 10 ) || 0 ) - this.margins.top,
  5339. co.left + ( over ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) -
  5340. ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) -
  5341. ( parseInt( $( ce ).css( "paddingRight" ), 10 ) || 0 ) -
  5342. this.helperProportions.width - this.margins.left,
  5343. co.top + ( over ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) -
  5344. ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) -
  5345. ( parseInt( $( ce ).css( "paddingBottom" ), 10 ) || 0 ) -
  5346. this.helperProportions.height - this.margins.top
  5347. ];
  5348. }
  5349. },
  5350. _convertPositionTo: function( d, pos ) {
  5351. if ( !pos ) {
  5352. pos = this.position;
  5353. }
  5354. var mod = d === "absolute" ? 1 : -1,
  5355. scroll = this.cssPosition === "absolute" &&
  5356. !( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  5357. $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ?
  5358. this.offsetParent :
  5359. this.scrollParent,
  5360. scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName );
  5361. return {
  5362. top: (
  5363. // The absolute mouse position
  5364. pos.top +
  5365. // Only for relative positioned nodes: Relative offset from element to offset parent
  5366. this.offset.relative.top * mod +
  5367. // The offsetParent's offset without borders (offset + border)
  5368. this.offset.parent.top * mod -
  5369. ( ( this.cssPosition === "fixed" ?
  5370. -this.scrollParent.scrollTop() :
  5371. ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod )
  5372. ),
  5373. left: (
  5374. // The absolute mouse position
  5375. pos.left +
  5376. // Only for relative positioned nodes: Relative offset from element to offset parent
  5377. this.offset.relative.left * mod +
  5378. // The offsetParent's offset without borders (offset + border)
  5379. this.offset.parent.left * mod -
  5380. ( ( this.cssPosition === "fixed" ?
  5381. -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 :
  5382. scroll.scrollLeft() ) * mod )
  5383. )
  5384. };
  5385. },
  5386. _generatePosition: function( event ) {
  5387. var top, left,
  5388. o = this.options,
  5389. pageX = event.pageX,
  5390. pageY = event.pageY,
  5391. scroll = this.cssPosition === "absolute" &&
  5392. !( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  5393. $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ?
  5394. this.offsetParent :
  5395. this.scrollParent,
  5396. scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName );
  5397. // This is another very weird special case that only happens for relative elements:
  5398. // 1. If the css position is relative
  5399. // 2. and the scroll parent is the document or similar to the offset parent
  5400. // we have to refresh the relative offset during the scroll so there are no jumps
  5401. if ( this.cssPosition === "relative" && !( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  5402. this.scrollParent[ 0 ] !== this.offsetParent[ 0 ] ) ) {
  5403. this.offset.relative = this._getRelativeOffset();
  5404. }
  5405. /*
  5406. * - Position constraining -
  5407. * Constrain the position to a mix of grid, containment.
  5408. */
  5409. if ( this.originalPosition ) { //If we are not dragging yet, we won't check for options
  5410. if ( this.containment ) {
  5411. if ( event.pageX - this.offset.click.left < this.containment[ 0 ] ) {
  5412. pageX = this.containment[ 0 ] + this.offset.click.left;
  5413. }
  5414. if ( event.pageY - this.offset.click.top < this.containment[ 1 ] ) {
  5415. pageY = this.containment[ 1 ] + this.offset.click.top;
  5416. }
  5417. if ( event.pageX - this.offset.click.left > this.containment[ 2 ] ) {
  5418. pageX = this.containment[ 2 ] + this.offset.click.left;
  5419. }
  5420. if ( event.pageY - this.offset.click.top > this.containment[ 3 ] ) {
  5421. pageY = this.containment[ 3 ] + this.offset.click.top;
  5422. }
  5423. }
  5424. if ( o.grid ) {
  5425. top = this.originalPageY + Math.round( ( pageY - this.originalPageY ) /
  5426. o.grid[ 1 ] ) * o.grid[ 1 ];
  5427. pageY = this.containment ?
  5428. ( ( top - this.offset.click.top >= this.containment[ 1 ] &&
  5429. top - this.offset.click.top <= this.containment[ 3 ] ) ?
  5430. top :
  5431. ( ( top - this.offset.click.top >= this.containment[ 1 ] ) ?
  5432. top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) :
  5433. top;
  5434. left = this.originalPageX + Math.round( ( pageX - this.originalPageX ) /
  5435. o.grid[ 0 ] ) * o.grid[ 0 ];
  5436. pageX = this.containment ?
  5437. ( ( left - this.offset.click.left >= this.containment[ 0 ] &&
  5438. left - this.offset.click.left <= this.containment[ 2 ] ) ?
  5439. left :
  5440. ( ( left - this.offset.click.left >= this.containment[ 0 ] ) ?
  5441. left - o.grid[ 0 ] : left + o.grid[ 0 ] ) ) :
  5442. left;
  5443. }
  5444. }
  5445. return {
  5446. top: (
  5447. // The absolute mouse position
  5448. pageY -
  5449. // Click offset (relative to the element)
  5450. this.offset.click.top -
  5451. // Only for relative positioned nodes: Relative offset from element to offset parent
  5452. this.offset.relative.top -
  5453. // The offsetParent's offset without borders (offset + border)
  5454. this.offset.parent.top +
  5455. ( ( this.cssPosition === "fixed" ?
  5456. -this.scrollParent.scrollTop() :
  5457. ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) )
  5458. ),
  5459. left: (
  5460. // The absolute mouse position
  5461. pageX -
  5462. // Click offset (relative to the element)
  5463. this.offset.click.left -
  5464. // Only for relative positioned nodes: Relative offset from element to offset parent
  5465. this.offset.relative.left -
  5466. // The offsetParent's offset without borders (offset + border)
  5467. this.offset.parent.left +
  5468. ( ( this.cssPosition === "fixed" ?
  5469. -this.scrollParent.scrollLeft() :
  5470. scrollIsRootNode ? 0 : scroll.scrollLeft() ) )
  5471. )
  5472. };
  5473. },
  5474. _rearrange: function( event, i, a, hardRefresh ) {
  5475. if ( a ) {
  5476. a[ 0 ].appendChild( this.placeholder[ 0 ] );
  5477. } else {
  5478. i.item[ 0 ].parentNode.insertBefore( this.placeholder[ 0 ],
  5479. ( this.direction === "down" ? i.item[ 0 ] : i.item[ 0 ].nextSibling ) );
  5480. }
  5481. //Various things done here to improve the performance:
  5482. // 1. we create a setTimeout, that calls refreshPositions
  5483. // 2. on the instance, we have a counter variable, that get's higher after every append
  5484. // 3. on the local scope, we copy the counter variable, and check in the timeout,
  5485. // if it's still the same
  5486. // 4. this lets only the last addition to the timeout stack through
  5487. this.counter = this.counter ? ++this.counter : 1;
  5488. var counter = this.counter;
  5489. this._delay( function() {
  5490. if ( counter === this.counter ) {
  5491. //Precompute after each DOM insertion, NOT on mousemove
  5492. this.refreshPositions( !hardRefresh );
  5493. }
  5494. } );
  5495. },
  5496. _clear: function( event, noPropagation ) {
  5497. this.reverting = false;
  5498. // We delay all events that have to be triggered to after the point where the placeholder
  5499. // has been removed and everything else normalized again
  5500. var i,
  5501. delayedTriggers = [];
  5502. // We first have to update the dom position of the actual currentItem
  5503. // Note: don't do it if the current item is already removed (by a user), or it gets
  5504. // reappended (see #4088)
  5505. if ( !this._noFinalSort && this.currentItem.parent().length ) {
  5506. this.placeholder.before( this.currentItem );
  5507. }
  5508. this._noFinalSort = null;
  5509. if ( this.helper[ 0 ] === this.currentItem[ 0 ] ) {
  5510. for ( i in this._storedCSS ) {
  5511. if ( this._storedCSS[ i ] === "auto" || this._storedCSS[ i ] === "static" ) {
  5512. this._storedCSS[ i ] = "";
  5513. }
  5514. }
  5515. this.currentItem.css( this._storedCSS );
  5516. this._removeClass( this.currentItem, "ui-sortable-helper" );
  5517. } else {
  5518. this.currentItem.show();
  5519. }
  5520. if ( this.fromOutside && !noPropagation ) {
  5521. delayedTriggers.push( function( event ) {
  5522. this._trigger( "receive", event, this._uiHash( this.fromOutside ) );
  5523. } );
  5524. }
  5525. if ( ( this.fromOutside ||
  5526. this.domPosition.prev !==
  5527. this.currentItem.prev().not( ".ui-sortable-helper" )[ 0 ] ||
  5528. this.domPosition.parent !== this.currentItem.parent()[ 0 ] ) && !noPropagation ) {
  5529. // Trigger update callback if the DOM position has changed
  5530. delayedTriggers.push( function( event ) {
  5531. this._trigger( "update", event, this._uiHash() );
  5532. } );
  5533. }
  5534. // Check if the items Container has Changed and trigger appropriate
  5535. // events.
  5536. if ( this !== this.currentContainer ) {
  5537. if ( !noPropagation ) {
  5538. delayedTriggers.push( function( event ) {
  5539. this._trigger( "remove", event, this._uiHash() );
  5540. } );
  5541. delayedTriggers.push( ( function( c ) {
  5542. return function( event ) {
  5543. c._trigger( "receive", event, this._uiHash( this ) );
  5544. };
  5545. } ).call( this, this.currentContainer ) );
  5546. delayedTriggers.push( ( function( c ) {
  5547. return function( event ) {
  5548. c._trigger( "update", event, this._uiHash( this ) );
  5549. };
  5550. } ).call( this, this.currentContainer ) );
  5551. }
  5552. }
  5553. //Post events to containers
  5554. function delayEvent( type, instance, container ) {
  5555. return function( event ) {
  5556. container._trigger( type, event, instance._uiHash( instance ) );
  5557. };
  5558. }
  5559. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  5560. if ( !noPropagation ) {
  5561. delayedTriggers.push( delayEvent( "deactivate", this, this.containers[ i ] ) );
  5562. }
  5563. if ( this.containers[ i ].containerCache.over ) {
  5564. delayedTriggers.push( delayEvent( "out", this, this.containers[ i ] ) );
  5565. this.containers[ i ].containerCache.over = 0;
  5566. }
  5567. }
  5568. //Do what was originally in plugins
  5569. if ( this.storedCursor ) {
  5570. this.document.find( "body" ).css( "cursor", this.storedCursor );
  5571. this.storedStylesheet.remove();
  5572. }
  5573. if ( this._storedOpacity ) {
  5574. this.helper.css( "opacity", this._storedOpacity );
  5575. }
  5576. if ( this._storedZIndex ) {
  5577. this.helper.css( "zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex );
  5578. }
  5579. this.dragging = false;
  5580. if ( !noPropagation ) {
  5581. this._trigger( "beforeStop", event, this._uiHash() );
  5582. }
  5583. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately,
  5584. // it unbinds ALL events from the original node!
  5585. this.placeholder[ 0 ].parentNode.removeChild( this.placeholder[ 0 ] );
  5586. if ( !this.cancelHelperRemoval ) {
  5587. if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) {
  5588. this.helper.remove();
  5589. }
  5590. this.helper = null;
  5591. }
  5592. if ( !noPropagation ) {
  5593. for ( i = 0; i < delayedTriggers.length; i++ ) {
  5594. // Trigger all delayed events
  5595. delayedTriggers[ i ].call( this, event );
  5596. }
  5597. this._trigger( "stop", event, this._uiHash() );
  5598. }
  5599. this.fromOutside = false;
  5600. return !this.cancelHelperRemoval;
  5601. },
  5602. _trigger: function() {
  5603. if ( $.Widget.prototype._trigger.apply( this, arguments ) === false ) {
  5604. this.cancel();
  5605. }
  5606. },
  5607. _uiHash: function( _inst ) {
  5608. var inst = _inst || this;
  5609. return {
  5610. helper: inst.helper,
  5611. placeholder: inst.placeholder || $( [] ),
  5612. position: inst.position,
  5613. originalPosition: inst.originalPosition,
  5614. offset: inst.positionAbs,
  5615. item: inst.currentItem,
  5616. sender: _inst ? _inst.element : null
  5617. };
  5618. }
  5619. } );
  5620. /*!
  5621. * jQuery UI Accordion 1.13.0
  5622. * http://jqueryui.com
  5623. *
  5624. * Copyright jQuery Foundation and other contributors
  5625. * Released under the MIT license.
  5626. * http://jquery.org/license
  5627. */
  5628. //>>label: Accordion
  5629. //>>group: Widgets
  5630. /* eslint-disable max-len */
  5631. //>>description: Displays collapsible content panels for presenting information in a limited amount of space.
  5632. /* eslint-enable max-len */
  5633. //>>docs: http://api.jqueryui.com/accordion/
  5634. //>>demos: http://jqueryui.com/accordion/
  5635. //>>css.structure: ../../themes/base/core.css
  5636. //>>css.structure: ../../themes/base/accordion.css
  5637. //>>css.theme: ../../themes/base/theme.css
  5638. var widgetsAccordion = $.widget( "ui.accordion", {
  5639. version: "1.13.0",
  5640. options: {
  5641. active: 0,
  5642. animate: {},
  5643. classes: {
  5644. "ui-accordion-header": "ui-corner-top",
  5645. "ui-accordion-header-collapsed": "ui-corner-all",
  5646. "ui-accordion-content": "ui-corner-bottom"
  5647. },
  5648. collapsible: false,
  5649. event: "click",
  5650. header: function( elem ) {
  5651. return elem.find( "> li > :first-child" ).add( elem.find( "> :not(li)" ).even() );
  5652. },
  5653. heightStyle: "auto",
  5654. icons: {
  5655. activeHeader: "ui-icon-triangle-1-s",
  5656. header: "ui-icon-triangle-1-e"
  5657. },
  5658. // Callbacks
  5659. activate: null,
  5660. beforeActivate: null
  5661. },
  5662. hideProps: {
  5663. borderTopWidth: "hide",
  5664. borderBottomWidth: "hide",
  5665. paddingTop: "hide",
  5666. paddingBottom: "hide",
  5667. height: "hide"
  5668. },
  5669. showProps: {
  5670. borderTopWidth: "show",
  5671. borderBottomWidth: "show",
  5672. paddingTop: "show",
  5673. paddingBottom: "show",
  5674. height: "show"
  5675. },
  5676. _create: function() {
  5677. var options = this.options;
  5678. this.prevShow = this.prevHide = $();
  5679. this._addClass( "ui-accordion", "ui-widget ui-helper-reset" );
  5680. this.element.attr( "role", "tablist" );
  5681. // Don't allow collapsible: false and active: false / null
  5682. if ( !options.collapsible && ( options.active === false || options.active == null ) ) {
  5683. options.active = 0;
  5684. }
  5685. this._processPanels();
  5686. // handle negative values
  5687. if ( options.active < 0 ) {
  5688. options.active += this.headers.length;
  5689. }
  5690. this._refresh();
  5691. },
  5692. _getCreateEventData: function() {
  5693. return {
  5694. header: this.active,
  5695. panel: !this.active.length ? $() : this.active.next()
  5696. };
  5697. },
  5698. _createIcons: function() {
  5699. var icon, children,
  5700. icons = this.options.icons;
  5701. if ( icons ) {
  5702. icon = $( "<span>" );
  5703. this._addClass( icon, "ui-accordion-header-icon", "ui-icon " + icons.header );
  5704. icon.prependTo( this.headers );
  5705. children = this.active.children( ".ui-accordion-header-icon" );
  5706. this._removeClass( children, icons.header )
  5707. ._addClass( children, null, icons.activeHeader )
  5708. ._addClass( this.headers, "ui-accordion-icons" );
  5709. }
  5710. },
  5711. _destroyIcons: function() {
  5712. this._removeClass( this.headers, "ui-accordion-icons" );
  5713. this.headers.children( ".ui-accordion-header-icon" ).remove();
  5714. },
  5715. _destroy: function() {
  5716. var contents;
  5717. // Clean up main element
  5718. this.element.removeAttr( "role" );
  5719. // Clean up headers
  5720. this.headers
  5721. .removeAttr( "role aria-expanded aria-selected aria-controls tabIndex" )
  5722. .removeUniqueId();
  5723. this._destroyIcons();
  5724. // Clean up content panels
  5725. contents = this.headers.next()
  5726. .css( "display", "" )
  5727. .removeAttr( "role aria-hidden aria-labelledby" )
  5728. .removeUniqueId();
  5729. if ( this.options.heightStyle !== "content" ) {
  5730. contents.css( "height", "" );
  5731. }
  5732. },
  5733. _setOption: function( key, value ) {
  5734. if ( key === "active" ) {
  5735. // _activate() will handle invalid values and update this.options
  5736. this._activate( value );
  5737. return;
  5738. }
  5739. if ( key === "event" ) {
  5740. if ( this.options.event ) {
  5741. this._off( this.headers, this.options.event );
  5742. }
  5743. this._setupEvents( value );
  5744. }
  5745. this._super( key, value );
  5746. // Setting collapsible: false while collapsed; open first panel
  5747. if ( key === "collapsible" && !value && this.options.active === false ) {
  5748. this._activate( 0 );
  5749. }
  5750. if ( key === "icons" ) {
  5751. this._destroyIcons();
  5752. if ( value ) {
  5753. this._createIcons();
  5754. }
  5755. }
  5756. },
  5757. _setOptionDisabled: function( value ) {
  5758. this._super( value );
  5759. this.element.attr( "aria-disabled", value );
  5760. // Support: IE8 Only
  5761. // #5332 / #6059 - opacity doesn't cascade to positioned elements in IE
  5762. // so we need to add the disabled class to the headers and panels
  5763. this._toggleClass( null, "ui-state-disabled", !!value );
  5764. this._toggleClass( this.headers.add( this.headers.next() ), null, "ui-state-disabled",
  5765. !!value );
  5766. },
  5767. _keydown: function( event ) {
  5768. if ( event.altKey || event.ctrlKey ) {
  5769. return;
  5770. }
  5771. var keyCode = $.ui.keyCode,
  5772. length = this.headers.length,
  5773. currentIndex = this.headers.index( event.target ),
  5774. toFocus = false;
  5775. switch ( event.keyCode ) {
  5776. case keyCode.RIGHT:
  5777. case keyCode.DOWN:
  5778. toFocus = this.headers[ ( currentIndex + 1 ) % length ];
  5779. break;
  5780. case keyCode.LEFT:
  5781. case keyCode.UP:
  5782. toFocus = this.headers[ ( currentIndex - 1 + length ) % length ];
  5783. break;
  5784. case keyCode.SPACE:
  5785. case keyCode.ENTER:
  5786. this._eventHandler( event );
  5787. break;
  5788. case keyCode.HOME:
  5789. toFocus = this.headers[ 0 ];
  5790. break;
  5791. case keyCode.END:
  5792. toFocus = this.headers[ length - 1 ];
  5793. break;
  5794. }
  5795. if ( toFocus ) {
  5796. $( event.target ).attr( "tabIndex", -1 );
  5797. $( toFocus ).attr( "tabIndex", 0 );
  5798. $( toFocus ).trigger( "focus" );
  5799. event.preventDefault();
  5800. }
  5801. },
  5802. _panelKeyDown: function( event ) {
  5803. if ( event.keyCode === $.ui.keyCode.UP && event.ctrlKey ) {
  5804. $( event.currentTarget ).prev().trigger( "focus" );
  5805. }
  5806. },
  5807. refresh: function() {
  5808. var options = this.options;
  5809. this._processPanels();
  5810. // Was collapsed or no panel
  5811. if ( ( options.active === false && options.collapsible === true ) ||
  5812. !this.headers.length ) {
  5813. options.active = false;
  5814. this.active = $();
  5815. // active false only when collapsible is true
  5816. } else if ( options.active === false ) {
  5817. this._activate( 0 );
  5818. // was active, but active panel is gone
  5819. } else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  5820. // all remaining panel are disabled
  5821. if ( this.headers.length === this.headers.find( ".ui-state-disabled" ).length ) {
  5822. options.active = false;
  5823. this.active = $();
  5824. // activate previous panel
  5825. } else {
  5826. this._activate( Math.max( 0, options.active - 1 ) );
  5827. }
  5828. // was active, active panel still exists
  5829. } else {
  5830. // make sure active index is correct
  5831. options.active = this.headers.index( this.active );
  5832. }
  5833. this._destroyIcons();
  5834. this._refresh();
  5835. },
  5836. _processPanels: function() {
  5837. var prevHeaders = this.headers,
  5838. prevPanels = this.panels;
  5839. if ( typeof this.options.header === "function" ) {
  5840. this.headers = this.options.header( this.element );
  5841. } else {
  5842. this.headers = this.element.find( this.options.header );
  5843. }
  5844. this._addClass( this.headers, "ui-accordion-header ui-accordion-header-collapsed",
  5845. "ui-state-default" );
  5846. this.panels = this.headers.next().filter( ":not(.ui-accordion-content-active)" ).hide();
  5847. this._addClass( this.panels, "ui-accordion-content", "ui-helper-reset ui-widget-content" );
  5848. // Avoid memory leaks (#10056)
  5849. if ( prevPanels ) {
  5850. this._off( prevHeaders.not( this.headers ) );
  5851. this._off( prevPanels.not( this.panels ) );
  5852. }
  5853. },
  5854. _refresh: function() {
  5855. var maxHeight,
  5856. options = this.options,
  5857. heightStyle = options.heightStyle,
  5858. parent = this.element.parent();
  5859. this.active = this._findActive( options.active );
  5860. this._addClass( this.active, "ui-accordion-header-active", "ui-state-active" )
  5861. ._removeClass( this.active, "ui-accordion-header-collapsed" );
  5862. this._addClass( this.active.next(), "ui-accordion-content-active" );
  5863. this.active.next().show();
  5864. this.headers
  5865. .attr( "role", "tab" )
  5866. .each( function() {
  5867. var header = $( this ),
  5868. headerId = header.uniqueId().attr( "id" ),
  5869. panel = header.next(),
  5870. panelId = panel.uniqueId().attr( "id" );
  5871. header.attr( "aria-controls", panelId );
  5872. panel.attr( "aria-labelledby", headerId );
  5873. } )
  5874. .next()
  5875. .attr( "role", "tabpanel" );
  5876. this.headers
  5877. .not( this.active )
  5878. .attr( {
  5879. "aria-selected": "false",
  5880. "aria-expanded": "false",
  5881. tabIndex: -1
  5882. } )
  5883. .next()
  5884. .attr( {
  5885. "aria-hidden": "true"
  5886. } )
  5887. .hide();
  5888. // Make sure at least one header is in the tab order
  5889. if ( !this.active.length ) {
  5890. this.headers.eq( 0 ).attr( "tabIndex", 0 );
  5891. } else {
  5892. this.active.attr( {
  5893. "aria-selected": "true",
  5894. "aria-expanded": "true",
  5895. tabIndex: 0
  5896. } )
  5897. .next()
  5898. .attr( {
  5899. "aria-hidden": "false"
  5900. } );
  5901. }
  5902. this._createIcons();
  5903. this._setupEvents( options.event );
  5904. if ( heightStyle === "fill" ) {
  5905. maxHeight = parent.height();
  5906. this.element.siblings( ":visible" ).each( function() {
  5907. var elem = $( this ),
  5908. position = elem.css( "position" );
  5909. if ( position === "absolute" || position === "fixed" ) {
  5910. return;
  5911. }
  5912. maxHeight -= elem.outerHeight( true );
  5913. } );
  5914. this.headers.each( function() {
  5915. maxHeight -= $( this ).outerHeight( true );
  5916. } );
  5917. this.headers.next()
  5918. .each( function() {
  5919. $( this ).height( Math.max( 0, maxHeight -
  5920. $( this ).innerHeight() + $( this ).height() ) );
  5921. } )
  5922. .css( "overflow", "auto" );
  5923. } else if ( heightStyle === "auto" ) {
  5924. maxHeight = 0;
  5925. this.headers.next()
  5926. .each( function() {
  5927. var isVisible = $( this ).is( ":visible" );
  5928. if ( !isVisible ) {
  5929. $( this ).show();
  5930. }
  5931. maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() );
  5932. if ( !isVisible ) {
  5933. $( this ).hide();
  5934. }
  5935. } )
  5936. .height( maxHeight );
  5937. }
  5938. },
  5939. _activate: function( index ) {
  5940. var active = this._findActive( index )[ 0 ];
  5941. // Trying to activate the already active panel
  5942. if ( active === this.active[ 0 ] ) {
  5943. return;
  5944. }
  5945. // Trying to collapse, simulate a click on the currently active header
  5946. active = active || this.active[ 0 ];
  5947. this._eventHandler( {
  5948. target: active,
  5949. currentTarget: active,
  5950. preventDefault: $.noop
  5951. } );
  5952. },
  5953. _findActive: function( selector ) {
  5954. return typeof selector === "number" ? this.headers.eq( selector ) : $();
  5955. },
  5956. _setupEvents: function( event ) {
  5957. var events = {
  5958. keydown: "_keydown"
  5959. };
  5960. if ( event ) {
  5961. $.each( event.split( " " ), function( index, eventName ) {
  5962. events[ eventName ] = "_eventHandler";
  5963. } );
  5964. }
  5965. this._off( this.headers.add( this.headers.next() ) );
  5966. this._on( this.headers, events );
  5967. this._on( this.headers.next(), { keydown: "_panelKeyDown" } );
  5968. this._hoverable( this.headers );
  5969. this._focusable( this.headers );
  5970. },
  5971. _eventHandler: function( event ) {
  5972. var activeChildren, clickedChildren,
  5973. options = this.options,
  5974. active = this.active,
  5975. clicked = $( event.currentTarget ),
  5976. clickedIsActive = clicked[ 0 ] === active[ 0 ],
  5977. collapsing = clickedIsActive && options.collapsible,
  5978. toShow = collapsing ? $() : clicked.next(),
  5979. toHide = active.next(),
  5980. eventData = {
  5981. oldHeader: active,
  5982. oldPanel: toHide,
  5983. newHeader: collapsing ? $() : clicked,
  5984. newPanel: toShow
  5985. };
  5986. event.preventDefault();
  5987. if (
  5988. // click on active header, but not collapsible
  5989. ( clickedIsActive && !options.collapsible ) ||
  5990. // allow canceling activation
  5991. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  5992. return;
  5993. }
  5994. options.active = collapsing ? false : this.headers.index( clicked );
  5995. // When the call to ._toggle() comes after the class changes
  5996. // it causes a very odd bug in IE 8 (see #6720)
  5997. this.active = clickedIsActive ? $() : clicked;
  5998. this._toggle( eventData );
  5999. // Switch classes
  6000. // corner classes on the previously active header stay after the animation
  6001. this._removeClass( active, "ui-accordion-header-active", "ui-state-active" );
  6002. if ( options.icons ) {
  6003. activeChildren = active.children( ".ui-accordion-header-icon" );
  6004. this._removeClass( activeChildren, null, options.icons.activeHeader )
  6005. ._addClass( activeChildren, null, options.icons.header );
  6006. }
  6007. if ( !clickedIsActive ) {
  6008. this._removeClass( clicked, "ui-accordion-header-collapsed" )
  6009. ._addClass( clicked, "ui-accordion-header-active", "ui-state-active" );
  6010. if ( options.icons ) {
  6011. clickedChildren = clicked.children( ".ui-accordion-header-icon" );
  6012. this._removeClass( clickedChildren, null, options.icons.header )
  6013. ._addClass( clickedChildren, null, options.icons.activeHeader );
  6014. }
  6015. this._addClass( clicked.next(), "ui-accordion-content-active" );
  6016. }
  6017. },
  6018. _toggle: function( data ) {
  6019. var toShow = data.newPanel,
  6020. toHide = this.prevShow.length ? this.prevShow : data.oldPanel;
  6021. // Handle activating a panel during the animation for another activation
  6022. this.prevShow.add( this.prevHide ).stop( true, true );
  6023. this.prevShow = toShow;
  6024. this.prevHide = toHide;
  6025. if ( this.options.animate ) {
  6026. this._animate( toShow, toHide, data );
  6027. } else {
  6028. toHide.hide();
  6029. toShow.show();
  6030. this._toggleComplete( data );
  6031. }
  6032. toHide.attr( {
  6033. "aria-hidden": "true"
  6034. } );
  6035. toHide.prev().attr( {
  6036. "aria-selected": "false",
  6037. "aria-expanded": "false"
  6038. } );
  6039. // if we're switching panels, remove the old header from the tab order
  6040. // if we're opening from collapsed state, remove the previous header from the tab order
  6041. // if we're collapsing, then keep the collapsing header in the tab order
  6042. if ( toShow.length && toHide.length ) {
  6043. toHide.prev().attr( {
  6044. "tabIndex": -1,
  6045. "aria-expanded": "false"
  6046. } );
  6047. } else if ( toShow.length ) {
  6048. this.headers.filter( function() {
  6049. return parseInt( $( this ).attr( "tabIndex" ), 10 ) === 0;
  6050. } )
  6051. .attr( "tabIndex", -1 );
  6052. }
  6053. toShow
  6054. .attr( "aria-hidden", "false" )
  6055. .prev()
  6056. .attr( {
  6057. "aria-selected": "true",
  6058. "aria-expanded": "true",
  6059. tabIndex: 0
  6060. } );
  6061. },
  6062. _animate: function( toShow, toHide, data ) {
  6063. var total, easing, duration,
  6064. that = this,
  6065. adjust = 0,
  6066. boxSizing = toShow.css( "box-sizing" ),
  6067. down = toShow.length &&
  6068. ( !toHide.length || ( toShow.index() < toHide.index() ) ),
  6069. animate = this.options.animate || {},
  6070. options = down && animate.down || animate,
  6071. complete = function() {
  6072. that._toggleComplete( data );
  6073. };
  6074. if ( typeof options === "number" ) {
  6075. duration = options;
  6076. }
  6077. if ( typeof options === "string" ) {
  6078. easing = options;
  6079. }
  6080. // fall back from options to animation in case of partial down settings
  6081. easing = easing || options.easing || animate.easing;
  6082. duration = duration || options.duration || animate.duration;
  6083. if ( !toHide.length ) {
  6084. return toShow.animate( this.showProps, duration, easing, complete );
  6085. }
  6086. if ( !toShow.length ) {
  6087. return toHide.animate( this.hideProps, duration, easing, complete );
  6088. }
  6089. total = toShow.show().outerHeight();
  6090. toHide.animate( this.hideProps, {
  6091. duration: duration,
  6092. easing: easing,
  6093. step: function( now, fx ) {
  6094. fx.now = Math.round( now );
  6095. }
  6096. } );
  6097. toShow
  6098. .hide()
  6099. .animate( this.showProps, {
  6100. duration: duration,
  6101. easing: easing,
  6102. complete: complete,
  6103. step: function( now, fx ) {
  6104. fx.now = Math.round( now );
  6105. if ( fx.prop !== "height" ) {
  6106. if ( boxSizing === "content-box" ) {
  6107. adjust += fx.now;
  6108. }
  6109. } else if ( that.options.heightStyle !== "content" ) {
  6110. fx.now = Math.round( total - toHide.outerHeight() - adjust );
  6111. adjust = 0;
  6112. }
  6113. }
  6114. } );
  6115. },
  6116. _toggleComplete: function( data ) {
  6117. var toHide = data.oldPanel,
  6118. prev = toHide.prev();
  6119. this._removeClass( toHide, "ui-accordion-content-active" );
  6120. this._removeClass( prev, "ui-accordion-header-active" )
  6121. ._addClass( prev, "ui-accordion-header-collapsed" );
  6122. // Work around for rendering bug in IE (#5421)
  6123. if ( toHide.length ) {
  6124. toHide.parent()[ 0 ].className = toHide.parent()[ 0 ].className;
  6125. }
  6126. this._trigger( "activate", null, data );
  6127. }
  6128. } );
  6129. /*!
  6130. * jQuery UI Menu 1.13.0
  6131. * http://jqueryui.com
  6132. *
  6133. * Copyright jQuery Foundation and other contributors
  6134. * Released under the MIT license.
  6135. * http://jquery.org/license
  6136. */
  6137. //>>label: Menu
  6138. //>>group: Widgets
  6139. //>>description: Creates nestable menus.
  6140. //>>docs: http://api.jqueryui.com/menu/
  6141. //>>demos: http://jqueryui.com/menu/
  6142. //>>css.structure: ../../themes/base/core.css
  6143. //>>css.structure: ../../themes/base/menu.css
  6144. //>>css.theme: ../../themes/base/theme.css
  6145. var widgetsMenu = $.widget( "ui.menu", {
  6146. version: "1.13.0",
  6147. defaultElement: "<ul>",
  6148. delay: 300,
  6149. options: {
  6150. icons: {
  6151. submenu: "ui-icon-caret-1-e"
  6152. },
  6153. items: "> *",
  6154. menus: "ul",
  6155. position: {
  6156. my: "left top",
  6157. at: "right top"
  6158. },
  6159. role: "menu",
  6160. // Callbacks
  6161. blur: null,
  6162. focus: null,
  6163. select: null
  6164. },
  6165. _create: function() {
  6166. this.activeMenu = this.element;
  6167. // Flag used to prevent firing of the click handler
  6168. // as the event bubbles up through nested menus
  6169. this.mouseHandled = false;
  6170. this.lastMousePosition = { x: null, y: null };
  6171. this.element
  6172. .uniqueId()
  6173. .attr( {
  6174. role: this.options.role,
  6175. tabIndex: 0
  6176. } );
  6177. this._addClass( "ui-menu", "ui-widget ui-widget-content" );
  6178. this._on( {
  6179. // Prevent focus from sticking to links inside menu after clicking
  6180. // them (focus should always stay on UL during navigation).
  6181. "mousedown .ui-menu-item": function( event ) {
  6182. event.preventDefault();
  6183. this._activateItem( event );
  6184. },
  6185. "click .ui-menu-item": function( event ) {
  6186. var target = $( event.target );
  6187. var active = $( $.ui.safeActiveElement( this.document[ 0 ] ) );
  6188. if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
  6189. this.select( event );
  6190. // Only set the mouseHandled flag if the event will bubble, see #9469.
  6191. if ( !event.isPropagationStopped() ) {
  6192. this.mouseHandled = true;
  6193. }
  6194. // Open submenu on click
  6195. if ( target.has( ".ui-menu" ).length ) {
  6196. this.expand( event );
  6197. } else if ( !this.element.is( ":focus" ) &&
  6198. active.closest( ".ui-menu" ).length ) {
  6199. // Redirect focus to the menu
  6200. this.element.trigger( "focus", [ true ] );
  6201. // If the active item is on the top level, let it stay active.
  6202. // Otherwise, blur the active item since it is no longer visible.
  6203. if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
  6204. clearTimeout( this.timer );
  6205. }
  6206. }
  6207. }
  6208. },
  6209. "mouseenter .ui-menu-item": "_activateItem",
  6210. "mousemove .ui-menu-item": "_activateItem",
  6211. mouseleave: "collapseAll",
  6212. "mouseleave .ui-menu": "collapseAll",
  6213. focus: function( event, keepActiveItem ) {
  6214. // If there's already an active item, keep it active
  6215. // If not, activate the first item
  6216. var item = this.active || this._menuItems().first();
  6217. if ( !keepActiveItem ) {
  6218. this.focus( event, item );
  6219. }
  6220. },
  6221. blur: function( event ) {
  6222. this._delay( function() {
  6223. var notContained = !$.contains(
  6224. this.element[ 0 ],
  6225. $.ui.safeActiveElement( this.document[ 0 ] )
  6226. );
  6227. if ( notContained ) {
  6228. this.collapseAll( event );
  6229. }
  6230. } );
  6231. },
  6232. keydown: "_keydown"
  6233. } );
  6234. this.refresh();
  6235. // Clicks outside of a menu collapse any open menus
  6236. this._on( this.document, {
  6237. click: function( event ) {
  6238. if ( this._closeOnDocumentClick( event ) ) {
  6239. this.collapseAll( event, true );
  6240. }
  6241. // Reset the mouseHandled flag
  6242. this.mouseHandled = false;
  6243. }
  6244. } );
  6245. },
  6246. _activateItem: function( event ) {
  6247. // Ignore mouse events while typeahead is active, see #10458.
  6248. // Prevents focusing the wrong item when typeahead causes a scroll while the mouse
  6249. // is over an item in the menu
  6250. if ( this.previousFilter ) {
  6251. return;
  6252. }
  6253. // If the mouse didn't actually move, but the page was scrolled, ignore the event (#9356)
  6254. if ( event.clientX === this.lastMousePosition.x &&
  6255. event.clientY === this.lastMousePosition.y ) {
  6256. return;
  6257. }
  6258. this.lastMousePosition = {
  6259. x: event.clientX,
  6260. y: event.clientY
  6261. };
  6262. var actualTarget = $( event.target ).closest( ".ui-menu-item" ),
  6263. target = $( event.currentTarget );
  6264. // Ignore bubbled events on parent items, see #11641
  6265. if ( actualTarget[ 0 ] !== target[ 0 ] ) {
  6266. return;
  6267. }
  6268. // If the item is already active, there's nothing to do
  6269. if ( target.is( ".ui-state-active" ) ) {
  6270. return;
  6271. }
  6272. // Remove ui-state-active class from siblings of the newly focused menu item
  6273. // to avoid a jump caused by adjacent elements both having a class with a border
  6274. this._removeClass( target.siblings().children( ".ui-state-active" ),
  6275. null, "ui-state-active" );
  6276. this.focus( event, target );
  6277. },
  6278. _destroy: function() {
  6279. var items = this.element.find( ".ui-menu-item" )
  6280. .removeAttr( "role aria-disabled" ),
  6281. submenus = items.children( ".ui-menu-item-wrapper" )
  6282. .removeUniqueId()
  6283. .removeAttr( "tabIndex role aria-haspopup" );
  6284. // Destroy (sub)menus
  6285. this.element
  6286. .removeAttr( "aria-activedescendant" )
  6287. .find( ".ui-menu" ).addBack()
  6288. .removeAttr( "role aria-labelledby aria-expanded aria-hidden aria-disabled " +
  6289. "tabIndex" )
  6290. .removeUniqueId()
  6291. .show();
  6292. submenus.children().each( function() {
  6293. var elem = $( this );
  6294. if ( elem.data( "ui-menu-submenu-caret" ) ) {
  6295. elem.remove();
  6296. }
  6297. } );
  6298. },
  6299. _keydown: function( event ) {
  6300. var match, prev, character, skip,
  6301. preventDefault = true;
  6302. switch ( event.keyCode ) {
  6303. case $.ui.keyCode.PAGE_UP:
  6304. this.previousPage( event );
  6305. break;
  6306. case $.ui.keyCode.PAGE_DOWN:
  6307. this.nextPage( event );
  6308. break;
  6309. case $.ui.keyCode.HOME:
  6310. this._move( "first", "first", event );
  6311. break;
  6312. case $.ui.keyCode.END:
  6313. this._move( "last", "last", event );
  6314. break;
  6315. case $.ui.keyCode.UP:
  6316. this.previous( event );
  6317. break;
  6318. case $.ui.keyCode.DOWN:
  6319. this.next( event );
  6320. break;
  6321. case $.ui.keyCode.LEFT:
  6322. this.collapse( event );
  6323. break;
  6324. case $.ui.keyCode.RIGHT:
  6325. if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
  6326. this.expand( event );
  6327. }
  6328. break;
  6329. case $.ui.keyCode.ENTER:
  6330. case $.ui.keyCode.SPACE:
  6331. this._activate( event );
  6332. break;
  6333. case $.ui.keyCode.ESCAPE:
  6334. this.collapse( event );
  6335. break;
  6336. default:
  6337. preventDefault = false;
  6338. prev = this.previousFilter || "";
  6339. skip = false;
  6340. // Support number pad values
  6341. character = event.keyCode >= 96 && event.keyCode <= 105 ?
  6342. ( event.keyCode - 96 ).toString() : String.fromCharCode( event.keyCode );
  6343. clearTimeout( this.filterTimer );
  6344. if ( character === prev ) {
  6345. skip = true;
  6346. } else {
  6347. character = prev + character;
  6348. }
  6349. match = this._filterMenuItems( character );
  6350. match = skip && match.index( this.active.next() ) !== -1 ?
  6351. this.active.nextAll( ".ui-menu-item" ) :
  6352. match;
  6353. // If no matches on the current filter, reset to the last character pressed
  6354. // to move down the menu to the first item that starts with that character
  6355. if ( !match.length ) {
  6356. character = String.fromCharCode( event.keyCode );
  6357. match = this._filterMenuItems( character );
  6358. }
  6359. if ( match.length ) {
  6360. this.focus( event, match );
  6361. this.previousFilter = character;
  6362. this.filterTimer = this._delay( function() {
  6363. delete this.previousFilter;
  6364. }, 1000 );
  6365. } else {
  6366. delete this.previousFilter;
  6367. }
  6368. }
  6369. if ( preventDefault ) {
  6370. event.preventDefault();
  6371. }
  6372. },
  6373. _activate: function( event ) {
  6374. if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
  6375. if ( this.active.children( "[aria-haspopup='true']" ).length ) {
  6376. this.expand( event );
  6377. } else {
  6378. this.select( event );
  6379. }
  6380. }
  6381. },
  6382. refresh: function() {
  6383. var menus, items, newSubmenus, newItems, newWrappers,
  6384. that = this,
  6385. icon = this.options.icons.submenu,
  6386. submenus = this.element.find( this.options.menus );
  6387. this._toggleClass( "ui-menu-icons", null, !!this.element.find( ".ui-icon" ).length );
  6388. // Initialize nested menus
  6389. newSubmenus = submenus.filter( ":not(.ui-menu)" )
  6390. .hide()
  6391. .attr( {
  6392. role: this.options.role,
  6393. "aria-hidden": "true",
  6394. "aria-expanded": "false"
  6395. } )
  6396. .each( function() {
  6397. var menu = $( this ),
  6398. item = menu.prev(),
  6399. submenuCaret = $( "<span>" ).data( "ui-menu-submenu-caret", true );
  6400. that._addClass( submenuCaret, "ui-menu-icon", "ui-icon " + icon );
  6401. item
  6402. .attr( "aria-haspopup", "true" )
  6403. .prepend( submenuCaret );
  6404. menu.attr( "aria-labelledby", item.attr( "id" ) );
  6405. } );
  6406. this._addClass( newSubmenus, "ui-menu", "ui-widget ui-widget-content ui-front" );
  6407. menus = submenus.add( this.element );
  6408. items = menus.find( this.options.items );
  6409. // Initialize menu-items containing spaces and/or dashes only as dividers
  6410. items.not( ".ui-menu-item" ).each( function() {
  6411. var item = $( this );
  6412. if ( that._isDivider( item ) ) {
  6413. that._addClass( item, "ui-menu-divider", "ui-widget-content" );
  6414. }
  6415. } );
  6416. // Don't refresh list items that are already adapted
  6417. newItems = items.not( ".ui-menu-item, .ui-menu-divider" );
  6418. newWrappers = newItems.children()
  6419. .not( ".ui-menu" )
  6420. .uniqueId()
  6421. .attr( {
  6422. tabIndex: -1,
  6423. role: this._itemRole()
  6424. } );
  6425. this._addClass( newItems, "ui-menu-item" )
  6426. ._addClass( newWrappers, "ui-menu-item-wrapper" );
  6427. // Add aria-disabled attribute to any disabled menu item
  6428. items.filter( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
  6429. // If the active item has been removed, blur the menu
  6430. if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  6431. this.blur();
  6432. }
  6433. },
  6434. _itemRole: function() {
  6435. return {
  6436. menu: "menuitem",
  6437. listbox: "option"
  6438. }[ this.options.role ];
  6439. },
  6440. _setOption: function( key, value ) {
  6441. if ( key === "icons" ) {
  6442. var icons = this.element.find( ".ui-menu-icon" );
  6443. this._removeClass( icons, null, this.options.icons.submenu )
  6444. ._addClass( icons, null, value.submenu );
  6445. }
  6446. this._super( key, value );
  6447. },
  6448. _setOptionDisabled: function( value ) {
  6449. this._super( value );
  6450. this.element.attr( "aria-disabled", String( value ) );
  6451. this._toggleClass( null, "ui-state-disabled", !!value );
  6452. },
  6453. focus: function( event, item ) {
  6454. var nested, focused, activeParent;
  6455. this.blur( event, event && event.type === "focus" );
  6456. this._scrollIntoView( item );
  6457. this.active = item.first();
  6458. focused = this.active.children( ".ui-menu-item-wrapper" );
  6459. this._addClass( focused, null, "ui-state-active" );
  6460. // Only update aria-activedescendant if there's a role
  6461. // otherwise we assume focus is managed elsewhere
  6462. if ( this.options.role ) {
  6463. this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
  6464. }
  6465. // Highlight active parent menu item, if any
  6466. activeParent = this.active
  6467. .parent()
  6468. .closest( ".ui-menu-item" )
  6469. .children( ".ui-menu-item-wrapper" );
  6470. this._addClass( activeParent, null, "ui-state-active" );
  6471. if ( event && event.type === "keydown" ) {
  6472. this._close();
  6473. } else {
  6474. this.timer = this._delay( function() {
  6475. this._close();
  6476. }, this.delay );
  6477. }
  6478. nested = item.children( ".ui-menu" );
  6479. if ( nested.length && event && ( /^mouse/.test( event.type ) ) ) {
  6480. this._startOpening( nested );
  6481. }
  6482. this.activeMenu = item.parent();
  6483. this._trigger( "focus", event, { item: item } );
  6484. },
  6485. _scrollIntoView: function( item ) {
  6486. var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
  6487. if ( this._hasScroll() ) {
  6488. borderTop = parseFloat( $.css( this.activeMenu[ 0 ], "borderTopWidth" ) ) || 0;
  6489. paddingTop = parseFloat( $.css( this.activeMenu[ 0 ], "paddingTop" ) ) || 0;
  6490. offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
  6491. scroll = this.activeMenu.scrollTop();
  6492. elementHeight = this.activeMenu.height();
  6493. itemHeight = item.outerHeight();
  6494. if ( offset < 0 ) {
  6495. this.activeMenu.scrollTop( scroll + offset );
  6496. } else if ( offset + itemHeight > elementHeight ) {
  6497. this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
  6498. }
  6499. }
  6500. },
  6501. blur: function( event, fromFocus ) {
  6502. if ( !fromFocus ) {
  6503. clearTimeout( this.timer );
  6504. }
  6505. if ( !this.active ) {
  6506. return;
  6507. }
  6508. this._removeClass( this.active.children( ".ui-menu-item-wrapper" ),
  6509. null, "ui-state-active" );
  6510. this._trigger( "blur", event, { item: this.active } );
  6511. this.active = null;
  6512. },
  6513. _startOpening: function( submenu ) {
  6514. clearTimeout( this.timer );
  6515. // Don't open if already open fixes a Firefox bug that caused a .5 pixel
  6516. // shift in the submenu position when mousing over the caret icon
  6517. if ( submenu.attr( "aria-hidden" ) !== "true" ) {
  6518. return;
  6519. }
  6520. this.timer = this._delay( function() {
  6521. this._close();
  6522. this._open( submenu );
  6523. }, this.delay );
  6524. },
  6525. _open: function( submenu ) {
  6526. var position = $.extend( {
  6527. of: this.active
  6528. }, this.options.position );
  6529. clearTimeout( this.timer );
  6530. this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
  6531. .hide()
  6532. .attr( "aria-hidden", "true" );
  6533. submenu
  6534. .show()
  6535. .removeAttr( "aria-hidden" )
  6536. .attr( "aria-expanded", "true" )
  6537. .position( position );
  6538. },
  6539. collapseAll: function( event, all ) {
  6540. clearTimeout( this.timer );
  6541. this.timer = this._delay( function() {
  6542. // If we were passed an event, look for the submenu that contains the event
  6543. var currentMenu = all ? this.element :
  6544. $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
  6545. // If we found no valid submenu ancestor, use the main menu to close all
  6546. // sub menus anyway
  6547. if ( !currentMenu.length ) {
  6548. currentMenu = this.element;
  6549. }
  6550. this._close( currentMenu );
  6551. this.blur( event );
  6552. // Work around active item staying active after menu is blurred
  6553. this._removeClass( currentMenu.find( ".ui-state-active" ), null, "ui-state-active" );
  6554. this.activeMenu = currentMenu;
  6555. }, all ? 0 : this.delay );
  6556. },
  6557. // With no arguments, closes the currently active menu - if nothing is active
  6558. // it closes all menus. If passed an argument, it will search for menus BELOW
  6559. _close: function( startMenu ) {
  6560. if ( !startMenu ) {
  6561. startMenu = this.active ? this.active.parent() : this.element;
  6562. }
  6563. startMenu.find( ".ui-menu" )
  6564. .hide()
  6565. .attr( "aria-hidden", "true" )
  6566. .attr( "aria-expanded", "false" );
  6567. },
  6568. _closeOnDocumentClick: function( event ) {
  6569. return !$( event.target ).closest( ".ui-menu" ).length;
  6570. },
  6571. _isDivider: function( item ) {
  6572. // Match hyphen, em dash, en dash
  6573. return !/[^\-\u2014\u2013\s]/.test( item.text() );
  6574. },
  6575. collapse: function( event ) {
  6576. var newItem = this.active &&
  6577. this.active.parent().closest( ".ui-menu-item", this.element );
  6578. if ( newItem && newItem.length ) {
  6579. this._close();
  6580. this.focus( event, newItem );
  6581. }
  6582. },
  6583. expand: function( event ) {
  6584. var newItem = this.active && this._menuItems( this.active.children( ".ui-menu" ) ).first();
  6585. if ( newItem && newItem.length ) {
  6586. this._open( newItem.parent() );
  6587. // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
  6588. this._delay( function() {
  6589. this.focus( event, newItem );
  6590. } );
  6591. }
  6592. },
  6593. next: function( event ) {
  6594. this._move( "next", "first", event );
  6595. },
  6596. previous: function( event ) {
  6597. this._move( "prev", "last", event );
  6598. },
  6599. isFirstItem: function() {
  6600. return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
  6601. },
  6602. isLastItem: function() {
  6603. return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
  6604. },
  6605. _menuItems: function( menu ) {
  6606. return ( menu || this.element )
  6607. .find( this.options.items )
  6608. .filter( ".ui-menu-item" );
  6609. },
  6610. _move: function( direction, filter, event ) {
  6611. var next;
  6612. if ( this.active ) {
  6613. if ( direction === "first" || direction === "last" ) {
  6614. next = this.active
  6615. [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
  6616. .last();
  6617. } else {
  6618. next = this.active
  6619. [ direction + "All" ]( ".ui-menu-item" )
  6620. .first();
  6621. }
  6622. }
  6623. if ( !next || !next.length || !this.active ) {
  6624. next = this._menuItems( this.activeMenu )[ filter ]();
  6625. }
  6626. this.focus( event, next );
  6627. },
  6628. nextPage: function( event ) {
  6629. var item, base, height;
  6630. if ( !this.active ) {
  6631. this.next( event );
  6632. return;
  6633. }
  6634. if ( this.isLastItem() ) {
  6635. return;
  6636. }
  6637. if ( this._hasScroll() ) {
  6638. base = this.active.offset().top;
  6639. height = this.element.innerHeight();
  6640. // jQuery 3.2 doesn't include scrollbars in innerHeight, add it back.
  6641. if ( $.fn.jquery.indexOf( "3.2." ) === 0 ) {
  6642. height += this.element[ 0 ].offsetHeight - this.element.outerHeight();
  6643. }
  6644. this.active.nextAll( ".ui-menu-item" ).each( function() {
  6645. item = $( this );
  6646. return item.offset().top - base - height < 0;
  6647. } );
  6648. this.focus( event, item );
  6649. } else {
  6650. this.focus( event, this._menuItems( this.activeMenu )
  6651. [ !this.active ? "first" : "last" ]() );
  6652. }
  6653. },
  6654. previousPage: function( event ) {
  6655. var item, base, height;
  6656. if ( !this.active ) {
  6657. this.next( event );
  6658. return;
  6659. }
  6660. if ( this.isFirstItem() ) {
  6661. return;
  6662. }
  6663. if ( this._hasScroll() ) {
  6664. base = this.active.offset().top;
  6665. height = this.element.innerHeight();
  6666. // jQuery 3.2 doesn't include scrollbars in innerHeight, add it back.
  6667. if ( $.fn.jquery.indexOf( "3.2." ) === 0 ) {
  6668. height += this.element[ 0 ].offsetHeight - this.element.outerHeight();
  6669. }
  6670. this.active.prevAll( ".ui-menu-item" ).each( function() {
  6671. item = $( this );
  6672. return item.offset().top - base + height > 0;
  6673. } );
  6674. this.focus( event, item );
  6675. } else {
  6676. this.focus( event, this._menuItems( this.activeMenu ).first() );
  6677. }
  6678. },
  6679. _hasScroll: function() {
  6680. return this.element.outerHeight() < this.element.prop( "scrollHeight" );
  6681. },
  6682. select: function( event ) {
  6683. // TODO: It should never be possible to not have an active item at this
  6684. // point, but the tests don't trigger mouseenter before click.
  6685. this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
  6686. var ui = { item: this.active };
  6687. if ( !this.active.has( ".ui-menu" ).length ) {
  6688. this.collapseAll( event, true );
  6689. }
  6690. this._trigger( "select", event, ui );
  6691. },
  6692. _filterMenuItems: function( character ) {
  6693. var escapedCharacter = character.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" ),
  6694. regex = new RegExp( "^" + escapedCharacter, "i" );
  6695. return this.activeMenu
  6696. .find( this.options.items )
  6697. // Only match on items, not dividers or other content (#10571)
  6698. .filter( ".ui-menu-item" )
  6699. .filter( function() {
  6700. return regex.test(
  6701. String.prototype.trim.call(
  6702. $( this ).children( ".ui-menu-item-wrapper" ).text() ) );
  6703. } );
  6704. }
  6705. } );
  6706. /*!
  6707. * jQuery UI Autocomplete 1.13.0
  6708. * http://jqueryui.com
  6709. *
  6710. * Copyright jQuery Foundation and other contributors
  6711. * Released under the MIT license.
  6712. * http://jquery.org/license
  6713. */
  6714. //>>label: Autocomplete
  6715. //>>group: Widgets
  6716. //>>description: Lists suggested words as the user is typing.
  6717. //>>docs: http://api.jqueryui.com/autocomplete/
  6718. //>>demos: http://jqueryui.com/autocomplete/
  6719. //>>css.structure: ../../themes/base/core.css
  6720. //>>css.structure: ../../themes/base/autocomplete.css
  6721. //>>css.theme: ../../themes/base/theme.css
  6722. $.widget( "ui.autocomplete", {
  6723. version: "1.13.0",
  6724. defaultElement: "<input>",
  6725. options: {
  6726. appendTo: null,
  6727. autoFocus: false,
  6728. delay: 300,
  6729. minLength: 1,
  6730. position: {
  6731. my: "left top",
  6732. at: "left bottom",
  6733. collision: "none"
  6734. },
  6735. source: null,
  6736. // Callbacks
  6737. change: null,
  6738. close: null,
  6739. focus: null,
  6740. open: null,
  6741. response: null,
  6742. search: null,
  6743. select: null
  6744. },
  6745. requestIndex: 0,
  6746. pending: 0,
  6747. _create: function() {
  6748. // Some browsers only repeat keydown events, not keypress events,
  6749. // so we use the suppressKeyPress flag to determine if we've already
  6750. // handled the keydown event. #7269
  6751. // Unfortunately the code for & in keypress is the same as the up arrow,
  6752. // so we use the suppressKeyPressRepeat flag to avoid handling keypress
  6753. // events when we know the keydown event was used to modify the
  6754. // search term. #7799
  6755. var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
  6756. nodeName = this.element[ 0 ].nodeName.toLowerCase(),
  6757. isTextarea = nodeName === "textarea",
  6758. isInput = nodeName === "input";
  6759. // Textareas are always multi-line
  6760. // Inputs are always single-line, even if inside a contentEditable element
  6761. // IE also treats inputs as contentEditable
  6762. // All other element types are determined by whether or not they're contentEditable
  6763. this.isMultiLine = isTextarea || !isInput && this._isContentEditable( this.element );
  6764. this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
  6765. this.isNewMenu = true;
  6766. this._addClass( "ui-autocomplete-input" );
  6767. this.element.attr( "autocomplete", "off" );
  6768. this._on( this.element, {
  6769. keydown: function( event ) {
  6770. if ( this.element.prop( "readOnly" ) ) {
  6771. suppressKeyPress = true;
  6772. suppressInput = true;
  6773. suppressKeyPressRepeat = true;
  6774. return;
  6775. }
  6776. suppressKeyPress = false;
  6777. suppressInput = false;
  6778. suppressKeyPressRepeat = false;
  6779. var keyCode = $.ui.keyCode;
  6780. switch ( event.keyCode ) {
  6781. case keyCode.PAGE_UP:
  6782. suppressKeyPress = true;
  6783. this._move( "previousPage", event );
  6784. break;
  6785. case keyCode.PAGE_DOWN:
  6786. suppressKeyPress = true;
  6787. this._move( "nextPage", event );
  6788. break;
  6789. case keyCode.UP:
  6790. suppressKeyPress = true;
  6791. this._keyEvent( "previous", event );
  6792. break;
  6793. case keyCode.DOWN:
  6794. suppressKeyPress = true;
  6795. this._keyEvent( "next", event );
  6796. break;
  6797. case keyCode.ENTER:
  6798. // when menu is open and has focus
  6799. if ( this.menu.active ) {
  6800. // #6055 - Opera still allows the keypress to occur
  6801. // which causes forms to submit
  6802. suppressKeyPress = true;
  6803. event.preventDefault();
  6804. this.menu.select( event );
  6805. }
  6806. break;
  6807. case keyCode.TAB:
  6808. if ( this.menu.active ) {
  6809. this.menu.select( event );
  6810. }
  6811. break;
  6812. case keyCode.ESCAPE:
  6813. if ( this.menu.element.is( ":visible" ) ) {
  6814. if ( !this.isMultiLine ) {
  6815. this._value( this.term );
  6816. }
  6817. this.close( event );
  6818. // Different browsers have different default behavior for escape
  6819. // Single press can mean undo or clear
  6820. // Double press in IE means clear the whole form
  6821. event.preventDefault();
  6822. }
  6823. break;
  6824. default:
  6825. suppressKeyPressRepeat = true;
  6826. // search timeout should be triggered before the input value is changed
  6827. this._searchTimeout( event );
  6828. break;
  6829. }
  6830. },
  6831. keypress: function( event ) {
  6832. if ( suppressKeyPress ) {
  6833. suppressKeyPress = false;
  6834. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  6835. event.preventDefault();
  6836. }
  6837. return;
  6838. }
  6839. if ( suppressKeyPressRepeat ) {
  6840. return;
  6841. }
  6842. // Replicate some key handlers to allow them to repeat in Firefox and Opera
  6843. var keyCode = $.ui.keyCode;
  6844. switch ( event.keyCode ) {
  6845. case keyCode.PAGE_UP:
  6846. this._move( "previousPage", event );
  6847. break;
  6848. case keyCode.PAGE_DOWN:
  6849. this._move( "nextPage", event );
  6850. break;
  6851. case keyCode.UP:
  6852. this._keyEvent( "previous", event );
  6853. break;
  6854. case keyCode.DOWN:
  6855. this._keyEvent( "next", event );
  6856. break;
  6857. }
  6858. },
  6859. input: function( event ) {
  6860. if ( suppressInput ) {
  6861. suppressInput = false;
  6862. event.preventDefault();
  6863. return;
  6864. }
  6865. this._searchTimeout( event );
  6866. },
  6867. focus: function() {
  6868. this.selectedItem = null;
  6869. this.previous = this._value();
  6870. },
  6871. blur: function( event ) {
  6872. clearTimeout( this.searching );
  6873. this.close( event );
  6874. this._change( event );
  6875. }
  6876. } );
  6877. this._initSource();
  6878. this.menu = $( "<ul>" )
  6879. .appendTo( this._appendTo() )
  6880. .menu( {
  6881. // disable ARIA support, the live region takes care of that
  6882. role: null
  6883. } )
  6884. .hide()
  6885. // Support: IE 11 only, Edge <= 14
  6886. // For other browsers, we preventDefault() on the mousedown event
  6887. // to keep the dropdown from taking focus from the input. This doesn't
  6888. // work for IE/Edge, causing problems with selection and scrolling (#9638)
  6889. // Happily, IE and Edge support an "unselectable" attribute that
  6890. // prevents an element from receiving focus, exactly what we want here.
  6891. .attr( {
  6892. "unselectable": "on"
  6893. } )
  6894. .menu( "instance" );
  6895. this._addClass( this.menu.element, "ui-autocomplete", "ui-front" );
  6896. this._on( this.menu.element, {
  6897. mousedown: function( event ) {
  6898. // Prevent moving focus out of the text field
  6899. event.preventDefault();
  6900. },
  6901. menufocus: function( event, ui ) {
  6902. var label, item;
  6903. // support: Firefox
  6904. // Prevent accidental activation of menu items in Firefox (#7024 #9118)
  6905. if ( this.isNewMenu ) {
  6906. this.isNewMenu = false;
  6907. if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
  6908. this.menu.blur();
  6909. this.document.one( "mousemove", function() {
  6910. $( event.target ).trigger( event.originalEvent );
  6911. } );
  6912. return;
  6913. }
  6914. }
  6915. item = ui.item.data( "ui-autocomplete-item" );
  6916. if ( false !== this._trigger( "focus", event, { item: item } ) ) {
  6917. // use value to match what will end up in the input, if it was a key event
  6918. if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
  6919. this._value( item.value );
  6920. }
  6921. }
  6922. // Announce the value in the liveRegion
  6923. label = ui.item.attr( "aria-label" ) || item.value;
  6924. if ( label && String.prototype.trim.call( label ).length ) {
  6925. this.liveRegion.children().hide();
  6926. $( "<div>" ).text( label ).appendTo( this.liveRegion );
  6927. }
  6928. },
  6929. menuselect: function( event, ui ) {
  6930. var item = ui.item.data( "ui-autocomplete-item" ),
  6931. previous = this.previous;
  6932. // Only trigger when focus was lost (click on menu)
  6933. if ( this.element[ 0 ] !== $.ui.safeActiveElement( this.document[ 0 ] ) ) {
  6934. this.element.trigger( "focus" );
  6935. this.previous = previous;
  6936. // #6109 - IE triggers two focus events and the second
  6937. // is asynchronous, so we need to reset the previous
  6938. // term synchronously and asynchronously :-(
  6939. this._delay( function() {
  6940. this.previous = previous;
  6941. this.selectedItem = item;
  6942. } );
  6943. }
  6944. if ( false !== this._trigger( "select", event, { item: item } ) ) {
  6945. this._value( item.value );
  6946. }
  6947. // reset the term after the select event
  6948. // this allows custom select handling to work properly
  6949. this.term = this._value();
  6950. this.close( event );
  6951. this.selectedItem = item;
  6952. }
  6953. } );
  6954. this.liveRegion = $( "<div>", {
  6955. role: "status",
  6956. "aria-live": "assertive",
  6957. "aria-relevant": "additions"
  6958. } )
  6959. .appendTo( this.document[ 0 ].body );
  6960. this._addClass( this.liveRegion, null, "ui-helper-hidden-accessible" );
  6961. // Turning off autocomplete prevents the browser from remembering the
  6962. // value when navigating through history, so we re-enable autocomplete
  6963. // if the page is unloaded before the widget is destroyed. #7790
  6964. this._on( this.window, {
  6965. beforeunload: function() {
  6966. this.element.removeAttr( "autocomplete" );
  6967. }
  6968. } );
  6969. },
  6970. _destroy: function() {
  6971. clearTimeout( this.searching );
  6972. this.element.removeAttr( "autocomplete" );
  6973. this.menu.element.remove();
  6974. this.liveRegion.remove();
  6975. },
  6976. _setOption: function( key, value ) {
  6977. this._super( key, value );
  6978. if ( key === "source" ) {
  6979. this._initSource();
  6980. }
  6981. if ( key === "appendTo" ) {
  6982. this.menu.element.appendTo( this._appendTo() );
  6983. }
  6984. if ( key === "disabled" && value && this.xhr ) {
  6985. this.xhr.abort();
  6986. }
  6987. },
  6988. _isEventTargetInWidget: function( event ) {
  6989. var menuElement = this.menu.element[ 0 ];
  6990. return event.target === this.element[ 0 ] ||
  6991. event.target === menuElement ||
  6992. $.contains( menuElement, event.target );
  6993. },
  6994. _closeOnClickOutside: function( event ) {
  6995. if ( !this._isEventTargetInWidget( event ) ) {
  6996. this.close();
  6997. }
  6998. },
  6999. _appendTo: function() {
  7000. var element = this.options.appendTo;
  7001. if ( element ) {
  7002. element = element.jquery || element.nodeType ?
  7003. $( element ) :
  7004. this.document.find( element ).eq( 0 );
  7005. }
  7006. if ( !element || !element[ 0 ] ) {
  7007. element = this.element.closest( ".ui-front, dialog" );
  7008. }
  7009. if ( !element.length ) {
  7010. element = this.document[ 0 ].body;
  7011. }
  7012. return element;
  7013. },
  7014. _initSource: function() {
  7015. var array, url,
  7016. that = this;
  7017. if ( Array.isArray( this.options.source ) ) {
  7018. array = this.options.source;
  7019. this.source = function( request, response ) {
  7020. response( $.ui.autocomplete.filter( array, request.term ) );
  7021. };
  7022. } else if ( typeof this.options.source === "string" ) {
  7023. url = this.options.source;
  7024. this.source = function( request, response ) {
  7025. if ( that.xhr ) {
  7026. that.xhr.abort();
  7027. }
  7028. that.xhr = $.ajax( {
  7029. url: url,
  7030. data: request,
  7031. dataType: "json",
  7032. success: function( data ) {
  7033. response( data );
  7034. },
  7035. error: function() {
  7036. response( [] );
  7037. }
  7038. } );
  7039. };
  7040. } else {
  7041. this.source = this.options.source;
  7042. }
  7043. },
  7044. _searchTimeout: function( event ) {
  7045. clearTimeout( this.searching );
  7046. this.searching = this._delay( function() {
  7047. // Search if the value has changed, or if the user retypes the same value (see #7434)
  7048. var equalValues = this.term === this._value(),
  7049. menuVisible = this.menu.element.is( ":visible" ),
  7050. modifierKey = event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;
  7051. if ( !equalValues || ( equalValues && !menuVisible && !modifierKey ) ) {
  7052. this.selectedItem = null;
  7053. this.search( null, event );
  7054. }
  7055. }, this.options.delay );
  7056. },
  7057. search: function( value, event ) {
  7058. value = value != null ? value : this._value();
  7059. // Always save the actual value, not the one passed as an argument
  7060. this.term = this._value();
  7061. if ( value.length < this.options.minLength ) {
  7062. return this.close( event );
  7063. }
  7064. if ( this._trigger( "search", event ) === false ) {
  7065. return;
  7066. }
  7067. return this._search( value );
  7068. },
  7069. _search: function( value ) {
  7070. this.pending++;
  7071. this._addClass( "ui-autocomplete-loading" );
  7072. this.cancelSearch = false;
  7073. this.source( { term: value }, this._response() );
  7074. },
  7075. _response: function() {
  7076. var index = ++this.requestIndex;
  7077. return function( content ) {
  7078. if ( index === this.requestIndex ) {
  7079. this.__response( content );
  7080. }
  7081. this.pending--;
  7082. if ( !this.pending ) {
  7083. this._removeClass( "ui-autocomplete-loading" );
  7084. }
  7085. }.bind( this );
  7086. },
  7087. __response: function( content ) {
  7088. if ( content ) {
  7089. content = this._normalize( content );
  7090. }
  7091. this._trigger( "response", null, { content: content } );
  7092. if ( !this.options.disabled && content && content.length && !this.cancelSearch ) {
  7093. this._suggest( content );
  7094. this._trigger( "open" );
  7095. } else {
  7096. // use ._close() instead of .close() so we don't cancel future searches
  7097. this._close();
  7098. }
  7099. },
  7100. close: function( event ) {
  7101. this.cancelSearch = true;
  7102. this._close( event );
  7103. },
  7104. _close: function( event ) {
  7105. // Remove the handler that closes the menu on outside clicks
  7106. this._off( this.document, "mousedown" );
  7107. if ( this.menu.element.is( ":visible" ) ) {
  7108. this.menu.element.hide();
  7109. this.menu.blur();
  7110. this.isNewMenu = true;
  7111. this._trigger( "close", event );
  7112. }
  7113. },
  7114. _change: function( event ) {
  7115. if ( this.previous !== this._value() ) {
  7116. this._trigger( "change", event, { item: this.selectedItem } );
  7117. }
  7118. },
  7119. _normalize: function( items ) {
  7120. // assume all items have the right format when the first item is complete
  7121. if ( items.length && items[ 0 ].label && items[ 0 ].value ) {
  7122. return items;
  7123. }
  7124. return $.map( items, function( item ) {
  7125. if ( typeof item === "string" ) {
  7126. return {
  7127. label: item,
  7128. value: item
  7129. };
  7130. }
  7131. return $.extend( {}, item, {
  7132. label: item.label || item.value,
  7133. value: item.value || item.label
  7134. } );
  7135. } );
  7136. },
  7137. _suggest: function( items ) {
  7138. var ul = this.menu.element.empty();
  7139. this._renderMenu( ul, items );
  7140. this.isNewMenu = true;
  7141. this.menu.refresh();
  7142. // Size and position menu
  7143. ul.show();
  7144. this._resizeMenu();
  7145. ul.position( $.extend( {
  7146. of: this.element
  7147. }, this.options.position ) );
  7148. if ( this.options.autoFocus ) {
  7149. this.menu.next();
  7150. }
  7151. // Listen for interactions outside of the widget (#6642)
  7152. this._on( this.document, {
  7153. mousedown: "_closeOnClickOutside"
  7154. } );
  7155. },
  7156. _resizeMenu: function() {
  7157. var ul = this.menu.element;
  7158. ul.outerWidth( Math.max(
  7159. // Firefox wraps long text (possibly a rounding bug)
  7160. // so we add 1px to avoid the wrapping (#7513)
  7161. ul.width( "" ).outerWidth() + 1,
  7162. this.element.outerWidth()
  7163. ) );
  7164. },
  7165. _renderMenu: function( ul, items ) {
  7166. var that = this;
  7167. $.each( items, function( index, item ) {
  7168. that._renderItemData( ul, item );
  7169. } );
  7170. },
  7171. _renderItemData: function( ul, item ) {
  7172. return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
  7173. },
  7174. _renderItem: function( ul, item ) {
  7175. return $( "<li>" )
  7176. .append( $( "<div>" ).text( item.label ) )
  7177. .appendTo( ul );
  7178. },
  7179. _move: function( direction, event ) {
  7180. if ( !this.menu.element.is( ":visible" ) ) {
  7181. this.search( null, event );
  7182. return;
  7183. }
  7184. if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
  7185. this.menu.isLastItem() && /^next/.test( direction ) ) {
  7186. if ( !this.isMultiLine ) {
  7187. this._value( this.term );
  7188. }
  7189. this.menu.blur();
  7190. return;
  7191. }
  7192. this.menu[ direction ]( event );
  7193. },
  7194. widget: function() {
  7195. return this.menu.element;
  7196. },
  7197. _value: function() {
  7198. return this.valueMethod.apply( this.element, arguments );
  7199. },
  7200. _keyEvent: function( keyEvent, event ) {
  7201. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  7202. this._move( keyEvent, event );
  7203. // Prevents moving cursor to beginning/end of the text field in some browsers
  7204. event.preventDefault();
  7205. }
  7206. },
  7207. // Support: Chrome <=50
  7208. // We should be able to just use this.element.prop( "isContentEditable" )
  7209. // but hidden elements always report false in Chrome.
  7210. // https://code.google.com/p/chromium/issues/detail?id=313082
  7211. _isContentEditable: function( element ) {
  7212. if ( !element.length ) {
  7213. return false;
  7214. }
  7215. var editable = element.prop( "contentEditable" );
  7216. if ( editable === "inherit" ) {
  7217. return this._isContentEditable( element.parent() );
  7218. }
  7219. return editable === "true";
  7220. }
  7221. } );
  7222. $.extend( $.ui.autocomplete, {
  7223. escapeRegex: function( value ) {
  7224. return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
  7225. },
  7226. filter: function( array, term ) {
  7227. var matcher = new RegExp( $.ui.autocomplete.escapeRegex( term ), "i" );
  7228. return $.grep( array, function( value ) {
  7229. return matcher.test( value.label || value.value || value );
  7230. } );
  7231. }
  7232. } );
  7233. // Live region extension, adding a `messages` option
  7234. // NOTE: This is an experimental API. We are still investigating
  7235. // a full solution for string manipulation and internationalization.
  7236. $.widget( "ui.autocomplete", $.ui.autocomplete, {
  7237. options: {
  7238. messages: {
  7239. noResults: "No search results.",
  7240. results: function( amount ) {
  7241. return amount + ( amount > 1 ? " results are" : " result is" ) +
  7242. " available, use up and down arrow keys to navigate.";
  7243. }
  7244. }
  7245. },
  7246. __response: function( content ) {
  7247. var message;
  7248. this._superApply( arguments );
  7249. if ( this.options.disabled || this.cancelSearch ) {
  7250. return;
  7251. }
  7252. if ( content && content.length ) {
  7253. message = this.options.messages.results( content.length );
  7254. } else {
  7255. message = this.options.messages.noResults;
  7256. }
  7257. this.liveRegion.children().hide();
  7258. $( "<div>" ).text( message ).appendTo( this.liveRegion );
  7259. }
  7260. } );
  7261. var widgetsAutocomplete = $.ui.autocomplete;
  7262. /*!
  7263. * jQuery UI Controlgroup 1.13.0
  7264. * http://jqueryui.com
  7265. *
  7266. * Copyright jQuery Foundation and other contributors
  7267. * Released under the MIT license.
  7268. * http://jquery.org/license
  7269. */
  7270. //>>label: Controlgroup
  7271. //>>group: Widgets
  7272. //>>description: Visually groups form control widgets
  7273. //>>docs: http://api.jqueryui.com/controlgroup/
  7274. //>>demos: http://jqueryui.com/controlgroup/
  7275. //>>css.structure: ../../themes/base/core.css
  7276. //>>css.structure: ../../themes/base/controlgroup.css
  7277. //>>css.theme: ../../themes/base/theme.css
  7278. var controlgroupCornerRegex = /ui-corner-([a-z]){2,6}/g;
  7279. var widgetsControlgroup = $.widget( "ui.controlgroup", {
  7280. version: "1.13.0",
  7281. defaultElement: "<div>",
  7282. options: {
  7283. direction: "horizontal",
  7284. disabled: null,
  7285. onlyVisible: true,
  7286. items: {
  7287. "button": "input[type=button], input[type=submit], input[type=reset], button, a",
  7288. "controlgroupLabel": ".ui-controlgroup-label",
  7289. "checkboxradio": "input[type='checkbox'], input[type='radio']",
  7290. "selectmenu": "select",
  7291. "spinner": ".ui-spinner-input"
  7292. }
  7293. },
  7294. _create: function() {
  7295. this._enhance();
  7296. },
  7297. // To support the enhanced option in jQuery Mobile, we isolate DOM manipulation
  7298. _enhance: function() {
  7299. this.element.attr( "role", "toolbar" );
  7300. this.refresh();
  7301. },
  7302. _destroy: function() {
  7303. this._callChildMethod( "destroy" );
  7304. this.childWidgets.removeData( "ui-controlgroup-data" );
  7305. this.element.removeAttr( "role" );
  7306. if ( this.options.items.controlgroupLabel ) {
  7307. this.element
  7308. .find( this.options.items.controlgroupLabel )
  7309. .find( ".ui-controlgroup-label-contents" )
  7310. .contents().unwrap();
  7311. }
  7312. },
  7313. _initWidgets: function() {
  7314. var that = this,
  7315. childWidgets = [];
  7316. // First we iterate over each of the items options
  7317. $.each( this.options.items, function( widget, selector ) {
  7318. var labels;
  7319. var options = {};
  7320. // Make sure the widget has a selector set
  7321. if ( !selector ) {
  7322. return;
  7323. }
  7324. if ( widget === "controlgroupLabel" ) {
  7325. labels = that.element.find( selector );
  7326. labels.each( function() {
  7327. var element = $( this );
  7328. if ( element.children( ".ui-controlgroup-label-contents" ).length ) {
  7329. return;
  7330. }
  7331. element.contents()
  7332. .wrapAll( "<span class='ui-controlgroup-label-contents'></span>" );
  7333. } );
  7334. that._addClass( labels, null, "ui-widget ui-widget-content ui-state-default" );
  7335. childWidgets = childWidgets.concat( labels.get() );
  7336. return;
  7337. }
  7338. // Make sure the widget actually exists
  7339. if ( !$.fn[ widget ] ) {
  7340. return;
  7341. }
  7342. // We assume everything is in the middle to start because we can't determine
  7343. // first / last elements until all enhancments are done.
  7344. if ( that[ "_" + widget + "Options" ] ) {
  7345. options = that[ "_" + widget + "Options" ]( "middle" );
  7346. } else {
  7347. options = { classes: {} };
  7348. }
  7349. // Find instances of this widget inside controlgroup and init them
  7350. that.element
  7351. .find( selector )
  7352. .each( function() {
  7353. var element = $( this );
  7354. var instance = element[ widget ]( "instance" );
  7355. // We need to clone the default options for this type of widget to avoid
  7356. // polluting the variable options which has a wider scope than a single widget.
  7357. var instanceOptions = $.widget.extend( {}, options );
  7358. // If the button is the child of a spinner ignore it
  7359. // TODO: Find a more generic solution
  7360. if ( widget === "button" && element.parent( ".ui-spinner" ).length ) {
  7361. return;
  7362. }
  7363. // Create the widget if it doesn't exist
  7364. if ( !instance ) {
  7365. instance = element[ widget ]()[ widget ]( "instance" );
  7366. }
  7367. if ( instance ) {
  7368. instanceOptions.classes =
  7369. that._resolveClassesValues( instanceOptions.classes, instance );
  7370. }
  7371. element[ widget ]( instanceOptions );
  7372. // Store an instance of the controlgroup to be able to reference
  7373. // from the outermost element for changing options and refresh
  7374. var widgetElement = element[ widget ]( "widget" );
  7375. $.data( widgetElement[ 0 ], "ui-controlgroup-data",
  7376. instance ? instance : element[ widget ]( "instance" ) );
  7377. childWidgets.push( widgetElement[ 0 ] );
  7378. } );
  7379. } );
  7380. this.childWidgets = $( $.uniqueSort( childWidgets ) );
  7381. this._addClass( this.childWidgets, "ui-controlgroup-item" );
  7382. },
  7383. _callChildMethod: function( method ) {
  7384. this.childWidgets.each( function() {
  7385. var element = $( this ),
  7386. data = element.data( "ui-controlgroup-data" );
  7387. if ( data && data[ method ] ) {
  7388. data[ method ]();
  7389. }
  7390. } );
  7391. },
  7392. _updateCornerClass: function( element, position ) {
  7393. var remove = "ui-corner-top ui-corner-bottom ui-corner-left ui-corner-right ui-corner-all";
  7394. var add = this._buildSimpleOptions( position, "label" ).classes.label;
  7395. this._removeClass( element, null, remove );
  7396. this._addClass( element, null, add );
  7397. },
  7398. _buildSimpleOptions: function( position, key ) {
  7399. var direction = this.options.direction === "vertical";
  7400. var result = {
  7401. classes: {}
  7402. };
  7403. result.classes[ key ] = {
  7404. "middle": "",
  7405. "first": "ui-corner-" + ( direction ? "top" : "left" ),
  7406. "last": "ui-corner-" + ( direction ? "bottom" : "right" ),
  7407. "only": "ui-corner-all"
  7408. }[ position ];
  7409. return result;
  7410. },
  7411. _spinnerOptions: function( position ) {
  7412. var options = this._buildSimpleOptions( position, "ui-spinner" );
  7413. options.classes[ "ui-spinner-up" ] = "";
  7414. options.classes[ "ui-spinner-down" ] = "";
  7415. return options;
  7416. },
  7417. _buttonOptions: function( position ) {
  7418. return this._buildSimpleOptions( position, "ui-button" );
  7419. },
  7420. _checkboxradioOptions: function( position ) {
  7421. return this._buildSimpleOptions( position, "ui-checkboxradio-label" );
  7422. },
  7423. _selectmenuOptions: function( position ) {
  7424. var direction = this.options.direction === "vertical";
  7425. return {
  7426. width: direction ? "auto" : false,
  7427. classes: {
  7428. middle: {
  7429. "ui-selectmenu-button-open": "",
  7430. "ui-selectmenu-button-closed": ""
  7431. },
  7432. first: {
  7433. "ui-selectmenu-button-open": "ui-corner-" + ( direction ? "top" : "tl" ),
  7434. "ui-selectmenu-button-closed": "ui-corner-" + ( direction ? "top" : "left" )
  7435. },
  7436. last: {
  7437. "ui-selectmenu-button-open": direction ? "" : "ui-corner-tr",
  7438. "ui-selectmenu-button-closed": "ui-corner-" + ( direction ? "bottom" : "right" )
  7439. },
  7440. only: {
  7441. "ui-selectmenu-button-open": "ui-corner-top",
  7442. "ui-selectmenu-button-closed": "ui-corner-all"
  7443. }
  7444. }[ position ]
  7445. };
  7446. },
  7447. _resolveClassesValues: function( classes, instance ) {
  7448. var result = {};
  7449. $.each( classes, function( key ) {
  7450. var current = instance.options.classes[ key ] || "";
  7451. current = String.prototype.trim.call( current.replace( controlgroupCornerRegex, "" ) );
  7452. result[ key ] = ( current + " " + classes[ key ] ).replace( /\s+/g, " " );
  7453. } );
  7454. return result;
  7455. },
  7456. _setOption: function( key, value ) {
  7457. if ( key === "direction" ) {
  7458. this._removeClass( "ui-controlgroup-" + this.options.direction );
  7459. }
  7460. this._super( key, value );
  7461. if ( key === "disabled" ) {
  7462. this._callChildMethod( value ? "disable" : "enable" );
  7463. return;
  7464. }
  7465. this.refresh();
  7466. },
  7467. refresh: function() {
  7468. var children,
  7469. that = this;
  7470. this._addClass( "ui-controlgroup ui-controlgroup-" + this.options.direction );
  7471. if ( this.options.direction === "horizontal" ) {
  7472. this._addClass( null, "ui-helper-clearfix" );
  7473. }
  7474. this._initWidgets();
  7475. children = this.childWidgets;
  7476. // We filter here because we need to track all childWidgets not just the visible ones
  7477. if ( this.options.onlyVisible ) {
  7478. children = children.filter( ":visible" );
  7479. }
  7480. if ( children.length ) {
  7481. // We do this last because we need to make sure all enhancment is done
  7482. // before determining first and last
  7483. $.each( [ "first", "last" ], function( index, value ) {
  7484. var instance = children[ value ]().data( "ui-controlgroup-data" );
  7485. if ( instance && that[ "_" + instance.widgetName + "Options" ] ) {
  7486. var options = that[ "_" + instance.widgetName + "Options" ](
  7487. children.length === 1 ? "only" : value
  7488. );
  7489. options.classes = that._resolveClassesValues( options.classes, instance );
  7490. instance.element[ instance.widgetName ]( options );
  7491. } else {
  7492. that._updateCornerClass( children[ value ](), value );
  7493. }
  7494. } );
  7495. // Finally call the refresh method on each of the child widgets.
  7496. this._callChildMethod( "refresh" );
  7497. }
  7498. }
  7499. } );
  7500. /*!
  7501. * jQuery UI Checkboxradio 1.13.0
  7502. * http://jqueryui.com
  7503. *
  7504. * Copyright jQuery Foundation and other contributors
  7505. * Released under the MIT license.
  7506. * http://jquery.org/license
  7507. */
  7508. //>>label: Checkboxradio
  7509. //>>group: Widgets
  7510. //>>description: Enhances a form with multiple themeable checkboxes or radio buttons.
  7511. //>>docs: http://api.jqueryui.com/checkboxradio/
  7512. //>>demos: http://jqueryui.com/checkboxradio/
  7513. //>>css.structure: ../../themes/base/core.css
  7514. //>>css.structure: ../../themes/base/button.css
  7515. //>>css.structure: ../../themes/base/checkboxradio.css
  7516. //>>css.theme: ../../themes/base/theme.css
  7517. $.widget( "ui.checkboxradio", [ $.ui.formResetMixin, {
  7518. version: "1.13.0",
  7519. options: {
  7520. disabled: null,
  7521. label: null,
  7522. icon: true,
  7523. classes: {
  7524. "ui-checkboxradio-label": "ui-corner-all",
  7525. "ui-checkboxradio-icon": "ui-corner-all"
  7526. }
  7527. },
  7528. _getCreateOptions: function() {
  7529. var disabled, labels;
  7530. var that = this;
  7531. var options = this._super() || {};
  7532. // We read the type here, because it makes more sense to throw a element type error first,
  7533. // rather then the error for lack of a label. Often if its the wrong type, it
  7534. // won't have a label (e.g. calling on a div, btn, etc)
  7535. this._readType();
  7536. labels = this.element.labels();
  7537. // If there are multiple labels, use the last one
  7538. this.label = $( labels[ labels.length - 1 ] );
  7539. if ( !this.label.length ) {
  7540. $.error( "No label found for checkboxradio widget" );
  7541. }
  7542. this.originalLabel = "";
  7543. // We need to get the label text but this may also need to make sure it does not contain the
  7544. // input itself.
  7545. this.label.contents().not( this.element[ 0 ] ).each( function() {
  7546. // The label contents could be text, html, or a mix. We concat each element to get a
  7547. // string representation of the label, without the input as part of it.
  7548. that.originalLabel += this.nodeType === 3 ? $( this ).text() : this.outerHTML;
  7549. } );
  7550. // Set the label option if we found label text
  7551. if ( this.originalLabel ) {
  7552. options.label = this.originalLabel;
  7553. }
  7554. disabled = this.element[ 0 ].disabled;
  7555. if ( disabled != null ) {
  7556. options.disabled = disabled;
  7557. }
  7558. return options;
  7559. },
  7560. _create: function() {
  7561. var checked = this.element[ 0 ].checked;
  7562. this._bindFormResetHandler();
  7563. if ( this.options.disabled == null ) {
  7564. this.options.disabled = this.element[ 0 ].disabled;
  7565. }
  7566. this._setOption( "disabled", this.options.disabled );
  7567. this._addClass( "ui-checkboxradio", "ui-helper-hidden-accessible" );
  7568. this._addClass( this.label, "ui-checkboxradio-label", "ui-button ui-widget" );
  7569. if ( this.type === "radio" ) {
  7570. this._addClass( this.label, "ui-checkboxradio-radio-label" );
  7571. }
  7572. if ( this.options.label && this.options.label !== this.originalLabel ) {
  7573. this._updateLabel();
  7574. } else if ( this.originalLabel ) {
  7575. this.options.label = this.originalLabel;
  7576. }
  7577. this._enhance();
  7578. if ( checked ) {
  7579. this._addClass( this.label, "ui-checkboxradio-checked", "ui-state-active" );
  7580. }
  7581. this._on( {
  7582. change: "_toggleClasses",
  7583. focus: function() {
  7584. this._addClass( this.label, null, "ui-state-focus ui-visual-focus" );
  7585. },
  7586. blur: function() {
  7587. this._removeClass( this.label, null, "ui-state-focus ui-visual-focus" );
  7588. }
  7589. } );
  7590. },
  7591. _readType: function() {
  7592. var nodeName = this.element[ 0 ].nodeName.toLowerCase();
  7593. this.type = this.element[ 0 ].type;
  7594. if ( nodeName !== "input" || !/radio|checkbox/.test( this.type ) ) {
  7595. $.error( "Can't create checkboxradio on element.nodeName=" + nodeName +
  7596. " and element.type=" + this.type );
  7597. }
  7598. },
  7599. // Support jQuery Mobile enhanced option
  7600. _enhance: function() {
  7601. this._updateIcon( this.element[ 0 ].checked );
  7602. },
  7603. widget: function() {
  7604. return this.label;
  7605. },
  7606. _getRadioGroup: function() {
  7607. var group;
  7608. var name = this.element[ 0 ].name;
  7609. var nameSelector = "input[name='" + $.escapeSelector( name ) + "']";
  7610. if ( !name ) {
  7611. return $( [] );
  7612. }
  7613. if ( this.form.length ) {
  7614. group = $( this.form[ 0 ].elements ).filter( nameSelector );
  7615. } else {
  7616. // Not inside a form, check all inputs that also are not inside a form
  7617. group = $( nameSelector ).filter( function() {
  7618. return $( this )._form().length === 0;
  7619. } );
  7620. }
  7621. return group.not( this.element );
  7622. },
  7623. _toggleClasses: function() {
  7624. var checked = this.element[ 0 ].checked;
  7625. this._toggleClass( this.label, "ui-checkboxradio-checked", "ui-state-active", checked );
  7626. if ( this.options.icon && this.type === "checkbox" ) {
  7627. this._toggleClass( this.icon, null, "ui-icon-check ui-state-checked", checked )
  7628. ._toggleClass( this.icon, null, "ui-icon-blank", !checked );
  7629. }
  7630. if ( this.type === "radio" ) {
  7631. this._getRadioGroup()
  7632. .each( function() {
  7633. var instance = $( this ).checkboxradio( "instance" );
  7634. if ( instance ) {
  7635. instance._removeClass( instance.label,
  7636. "ui-checkboxradio-checked", "ui-state-active" );
  7637. }
  7638. } );
  7639. }
  7640. },
  7641. _destroy: function() {
  7642. this._unbindFormResetHandler();
  7643. if ( this.icon ) {
  7644. this.icon.remove();
  7645. this.iconSpace.remove();
  7646. }
  7647. },
  7648. _setOption: function( key, value ) {
  7649. // We don't allow the value to be set to nothing
  7650. if ( key === "label" && !value ) {
  7651. return;
  7652. }
  7653. this._super( key, value );
  7654. if ( key === "disabled" ) {
  7655. this._toggleClass( this.label, null, "ui-state-disabled", value );
  7656. this.element[ 0 ].disabled = value;
  7657. // Don't refresh when setting disabled
  7658. return;
  7659. }
  7660. this.refresh();
  7661. },
  7662. _updateIcon: function( checked ) {
  7663. var toAdd = "ui-icon ui-icon-background ";
  7664. if ( this.options.icon ) {
  7665. if ( !this.icon ) {
  7666. this.icon = $( "<span>" );
  7667. this.iconSpace = $( "<span> </span>" );
  7668. this._addClass( this.iconSpace, "ui-checkboxradio-icon-space" );
  7669. }
  7670. if ( this.type === "checkbox" ) {
  7671. toAdd += checked ? "ui-icon-check ui-state-checked" : "ui-icon-blank";
  7672. this._removeClass( this.icon, null, checked ? "ui-icon-blank" : "ui-icon-check" );
  7673. } else {
  7674. toAdd += "ui-icon-blank";
  7675. }
  7676. this._addClass( this.icon, "ui-checkboxradio-icon", toAdd );
  7677. if ( !checked ) {
  7678. this._removeClass( this.icon, null, "ui-icon-check ui-state-checked" );
  7679. }
  7680. this.icon.prependTo( this.label ).after( this.iconSpace );
  7681. } else if ( this.icon !== undefined ) {
  7682. this.icon.remove();
  7683. this.iconSpace.remove();
  7684. delete this.icon;
  7685. }
  7686. },
  7687. _updateLabel: function() {
  7688. // Remove the contents of the label ( minus the icon, icon space, and input )
  7689. var contents = this.label.contents().not( this.element[ 0 ] );
  7690. if ( this.icon ) {
  7691. contents = contents.not( this.icon[ 0 ] );
  7692. }
  7693. if ( this.iconSpace ) {
  7694. contents = contents.not( this.iconSpace[ 0 ] );
  7695. }
  7696. contents.remove();
  7697. this.label.append( this.options.label );
  7698. },
  7699. refresh: function() {
  7700. var checked = this.element[ 0 ].checked,
  7701. isDisabled = this.element[ 0 ].disabled;
  7702. this._updateIcon( checked );
  7703. this._toggleClass( this.label, "ui-checkboxradio-checked", "ui-state-active", checked );
  7704. if ( this.options.label !== null ) {
  7705. this._updateLabel();
  7706. }
  7707. if ( isDisabled !== this.options.disabled ) {
  7708. this._setOptions( { "disabled": isDisabled } );
  7709. }
  7710. }
  7711. } ] );
  7712. var widgetsCheckboxradio = $.ui.checkboxradio;
  7713. /*!
  7714. * jQuery UI Button 1.13.0
  7715. * http://jqueryui.com
  7716. *
  7717. * Copyright jQuery Foundation and other contributors
  7718. * Released under the MIT license.
  7719. * http://jquery.org/license
  7720. */
  7721. //>>label: Button
  7722. //>>group: Widgets
  7723. //>>description: Enhances a form with themeable buttons.
  7724. //>>docs: http://api.jqueryui.com/button/
  7725. //>>demos: http://jqueryui.com/button/
  7726. //>>css.structure: ../../themes/base/core.css
  7727. //>>css.structure: ../../themes/base/button.css
  7728. //>>css.theme: ../../themes/base/theme.css
  7729. $.widget( "ui.button", {
  7730. version: "1.13.0",
  7731. defaultElement: "<button>",
  7732. options: {
  7733. classes: {
  7734. "ui-button": "ui-corner-all"
  7735. },
  7736. disabled: null,
  7737. icon: null,
  7738. iconPosition: "beginning",
  7739. label: null,
  7740. showLabel: true
  7741. },
  7742. _getCreateOptions: function() {
  7743. var disabled,
  7744. // This is to support cases like in jQuery Mobile where the base widget does have
  7745. // an implementation of _getCreateOptions
  7746. options = this._super() || {};
  7747. this.isInput = this.element.is( "input" );
  7748. disabled = this.element[ 0 ].disabled;
  7749. if ( disabled != null ) {
  7750. options.disabled = disabled;
  7751. }
  7752. this.originalLabel = this.isInput ? this.element.val() : this.element.html();
  7753. if ( this.originalLabel ) {
  7754. options.label = this.originalLabel;
  7755. }
  7756. return options;
  7757. },
  7758. _create: function() {
  7759. if ( !this.option.showLabel & !this.options.icon ) {
  7760. this.options.showLabel = true;
  7761. }
  7762. // We have to check the option again here even though we did in _getCreateOptions,
  7763. // because null may have been passed on init which would override what was set in
  7764. // _getCreateOptions
  7765. if ( this.options.disabled == null ) {
  7766. this.options.disabled = this.element[ 0 ].disabled || false;
  7767. }
  7768. this.hasTitle = !!this.element.attr( "title" );
  7769. // Check to see if the label needs to be set or if its already correct
  7770. if ( this.options.label && this.options.label !== this.originalLabel ) {
  7771. if ( this.isInput ) {
  7772. this.element.val( this.options.label );
  7773. } else {
  7774. this.element.html( this.options.label );
  7775. }
  7776. }
  7777. this._addClass( "ui-button", "ui-widget" );
  7778. this._setOption( "disabled", this.options.disabled );
  7779. this._enhance();
  7780. if ( this.element.is( "a" ) ) {
  7781. this._on( {
  7782. "keyup": function( event ) {
  7783. if ( event.keyCode === $.ui.keyCode.SPACE ) {
  7784. event.preventDefault();
  7785. // Support: PhantomJS <= 1.9, IE 8 Only
  7786. // If a native click is available use it so we actually cause navigation
  7787. // otherwise just trigger a click event
  7788. if ( this.element[ 0 ].click ) {
  7789. this.element[ 0 ].click();
  7790. } else {
  7791. this.element.trigger( "click" );
  7792. }
  7793. }
  7794. }
  7795. } );
  7796. }
  7797. },
  7798. _enhance: function() {
  7799. if ( !this.element.is( "button" ) ) {
  7800. this.element.attr( "role", "button" );
  7801. }
  7802. if ( this.options.icon ) {
  7803. this._updateIcon( "icon", this.options.icon );
  7804. this._updateTooltip();
  7805. }
  7806. },
  7807. _updateTooltip: function() {
  7808. this.title = this.element.attr( "title" );
  7809. if ( !this.options.showLabel && !this.title ) {
  7810. this.element.attr( "title", this.options.label );
  7811. }
  7812. },
  7813. _updateIcon: function( option, value ) {
  7814. var icon = option !== "iconPosition",
  7815. position = icon ? this.options.iconPosition : value,
  7816. displayBlock = position === "top" || position === "bottom";
  7817. // Create icon
  7818. if ( !this.icon ) {
  7819. this.icon = $( "<span>" );
  7820. this._addClass( this.icon, "ui-button-icon", "ui-icon" );
  7821. if ( !this.options.showLabel ) {
  7822. this._addClass( "ui-button-icon-only" );
  7823. }
  7824. } else if ( icon ) {
  7825. // If we are updating the icon remove the old icon class
  7826. this._removeClass( this.icon, null, this.options.icon );
  7827. }
  7828. // If we are updating the icon add the new icon class
  7829. if ( icon ) {
  7830. this._addClass( this.icon, null, value );
  7831. }
  7832. this._attachIcon( position );
  7833. // If the icon is on top or bottom we need to add the ui-widget-icon-block class and remove
  7834. // the iconSpace if there is one.
  7835. if ( displayBlock ) {
  7836. this._addClass( this.icon, null, "ui-widget-icon-block" );
  7837. if ( this.iconSpace ) {
  7838. this.iconSpace.remove();
  7839. }
  7840. } else {
  7841. // Position is beginning or end so remove the ui-widget-icon-block class and add the
  7842. // space if it does not exist
  7843. if ( !this.iconSpace ) {
  7844. this.iconSpace = $( "<span> </span>" );
  7845. this._addClass( this.iconSpace, "ui-button-icon-space" );
  7846. }
  7847. this._removeClass( this.icon, null, "ui-wiget-icon-block" );
  7848. this._attachIconSpace( position );
  7849. }
  7850. },
  7851. _destroy: function() {
  7852. this.element.removeAttr( "role" );
  7853. if ( this.icon ) {
  7854. this.icon.remove();
  7855. }
  7856. if ( this.iconSpace ) {
  7857. this.iconSpace.remove();
  7858. }
  7859. if ( !this.hasTitle ) {
  7860. this.element.removeAttr( "title" );
  7861. }
  7862. },
  7863. _attachIconSpace: function( iconPosition ) {
  7864. this.icon[ /^(?:end|bottom)/.test( iconPosition ) ? "before" : "after" ]( this.iconSpace );
  7865. },
  7866. _attachIcon: function( iconPosition ) {
  7867. this.element[ /^(?:end|bottom)/.test( iconPosition ) ? "append" : "prepend" ]( this.icon );
  7868. },
  7869. _setOptions: function( options ) {
  7870. var newShowLabel = options.showLabel === undefined ?
  7871. this.options.showLabel :
  7872. options.showLabel,
  7873. newIcon = options.icon === undefined ? this.options.icon : options.icon;
  7874. if ( !newShowLabel && !newIcon ) {
  7875. options.showLabel = true;
  7876. }
  7877. this._super( options );
  7878. },
  7879. _setOption: function( key, value ) {
  7880. if ( key === "icon" ) {
  7881. if ( value ) {
  7882. this._updateIcon( key, value );
  7883. } else if ( this.icon ) {
  7884. this.icon.remove();
  7885. if ( this.iconSpace ) {
  7886. this.iconSpace.remove();
  7887. }
  7888. }
  7889. }
  7890. if ( key === "iconPosition" ) {
  7891. this._updateIcon( key, value );
  7892. }
  7893. // Make sure we can't end up with a button that has neither text nor icon
  7894. if ( key === "showLabel" ) {
  7895. this._toggleClass( "ui-button-icon-only", null, !value );
  7896. this._updateTooltip();
  7897. }
  7898. if ( key === "label" ) {
  7899. if ( this.isInput ) {
  7900. this.element.val( value );
  7901. } else {
  7902. // If there is an icon, append it, else nothing then append the value
  7903. // this avoids removal of the icon when setting label text
  7904. this.element.html( value );
  7905. if ( this.icon ) {
  7906. this._attachIcon( this.options.iconPosition );
  7907. this._attachIconSpace( this.options.iconPosition );
  7908. }
  7909. }
  7910. }
  7911. this._super( key, value );
  7912. if ( key === "disabled" ) {
  7913. this._toggleClass( null, "ui-state-disabled", value );
  7914. this.element[ 0 ].disabled = value;
  7915. if ( value ) {
  7916. this.element.trigger( "blur" );
  7917. }
  7918. }
  7919. },
  7920. refresh: function() {
  7921. // Make sure to only check disabled if its an element that supports this otherwise
  7922. // check for the disabled class to determine state
  7923. var isDisabled = this.element.is( "input, button" ) ?
  7924. this.element[ 0 ].disabled : this.element.hasClass( "ui-button-disabled" );
  7925. if ( isDisabled !== this.options.disabled ) {
  7926. this._setOptions( { disabled: isDisabled } );
  7927. }
  7928. this._updateTooltip();
  7929. }
  7930. } );
  7931. // DEPRECATED
  7932. if ( $.uiBackCompat !== false ) {
  7933. // Text and Icons options
  7934. $.widget( "ui.button", $.ui.button, {
  7935. options: {
  7936. text: true,
  7937. icons: {
  7938. primary: null,
  7939. secondary: null
  7940. }
  7941. },
  7942. _create: function() {
  7943. if ( this.options.showLabel && !this.options.text ) {
  7944. this.options.showLabel = this.options.text;
  7945. }
  7946. if ( !this.options.showLabel && this.options.text ) {
  7947. this.options.text = this.options.showLabel;
  7948. }
  7949. if ( !this.options.icon && ( this.options.icons.primary ||
  7950. this.options.icons.secondary ) ) {
  7951. if ( this.options.icons.primary ) {
  7952. this.options.icon = this.options.icons.primary;
  7953. } else {
  7954. this.options.icon = this.options.icons.secondary;
  7955. this.options.iconPosition = "end";
  7956. }
  7957. } else if ( this.options.icon ) {
  7958. this.options.icons.primary = this.options.icon;
  7959. }
  7960. this._super();
  7961. },
  7962. _setOption: function( key, value ) {
  7963. if ( key === "text" ) {
  7964. this._super( "showLabel", value );
  7965. return;
  7966. }
  7967. if ( key === "showLabel" ) {
  7968. this.options.text = value;
  7969. }
  7970. if ( key === "icon" ) {
  7971. this.options.icons.primary = value;
  7972. }
  7973. if ( key === "icons" ) {
  7974. if ( value.primary ) {
  7975. this._super( "icon", value.primary );
  7976. this._super( "iconPosition", "beginning" );
  7977. } else if ( value.secondary ) {
  7978. this._super( "icon", value.secondary );
  7979. this._super( "iconPosition", "end" );
  7980. }
  7981. }
  7982. this._superApply( arguments );
  7983. }
  7984. } );
  7985. $.fn.button = ( function( orig ) {
  7986. return function( options ) {
  7987. var isMethodCall = typeof options === "string";
  7988. var args = Array.prototype.slice.call( arguments, 1 );
  7989. var returnValue = this;
  7990. if ( isMethodCall ) {
  7991. // If this is an empty collection, we need to have the instance method
  7992. // return undefined instead of the jQuery instance
  7993. if ( !this.length && options === "instance" ) {
  7994. returnValue = undefined;
  7995. } else {
  7996. this.each( function() {
  7997. var methodValue;
  7998. var type = $( this ).attr( "type" );
  7999. var name = type !== "checkbox" && type !== "radio" ?
  8000. "button" :
  8001. "checkboxradio";
  8002. var instance = $.data( this, "ui-" + name );
  8003. if ( options === "instance" ) {
  8004. returnValue = instance;
  8005. return false;
  8006. }
  8007. if ( !instance ) {
  8008. return $.error( "cannot call methods on button" +
  8009. " prior to initialization; " +
  8010. "attempted to call method '" + options + "'" );
  8011. }
  8012. if ( typeof instance[ options ] !== "function" ||
  8013. options.charAt( 0 ) === "_" ) {
  8014. return $.error( "no such method '" + options + "' for button" +
  8015. " widget instance" );
  8016. }
  8017. methodValue = instance[ options ].apply( instance, args );
  8018. if ( methodValue !== instance && methodValue !== undefined ) {
  8019. returnValue = methodValue && methodValue.jquery ?
  8020. returnValue.pushStack( methodValue.get() ) :
  8021. methodValue;
  8022. return false;
  8023. }
  8024. } );
  8025. }
  8026. } else {
  8027. // Allow multiple hashes to be passed on init
  8028. if ( args.length ) {
  8029. options = $.widget.extend.apply( null, [ options ].concat( args ) );
  8030. }
  8031. this.each( function() {
  8032. var type = $( this ).attr( "type" );
  8033. var name = type !== "checkbox" && type !== "radio" ? "button" : "checkboxradio";
  8034. var instance = $.data( this, "ui-" + name );
  8035. if ( instance ) {
  8036. instance.option( options || {} );
  8037. if ( instance._init ) {
  8038. instance._init();
  8039. }
  8040. } else {
  8041. if ( name === "button" ) {
  8042. orig.call( $( this ), options );
  8043. return;
  8044. }
  8045. $( this ).checkboxradio( $.extend( { icon: false }, options ) );
  8046. }
  8047. } );
  8048. }
  8049. return returnValue;
  8050. };
  8051. } )( $.fn.button );
  8052. $.fn.buttonset = function() {
  8053. if ( !$.ui.controlgroup ) {
  8054. $.error( "Controlgroup widget missing" );
  8055. }
  8056. if ( arguments[ 0 ] === "option" && arguments[ 1 ] === "items" && arguments[ 2 ] ) {
  8057. return this.controlgroup.apply( this,
  8058. [ arguments[ 0 ], "items.button", arguments[ 2 ] ] );
  8059. }
  8060. if ( arguments[ 0 ] === "option" && arguments[ 1 ] === "items" ) {
  8061. return this.controlgroup.apply( this, [ arguments[ 0 ], "items.button" ] );
  8062. }
  8063. if ( typeof arguments[ 0 ] === "object" && arguments[ 0 ].items ) {
  8064. arguments[ 0 ].items = {
  8065. button: arguments[ 0 ].items
  8066. };
  8067. }
  8068. return this.controlgroup.apply( this, arguments );
  8069. };
  8070. }
  8071. var widgetsButton = $.ui.button;
  8072. /* eslint-disable max-len, camelcase */
  8073. /*!
  8074. * jQuery UI Datepicker 1.13.0
  8075. * http://jqueryui.com
  8076. *
  8077. * Copyright jQuery Foundation and other contributors
  8078. * Released under the MIT license.
  8079. * http://jquery.org/license
  8080. */
  8081. //>>label: Datepicker
  8082. //>>group: Widgets
  8083. //>>description: Displays a calendar from an input or inline for selecting dates.
  8084. //>>docs: http://api.jqueryui.com/datepicker/
  8085. //>>demos: http://jqueryui.com/datepicker/
  8086. //>>css.structure: ../../themes/base/core.css
  8087. //>>css.structure: ../../themes/base/datepicker.css
  8088. //>>css.theme: ../../themes/base/theme.css
  8089. $.extend( $.ui, { datepicker: { version: "1.13.0" } } );
  8090. var datepicker_instActive;
  8091. function datepicker_getZindex( elem ) {
  8092. var position, value;
  8093. while ( elem.length && elem[ 0 ] !== document ) {
  8094. // Ignore z-index if position is set to a value where z-index is ignored by the browser
  8095. // This makes behavior of this function consistent across browsers
  8096. // WebKit always returns auto if the element is positioned
  8097. position = elem.css( "position" );
  8098. if ( position === "absolute" || position === "relative" || position === "fixed" ) {
  8099. // IE returns 0 when zIndex is not specified
  8100. // other browsers return a string
  8101. // we ignore the case of nested elements with an explicit value of 0
  8102. // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
  8103. value = parseInt( elem.css( "zIndex" ), 10 );
  8104. if ( !isNaN( value ) && value !== 0 ) {
  8105. return value;
  8106. }
  8107. }
  8108. elem = elem.parent();
  8109. }
  8110. return 0;
  8111. }
  8112. /* Date picker manager.
  8113. Use the singleton instance of this class, $.datepicker, to interact with the date picker.
  8114. Settings for (groups of) date pickers are maintained in an instance object,
  8115. allowing multiple different settings on the same page. */
  8116. function Datepicker() {
  8117. this._curInst = null; // The current instance in use
  8118. this._keyEvent = false; // If the last event was a key event
  8119. this._disabledInputs = []; // List of date picker inputs that have been disabled
  8120. this._datepickerShowing = false; // True if the popup picker is showing , false if not
  8121. this._inDialog = false; // True if showing within a "dialog", false if not
  8122. this._mainDivId = "ui-datepicker-div"; // The ID of the main datepicker division
  8123. this._inlineClass = "ui-datepicker-inline"; // The name of the inline marker class
  8124. this._appendClass = "ui-datepicker-append"; // The name of the append marker class
  8125. this._triggerClass = "ui-datepicker-trigger"; // The name of the trigger marker class
  8126. this._dialogClass = "ui-datepicker-dialog"; // The name of the dialog marker class
  8127. this._disableClass = "ui-datepicker-disabled"; // The name of the disabled covering marker class
  8128. this._unselectableClass = "ui-datepicker-unselectable"; // The name of the unselectable cell marker class
  8129. this._currentClass = "ui-datepicker-current-day"; // The name of the current day marker class
  8130. this._dayOverClass = "ui-datepicker-days-cell-over"; // The name of the day hover marker class
  8131. this.regional = []; // Available regional settings, indexed by language code
  8132. this.regional[ "" ] = { // Default regional settings
  8133. closeText: "Done", // Display text for close link
  8134. prevText: "Prev", // Display text for previous month link
  8135. nextText: "Next", // Display text for next month link
  8136. currentText: "Today", // Display text for current month link
  8137. monthNames: [ "January", "February", "March", "April", "May", "June",
  8138. "July", "August", "September", "October", "November", "December" ], // Names of months for drop-down and formatting
  8139. monthNamesShort: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ], // For formatting
  8140. dayNames: [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ], // For formatting
  8141. dayNamesShort: [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ], // For formatting
  8142. dayNamesMin: [ "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" ], // Column headings for days starting at Sunday
  8143. weekHeader: "Wk", // Column header for week of the year
  8144. dateFormat: "mm/dd/yy", // See format options on parseDate
  8145. firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
  8146. isRTL: false, // True if right-to-left language, false if left-to-right
  8147. showMonthAfterYear: false, // True if the year select precedes month, false for month then year
  8148. yearSuffix: "", // Additional text to append to the year in the month headers,
  8149. selectMonthLabel: "Select month", // Invisible label for month selector
  8150. selectYearLabel: "Select year" // Invisible label for year selector
  8151. };
  8152. this._defaults = { // Global defaults for all the date picker instances
  8153. showOn: "focus", // "focus" for popup on focus,
  8154. // "button" for trigger button, or "both" for either
  8155. showAnim: "fadeIn", // Name of jQuery animation for popup
  8156. showOptions: {}, // Options for enhanced animations
  8157. defaultDate: null, // Used when field is blank: actual date,
  8158. // +/-number for offset from today, null for today
  8159. appendText: "", // Display text following the input box, e.g. showing the format
  8160. buttonText: "...", // Text for trigger button
  8161. buttonImage: "", // URL for trigger button image
  8162. buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
  8163. hideIfNoPrevNext: false, // True to hide next/previous month links
  8164. // if not applicable, false to just disable them
  8165. navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
  8166. gotoCurrent: false, // True if today link goes back to current selection instead
  8167. changeMonth: false, // True if month can be selected directly, false if only prev/next
  8168. changeYear: false, // True if year can be selected directly, false if only prev/next
  8169. yearRange: "c-10:c+10", // Range of years to display in drop-down,
  8170. // either relative to today's year (-nn:+nn), relative to currently displayed year
  8171. // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
  8172. showOtherMonths: false, // True to show dates in other months, false to leave blank
  8173. selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
  8174. showWeek: false, // True to show week of the year, false to not show it
  8175. calculateWeek: this.iso8601Week, // How to calculate the week of the year,
  8176. // takes a Date and returns the number of the week for it
  8177. shortYearCutoff: "+10", // Short year values < this are in the current century,
  8178. // > this are in the previous century,
  8179. // string value starting with "+" for current year + value
  8180. minDate: null, // The earliest selectable date, or null for no limit
  8181. maxDate: null, // The latest selectable date, or null for no limit
  8182. duration: "fast", // Duration of display/closure
  8183. beforeShowDay: null, // Function that takes a date and returns an array with
  8184. // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "",
  8185. // [2] = cell title (optional), e.g. $.datepicker.noWeekends
  8186. beforeShow: null, // Function that takes an input field and
  8187. // returns a set of custom settings for the date picker
  8188. onSelect: null, // Define a callback function when a date is selected
  8189. onChangeMonthYear: null, // Define a callback function when the month or year is changed
  8190. onClose: null, // Define a callback function when the datepicker is closed
  8191. onUpdateDatepicker: null, // Define a callback function when the datepicker is updated
  8192. numberOfMonths: 1, // Number of months to show at a time
  8193. showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
  8194. stepMonths: 1, // Number of months to step back/forward
  8195. stepBigMonths: 12, // Number of months to step back/forward for the big links
  8196. altField: "", // Selector for an alternate field to store selected dates into
  8197. altFormat: "", // The date format to use for the alternate field
  8198. constrainInput: true, // The input is constrained by the current date format
  8199. showButtonPanel: false, // True to show button panel, false to not show it
  8200. autoSize: false, // True to size the input for the date format, false to leave as is
  8201. disabled: false // The initial disabled state
  8202. };
  8203. $.extend( this._defaults, this.regional[ "" ] );
  8204. this.regional.en = $.extend( true, {}, this.regional[ "" ] );
  8205. this.regional[ "en-US" ] = $.extend( true, {}, this.regional.en );
  8206. this.dpDiv = datepicker_bindHover( $( "<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>" ) );
  8207. }
  8208. $.extend( Datepicker.prototype, {
  8209. /* Class name added to elements to indicate already configured with a date picker. */
  8210. markerClassName: "hasDatepicker",
  8211. //Keep track of the maximum number of rows displayed (see #7043)
  8212. maxRows: 4,
  8213. // TODO rename to "widget" when switching to widget factory
  8214. _widgetDatepicker: function() {
  8215. return this.dpDiv;
  8216. },
  8217. /* Override the default settings for all instances of the date picker.
  8218. * @param settings object - the new settings to use as defaults (anonymous object)
  8219. * @return the manager object
  8220. */
  8221. setDefaults: function( settings ) {
  8222. datepicker_extendRemove( this._defaults, settings || {} );
  8223. return this;
  8224. },
  8225. /* Attach the date picker to a jQuery selection.
  8226. * @param target element - the target input field or division or span
  8227. * @param settings object - the new settings to use for this date picker instance (anonymous)
  8228. */
  8229. _attachDatepicker: function( target, settings ) {
  8230. var nodeName, inline, inst;
  8231. nodeName = target.nodeName.toLowerCase();
  8232. inline = ( nodeName === "div" || nodeName === "span" );
  8233. if ( !target.id ) {
  8234. this.uuid += 1;
  8235. target.id = "dp" + this.uuid;
  8236. }
  8237. inst = this._newInst( $( target ), inline );
  8238. inst.settings = $.extend( {}, settings || {} );
  8239. if ( nodeName === "input" ) {
  8240. this._connectDatepicker( target, inst );
  8241. } else if ( inline ) {
  8242. this._inlineDatepicker( target, inst );
  8243. }
  8244. },
  8245. /* Create a new instance object. */
  8246. _newInst: function( target, inline ) {
  8247. var id = target[ 0 ].id.replace( /([^A-Za-z0-9_\-])/g, "\\\\$1" ); // escape jQuery meta chars
  8248. return { id: id, input: target, // associated target
  8249. selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
  8250. drawMonth: 0, drawYear: 0, // month being drawn
  8251. inline: inline, // is datepicker inline or not
  8252. dpDiv: ( !inline ? this.dpDiv : // presentation div
  8253. datepicker_bindHover( $( "<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>" ) ) ) };
  8254. },
  8255. /* Attach the date picker to an input field. */
  8256. _connectDatepicker: function( target, inst ) {
  8257. var input = $( target );
  8258. inst.append = $( [] );
  8259. inst.trigger = $( [] );
  8260. if ( input.hasClass( this.markerClassName ) ) {
  8261. return;
  8262. }
  8263. this._attachments( input, inst );
  8264. input.addClass( this.markerClassName ).on( "keydown", this._doKeyDown ).
  8265. on( "keypress", this._doKeyPress ).on( "keyup", this._doKeyUp );
  8266. this._autoSize( inst );
  8267. $.data( target, "datepicker", inst );
  8268. //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
  8269. if ( inst.settings.disabled ) {
  8270. this._disableDatepicker( target );
  8271. }
  8272. },
  8273. /* Make attachments based on settings. */
  8274. _attachments: function( input, inst ) {
  8275. var showOn, buttonText, buttonImage,
  8276. appendText = this._get( inst, "appendText" ),
  8277. isRTL = this._get( inst, "isRTL" );
  8278. if ( inst.append ) {
  8279. inst.append.remove();
  8280. }
  8281. if ( appendText ) {
  8282. inst.append = $( "<span>" )
  8283. .addClass( this._appendClass )
  8284. .text( appendText );
  8285. input[ isRTL ? "before" : "after" ]( inst.append );
  8286. }
  8287. input.off( "focus", this._showDatepicker );
  8288. if ( inst.trigger ) {
  8289. inst.trigger.remove();
  8290. }
  8291. showOn = this._get( inst, "showOn" );
  8292. if ( showOn === "focus" || showOn === "both" ) { // pop-up date picker when in the marked field
  8293. input.on( "focus", this._showDatepicker );
  8294. }
  8295. if ( showOn === "button" || showOn === "both" ) { // pop-up date picker when button clicked
  8296. buttonText = this._get( inst, "buttonText" );
  8297. buttonImage = this._get( inst, "buttonImage" );
  8298. if ( this._get( inst, "buttonImageOnly" ) ) {
  8299. inst.trigger = $( "<img>" )
  8300. .addClass( this._triggerClass )
  8301. .attr( {
  8302. src: buttonImage,
  8303. alt: buttonText,
  8304. title: buttonText
  8305. } );
  8306. } else {
  8307. inst.trigger = $( "<button type='button'>" )
  8308. .addClass( this._triggerClass );
  8309. if ( buttonImage ) {
  8310. inst.trigger.html(
  8311. $( "<img>" )
  8312. .attr( {
  8313. src: buttonImage,
  8314. alt: buttonText,
  8315. title: buttonText
  8316. } )
  8317. );
  8318. } else {
  8319. inst.trigger.text( buttonText );
  8320. }
  8321. }
  8322. input[ isRTL ? "before" : "after" ]( inst.trigger );
  8323. inst.trigger.on( "click", function() {
  8324. if ( $.datepicker._datepickerShowing && $.datepicker._lastInput === input[ 0 ] ) {
  8325. $.datepicker._hideDatepicker();
  8326. } else if ( $.datepicker._datepickerShowing && $.datepicker._lastInput !== input[ 0 ] ) {
  8327. $.datepicker._hideDatepicker();
  8328. $.datepicker._showDatepicker( input[ 0 ] );
  8329. } else {
  8330. $.datepicker._showDatepicker( input[ 0 ] );
  8331. }
  8332. return false;
  8333. } );
  8334. }
  8335. },
  8336. /* Apply the maximum length for the date format. */
  8337. _autoSize: function( inst ) {
  8338. if ( this._get( inst, "autoSize" ) && !inst.inline ) {
  8339. var findMax, max, maxI, i,
  8340. date = new Date( 2009, 12 - 1, 20 ), // Ensure double digits
  8341. dateFormat = this._get( inst, "dateFormat" );
  8342. if ( dateFormat.match( /[DM]/ ) ) {
  8343. findMax = function( names ) {
  8344. max = 0;
  8345. maxI = 0;
  8346. for ( i = 0; i < names.length; i++ ) {
  8347. if ( names[ i ].length > max ) {
  8348. max = names[ i ].length;
  8349. maxI = i;
  8350. }
  8351. }
  8352. return maxI;
  8353. };
  8354. date.setMonth( findMax( this._get( inst, ( dateFormat.match( /MM/ ) ?
  8355. "monthNames" : "monthNamesShort" ) ) ) );
  8356. date.setDate( findMax( this._get( inst, ( dateFormat.match( /DD/ ) ?
  8357. "dayNames" : "dayNamesShort" ) ) ) + 20 - date.getDay() );
  8358. }
  8359. inst.input.attr( "size", this._formatDate( inst, date ).length );
  8360. }
  8361. },
  8362. /* Attach an inline date picker to a div. */
  8363. _inlineDatepicker: function( target, inst ) {
  8364. var divSpan = $( target );
  8365. if ( divSpan.hasClass( this.markerClassName ) ) {
  8366. return;
  8367. }
  8368. divSpan.addClass( this.markerClassName ).append( inst.dpDiv );
  8369. $.data( target, "datepicker", inst );
  8370. this._setDate( inst, this._getDefaultDate( inst ), true );
  8371. this._updateDatepicker( inst );
  8372. this._updateAlternate( inst );
  8373. //If disabled option is true, disable the datepicker before showing it (see ticket #5665)
  8374. if ( inst.settings.disabled ) {
  8375. this._disableDatepicker( target );
  8376. }
  8377. // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
  8378. // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
  8379. inst.dpDiv.css( "display", "block" );
  8380. },
  8381. /* Pop-up the date picker in a "dialog" box.
  8382. * @param input element - ignored
  8383. * @param date string or Date - the initial date to display
  8384. * @param onSelect function - the function to call when a date is selected
  8385. * @param settings object - update the dialog date picker instance's settings (anonymous object)
  8386. * @param pos int[2] - coordinates for the dialog's position within the screen or
  8387. * event - with x/y coordinates or
  8388. * leave empty for default (screen centre)
  8389. * @return the manager object
  8390. */
  8391. _dialogDatepicker: function( input, date, onSelect, settings, pos ) {
  8392. var id, browserWidth, browserHeight, scrollX, scrollY,
  8393. inst = this._dialogInst; // internal instance
  8394. if ( !inst ) {
  8395. this.uuid += 1;
  8396. id = "dp" + this.uuid;
  8397. this._dialogInput = $( "<input type='text' id='" + id +
  8398. "' style='position: absolute; top: -100px; width: 0px;'/>" );
  8399. this._dialogInput.on( "keydown", this._doKeyDown );
  8400. $( "body" ).append( this._dialogInput );
  8401. inst = this._dialogInst = this._newInst( this._dialogInput, false );
  8402. inst.settings = {};
  8403. $.data( this._dialogInput[ 0 ], "datepicker", inst );
  8404. }
  8405. datepicker_extendRemove( inst.settings, settings || {} );
  8406. date = ( date && date.constructor === Date ? this._formatDate( inst, date ) : date );
  8407. this._dialogInput.val( date );
  8408. this._pos = ( pos ? ( pos.length ? pos : [ pos.pageX, pos.pageY ] ) : null );
  8409. if ( !this._pos ) {
  8410. browserWidth = document.documentElement.clientWidth;
  8411. browserHeight = document.documentElement.clientHeight;
  8412. scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
  8413. scrollY = document.documentElement.scrollTop || document.body.scrollTop;
  8414. this._pos = // should use actual width/height below
  8415. [ ( browserWidth / 2 ) - 100 + scrollX, ( browserHeight / 2 ) - 150 + scrollY ];
  8416. }
  8417. // Move input on screen for focus, but hidden behind dialog
  8418. this._dialogInput.css( "left", ( this._pos[ 0 ] + 20 ) + "px" ).css( "top", this._pos[ 1 ] + "px" );
  8419. inst.settings.onSelect = onSelect;
  8420. this._inDialog = true;
  8421. this.dpDiv.addClass( this._dialogClass );
  8422. this._showDatepicker( this._dialogInput[ 0 ] );
  8423. if ( $.blockUI ) {
  8424. $.blockUI( this.dpDiv );
  8425. }
  8426. $.data( this._dialogInput[ 0 ], "datepicker", inst );
  8427. return this;
  8428. },
  8429. /* Detach a datepicker from its control.
  8430. * @param target element - the target input field or division or span
  8431. */
  8432. _destroyDatepicker: function( target ) {
  8433. var nodeName,
  8434. $target = $( target ),
  8435. inst = $.data( target, "datepicker" );
  8436. if ( !$target.hasClass( this.markerClassName ) ) {
  8437. return;
  8438. }
  8439. nodeName = target.nodeName.toLowerCase();
  8440. $.removeData( target, "datepicker" );
  8441. if ( nodeName === "input" ) {
  8442. inst.append.remove();
  8443. inst.trigger.remove();
  8444. $target.removeClass( this.markerClassName ).
  8445. off( "focus", this._showDatepicker ).
  8446. off( "keydown", this._doKeyDown ).
  8447. off( "keypress", this._doKeyPress ).
  8448. off( "keyup", this._doKeyUp );
  8449. } else if ( nodeName === "div" || nodeName === "span" ) {
  8450. $target.removeClass( this.markerClassName ).empty();
  8451. }
  8452. if ( datepicker_instActive === inst ) {
  8453. datepicker_instActive = null;
  8454. this._curInst = null;
  8455. }
  8456. },
  8457. /* Enable the date picker to a jQuery selection.
  8458. * @param target element - the target input field or division or span
  8459. */
  8460. _enableDatepicker: function( target ) {
  8461. var nodeName, inline,
  8462. $target = $( target ),
  8463. inst = $.data( target, "datepicker" );
  8464. if ( !$target.hasClass( this.markerClassName ) ) {
  8465. return;
  8466. }
  8467. nodeName = target.nodeName.toLowerCase();
  8468. if ( nodeName === "input" ) {
  8469. target.disabled = false;
  8470. inst.trigger.filter( "button" ).
  8471. each( function() {
  8472. this.disabled = false;
  8473. } ).end().
  8474. filter( "img" ).css( { opacity: "1.0", cursor: "" } );
  8475. } else if ( nodeName === "div" || nodeName === "span" ) {
  8476. inline = $target.children( "." + this._inlineClass );
  8477. inline.children().removeClass( "ui-state-disabled" );
  8478. inline.find( "select.ui-datepicker-month, select.ui-datepicker-year" ).
  8479. prop( "disabled", false );
  8480. }
  8481. this._disabledInputs = $.map( this._disabledInputs,
  8482. // Delete entry
  8483. function( value ) {
  8484. return ( value === target ? null : value );
  8485. } );
  8486. },
  8487. /* Disable the date picker to a jQuery selection.
  8488. * @param target element - the target input field or division or span
  8489. */
  8490. _disableDatepicker: function( target ) {
  8491. var nodeName, inline,
  8492. $target = $( target ),
  8493. inst = $.data( target, "datepicker" );
  8494. if ( !$target.hasClass( this.markerClassName ) ) {
  8495. return;
  8496. }
  8497. nodeName = target.nodeName.toLowerCase();
  8498. if ( nodeName === "input" ) {
  8499. target.disabled = true;
  8500. inst.trigger.filter( "button" ).
  8501. each( function() {
  8502. this.disabled = true;
  8503. } ).end().
  8504. filter( "img" ).css( { opacity: "0.5", cursor: "default" } );
  8505. } else if ( nodeName === "div" || nodeName === "span" ) {
  8506. inline = $target.children( "." + this._inlineClass );
  8507. inline.children().addClass( "ui-state-disabled" );
  8508. inline.find( "select.ui-datepicker-month, select.ui-datepicker-year" ).
  8509. prop( "disabled", true );
  8510. }
  8511. this._disabledInputs = $.map( this._disabledInputs,
  8512. // Delete entry
  8513. function( value ) {
  8514. return ( value === target ? null : value );
  8515. } );
  8516. this._disabledInputs[ this._disabledInputs.length ] = target;
  8517. },
  8518. /* Is the first field in a jQuery collection disabled as a datepicker?
  8519. * @param target element - the target input field or division or span
  8520. * @return boolean - true if disabled, false if enabled
  8521. */
  8522. _isDisabledDatepicker: function( target ) {
  8523. if ( !target ) {
  8524. return false;
  8525. }
  8526. for ( var i = 0; i < this._disabledInputs.length; i++ ) {
  8527. if ( this._disabledInputs[ i ] === target ) {
  8528. return true;
  8529. }
  8530. }
  8531. return false;
  8532. },
  8533. /* Retrieve the instance data for the target control.
  8534. * @param target element - the target input field or division or span
  8535. * @return object - the associated instance data
  8536. * @throws error if a jQuery problem getting data
  8537. */
  8538. _getInst: function( target ) {
  8539. try {
  8540. return $.data( target, "datepicker" );
  8541. } catch ( err ) {
  8542. throw "Missing instance data for this datepicker";
  8543. }
  8544. },
  8545. /* Update or retrieve the settings for a date picker attached to an input field or division.
  8546. * @param target element - the target input field or division or span
  8547. * @param name object - the new settings to update or
  8548. * string - the name of the setting to change or retrieve,
  8549. * when retrieving also "all" for all instance settings or
  8550. * "defaults" for all global defaults
  8551. * @param value any - the new value for the setting
  8552. * (omit if above is an object or to retrieve a value)
  8553. */
  8554. _optionDatepicker: function( target, name, value ) {
  8555. var settings, date, minDate, maxDate,
  8556. inst = this._getInst( target );
  8557. if ( arguments.length === 2 && typeof name === "string" ) {
  8558. return ( name === "defaults" ? $.extend( {}, $.datepicker._defaults ) :
  8559. ( inst ? ( name === "all" ? $.extend( {}, inst.settings ) :
  8560. this._get( inst, name ) ) : null ) );
  8561. }
  8562. settings = name || {};
  8563. if ( typeof name === "string" ) {
  8564. settings = {};
  8565. settings[ name ] = value;
  8566. }
  8567. if ( inst ) {
  8568. if ( this._curInst === inst ) {
  8569. this._hideDatepicker();
  8570. }
  8571. date = this._getDateDatepicker( target, true );
  8572. minDate = this._getMinMaxDate( inst, "min" );
  8573. maxDate = this._getMinMaxDate( inst, "max" );
  8574. datepicker_extendRemove( inst.settings, settings );
  8575. // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
  8576. if ( minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined ) {
  8577. inst.settings.minDate = this._formatDate( inst, minDate );
  8578. }
  8579. if ( maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined ) {
  8580. inst.settings.maxDate = this._formatDate( inst, maxDate );
  8581. }
  8582. if ( "disabled" in settings ) {
  8583. if ( settings.disabled ) {
  8584. this._disableDatepicker( target );
  8585. } else {
  8586. this._enableDatepicker( target );
  8587. }
  8588. }
  8589. this._attachments( $( target ), inst );
  8590. this._autoSize( inst );
  8591. this._setDate( inst, date );
  8592. this._updateAlternate( inst );
  8593. this._updateDatepicker( inst );
  8594. }
  8595. },
  8596. // Change method deprecated
  8597. _changeDatepicker: function( target, name, value ) {
  8598. this._optionDatepicker( target, name, value );
  8599. },
  8600. /* Redraw the date picker attached to an input field or division.
  8601. * @param target element - the target input field or division or span
  8602. */
  8603. _refreshDatepicker: function( target ) {
  8604. var inst = this._getInst( target );
  8605. if ( inst ) {
  8606. this._updateDatepicker( inst );
  8607. }
  8608. },
  8609. /* Set the dates for a jQuery selection.
  8610. * @param target element - the target input field or division or span
  8611. * @param date Date - the new date
  8612. */
  8613. _setDateDatepicker: function( target, date ) {
  8614. var inst = this._getInst( target );
  8615. if ( inst ) {
  8616. this._setDate( inst, date );
  8617. this._updateDatepicker( inst );
  8618. this._updateAlternate( inst );
  8619. }
  8620. },
  8621. /* Get the date(s) for the first entry in a jQuery selection.
  8622. * @param target element - the target input field or division or span
  8623. * @param noDefault boolean - true if no default date is to be used
  8624. * @return Date - the current date
  8625. */
  8626. _getDateDatepicker: function( target, noDefault ) {
  8627. var inst = this._getInst( target );
  8628. if ( inst && !inst.inline ) {
  8629. this._setDateFromField( inst, noDefault );
  8630. }
  8631. return ( inst ? this._getDate( inst ) : null );
  8632. },
  8633. /* Handle keystrokes. */
  8634. _doKeyDown: function( event ) {
  8635. var onSelect, dateStr, sel,
  8636. inst = $.datepicker._getInst( event.target ),
  8637. handled = true,
  8638. isRTL = inst.dpDiv.is( ".ui-datepicker-rtl" );
  8639. inst._keyEvent = true;
  8640. if ( $.datepicker._datepickerShowing ) {
  8641. switch ( event.keyCode ) {
  8642. case 9: $.datepicker._hideDatepicker();
  8643. handled = false;
  8644. break; // hide on tab out
  8645. case 13: sel = $( "td." + $.datepicker._dayOverClass + ":not(." +
  8646. $.datepicker._currentClass + ")", inst.dpDiv );
  8647. if ( sel[ 0 ] ) {
  8648. $.datepicker._selectDay( event.target, inst.selectedMonth, inst.selectedYear, sel[ 0 ] );
  8649. }
  8650. onSelect = $.datepicker._get( inst, "onSelect" );
  8651. if ( onSelect ) {
  8652. dateStr = $.datepicker._formatDate( inst );
  8653. // Trigger custom callback
  8654. onSelect.apply( ( inst.input ? inst.input[ 0 ] : null ), [ dateStr, inst ] );
  8655. } else {
  8656. $.datepicker._hideDatepicker();
  8657. }
  8658. return false; // don't submit the form
  8659. case 27: $.datepicker._hideDatepicker();
  8660. break; // hide on escape
  8661. case 33: $.datepicker._adjustDate( event.target, ( event.ctrlKey ?
  8662. -$.datepicker._get( inst, "stepBigMonths" ) :
  8663. -$.datepicker._get( inst, "stepMonths" ) ), "M" );
  8664. break; // previous month/year on page up/+ ctrl
  8665. case 34: $.datepicker._adjustDate( event.target, ( event.ctrlKey ?
  8666. +$.datepicker._get( inst, "stepBigMonths" ) :
  8667. +$.datepicker._get( inst, "stepMonths" ) ), "M" );
  8668. break; // next month/year on page down/+ ctrl
  8669. case 35: if ( event.ctrlKey || event.metaKey ) {
  8670. $.datepicker._clearDate( event.target );
  8671. }
  8672. handled = event.ctrlKey || event.metaKey;
  8673. break; // clear on ctrl or command +end
  8674. case 36: if ( event.ctrlKey || event.metaKey ) {
  8675. $.datepicker._gotoToday( event.target );
  8676. }
  8677. handled = event.ctrlKey || event.metaKey;
  8678. break; // current on ctrl or command +home
  8679. case 37: if ( event.ctrlKey || event.metaKey ) {
  8680. $.datepicker._adjustDate( event.target, ( isRTL ? +1 : -1 ), "D" );
  8681. }
  8682. handled = event.ctrlKey || event.metaKey;
  8683. // -1 day on ctrl or command +left
  8684. if ( event.originalEvent.altKey ) {
  8685. $.datepicker._adjustDate( event.target, ( event.ctrlKey ?
  8686. -$.datepicker._get( inst, "stepBigMonths" ) :
  8687. -$.datepicker._get( inst, "stepMonths" ) ), "M" );
  8688. }
  8689. // next month/year on alt +left on Mac
  8690. break;
  8691. case 38: if ( event.ctrlKey || event.metaKey ) {
  8692. $.datepicker._adjustDate( event.target, -7, "D" );
  8693. }
  8694. handled = event.ctrlKey || event.metaKey;
  8695. break; // -1 week on ctrl or command +up
  8696. case 39: if ( event.ctrlKey || event.metaKey ) {
  8697. $.datepicker._adjustDate( event.target, ( isRTL ? -1 : +1 ), "D" );
  8698. }
  8699. handled = event.ctrlKey || event.metaKey;
  8700. // +1 day on ctrl or command +right
  8701. if ( event.originalEvent.altKey ) {
  8702. $.datepicker._adjustDate( event.target, ( event.ctrlKey ?
  8703. +$.datepicker._get( inst, "stepBigMonths" ) :
  8704. +$.datepicker._get( inst, "stepMonths" ) ), "M" );
  8705. }
  8706. // next month/year on alt +right
  8707. break;
  8708. case 40: if ( event.ctrlKey || event.metaKey ) {
  8709. $.datepicker._adjustDate( event.target, +7, "D" );
  8710. }
  8711. handled = event.ctrlKey || event.metaKey;
  8712. break; // +1 week on ctrl or command +down
  8713. default: handled = false;
  8714. }
  8715. } else if ( event.keyCode === 36 && event.ctrlKey ) { // display the date picker on ctrl+home
  8716. $.datepicker._showDatepicker( this );
  8717. } else {
  8718. handled = false;
  8719. }
  8720. if ( handled ) {
  8721. event.preventDefault();
  8722. event.stopPropagation();
  8723. }
  8724. },
  8725. /* Filter entered characters - based on date format. */
  8726. _doKeyPress: function( event ) {
  8727. var chars, chr,
  8728. inst = $.datepicker._getInst( event.target );
  8729. if ( $.datepicker._get( inst, "constrainInput" ) ) {
  8730. chars = $.datepicker._possibleChars( $.datepicker._get( inst, "dateFormat" ) );
  8731. chr = String.fromCharCode( event.charCode == null ? event.keyCode : event.charCode );
  8732. return event.ctrlKey || event.metaKey || ( chr < " " || !chars || chars.indexOf( chr ) > -1 );
  8733. }
  8734. },
  8735. /* Synchronise manual entry and field/alternate field. */
  8736. _doKeyUp: function( event ) {
  8737. var date,
  8738. inst = $.datepicker._getInst( event.target );
  8739. if ( inst.input.val() !== inst.lastVal ) {
  8740. try {
  8741. date = $.datepicker.parseDate( $.datepicker._get( inst, "dateFormat" ),
  8742. ( inst.input ? inst.input.val() : null ),
  8743. $.datepicker._getFormatConfig( inst ) );
  8744. if ( date ) { // only if valid
  8745. $.datepicker._setDateFromField( inst );
  8746. $.datepicker._updateAlternate( inst );
  8747. $.datepicker._updateDatepicker( inst );
  8748. }
  8749. } catch ( err ) {
  8750. }
  8751. }
  8752. return true;
  8753. },
  8754. /* Pop-up the date picker for a given input field.
  8755. * If false returned from beforeShow event handler do not show.
  8756. * @param input element - the input field attached to the date picker or
  8757. * event - if triggered by focus
  8758. */
  8759. _showDatepicker: function( input ) {
  8760. input = input.target || input;
  8761. if ( input.nodeName.toLowerCase() !== "input" ) { // find from button/image trigger
  8762. input = $( "input", input.parentNode )[ 0 ];
  8763. }
  8764. if ( $.datepicker._isDisabledDatepicker( input ) || $.datepicker._lastInput === input ) { // already here
  8765. return;
  8766. }
  8767. var inst, beforeShow, beforeShowSettings, isFixed,
  8768. offset, showAnim, duration;
  8769. inst = $.datepicker._getInst( input );
  8770. if ( $.datepicker._curInst && $.datepicker._curInst !== inst ) {
  8771. $.datepicker._curInst.dpDiv.stop( true, true );
  8772. if ( inst && $.datepicker._datepickerShowing ) {
  8773. $.datepicker._hideDatepicker( $.datepicker._curInst.input[ 0 ] );
  8774. }
  8775. }
  8776. beforeShow = $.datepicker._get( inst, "beforeShow" );
  8777. beforeShowSettings = beforeShow ? beforeShow.apply( input, [ input, inst ] ) : {};
  8778. if ( beforeShowSettings === false ) {
  8779. return;
  8780. }
  8781. datepicker_extendRemove( inst.settings, beforeShowSettings );
  8782. inst.lastVal = null;
  8783. $.datepicker._lastInput = input;
  8784. $.datepicker._setDateFromField( inst );
  8785. if ( $.datepicker._inDialog ) { // hide cursor
  8786. input.value = "";
  8787. }
  8788. if ( !$.datepicker._pos ) { // position below input
  8789. $.datepicker._pos = $.datepicker._findPos( input );
  8790. $.datepicker._pos[ 1 ] += input.offsetHeight; // add the height
  8791. }
  8792. isFixed = false;
  8793. $( input ).parents().each( function() {
  8794. isFixed |= $( this ).css( "position" ) === "fixed";
  8795. return !isFixed;
  8796. } );
  8797. offset = { left: $.datepicker._pos[ 0 ], top: $.datepicker._pos[ 1 ] };
  8798. $.datepicker._pos = null;
  8799. //to avoid flashes on Firefox
  8800. inst.dpDiv.empty();
  8801. // determine sizing offscreen
  8802. inst.dpDiv.css( { position: "absolute", display: "block", top: "-1000px" } );
  8803. $.datepicker._updateDatepicker( inst );
  8804. // fix width for dynamic number of date pickers
  8805. // and adjust position before showing
  8806. offset = $.datepicker._checkOffset( inst, offset, isFixed );
  8807. inst.dpDiv.css( { position: ( $.datepicker._inDialog && $.blockUI ?
  8808. "static" : ( isFixed ? "fixed" : "absolute" ) ), display: "none",
  8809. left: offset.left + "px", top: offset.top + "px" } );
  8810. if ( !inst.inline ) {
  8811. showAnim = $.datepicker._get( inst, "showAnim" );
  8812. duration = $.datepicker._get( inst, "duration" );
  8813. inst.dpDiv.css( "z-index", datepicker_getZindex( $( input ) ) + 1 );
  8814. $.datepicker._datepickerShowing = true;
  8815. if ( $.effects && $.effects.effect[ showAnim ] ) {
  8816. inst.dpDiv.show( showAnim, $.datepicker._get( inst, "showOptions" ), duration );
  8817. } else {
  8818. inst.dpDiv[ showAnim || "show" ]( showAnim ? duration : null );
  8819. }
  8820. if ( $.datepicker._shouldFocusInput( inst ) ) {
  8821. inst.input.trigger( "focus" );
  8822. }
  8823. $.datepicker._curInst = inst;
  8824. }
  8825. },
  8826. /* Generate the date picker content. */
  8827. _updateDatepicker: function( inst ) {
  8828. this.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
  8829. datepicker_instActive = inst; // for delegate hover events
  8830. inst.dpDiv.empty().append( this._generateHTML( inst ) );
  8831. this._attachHandlers( inst );
  8832. var origyearshtml,
  8833. numMonths = this._getNumberOfMonths( inst ),
  8834. cols = numMonths[ 1 ],
  8835. width = 17,
  8836. activeCell = inst.dpDiv.find( "." + this._dayOverClass + " a" ),
  8837. onUpdateDatepicker = $.datepicker._get( inst, "onUpdateDatepicker" );
  8838. if ( activeCell.length > 0 ) {
  8839. datepicker_handleMouseover.apply( activeCell.get( 0 ) );
  8840. }
  8841. inst.dpDiv.removeClass( "ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4" ).width( "" );
  8842. if ( cols > 1 ) {
  8843. inst.dpDiv.addClass( "ui-datepicker-multi-" + cols ).css( "width", ( width * cols ) + "em" );
  8844. }
  8845. inst.dpDiv[ ( numMonths[ 0 ] !== 1 || numMonths[ 1 ] !== 1 ? "add" : "remove" ) +
  8846. "Class" ]( "ui-datepicker-multi" );
  8847. inst.dpDiv[ ( this._get( inst, "isRTL" ) ? "add" : "remove" ) +
  8848. "Class" ]( "ui-datepicker-rtl" );
  8849. if ( inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) {
  8850. inst.input.trigger( "focus" );
  8851. }
  8852. // Deffered render of the years select (to avoid flashes on Firefox)
  8853. if ( inst.yearshtml ) {
  8854. origyearshtml = inst.yearshtml;
  8855. setTimeout( function() {
  8856. //assure that inst.yearshtml didn't change.
  8857. if ( origyearshtml === inst.yearshtml && inst.yearshtml ) {
  8858. inst.dpDiv.find( "select.ui-datepicker-year" ).first().replaceWith( inst.yearshtml );
  8859. }
  8860. origyearshtml = inst.yearshtml = null;
  8861. }, 0 );
  8862. }
  8863. if ( onUpdateDatepicker ) {
  8864. onUpdateDatepicker.apply( ( inst.input ? inst.input[ 0 ] : null ), [ inst ] );
  8865. }
  8866. },
  8867. // #6694 - don't focus the input if it's already focused
  8868. // this breaks the change event in IE
  8869. // Support: IE and jQuery <1.9
  8870. _shouldFocusInput: function( inst ) {
  8871. return inst.input && inst.input.is( ":visible" ) && !inst.input.is( ":disabled" ) && !inst.input.is( ":focus" );
  8872. },
  8873. /* Check positioning to remain on screen. */
  8874. _checkOffset: function( inst, offset, isFixed ) {
  8875. var dpWidth = inst.dpDiv.outerWidth(),
  8876. dpHeight = inst.dpDiv.outerHeight(),
  8877. inputWidth = inst.input ? inst.input.outerWidth() : 0,
  8878. inputHeight = inst.input ? inst.input.outerHeight() : 0,
  8879. viewWidth = document.documentElement.clientWidth + ( isFixed ? 0 : $( document ).scrollLeft() ),
  8880. viewHeight = document.documentElement.clientHeight + ( isFixed ? 0 : $( document ).scrollTop() );
  8881. offset.left -= ( this._get( inst, "isRTL" ) ? ( dpWidth - inputWidth ) : 0 );
  8882. offset.left -= ( isFixed && offset.left === inst.input.offset().left ) ? $( document ).scrollLeft() : 0;
  8883. offset.top -= ( isFixed && offset.top === ( inst.input.offset().top + inputHeight ) ) ? $( document ).scrollTop() : 0;
  8884. // Now check if datepicker is showing outside window viewport - move to a better place if so.
  8885. offset.left -= Math.min( offset.left, ( offset.left + dpWidth > viewWidth && viewWidth > dpWidth ) ?
  8886. Math.abs( offset.left + dpWidth - viewWidth ) : 0 );
  8887. offset.top -= Math.min( offset.top, ( offset.top + dpHeight > viewHeight && viewHeight > dpHeight ) ?
  8888. Math.abs( dpHeight + inputHeight ) : 0 );
  8889. return offset;
  8890. },
  8891. /* Find an object's position on the screen. */
  8892. _findPos: function( obj ) {
  8893. var position,
  8894. inst = this._getInst( obj ),
  8895. isRTL = this._get( inst, "isRTL" );
  8896. while ( obj && ( obj.type === "hidden" || obj.nodeType !== 1 || $.expr.pseudos.hidden( obj ) ) ) {
  8897. obj = obj[ isRTL ? "previousSibling" : "nextSibling" ];
  8898. }
  8899. position = $( obj ).offset();
  8900. return [ position.left, position.top ];
  8901. },
  8902. /* Hide the date picker from view.
  8903. * @param input element - the input field attached to the date picker
  8904. */
  8905. _hideDatepicker: function( input ) {
  8906. var showAnim, duration, postProcess, onClose,
  8907. inst = this._curInst;
  8908. if ( !inst || ( input && inst !== $.data( input, "datepicker" ) ) ) {
  8909. return;
  8910. }
  8911. if ( this._datepickerShowing ) {
  8912. showAnim = this._get( inst, "showAnim" );
  8913. duration = this._get( inst, "duration" );
  8914. postProcess = function() {
  8915. $.datepicker._tidyDialog( inst );
  8916. };
  8917. // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
  8918. if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) {
  8919. inst.dpDiv.hide( showAnim, $.datepicker._get( inst, "showOptions" ), duration, postProcess );
  8920. } else {
  8921. inst.dpDiv[ ( showAnim === "slideDown" ? "slideUp" :
  8922. ( showAnim === "fadeIn" ? "fadeOut" : "hide" ) ) ]( ( showAnim ? duration : null ), postProcess );
  8923. }
  8924. if ( !showAnim ) {
  8925. postProcess();
  8926. }
  8927. this._datepickerShowing = false;
  8928. onClose = this._get( inst, "onClose" );
  8929. if ( onClose ) {
  8930. onClose.apply( ( inst.input ? inst.input[ 0 ] : null ), [ ( inst.input ? inst.input.val() : "" ), inst ] );
  8931. }
  8932. this._lastInput = null;
  8933. if ( this._inDialog ) {
  8934. this._dialogInput.css( { position: "absolute", left: "0", top: "-100px" } );
  8935. if ( $.blockUI ) {
  8936. $.unblockUI();
  8937. $( "body" ).append( this.dpDiv );
  8938. }
  8939. }
  8940. this._inDialog = false;
  8941. }
  8942. },
  8943. /* Tidy up after a dialog display. */
  8944. _tidyDialog: function( inst ) {
  8945. inst.dpDiv.removeClass( this._dialogClass ).off( ".ui-datepicker-calendar" );
  8946. },
  8947. /* Close date picker if clicked elsewhere. */
  8948. _checkExternalClick: function( event ) {
  8949. if ( !$.datepicker._curInst ) {
  8950. return;
  8951. }
  8952. var $target = $( event.target ),
  8953. inst = $.datepicker._getInst( $target[ 0 ] );
  8954. if ( ( ( $target[ 0 ].id !== $.datepicker._mainDivId &&
  8955. $target.parents( "#" + $.datepicker._mainDivId ).length === 0 &&
  8956. !$target.hasClass( $.datepicker.markerClassName ) &&
  8957. !$target.closest( "." + $.datepicker._triggerClass ).length &&
  8958. $.datepicker._datepickerShowing && !( $.datepicker._inDialog && $.blockUI ) ) ) ||
  8959. ( $target.hasClass( $.datepicker.markerClassName ) && $.datepicker._curInst !== inst ) ) {
  8960. $.datepicker._hideDatepicker();
  8961. }
  8962. },
  8963. /* Adjust one of the date sub-fields. */
  8964. _adjustDate: function( id, offset, period ) {
  8965. var target = $( id ),
  8966. inst = this._getInst( target[ 0 ] );
  8967. if ( this._isDisabledDatepicker( target[ 0 ] ) ) {
  8968. return;
  8969. }
  8970. this._adjustInstDate( inst, offset, period );
  8971. this._updateDatepicker( inst );
  8972. },
  8973. /* Action for current link. */
  8974. _gotoToday: function( id ) {
  8975. var date,
  8976. target = $( id ),
  8977. inst = this._getInst( target[ 0 ] );
  8978. if ( this._get( inst, "gotoCurrent" ) && inst.currentDay ) {
  8979. inst.selectedDay = inst.currentDay;
  8980. inst.drawMonth = inst.selectedMonth = inst.currentMonth;
  8981. inst.drawYear = inst.selectedYear = inst.currentYear;
  8982. } else {
  8983. date = new Date();
  8984. inst.selectedDay = date.getDate();
  8985. inst.drawMonth = inst.selectedMonth = date.getMonth();
  8986. inst.drawYear = inst.selectedYear = date.getFullYear();
  8987. }
  8988. this._notifyChange( inst );
  8989. this._adjustDate( target );
  8990. },
  8991. /* Action for selecting a new month/year. */
  8992. _selectMonthYear: function( id, select, period ) {
  8993. var target = $( id ),
  8994. inst = this._getInst( target[ 0 ] );
  8995. inst[ "selected" + ( period === "M" ? "Month" : "Year" ) ] =
  8996. inst[ "draw" + ( period === "M" ? "Month" : "Year" ) ] =
  8997. parseInt( select.options[ select.selectedIndex ].value, 10 );
  8998. this._notifyChange( inst );
  8999. this._adjustDate( target );
  9000. },
  9001. /* Action for selecting a day. */
  9002. _selectDay: function( id, month, year, td ) {
  9003. var inst,
  9004. target = $( id );
  9005. if ( $( td ).hasClass( this._unselectableClass ) || this._isDisabledDatepicker( target[ 0 ] ) ) {
  9006. return;
  9007. }
  9008. inst = this._getInst( target[ 0 ] );
  9009. inst.selectedDay = inst.currentDay = parseInt( $( "a", td ).attr( "data-date" ) );
  9010. inst.selectedMonth = inst.currentMonth = month;
  9011. inst.selectedYear = inst.currentYear = year;
  9012. this._selectDate( id, this._formatDate( inst,
  9013. inst.currentDay, inst.currentMonth, inst.currentYear ) );
  9014. },
  9015. /* Erase the input field and hide the date picker. */
  9016. _clearDate: function( id ) {
  9017. var target = $( id );
  9018. this._selectDate( target, "" );
  9019. },
  9020. /* Update the input field with the selected date. */
  9021. _selectDate: function( id, dateStr ) {
  9022. var onSelect,
  9023. target = $( id ),
  9024. inst = this._getInst( target[ 0 ] );
  9025. dateStr = ( dateStr != null ? dateStr : this._formatDate( inst ) );
  9026. if ( inst.input ) {
  9027. inst.input.val( dateStr );
  9028. }
  9029. this._updateAlternate( inst );
  9030. onSelect = this._get( inst, "onSelect" );
  9031. if ( onSelect ) {
  9032. onSelect.apply( ( inst.input ? inst.input[ 0 ] : null ), [ dateStr, inst ] ); // trigger custom callback
  9033. } else if ( inst.input ) {
  9034. inst.input.trigger( "change" ); // fire the change event
  9035. }
  9036. if ( inst.inline ) {
  9037. this._updateDatepicker( inst );
  9038. } else {
  9039. this._hideDatepicker();
  9040. this._lastInput = inst.input[ 0 ];
  9041. if ( typeof( inst.input[ 0 ] ) !== "object" ) {
  9042. inst.input.trigger( "focus" ); // restore focus
  9043. }
  9044. this._lastInput = null;
  9045. }
  9046. },
  9047. /* Update any alternate field to synchronise with the main field. */
  9048. _updateAlternate: function( inst ) {
  9049. var altFormat, date, dateStr,
  9050. altField = this._get( inst, "altField" );
  9051. if ( altField ) { // update alternate field too
  9052. altFormat = this._get( inst, "altFormat" ) || this._get( inst, "dateFormat" );
  9053. date = this._getDate( inst );
  9054. dateStr = this.formatDate( altFormat, date, this._getFormatConfig( inst ) );
  9055. $( document ).find( altField ).val( dateStr );
  9056. }
  9057. },
  9058. /* Set as beforeShowDay function to prevent selection of weekends.
  9059. * @param date Date - the date to customise
  9060. * @return [boolean, string] - is this date selectable?, what is its CSS class?
  9061. */
  9062. noWeekends: function( date ) {
  9063. var day = date.getDay();
  9064. return [ ( day > 0 && day < 6 ), "" ];
  9065. },
  9066. /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
  9067. * @param date Date - the date to get the week for
  9068. * @return number - the number of the week within the year that contains this date
  9069. */
  9070. iso8601Week: function( date ) {
  9071. var time,
  9072. checkDate = new Date( date.getTime() );
  9073. // Find Thursday of this week starting on Monday
  9074. checkDate.setDate( checkDate.getDate() + 4 - ( checkDate.getDay() || 7 ) );
  9075. time = checkDate.getTime();
  9076. checkDate.setMonth( 0 ); // Compare with Jan 1
  9077. checkDate.setDate( 1 );
  9078. return Math.floor( Math.round( ( time - checkDate ) / 86400000 ) / 7 ) + 1;
  9079. },
  9080. /* Parse a string value into a date object.
  9081. * See formatDate below for the possible formats.
  9082. *
  9083. * @param format string - the expected format of the date
  9084. * @param value string - the date in the above format
  9085. * @param settings Object - attributes include:
  9086. * shortYearCutoff number - the cutoff year for determining the century (optional)
  9087. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  9088. * dayNames string[7] - names of the days from Sunday (optional)
  9089. * monthNamesShort string[12] - abbreviated names of the months (optional)
  9090. * monthNames string[12] - names of the months (optional)
  9091. * @return Date - the extracted date value or null if value is blank
  9092. */
  9093. parseDate: function( format, value, settings ) {
  9094. if ( format == null || value == null ) {
  9095. throw "Invalid arguments";
  9096. }
  9097. value = ( typeof value === "object" ? value.toString() : value + "" );
  9098. if ( value === "" ) {
  9099. return null;
  9100. }
  9101. var iFormat, dim, extra,
  9102. iValue = 0,
  9103. shortYearCutoffTemp = ( settings ? settings.shortYearCutoff : null ) || this._defaults.shortYearCutoff,
  9104. shortYearCutoff = ( typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp :
  9105. new Date().getFullYear() % 100 + parseInt( shortYearCutoffTemp, 10 ) ),
  9106. dayNamesShort = ( settings ? settings.dayNamesShort : null ) || this._defaults.dayNamesShort,
  9107. dayNames = ( settings ? settings.dayNames : null ) || this._defaults.dayNames,
  9108. monthNamesShort = ( settings ? settings.monthNamesShort : null ) || this._defaults.monthNamesShort,
  9109. monthNames = ( settings ? settings.monthNames : null ) || this._defaults.monthNames,
  9110. year = -1,
  9111. month = -1,
  9112. day = -1,
  9113. doy = -1,
  9114. literal = false,
  9115. date,
  9116. // Check whether a format character is doubled
  9117. lookAhead = function( match ) {
  9118. var matches = ( iFormat + 1 < format.length && format.charAt( iFormat + 1 ) === match );
  9119. if ( matches ) {
  9120. iFormat++;
  9121. }
  9122. return matches;
  9123. },
  9124. // Extract a number from the string value
  9125. getNumber = function( match ) {
  9126. var isDoubled = lookAhead( match ),
  9127. size = ( match === "@" ? 14 : ( match === "!" ? 20 :
  9128. ( match === "y" && isDoubled ? 4 : ( match === "o" ? 3 : 2 ) ) ) ),
  9129. minSize = ( match === "y" ? size : 1 ),
  9130. digits = new RegExp( "^\\d{" + minSize + "," + size + "}" ),
  9131. num = value.substring( iValue ).match( digits );
  9132. if ( !num ) {
  9133. throw "Missing number at position " + iValue;
  9134. }
  9135. iValue += num[ 0 ].length;
  9136. return parseInt( num[ 0 ], 10 );
  9137. },
  9138. // Extract a name from the string value and convert to an index
  9139. getName = function( match, shortNames, longNames ) {
  9140. var index = -1,
  9141. names = $.map( lookAhead( match ) ? longNames : shortNames, function( v, k ) {
  9142. return [ [ k, v ] ];
  9143. } ).sort( function( a, b ) {
  9144. return -( a[ 1 ].length - b[ 1 ].length );
  9145. } );
  9146. $.each( names, function( i, pair ) {
  9147. var name = pair[ 1 ];
  9148. if ( value.substr( iValue, name.length ).toLowerCase() === name.toLowerCase() ) {
  9149. index = pair[ 0 ];
  9150. iValue += name.length;
  9151. return false;
  9152. }
  9153. } );
  9154. if ( index !== -1 ) {
  9155. return index + 1;
  9156. } else {
  9157. throw "Unknown name at position " + iValue;
  9158. }
  9159. },
  9160. // Confirm that a literal character matches the string value
  9161. checkLiteral = function() {
  9162. if ( value.charAt( iValue ) !== format.charAt( iFormat ) ) {
  9163. throw "Unexpected literal at position " + iValue;
  9164. }
  9165. iValue++;
  9166. };
  9167. for ( iFormat = 0; iFormat < format.length; iFormat++ ) {
  9168. if ( literal ) {
  9169. if ( format.charAt( iFormat ) === "'" && !lookAhead( "'" ) ) {
  9170. literal = false;
  9171. } else {
  9172. checkLiteral();
  9173. }
  9174. } else {
  9175. switch ( format.charAt( iFormat ) ) {
  9176. case "d":
  9177. day = getNumber( "d" );
  9178. break;
  9179. case "D":
  9180. getName( "D", dayNamesShort, dayNames );
  9181. break;
  9182. case "o":
  9183. doy = getNumber( "o" );
  9184. break;
  9185. case "m":
  9186. month = getNumber( "m" );
  9187. break;
  9188. case "M":
  9189. month = getName( "M", monthNamesShort, monthNames );
  9190. break;
  9191. case "y":
  9192. year = getNumber( "y" );
  9193. break;
  9194. case "@":
  9195. date = new Date( getNumber( "@" ) );
  9196. year = date.getFullYear();
  9197. month = date.getMonth() + 1;
  9198. day = date.getDate();
  9199. break;
  9200. case "!":
  9201. date = new Date( ( getNumber( "!" ) - this._ticksTo1970 ) / 10000 );
  9202. year = date.getFullYear();
  9203. month = date.getMonth() + 1;
  9204. day = date.getDate();
  9205. break;
  9206. case "'":
  9207. if ( lookAhead( "'" ) ) {
  9208. checkLiteral();
  9209. } else {
  9210. literal = true;
  9211. }
  9212. break;
  9213. default:
  9214. checkLiteral();
  9215. }
  9216. }
  9217. }
  9218. if ( iValue < value.length ) {
  9219. extra = value.substr( iValue );
  9220. if ( !/^\s+/.test( extra ) ) {
  9221. throw "Extra/unparsed characters found in date: " + extra;
  9222. }
  9223. }
  9224. if ( year === -1 ) {
  9225. year = new Date().getFullYear();
  9226. } else if ( year < 100 ) {
  9227. year += new Date().getFullYear() - new Date().getFullYear() % 100 +
  9228. ( year <= shortYearCutoff ? 0 : -100 );
  9229. }
  9230. if ( doy > -1 ) {
  9231. month = 1;
  9232. day = doy;
  9233. do {
  9234. dim = this._getDaysInMonth( year, month - 1 );
  9235. if ( day <= dim ) {
  9236. break;
  9237. }
  9238. month++;
  9239. day -= dim;
  9240. } while ( true );
  9241. }
  9242. date = this._daylightSavingAdjust( new Date( year, month - 1, day ) );
  9243. if ( date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day ) {
  9244. throw "Invalid date"; // E.g. 31/02/00
  9245. }
  9246. return date;
  9247. },
  9248. /* Standard date formats. */
  9249. ATOM: "yy-mm-dd", // RFC 3339 (ISO 8601)
  9250. COOKIE: "D, dd M yy",
  9251. ISO_8601: "yy-mm-dd",
  9252. RFC_822: "D, d M y",
  9253. RFC_850: "DD, dd-M-y",
  9254. RFC_1036: "D, d M y",
  9255. RFC_1123: "D, d M yy",
  9256. RFC_2822: "D, d M yy",
  9257. RSS: "D, d M y", // RFC 822
  9258. TICKS: "!",
  9259. TIMESTAMP: "@",
  9260. W3C: "yy-mm-dd", // ISO 8601
  9261. _ticksTo1970: ( ( ( 1970 - 1 ) * 365 + Math.floor( 1970 / 4 ) - Math.floor( 1970 / 100 ) +
  9262. Math.floor( 1970 / 400 ) ) * 24 * 60 * 60 * 10000000 ),
  9263. /* Format a date object into a string value.
  9264. * The format can be combinations of the following:
  9265. * d - day of month (no leading zero)
  9266. * dd - day of month (two digit)
  9267. * o - day of year (no leading zeros)
  9268. * oo - day of year (three digit)
  9269. * D - day name short
  9270. * DD - day name long
  9271. * m - month of year (no leading zero)
  9272. * mm - month of year (two digit)
  9273. * M - month name short
  9274. * MM - month name long
  9275. * y - year (two digit)
  9276. * yy - year (four digit)
  9277. * @ - Unix timestamp (ms since 01/01/1970)
  9278. * ! - Windows ticks (100ns since 01/01/0001)
  9279. * "..." - literal text
  9280. * '' - single quote
  9281. *
  9282. * @param format string - the desired format of the date
  9283. * @param date Date - the date value to format
  9284. * @param settings Object - attributes include:
  9285. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  9286. * dayNames string[7] - names of the days from Sunday (optional)
  9287. * monthNamesShort string[12] - abbreviated names of the months (optional)
  9288. * monthNames string[12] - names of the months (optional)
  9289. * @return string - the date in the above format
  9290. */
  9291. formatDate: function( format, date, settings ) {
  9292. if ( !date ) {
  9293. return "";
  9294. }
  9295. var iFormat,
  9296. dayNamesShort = ( settings ? settings.dayNamesShort : null ) || this._defaults.dayNamesShort,
  9297. dayNames = ( settings ? settings.dayNames : null ) || this._defaults.dayNames,
  9298. monthNamesShort = ( settings ? settings.monthNamesShort : null ) || this._defaults.monthNamesShort,
  9299. monthNames = ( settings ? settings.monthNames : null ) || this._defaults.monthNames,
  9300. // Check whether a format character is doubled
  9301. lookAhead = function( match ) {
  9302. var matches = ( iFormat + 1 < format.length && format.charAt( iFormat + 1 ) === match );
  9303. if ( matches ) {
  9304. iFormat++;
  9305. }
  9306. return matches;
  9307. },
  9308. // Format a number, with leading zero if necessary
  9309. formatNumber = function( match, value, len ) {
  9310. var num = "" + value;
  9311. if ( lookAhead( match ) ) {
  9312. while ( num.length < len ) {
  9313. num = "0" + num;
  9314. }
  9315. }
  9316. return num;
  9317. },
  9318. // Format a name, short or long as requested
  9319. formatName = function( match, value, shortNames, longNames ) {
  9320. return ( lookAhead( match ) ? longNames[ value ] : shortNames[ value ] );
  9321. },
  9322. output = "",
  9323. literal = false;
  9324. if ( date ) {
  9325. for ( iFormat = 0; iFormat < format.length; iFormat++ ) {
  9326. if ( literal ) {
  9327. if ( format.charAt( iFormat ) === "'" && !lookAhead( "'" ) ) {
  9328. literal = false;
  9329. } else {
  9330. output += format.charAt( iFormat );
  9331. }
  9332. } else {
  9333. switch ( format.charAt( iFormat ) ) {
  9334. case "d":
  9335. output += formatNumber( "d", date.getDate(), 2 );
  9336. break;
  9337. case "D":
  9338. output += formatName( "D", date.getDay(), dayNamesShort, dayNames );
  9339. break;
  9340. case "o":
  9341. output += formatNumber( "o",
  9342. Math.round( ( new Date( date.getFullYear(), date.getMonth(), date.getDate() ).getTime() - new Date( date.getFullYear(), 0, 0 ).getTime() ) / 86400000 ), 3 );
  9343. break;
  9344. case "m":
  9345. output += formatNumber( "m", date.getMonth() + 1, 2 );
  9346. break;
  9347. case "M":
  9348. output += formatName( "M", date.getMonth(), monthNamesShort, monthNames );
  9349. break;
  9350. case "y":
  9351. output += ( lookAhead( "y" ) ? date.getFullYear() :
  9352. ( date.getFullYear() % 100 < 10 ? "0" : "" ) + date.getFullYear() % 100 );
  9353. break;
  9354. case "@":
  9355. output += date.getTime();
  9356. break;
  9357. case "!":
  9358. output += date.getTime() * 10000 + this._ticksTo1970;
  9359. break;
  9360. case "'":
  9361. if ( lookAhead( "'" ) ) {
  9362. output += "'";
  9363. } else {
  9364. literal = true;
  9365. }
  9366. break;
  9367. default:
  9368. output += format.charAt( iFormat );
  9369. }
  9370. }
  9371. }
  9372. }
  9373. return output;
  9374. },
  9375. /* Extract all possible characters from the date format. */
  9376. _possibleChars: function( format ) {
  9377. var iFormat,
  9378. chars = "",
  9379. literal = false,
  9380. // Check whether a format character is doubled
  9381. lookAhead = function( match ) {
  9382. var matches = ( iFormat + 1 < format.length && format.charAt( iFormat + 1 ) === match );
  9383. if ( matches ) {
  9384. iFormat++;
  9385. }
  9386. return matches;
  9387. };
  9388. for ( iFormat = 0; iFormat < format.length; iFormat++ ) {
  9389. if ( literal ) {
  9390. if ( format.charAt( iFormat ) === "'" && !lookAhead( "'" ) ) {
  9391. literal = false;
  9392. } else {
  9393. chars += format.charAt( iFormat );
  9394. }
  9395. } else {
  9396. switch ( format.charAt( iFormat ) ) {
  9397. case "d": case "m": case "y": case "@":
  9398. chars += "0123456789";
  9399. break;
  9400. case "D": case "M":
  9401. return null; // Accept anything
  9402. case "'":
  9403. if ( lookAhead( "'" ) ) {
  9404. chars += "'";
  9405. } else {
  9406. literal = true;
  9407. }
  9408. break;
  9409. default:
  9410. chars += format.charAt( iFormat );
  9411. }
  9412. }
  9413. }
  9414. return chars;
  9415. },
  9416. /* Get a setting value, defaulting if necessary. */
  9417. _get: function( inst, name ) {
  9418. return inst.settings[ name ] !== undefined ?
  9419. inst.settings[ name ] : this._defaults[ name ];
  9420. },
  9421. /* Parse existing date and initialise date picker. */
  9422. _setDateFromField: function( inst, noDefault ) {
  9423. if ( inst.input.val() === inst.lastVal ) {
  9424. return;
  9425. }
  9426. var dateFormat = this._get( inst, "dateFormat" ),
  9427. dates = inst.lastVal = inst.input ? inst.input.val() : null,
  9428. defaultDate = this._getDefaultDate( inst ),
  9429. date = defaultDate,
  9430. settings = this._getFormatConfig( inst );
  9431. try {
  9432. date = this.parseDate( dateFormat, dates, settings ) || defaultDate;
  9433. } catch ( event ) {
  9434. dates = ( noDefault ? "" : dates );
  9435. }
  9436. inst.selectedDay = date.getDate();
  9437. inst.drawMonth = inst.selectedMonth = date.getMonth();
  9438. inst.drawYear = inst.selectedYear = date.getFullYear();
  9439. inst.currentDay = ( dates ? date.getDate() : 0 );
  9440. inst.currentMonth = ( dates ? date.getMonth() : 0 );
  9441. inst.currentYear = ( dates ? date.getFullYear() : 0 );
  9442. this._adjustInstDate( inst );
  9443. },
  9444. /* Retrieve the default date shown on opening. */
  9445. _getDefaultDate: function( inst ) {
  9446. return this._restrictMinMax( inst,
  9447. this._determineDate( inst, this._get( inst, "defaultDate" ), new Date() ) );
  9448. },
  9449. /* A date may be specified as an exact value or a relative one. */
  9450. _determineDate: function( inst, date, defaultDate ) {
  9451. var offsetNumeric = function( offset ) {
  9452. var date = new Date();
  9453. date.setDate( date.getDate() + offset );
  9454. return date;
  9455. },
  9456. offsetString = function( offset ) {
  9457. try {
  9458. return $.datepicker.parseDate( $.datepicker._get( inst, "dateFormat" ),
  9459. offset, $.datepicker._getFormatConfig( inst ) );
  9460. } catch ( e ) {
  9461. // Ignore
  9462. }
  9463. var date = ( offset.toLowerCase().match( /^c/ ) ?
  9464. $.datepicker._getDate( inst ) : null ) || new Date(),
  9465. year = date.getFullYear(),
  9466. month = date.getMonth(),
  9467. day = date.getDate(),
  9468. pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,
  9469. matches = pattern.exec( offset );
  9470. while ( matches ) {
  9471. switch ( matches[ 2 ] || "d" ) {
  9472. case "d" : case "D" :
  9473. day += parseInt( matches[ 1 ], 10 ); break;
  9474. case "w" : case "W" :
  9475. day += parseInt( matches[ 1 ], 10 ) * 7; break;
  9476. case "m" : case "M" :
  9477. month += parseInt( matches[ 1 ], 10 );
  9478. day = Math.min( day, $.datepicker._getDaysInMonth( year, month ) );
  9479. break;
  9480. case "y": case "Y" :
  9481. year += parseInt( matches[ 1 ], 10 );
  9482. day = Math.min( day, $.datepicker._getDaysInMonth( year, month ) );
  9483. break;
  9484. }
  9485. matches = pattern.exec( offset );
  9486. }
  9487. return new Date( year, month, day );
  9488. },
  9489. newDate = ( date == null || date === "" ? defaultDate : ( typeof date === "string" ? offsetString( date ) :
  9490. ( typeof date === "number" ? ( isNaN( date ) ? defaultDate : offsetNumeric( date ) ) : new Date( date.getTime() ) ) ) );
  9491. newDate = ( newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate );
  9492. if ( newDate ) {
  9493. newDate.setHours( 0 );
  9494. newDate.setMinutes( 0 );
  9495. newDate.setSeconds( 0 );
  9496. newDate.setMilliseconds( 0 );
  9497. }
  9498. return this._daylightSavingAdjust( newDate );
  9499. },
  9500. /* Handle switch to/from daylight saving.
  9501. * Hours may be non-zero on daylight saving cut-over:
  9502. * > 12 when midnight changeover, but then cannot generate
  9503. * midnight datetime, so jump to 1AM, otherwise reset.
  9504. * @param date (Date) the date to check
  9505. * @return (Date) the corrected date
  9506. */
  9507. _daylightSavingAdjust: function( date ) {
  9508. if ( !date ) {
  9509. return null;
  9510. }
  9511. date.setHours( date.getHours() > 12 ? date.getHours() + 2 : 0 );
  9512. return date;
  9513. },
  9514. /* Set the date(s) directly. */
  9515. _setDate: function( inst, date, noChange ) {
  9516. var clear = !date,
  9517. origMonth = inst.selectedMonth,
  9518. origYear = inst.selectedYear,
  9519. newDate = this._restrictMinMax( inst, this._determineDate( inst, date, new Date() ) );
  9520. inst.selectedDay = inst.currentDay = newDate.getDate();
  9521. inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
  9522. inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
  9523. if ( ( origMonth !== inst.selectedMonth || origYear !== inst.selectedYear ) && !noChange ) {
  9524. this._notifyChange( inst );
  9525. }
  9526. this._adjustInstDate( inst );
  9527. if ( inst.input ) {
  9528. inst.input.val( clear ? "" : this._formatDate( inst ) );
  9529. }
  9530. },
  9531. /* Retrieve the date(s) directly. */
  9532. _getDate: function( inst ) {
  9533. var startDate = ( !inst.currentYear || ( inst.input && inst.input.val() === "" ) ? null :
  9534. this._daylightSavingAdjust( new Date(
  9535. inst.currentYear, inst.currentMonth, inst.currentDay ) ) );
  9536. return startDate;
  9537. },
  9538. /* Attach the onxxx handlers. These are declared statically so
  9539. * they work with static code transformers like Caja.
  9540. */
  9541. _attachHandlers: function( inst ) {
  9542. var stepMonths = this._get( inst, "stepMonths" ),
  9543. id = "#" + inst.id.replace( /\\\\/g, "\\" );
  9544. inst.dpDiv.find( "[data-handler]" ).map( function() {
  9545. var handler = {
  9546. prev: function() {
  9547. $.datepicker._adjustDate( id, -stepMonths, "M" );
  9548. },
  9549. next: function() {
  9550. $.datepicker._adjustDate( id, +stepMonths, "M" );
  9551. },
  9552. hide: function() {
  9553. $.datepicker._hideDatepicker();
  9554. },
  9555. today: function() {
  9556. $.datepicker._gotoToday( id );
  9557. },
  9558. selectDay: function() {
  9559. $.datepicker._selectDay( id, +this.getAttribute( "data-month" ), +this.getAttribute( "data-year" ), this );
  9560. return false;
  9561. },
  9562. selectMonth: function() {
  9563. $.datepicker._selectMonthYear( id, this, "M" );
  9564. return false;
  9565. },
  9566. selectYear: function() {
  9567. $.datepicker._selectMonthYear( id, this, "Y" );
  9568. return false;
  9569. }
  9570. };
  9571. $( this ).on( this.getAttribute( "data-event" ), handler[ this.getAttribute( "data-handler" ) ] );
  9572. } );
  9573. },
  9574. /* Generate the HTML for the current state of the date picker. */
  9575. _generateHTML: function( inst ) {
  9576. var maxDraw, prevText, prev, nextText, next, currentText, gotoDate,
  9577. controls, buttonPanel, firstDay, showWeek, dayNames, dayNamesMin,
  9578. monthNames, monthNamesShort, beforeShowDay, showOtherMonths,
  9579. selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate,
  9580. cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows,
  9581. printDate, dRow, tbody, daySettings, otherMonth, unselectable,
  9582. tempDate = new Date(),
  9583. today = this._daylightSavingAdjust(
  9584. new Date( tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate() ) ), // clear time
  9585. isRTL = this._get( inst, "isRTL" ),
  9586. showButtonPanel = this._get( inst, "showButtonPanel" ),
  9587. hideIfNoPrevNext = this._get( inst, "hideIfNoPrevNext" ),
  9588. navigationAsDateFormat = this._get( inst, "navigationAsDateFormat" ),
  9589. numMonths = this._getNumberOfMonths( inst ),
  9590. showCurrentAtPos = this._get( inst, "showCurrentAtPos" ),
  9591. stepMonths = this._get( inst, "stepMonths" ),
  9592. isMultiMonth = ( numMonths[ 0 ] !== 1 || numMonths[ 1 ] !== 1 ),
  9593. currentDate = this._daylightSavingAdjust( ( !inst.currentDay ? new Date( 9999, 9, 9 ) :
  9594. new Date( inst.currentYear, inst.currentMonth, inst.currentDay ) ) ),
  9595. minDate = this._getMinMaxDate( inst, "min" ),
  9596. maxDate = this._getMinMaxDate( inst, "max" ),
  9597. drawMonth = inst.drawMonth - showCurrentAtPos,
  9598. drawYear = inst.drawYear;
  9599. if ( drawMonth < 0 ) {
  9600. drawMonth += 12;
  9601. drawYear--;
  9602. }
  9603. if ( maxDate ) {
  9604. maxDraw = this._daylightSavingAdjust( new Date( maxDate.getFullYear(),
  9605. maxDate.getMonth() - ( numMonths[ 0 ] * numMonths[ 1 ] ) + 1, maxDate.getDate() ) );
  9606. maxDraw = ( minDate && maxDraw < minDate ? minDate : maxDraw );
  9607. while ( this._daylightSavingAdjust( new Date( drawYear, drawMonth, 1 ) ) > maxDraw ) {
  9608. drawMonth--;
  9609. if ( drawMonth < 0 ) {
  9610. drawMonth = 11;
  9611. drawYear--;
  9612. }
  9613. }
  9614. }
  9615. inst.drawMonth = drawMonth;
  9616. inst.drawYear = drawYear;
  9617. prevText = this._get( inst, "prevText" );
  9618. prevText = ( !navigationAsDateFormat ? prevText : this.formatDate( prevText,
  9619. this._daylightSavingAdjust( new Date( drawYear, drawMonth - stepMonths, 1 ) ),
  9620. this._getFormatConfig( inst ) ) );
  9621. if ( this._canAdjustMonth( inst, -1, drawYear, drawMonth ) ) {
  9622. prev = $( "<a>" )
  9623. .attr( {
  9624. "class": "ui-datepicker-prev ui-corner-all",
  9625. "data-handler": "prev",
  9626. "data-event": "click",
  9627. title: prevText
  9628. } )
  9629. .append(
  9630. $( "<span>" )
  9631. .addClass( "ui-icon ui-icon-circle-triangle-" +
  9632. ( isRTL ? "e" : "w" ) )
  9633. .text( prevText )
  9634. )[ 0 ].outerHTML;
  9635. } else if ( hideIfNoPrevNext ) {
  9636. prev = "";
  9637. } else {
  9638. prev = $( "<a>" )
  9639. .attr( {
  9640. "class": "ui-datepicker-prev ui-corner-all ui-state-disabled",
  9641. title: prevText
  9642. } )
  9643. .append(
  9644. $( "<span>" )
  9645. .addClass( "ui-icon ui-icon-circle-triangle-" +
  9646. ( isRTL ? "e" : "w" ) )
  9647. .text( prevText )
  9648. )[ 0 ].outerHTML;
  9649. }
  9650. nextText = this._get( inst, "nextText" );
  9651. nextText = ( !navigationAsDateFormat ? nextText : this.formatDate( nextText,
  9652. this._daylightSavingAdjust( new Date( drawYear, drawMonth + stepMonths, 1 ) ),
  9653. this._getFormatConfig( inst ) ) );
  9654. if ( this._canAdjustMonth( inst, +1, drawYear, drawMonth ) ) {
  9655. next = $( "<a>" )
  9656. .attr( {
  9657. "class": "ui-datepicker-next ui-corner-all",
  9658. "data-handler": "next",
  9659. "data-event": "click",
  9660. title: nextText
  9661. } )
  9662. .append(
  9663. $( "<span>" )
  9664. .addClass( "ui-icon ui-icon-circle-triangle-" +
  9665. ( isRTL ? "w" : "e" ) )
  9666. .text( nextText )
  9667. )[ 0 ].outerHTML;
  9668. } else if ( hideIfNoPrevNext ) {
  9669. next = "";
  9670. } else {
  9671. next = $( "<a>" )
  9672. .attr( {
  9673. "class": "ui-datepicker-next ui-corner-all ui-state-disabled",
  9674. title: nextText
  9675. } )
  9676. .append(
  9677. $( "<span>" )
  9678. .attr( "class", "ui-icon ui-icon-circle-triangle-" +
  9679. ( isRTL ? "w" : "e" ) )
  9680. .text( nextText )
  9681. )[ 0 ].outerHTML;
  9682. }
  9683. currentText = this._get( inst, "currentText" );
  9684. gotoDate = ( this._get( inst, "gotoCurrent" ) && inst.currentDay ? currentDate : today );
  9685. currentText = ( !navigationAsDateFormat ? currentText :
  9686. this.formatDate( currentText, gotoDate, this._getFormatConfig( inst ) ) );
  9687. controls = "";
  9688. if ( !inst.inline ) {
  9689. controls = $( "<button>" )
  9690. .attr( {
  9691. type: "button",
  9692. "class": "ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all",
  9693. "data-handler": "hide",
  9694. "data-event": "click"
  9695. } )
  9696. .text( this._get( inst, "closeText" ) )[ 0 ].outerHTML;
  9697. }
  9698. buttonPanel = "";
  9699. if ( showButtonPanel ) {
  9700. buttonPanel = $( "<div class='ui-datepicker-buttonpane ui-widget-content'>" )
  9701. .append( isRTL ? controls : "" )
  9702. .append( this._isInRange( inst, gotoDate ) ?
  9703. $( "<button>" )
  9704. .attr( {
  9705. type: "button",
  9706. "class": "ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all",
  9707. "data-handler": "today",
  9708. "data-event": "click"
  9709. } )
  9710. .text( currentText ) :
  9711. "" )
  9712. .append( isRTL ? "" : controls )[ 0 ].outerHTML;
  9713. }
  9714. firstDay = parseInt( this._get( inst, "firstDay" ), 10 );
  9715. firstDay = ( isNaN( firstDay ) ? 0 : firstDay );
  9716. showWeek = this._get( inst, "showWeek" );
  9717. dayNames = this._get( inst, "dayNames" );
  9718. dayNamesMin = this._get( inst, "dayNamesMin" );
  9719. monthNames = this._get( inst, "monthNames" );
  9720. monthNamesShort = this._get( inst, "monthNamesShort" );
  9721. beforeShowDay = this._get( inst, "beforeShowDay" );
  9722. showOtherMonths = this._get( inst, "showOtherMonths" );
  9723. selectOtherMonths = this._get( inst, "selectOtherMonths" );
  9724. defaultDate = this._getDefaultDate( inst );
  9725. html = "";
  9726. for ( row = 0; row < numMonths[ 0 ]; row++ ) {
  9727. group = "";
  9728. this.maxRows = 4;
  9729. for ( col = 0; col < numMonths[ 1 ]; col++ ) {
  9730. selectedDate = this._daylightSavingAdjust( new Date( drawYear, drawMonth, inst.selectedDay ) );
  9731. cornerClass = " ui-corner-all";
  9732. calender = "";
  9733. if ( isMultiMonth ) {
  9734. calender += "<div class='ui-datepicker-group";
  9735. if ( numMonths[ 1 ] > 1 ) {
  9736. switch ( col ) {
  9737. case 0: calender += " ui-datepicker-group-first";
  9738. cornerClass = " ui-corner-" + ( isRTL ? "right" : "left" ); break;
  9739. case numMonths[ 1 ] - 1: calender += " ui-datepicker-group-last";
  9740. cornerClass = " ui-corner-" + ( isRTL ? "left" : "right" ); break;
  9741. default: calender += " ui-datepicker-group-middle"; cornerClass = ""; break;
  9742. }
  9743. }
  9744. calender += "'>";
  9745. }
  9746. calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" +
  9747. ( /all|left/.test( cornerClass ) && row === 0 ? ( isRTL ? next : prev ) : "" ) +
  9748. ( /all|right/.test( cornerClass ) && row === 0 ? ( isRTL ? prev : next ) : "" ) +
  9749. this._generateMonthYearHeader( inst, drawMonth, drawYear, minDate, maxDate,
  9750. row > 0 || col > 0, monthNames, monthNamesShort ) + // draw month headers
  9751. "</div><table class='ui-datepicker-calendar'><thead>" +
  9752. "<tr>";
  9753. thead = ( showWeek ? "<th class='ui-datepicker-week-col'>" + this._get( inst, "weekHeader" ) + "</th>" : "" );
  9754. for ( dow = 0; dow < 7; dow++ ) { // days of the week
  9755. day = ( dow + firstDay ) % 7;
  9756. thead += "<th scope='col'" + ( ( dow + firstDay + 6 ) % 7 >= 5 ? " class='ui-datepicker-week-end'" : "" ) + ">" +
  9757. "<span title='" + dayNames[ day ] + "'>" + dayNamesMin[ day ] + "</span></th>";
  9758. }
  9759. calender += thead + "</tr></thead><tbody>";
  9760. daysInMonth = this._getDaysInMonth( drawYear, drawMonth );
  9761. if ( drawYear === inst.selectedYear && drawMonth === inst.selectedMonth ) {
  9762. inst.selectedDay = Math.min( inst.selectedDay, daysInMonth );
  9763. }
  9764. leadDays = ( this._getFirstDayOfMonth( drawYear, drawMonth ) - firstDay + 7 ) % 7;
  9765. curRows = Math.ceil( ( leadDays + daysInMonth ) / 7 ); // calculate the number of rows to generate
  9766. numRows = ( isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows ); //If multiple months, use the higher number of rows (see #7043)
  9767. this.maxRows = numRows;
  9768. printDate = this._daylightSavingAdjust( new Date( drawYear, drawMonth, 1 - leadDays ) );
  9769. for ( dRow = 0; dRow < numRows; dRow++ ) { // create date picker rows
  9770. calender += "<tr>";
  9771. tbody = ( !showWeek ? "" : "<td class='ui-datepicker-week-col'>" +
  9772. this._get( inst, "calculateWeek" )( printDate ) + "</td>" );
  9773. for ( dow = 0; dow < 7; dow++ ) { // create date picker days
  9774. daySettings = ( beforeShowDay ?
  9775. beforeShowDay.apply( ( inst.input ? inst.input[ 0 ] : null ), [ printDate ] ) : [ true, "" ] );
  9776. otherMonth = ( printDate.getMonth() !== drawMonth );
  9777. unselectable = ( otherMonth && !selectOtherMonths ) || !daySettings[ 0 ] ||
  9778. ( minDate && printDate < minDate ) || ( maxDate && printDate > maxDate );
  9779. tbody += "<td class='" +
  9780. ( ( dow + firstDay + 6 ) % 7 >= 5 ? " ui-datepicker-week-end" : "" ) + // highlight weekends
  9781. ( otherMonth ? " ui-datepicker-other-month" : "" ) + // highlight days from other months
  9782. ( ( printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent ) || // user pressed key
  9783. ( defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime() ) ?
  9784. // or defaultDate is current printedDate and defaultDate is selectedDate
  9785. " " + this._dayOverClass : "" ) + // highlight selected day
  9786. ( unselectable ? " " + this._unselectableClass + " ui-state-disabled" : "" ) + // highlight unselectable days
  9787. ( otherMonth && !showOtherMonths ? "" : " " + daySettings[ 1 ] + // highlight custom dates
  9788. ( printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "" ) + // highlight selected day
  9789. ( printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "" ) ) + "'" + // highlight today (if different)
  9790. ( ( !otherMonth || showOtherMonths ) && daySettings[ 2 ] ? " title='" + daySettings[ 2 ].replace( /'/g, "&#39;" ) + "'" : "" ) + // cell title
  9791. ( unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'" ) + ">" + // actions
  9792. ( otherMonth && !showOtherMonths ? "&#xa0;" : // display for other months
  9793. ( unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" +
  9794. ( printDate.getTime() === today.getTime() ? " ui-state-highlight" : "" ) +
  9795. ( printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "" ) + // highlight selected day
  9796. ( otherMonth ? " ui-priority-secondary" : "" ) + // distinguish dates from other months
  9797. "' href='#' aria-current='" + ( printDate.getTime() === currentDate.getTime() ? "true" : "false" ) + // mark date as selected for screen reader
  9798. "' data-date='" + printDate.getDate() + // store date as data
  9799. "'>" + printDate.getDate() + "</a>" ) ) + "</td>"; // display selectable date
  9800. printDate.setDate( printDate.getDate() + 1 );
  9801. printDate = this._daylightSavingAdjust( printDate );
  9802. }
  9803. calender += tbody + "</tr>";
  9804. }
  9805. drawMonth++;
  9806. if ( drawMonth > 11 ) {
  9807. drawMonth = 0;
  9808. drawYear++;
  9809. }
  9810. calender += "</tbody></table>" + ( isMultiMonth ? "</div>" +
  9811. ( ( numMonths[ 0 ] > 0 && col === numMonths[ 1 ] - 1 ) ? "<div class='ui-datepicker-row-break'></div>" : "" ) : "" );
  9812. group += calender;
  9813. }
  9814. html += group;
  9815. }
  9816. html += buttonPanel;
  9817. inst._keyEvent = false;
  9818. return html;
  9819. },
  9820. /* Generate the month and year header. */
  9821. _generateMonthYearHeader: function( inst, drawMonth, drawYear, minDate, maxDate,
  9822. secondary, monthNames, monthNamesShort ) {
  9823. var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear,
  9824. changeMonth = this._get( inst, "changeMonth" ),
  9825. changeYear = this._get( inst, "changeYear" ),
  9826. showMonthAfterYear = this._get( inst, "showMonthAfterYear" ),
  9827. selectMonthLabel = this._get( inst, "selectMonthLabel" ),
  9828. selectYearLabel = this._get( inst, "selectYearLabel" ),
  9829. html = "<div class='ui-datepicker-title'>",
  9830. monthHtml = "";
  9831. // Month selection
  9832. if ( secondary || !changeMonth ) {
  9833. monthHtml += "<span class='ui-datepicker-month'>" + monthNames[ drawMonth ] + "</span>";
  9834. } else {
  9835. inMinYear = ( minDate && minDate.getFullYear() === drawYear );
  9836. inMaxYear = ( maxDate && maxDate.getFullYear() === drawYear );
  9837. monthHtml += "<select class='ui-datepicker-month' aria-label='" + selectMonthLabel + "' data-handler='selectMonth' data-event='change'>";
  9838. for ( month = 0; month < 12; month++ ) {
  9839. if ( ( !inMinYear || month >= minDate.getMonth() ) && ( !inMaxYear || month <= maxDate.getMonth() ) ) {
  9840. monthHtml += "<option value='" + month + "'" +
  9841. ( month === drawMonth ? " selected='selected'" : "" ) +
  9842. ">" + monthNamesShort[ month ] + "</option>";
  9843. }
  9844. }
  9845. monthHtml += "</select>";
  9846. }
  9847. if ( !showMonthAfterYear ) {
  9848. html += monthHtml + ( secondary || !( changeMonth && changeYear ) ? "&#xa0;" : "" );
  9849. }
  9850. // Year selection
  9851. if ( !inst.yearshtml ) {
  9852. inst.yearshtml = "";
  9853. if ( secondary || !changeYear ) {
  9854. html += "<span class='ui-datepicker-year'>" + drawYear + "</span>";
  9855. } else {
  9856. // determine range of years to display
  9857. years = this._get( inst, "yearRange" ).split( ":" );
  9858. thisYear = new Date().getFullYear();
  9859. determineYear = function( value ) {
  9860. var year = ( value.match( /c[+\-].*/ ) ? drawYear + parseInt( value.substring( 1 ), 10 ) :
  9861. ( value.match( /[+\-].*/ ) ? thisYear + parseInt( value, 10 ) :
  9862. parseInt( value, 10 ) ) );
  9863. return ( isNaN( year ) ? thisYear : year );
  9864. };
  9865. year = determineYear( years[ 0 ] );
  9866. endYear = Math.max( year, determineYear( years[ 1 ] || "" ) );
  9867. year = ( minDate ? Math.max( year, minDate.getFullYear() ) : year );
  9868. endYear = ( maxDate ? Math.min( endYear, maxDate.getFullYear() ) : endYear );
  9869. inst.yearshtml += "<select class='ui-datepicker-year' aria-label='" + selectYearLabel + "' data-handler='selectYear' data-event='change'>";
  9870. for ( ; year <= endYear; year++ ) {
  9871. inst.yearshtml += "<option value='" + year + "'" +
  9872. ( year === drawYear ? " selected='selected'" : "" ) +
  9873. ">" + year + "</option>";
  9874. }
  9875. inst.yearshtml += "</select>";
  9876. html += inst.yearshtml;
  9877. inst.yearshtml = null;
  9878. }
  9879. }
  9880. html += this._get( inst, "yearSuffix" );
  9881. if ( showMonthAfterYear ) {
  9882. html += ( secondary || !( changeMonth && changeYear ) ? "&#xa0;" : "" ) + monthHtml;
  9883. }
  9884. html += "</div>"; // Close datepicker_header
  9885. return html;
  9886. },
  9887. /* Adjust one of the date sub-fields. */
  9888. _adjustInstDate: function( inst, offset, period ) {
  9889. var year = inst.selectedYear + ( period === "Y" ? offset : 0 ),
  9890. month = inst.selectedMonth + ( period === "M" ? offset : 0 ),
  9891. day = Math.min( inst.selectedDay, this._getDaysInMonth( year, month ) ) + ( period === "D" ? offset : 0 ),
  9892. date = this._restrictMinMax( inst, this._daylightSavingAdjust( new Date( year, month, day ) ) );
  9893. inst.selectedDay = date.getDate();
  9894. inst.drawMonth = inst.selectedMonth = date.getMonth();
  9895. inst.drawYear = inst.selectedYear = date.getFullYear();
  9896. if ( period === "M" || period === "Y" ) {
  9897. this._notifyChange( inst );
  9898. }
  9899. },
  9900. /* Ensure a date is within any min/max bounds. */
  9901. _restrictMinMax: function( inst, date ) {
  9902. var minDate = this._getMinMaxDate( inst, "min" ),
  9903. maxDate = this._getMinMaxDate( inst, "max" ),
  9904. newDate = ( minDate && date < minDate ? minDate : date );
  9905. return ( maxDate && newDate > maxDate ? maxDate : newDate );
  9906. },
  9907. /* Notify change of month/year. */
  9908. _notifyChange: function( inst ) {
  9909. var onChange = this._get( inst, "onChangeMonthYear" );
  9910. if ( onChange ) {
  9911. onChange.apply( ( inst.input ? inst.input[ 0 ] : null ),
  9912. [ inst.selectedYear, inst.selectedMonth + 1, inst ] );
  9913. }
  9914. },
  9915. /* Determine the number of months to show. */
  9916. _getNumberOfMonths: function( inst ) {
  9917. var numMonths = this._get( inst, "numberOfMonths" );
  9918. return ( numMonths == null ? [ 1, 1 ] : ( typeof numMonths === "number" ? [ 1, numMonths ] : numMonths ) );
  9919. },
  9920. /* Determine the current maximum date - ensure no time components are set. */
  9921. _getMinMaxDate: function( inst, minMax ) {
  9922. return this._determineDate( inst, this._get( inst, minMax + "Date" ), null );
  9923. },
  9924. /* Find the number of days in a given month. */
  9925. _getDaysInMonth: function( year, month ) {
  9926. return 32 - this._daylightSavingAdjust( new Date( year, month, 32 ) ).getDate();
  9927. },
  9928. /* Find the day of the week of the first of a month. */
  9929. _getFirstDayOfMonth: function( year, month ) {
  9930. return new Date( year, month, 1 ).getDay();
  9931. },
  9932. /* Determines if we should allow a "next/prev" month display change. */
  9933. _canAdjustMonth: function( inst, offset, curYear, curMonth ) {
  9934. var numMonths = this._getNumberOfMonths( inst ),
  9935. date = this._daylightSavingAdjust( new Date( curYear,
  9936. curMonth + ( offset < 0 ? offset : numMonths[ 0 ] * numMonths[ 1 ] ), 1 ) );
  9937. if ( offset < 0 ) {
  9938. date.setDate( this._getDaysInMonth( date.getFullYear(), date.getMonth() ) );
  9939. }
  9940. return this._isInRange( inst, date );
  9941. },
  9942. /* Is the given date in the accepted range? */
  9943. _isInRange: function( inst, date ) {
  9944. var yearSplit, currentYear,
  9945. minDate = this._getMinMaxDate( inst, "min" ),
  9946. maxDate = this._getMinMaxDate( inst, "max" ),
  9947. minYear = null,
  9948. maxYear = null,
  9949. years = this._get( inst, "yearRange" );
  9950. if ( years ) {
  9951. yearSplit = years.split( ":" );
  9952. currentYear = new Date().getFullYear();
  9953. minYear = parseInt( yearSplit[ 0 ], 10 );
  9954. maxYear = parseInt( yearSplit[ 1 ], 10 );
  9955. if ( yearSplit[ 0 ].match( /[+\-].*/ ) ) {
  9956. minYear += currentYear;
  9957. }
  9958. if ( yearSplit[ 1 ].match( /[+\-].*/ ) ) {
  9959. maxYear += currentYear;
  9960. }
  9961. }
  9962. return ( ( !minDate || date.getTime() >= minDate.getTime() ) &&
  9963. ( !maxDate || date.getTime() <= maxDate.getTime() ) &&
  9964. ( !minYear || date.getFullYear() >= minYear ) &&
  9965. ( !maxYear || date.getFullYear() <= maxYear ) );
  9966. },
  9967. /* Provide the configuration settings for formatting/parsing. */
  9968. _getFormatConfig: function( inst ) {
  9969. var shortYearCutoff = this._get( inst, "shortYearCutoff" );
  9970. shortYearCutoff = ( typeof shortYearCutoff !== "string" ? shortYearCutoff :
  9971. new Date().getFullYear() % 100 + parseInt( shortYearCutoff, 10 ) );
  9972. return { shortYearCutoff: shortYearCutoff,
  9973. dayNamesShort: this._get( inst, "dayNamesShort" ), dayNames: this._get( inst, "dayNames" ),
  9974. monthNamesShort: this._get( inst, "monthNamesShort" ), monthNames: this._get( inst, "monthNames" ) };
  9975. },
  9976. /* Format the given date for display. */
  9977. _formatDate: function( inst, day, month, year ) {
  9978. if ( !day ) {
  9979. inst.currentDay = inst.selectedDay;
  9980. inst.currentMonth = inst.selectedMonth;
  9981. inst.currentYear = inst.selectedYear;
  9982. }
  9983. var date = ( day ? ( typeof day === "object" ? day :
  9984. this._daylightSavingAdjust( new Date( year, month, day ) ) ) :
  9985. this._daylightSavingAdjust( new Date( inst.currentYear, inst.currentMonth, inst.currentDay ) ) );
  9986. return this.formatDate( this._get( inst, "dateFormat" ), date, this._getFormatConfig( inst ) );
  9987. }
  9988. } );
  9989. /*
  9990. * Bind hover events for datepicker elements.
  9991. * Done via delegate so the binding only occurs once in the lifetime of the parent div.
  9992. * Global datepicker_instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
  9993. */
  9994. function datepicker_bindHover( dpDiv ) {
  9995. var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";
  9996. return dpDiv.on( "mouseout", selector, function() {
  9997. $( this ).removeClass( "ui-state-hover" );
  9998. if ( this.className.indexOf( "ui-datepicker-prev" ) !== -1 ) {
  9999. $( this ).removeClass( "ui-datepicker-prev-hover" );
  10000. }
  10001. if ( this.className.indexOf( "ui-datepicker-next" ) !== -1 ) {
  10002. $( this ).removeClass( "ui-datepicker-next-hover" );
  10003. }
  10004. } )
  10005. .on( "mouseover", selector, datepicker_handleMouseover );
  10006. }
  10007. function datepicker_handleMouseover() {
  10008. if ( !$.datepicker._isDisabledDatepicker( datepicker_instActive.inline ? datepicker_instActive.dpDiv.parent()[ 0 ] : datepicker_instActive.input[ 0 ] ) ) {
  10009. $( this ).parents( ".ui-datepicker-calendar" ).find( "a" ).removeClass( "ui-state-hover" );
  10010. $( this ).addClass( "ui-state-hover" );
  10011. if ( this.className.indexOf( "ui-datepicker-prev" ) !== -1 ) {
  10012. $( this ).addClass( "ui-datepicker-prev-hover" );
  10013. }
  10014. if ( this.className.indexOf( "ui-datepicker-next" ) !== -1 ) {
  10015. $( this ).addClass( "ui-datepicker-next-hover" );
  10016. }
  10017. }
  10018. }
  10019. /* jQuery extend now ignores nulls! */
  10020. function datepicker_extendRemove( target, props ) {
  10021. $.extend( target, props );
  10022. for ( var name in props ) {
  10023. if ( props[ name ] == null ) {
  10024. target[ name ] = props[ name ];
  10025. }
  10026. }
  10027. return target;
  10028. }
  10029. /* Invoke the datepicker functionality.
  10030. @param options string - a command, optionally followed by additional parameters or
  10031. Object - settings for attaching new datepicker functionality
  10032. @return jQuery object */
  10033. $.fn.datepicker = function( options ) {
  10034. /* Verify an empty collection wasn't passed - Fixes #6976 */
  10035. if ( !this.length ) {
  10036. return this;
  10037. }
  10038. /* Initialise the date picker. */
  10039. if ( !$.datepicker.initialized ) {
  10040. $( document ).on( "mousedown", $.datepicker._checkExternalClick );
  10041. $.datepicker.initialized = true;
  10042. }
  10043. /* Append datepicker main container to body if not exist. */
  10044. if ( $( "#" + $.datepicker._mainDivId ).length === 0 ) {
  10045. $( "body" ).append( $.datepicker.dpDiv );
  10046. }
  10047. var otherArgs = Array.prototype.slice.call( arguments, 1 );
  10048. if ( typeof options === "string" && ( options === "isDisabled" || options === "getDate" || options === "widget" ) ) {
  10049. return $.datepicker[ "_" + options + "Datepicker" ].
  10050. apply( $.datepicker, [ this[ 0 ] ].concat( otherArgs ) );
  10051. }
  10052. if ( options === "option" && arguments.length === 2 && typeof arguments[ 1 ] === "string" ) {
  10053. return $.datepicker[ "_" + options + "Datepicker" ].
  10054. apply( $.datepicker, [ this[ 0 ] ].concat( otherArgs ) );
  10055. }
  10056. return this.each( function() {
  10057. if ( typeof options === "string" ) {
  10058. $.datepicker[ "_" + options + "Datepicker" ]
  10059. .apply( $.datepicker, [ this ].concat( otherArgs ) );
  10060. } else {
  10061. $.datepicker._attachDatepicker( this, options );
  10062. }
  10063. } );
  10064. };
  10065. $.datepicker = new Datepicker(); // singleton instance
  10066. $.datepicker.initialized = false;
  10067. $.datepicker.uuid = new Date().getTime();
  10068. $.datepicker.version = "1.13.0";
  10069. var widgetsDatepicker = $.datepicker;
  10070. /*!
  10071. * jQuery UI Dialog 1.13.0
  10072. * http://jqueryui.com
  10073. *
  10074. * Copyright jQuery Foundation and other contributors
  10075. * Released under the MIT license.
  10076. * http://jquery.org/license
  10077. */
  10078. //>>label: Dialog
  10079. //>>group: Widgets
  10080. //>>description: Displays customizable dialog windows.
  10081. //>>docs: http://api.jqueryui.com/dialog/
  10082. //>>demos: http://jqueryui.com/dialog/
  10083. //>>css.structure: ../../themes/base/core.css
  10084. //>>css.structure: ../../themes/base/dialog.css
  10085. //>>css.theme: ../../themes/base/theme.css
  10086. $.widget( "ui.dialog", {
  10087. version: "1.13.0",
  10088. options: {
  10089. appendTo: "body",
  10090. autoOpen: true,
  10091. buttons: [],
  10092. classes: {
  10093. "ui-dialog": "ui-corner-all",
  10094. "ui-dialog-titlebar": "ui-corner-all"
  10095. },
  10096. closeOnEscape: true,
  10097. closeText: "Close",
  10098. draggable: true,
  10099. hide: null,
  10100. height: "auto",
  10101. maxHeight: null,
  10102. maxWidth: null,
  10103. minHeight: 150,
  10104. minWidth: 150,
  10105. modal: false,
  10106. position: {
  10107. my: "center",
  10108. at: "center",
  10109. of: window,
  10110. collision: "fit",
  10111. // Ensure the titlebar is always visible
  10112. using: function( pos ) {
  10113. var topOffset = $( this ).css( pos ).offset().top;
  10114. if ( topOffset < 0 ) {
  10115. $( this ).css( "top", pos.top - topOffset );
  10116. }
  10117. }
  10118. },
  10119. resizable: true,
  10120. show: null,
  10121. title: null,
  10122. width: 300,
  10123. // Callbacks
  10124. beforeClose: null,
  10125. close: null,
  10126. drag: null,
  10127. dragStart: null,
  10128. dragStop: null,
  10129. focus: null,
  10130. open: null,
  10131. resize: null,
  10132. resizeStart: null,
  10133. resizeStop: null
  10134. },
  10135. sizeRelatedOptions: {
  10136. buttons: true,
  10137. height: true,
  10138. maxHeight: true,
  10139. maxWidth: true,
  10140. minHeight: true,
  10141. minWidth: true,
  10142. width: true
  10143. },
  10144. resizableRelatedOptions: {
  10145. maxHeight: true,
  10146. maxWidth: true,
  10147. minHeight: true,
  10148. minWidth: true
  10149. },
  10150. _create: function() {
  10151. this.originalCss = {
  10152. display: this.element[ 0 ].style.display,
  10153. width: this.element[ 0 ].style.width,
  10154. minHeight: this.element[ 0 ].style.minHeight,
  10155. maxHeight: this.element[ 0 ].style.maxHeight,
  10156. height: this.element[ 0 ].style.height
  10157. };
  10158. this.originalPosition = {
  10159. parent: this.element.parent(),
  10160. index: this.element.parent().children().index( this.element )
  10161. };
  10162. this.originalTitle = this.element.attr( "title" );
  10163. if ( this.options.title == null && this.originalTitle != null ) {
  10164. this.options.title = this.originalTitle;
  10165. }
  10166. // Dialogs can't be disabled
  10167. if ( this.options.disabled ) {
  10168. this.options.disabled = false;
  10169. }
  10170. this._createWrapper();
  10171. this.element
  10172. .show()
  10173. .removeAttr( "title" )
  10174. .appendTo( this.uiDialog );
  10175. this._addClass( "ui-dialog-content", "ui-widget-content" );
  10176. this._createTitlebar();
  10177. this._createButtonPane();
  10178. if ( this.options.draggable && $.fn.draggable ) {
  10179. this._makeDraggable();
  10180. }
  10181. if ( this.options.resizable && $.fn.resizable ) {
  10182. this._makeResizable();
  10183. }
  10184. this._isOpen = false;
  10185. this._trackFocus();
  10186. },
  10187. _init: function() {
  10188. if ( this.options.autoOpen ) {
  10189. this.open();
  10190. }
  10191. },
  10192. _appendTo: function() {
  10193. var element = this.options.appendTo;
  10194. if ( element && ( element.jquery || element.nodeType ) ) {
  10195. return $( element );
  10196. }
  10197. return this.document.find( element || "body" ).eq( 0 );
  10198. },
  10199. _destroy: function() {
  10200. var next,
  10201. originalPosition = this.originalPosition;
  10202. this._untrackInstance();
  10203. this._destroyOverlay();
  10204. this.element
  10205. .removeUniqueId()
  10206. .css( this.originalCss )
  10207. // Without detaching first, the following becomes really slow
  10208. .detach();
  10209. this.uiDialog.remove();
  10210. if ( this.originalTitle ) {
  10211. this.element.attr( "title", this.originalTitle );
  10212. }
  10213. next = originalPosition.parent.children().eq( originalPosition.index );
  10214. // Don't try to place the dialog next to itself (#8613)
  10215. if ( next.length && next[ 0 ] !== this.element[ 0 ] ) {
  10216. next.before( this.element );
  10217. } else {
  10218. originalPosition.parent.append( this.element );
  10219. }
  10220. },
  10221. widget: function() {
  10222. return this.uiDialog;
  10223. },
  10224. disable: $.noop,
  10225. enable: $.noop,
  10226. close: function( event ) {
  10227. var that = this;
  10228. if ( !this._isOpen || this._trigger( "beforeClose", event ) === false ) {
  10229. return;
  10230. }
  10231. this._isOpen = false;
  10232. this._focusedElement = null;
  10233. this._destroyOverlay();
  10234. this._untrackInstance();
  10235. if ( !this.opener.filter( ":focusable" ).trigger( "focus" ).length ) {
  10236. // Hiding a focused element doesn't trigger blur in WebKit
  10237. // so in case we have nothing to focus on, explicitly blur the active element
  10238. // https://bugs.webkit.org/show_bug.cgi?id=47182
  10239. $.ui.safeBlur( $.ui.safeActiveElement( this.document[ 0 ] ) );
  10240. }
  10241. this._hide( this.uiDialog, this.options.hide, function() {
  10242. that._trigger( "close", event );
  10243. } );
  10244. },
  10245. isOpen: function() {
  10246. return this._isOpen;
  10247. },
  10248. moveToTop: function() {
  10249. this._moveToTop();
  10250. },
  10251. _moveToTop: function( event, silent ) {
  10252. var moved = false,
  10253. zIndices = this.uiDialog.siblings( ".ui-front:visible" ).map( function() {
  10254. return +$( this ).css( "z-index" );
  10255. } ).get(),
  10256. zIndexMax = Math.max.apply( null, zIndices );
  10257. if ( zIndexMax >= +this.uiDialog.css( "z-index" ) ) {
  10258. this.uiDialog.css( "z-index", zIndexMax + 1 );
  10259. moved = true;
  10260. }
  10261. if ( moved && !silent ) {
  10262. this._trigger( "focus", event );
  10263. }
  10264. return moved;
  10265. },
  10266. open: function() {
  10267. var that = this;
  10268. if ( this._isOpen ) {
  10269. if ( this._moveToTop() ) {
  10270. this._focusTabbable();
  10271. }
  10272. return;
  10273. }
  10274. this._isOpen = true;
  10275. this.opener = $( $.ui.safeActiveElement( this.document[ 0 ] ) );
  10276. this._size();
  10277. this._position();
  10278. this._createOverlay();
  10279. this._moveToTop( null, true );
  10280. // Ensure the overlay is moved to the top with the dialog, but only when
  10281. // opening. The overlay shouldn't move after the dialog is open so that
  10282. // modeless dialogs opened after the modal dialog stack properly.
  10283. if ( this.overlay ) {
  10284. this.overlay.css( "z-index", this.uiDialog.css( "z-index" ) - 1 );
  10285. }
  10286. this._show( this.uiDialog, this.options.show, function() {
  10287. that._focusTabbable();
  10288. that._trigger( "focus" );
  10289. } );
  10290. // Track the dialog immediately upon opening in case a focus event
  10291. // somehow occurs outside of the dialog before an element inside the
  10292. // dialog is focused (#10152)
  10293. this._makeFocusTarget();
  10294. this._trigger( "open" );
  10295. },
  10296. _focusTabbable: function() {
  10297. // Set focus to the first match:
  10298. // 1. An element that was focused previously
  10299. // 2. First element inside the dialog matching [autofocus]
  10300. // 3. Tabbable element inside the content element
  10301. // 4. Tabbable element inside the buttonpane
  10302. // 5. The close button
  10303. // 6. The dialog itself
  10304. var hasFocus = this._focusedElement;
  10305. if ( !hasFocus ) {
  10306. hasFocus = this.element.find( "[autofocus]" );
  10307. }
  10308. if ( !hasFocus.length ) {
  10309. hasFocus = this.element.find( ":tabbable" );
  10310. }
  10311. if ( !hasFocus.length ) {
  10312. hasFocus = this.uiDialogButtonPane.find( ":tabbable" );
  10313. }
  10314. if ( !hasFocus.length ) {
  10315. hasFocus = this.uiDialogTitlebarClose.filter( ":tabbable" );
  10316. }
  10317. if ( !hasFocus.length ) {
  10318. hasFocus = this.uiDialog;
  10319. }
  10320. hasFocus.eq( 0 ).trigger( "focus" );
  10321. },
  10322. _restoreTabbableFocus: function() {
  10323. var activeElement = $.ui.safeActiveElement( this.document[ 0 ] ),
  10324. isActive = this.uiDialog[ 0 ] === activeElement ||
  10325. $.contains( this.uiDialog[ 0 ], activeElement );
  10326. if ( !isActive ) {
  10327. this._focusTabbable();
  10328. }
  10329. },
  10330. _keepFocus: function( event ) {
  10331. event.preventDefault();
  10332. this._restoreTabbableFocus();
  10333. // support: IE
  10334. // IE <= 8 doesn't prevent moving focus even with event.preventDefault()
  10335. // so we check again later
  10336. this._delay( this._restoreTabbableFocus );
  10337. },
  10338. _createWrapper: function() {
  10339. this.uiDialog = $( "<div>" )
  10340. .hide()
  10341. .attr( {
  10342. // Setting tabIndex makes the div focusable
  10343. tabIndex: -1,
  10344. role: "dialog"
  10345. } )
  10346. .appendTo( this._appendTo() );
  10347. this._addClass( this.uiDialog, "ui-dialog", "ui-widget ui-widget-content ui-front" );
  10348. this._on( this.uiDialog, {
  10349. keydown: function( event ) {
  10350. if ( this.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
  10351. event.keyCode === $.ui.keyCode.ESCAPE ) {
  10352. event.preventDefault();
  10353. this.close( event );
  10354. return;
  10355. }
  10356. // Prevent tabbing out of dialogs
  10357. if ( event.keyCode !== $.ui.keyCode.TAB || event.isDefaultPrevented() ) {
  10358. return;
  10359. }
  10360. var tabbables = this.uiDialog.find( ":tabbable" ),
  10361. first = tabbables.first(),
  10362. last = tabbables.last();
  10363. if ( ( event.target === last[ 0 ] || event.target === this.uiDialog[ 0 ] ) &&
  10364. !event.shiftKey ) {
  10365. this._delay( function() {
  10366. first.trigger( "focus" );
  10367. } );
  10368. event.preventDefault();
  10369. } else if ( ( event.target === first[ 0 ] ||
  10370. event.target === this.uiDialog[ 0 ] ) && event.shiftKey ) {
  10371. this._delay( function() {
  10372. last.trigger( "focus" );
  10373. } );
  10374. event.preventDefault();
  10375. }
  10376. },
  10377. mousedown: function( event ) {
  10378. if ( this._moveToTop( event ) ) {
  10379. this._focusTabbable();
  10380. }
  10381. }
  10382. } );
  10383. // We assume that any existing aria-describedby attribute means
  10384. // that the dialog content is marked up properly
  10385. // otherwise we brute force the content as the description
  10386. if ( !this.element.find( "[aria-describedby]" ).length ) {
  10387. this.uiDialog.attr( {
  10388. "aria-describedby": this.element.uniqueId().attr( "id" )
  10389. } );
  10390. }
  10391. },
  10392. _createTitlebar: function() {
  10393. var uiDialogTitle;
  10394. this.uiDialogTitlebar = $( "<div>" );
  10395. this._addClass( this.uiDialogTitlebar,
  10396. "ui-dialog-titlebar", "ui-widget-header ui-helper-clearfix" );
  10397. this._on( this.uiDialogTitlebar, {
  10398. mousedown: function( event ) {
  10399. // Don't prevent click on close button (#8838)
  10400. // Focusing a dialog that is partially scrolled out of view
  10401. // causes the browser to scroll it into view, preventing the click event
  10402. if ( !$( event.target ).closest( ".ui-dialog-titlebar-close" ) ) {
  10403. // Dialog isn't getting focus when dragging (#8063)
  10404. this.uiDialog.trigger( "focus" );
  10405. }
  10406. }
  10407. } );
  10408. // Support: IE
  10409. // Use type="button" to prevent enter keypresses in textboxes from closing the
  10410. // dialog in IE (#9312)
  10411. this.uiDialogTitlebarClose = $( "<button type='button'></button>" )
  10412. .button( {
  10413. label: $( "<a>" ).text( this.options.closeText ).html(),
  10414. icon: "ui-icon-closethick",
  10415. showLabel: false
  10416. } )
  10417. .appendTo( this.uiDialogTitlebar );
  10418. this._addClass( this.uiDialogTitlebarClose, "ui-dialog-titlebar-close" );
  10419. this._on( this.uiDialogTitlebarClose, {
  10420. click: function( event ) {
  10421. event.preventDefault();
  10422. this.close( event );
  10423. }
  10424. } );
  10425. uiDialogTitle = $( "<span>" ).uniqueId().prependTo( this.uiDialogTitlebar );
  10426. this._addClass( uiDialogTitle, "ui-dialog-title" );
  10427. this._title( uiDialogTitle );
  10428. this.uiDialogTitlebar.prependTo( this.uiDialog );
  10429. this.uiDialog.attr( {
  10430. "aria-labelledby": uiDialogTitle.attr( "id" )
  10431. } );
  10432. },
  10433. _title: function( title ) {
  10434. if ( this.options.title ) {
  10435. title.text( this.options.title );
  10436. } else {
  10437. title.html( "&#160;" );
  10438. }
  10439. },
  10440. _createButtonPane: function() {
  10441. this.uiDialogButtonPane = $( "<div>" );
  10442. this._addClass( this.uiDialogButtonPane, "ui-dialog-buttonpane",
  10443. "ui-widget-content ui-helper-clearfix" );
  10444. this.uiButtonSet = $( "<div>" )
  10445. .appendTo( this.uiDialogButtonPane );
  10446. this._addClass( this.uiButtonSet, "ui-dialog-buttonset" );
  10447. this._createButtons();
  10448. },
  10449. _createButtons: function() {
  10450. var that = this,
  10451. buttons = this.options.buttons;
  10452. // If we already have a button pane, remove it
  10453. this.uiDialogButtonPane.remove();
  10454. this.uiButtonSet.empty();
  10455. if ( $.isEmptyObject( buttons ) || ( Array.isArray( buttons ) && !buttons.length ) ) {
  10456. this._removeClass( this.uiDialog, "ui-dialog-buttons" );
  10457. return;
  10458. }
  10459. $.each( buttons, function( name, props ) {
  10460. var click, buttonOptions;
  10461. props = typeof props === "function" ?
  10462. { click: props, text: name } :
  10463. props;
  10464. // Default to a non-submitting button
  10465. props = $.extend( { type: "button" }, props );
  10466. // Change the context for the click callback to be the main element
  10467. click = props.click;
  10468. buttonOptions = {
  10469. icon: props.icon,
  10470. iconPosition: props.iconPosition,
  10471. showLabel: props.showLabel,
  10472. // Deprecated options
  10473. icons: props.icons,
  10474. text: props.text
  10475. };
  10476. delete props.click;
  10477. delete props.icon;
  10478. delete props.iconPosition;
  10479. delete props.showLabel;
  10480. // Deprecated options
  10481. delete props.icons;
  10482. if ( typeof props.text === "boolean" ) {
  10483. delete props.text;
  10484. }
  10485. $( "<button></button>", props )
  10486. .button( buttonOptions )
  10487. .appendTo( that.uiButtonSet )
  10488. .on( "click", function() {
  10489. click.apply( that.element[ 0 ], arguments );
  10490. } );
  10491. } );
  10492. this._addClass( this.uiDialog, "ui-dialog-buttons" );
  10493. this.uiDialogButtonPane.appendTo( this.uiDialog );
  10494. },
  10495. _makeDraggable: function() {
  10496. var that = this,
  10497. options = this.options;
  10498. function filteredUi( ui ) {
  10499. return {
  10500. position: ui.position,
  10501. offset: ui.offset
  10502. };
  10503. }
  10504. this.uiDialog.draggable( {
  10505. cancel: ".ui-dialog-content, .ui-dialog-titlebar-close",
  10506. handle: ".ui-dialog-titlebar",
  10507. containment: "document",
  10508. start: function( event, ui ) {
  10509. that._addClass( $( this ), "ui-dialog-dragging" );
  10510. that._blockFrames();
  10511. that._trigger( "dragStart", event, filteredUi( ui ) );
  10512. },
  10513. drag: function( event, ui ) {
  10514. that._trigger( "drag", event, filteredUi( ui ) );
  10515. },
  10516. stop: function( event, ui ) {
  10517. var left = ui.offset.left - that.document.scrollLeft(),
  10518. top = ui.offset.top - that.document.scrollTop();
  10519. options.position = {
  10520. my: "left top",
  10521. at: "left" + ( left >= 0 ? "+" : "" ) + left + " " +
  10522. "top" + ( top >= 0 ? "+" : "" ) + top,
  10523. of: that.window
  10524. };
  10525. that._removeClass( $( this ), "ui-dialog-dragging" );
  10526. that._unblockFrames();
  10527. that._trigger( "dragStop", event, filteredUi( ui ) );
  10528. }
  10529. } );
  10530. },
  10531. _makeResizable: function() {
  10532. var that = this,
  10533. options = this.options,
  10534. handles = options.resizable,
  10535. // .ui-resizable has position: relative defined in the stylesheet
  10536. // but dialogs have to use absolute or fixed positioning
  10537. position = this.uiDialog.css( "position" ),
  10538. resizeHandles = typeof handles === "string" ?
  10539. handles :
  10540. "n,e,s,w,se,sw,ne,nw";
  10541. function filteredUi( ui ) {
  10542. return {
  10543. originalPosition: ui.originalPosition,
  10544. originalSize: ui.originalSize,
  10545. position: ui.position,
  10546. size: ui.size
  10547. };
  10548. }
  10549. this.uiDialog.resizable( {
  10550. cancel: ".ui-dialog-content",
  10551. containment: "document",
  10552. alsoResize: this.element,
  10553. maxWidth: options.maxWidth,
  10554. maxHeight: options.maxHeight,
  10555. minWidth: options.minWidth,
  10556. minHeight: this._minHeight(),
  10557. handles: resizeHandles,
  10558. start: function( event, ui ) {
  10559. that._addClass( $( this ), "ui-dialog-resizing" );
  10560. that._blockFrames();
  10561. that._trigger( "resizeStart", event, filteredUi( ui ) );
  10562. },
  10563. resize: function( event, ui ) {
  10564. that._trigger( "resize", event, filteredUi( ui ) );
  10565. },
  10566. stop: function( event, ui ) {
  10567. var offset = that.uiDialog.offset(),
  10568. left = offset.left - that.document.scrollLeft(),
  10569. top = offset.top - that.document.scrollTop();
  10570. options.height = that.uiDialog.height();
  10571. options.width = that.uiDialog.width();
  10572. options.position = {
  10573. my: "left top",
  10574. at: "left" + ( left >= 0 ? "+" : "" ) + left + " " +
  10575. "top" + ( top >= 0 ? "+" : "" ) + top,
  10576. of: that.window
  10577. };
  10578. that._removeClass( $( this ), "ui-dialog-resizing" );
  10579. that._unblockFrames();
  10580. that._trigger( "resizeStop", event, filteredUi( ui ) );
  10581. }
  10582. } )
  10583. .css( "position", position );
  10584. },
  10585. _trackFocus: function() {
  10586. this._on( this.widget(), {
  10587. focusin: function( event ) {
  10588. this._makeFocusTarget();
  10589. this._focusedElement = $( event.target );
  10590. }
  10591. } );
  10592. },
  10593. _makeFocusTarget: function() {
  10594. this._untrackInstance();
  10595. this._trackingInstances().unshift( this );
  10596. },
  10597. _untrackInstance: function() {
  10598. var instances = this._trackingInstances(),
  10599. exists = $.inArray( this, instances );
  10600. if ( exists !== -1 ) {
  10601. instances.splice( exists, 1 );
  10602. }
  10603. },
  10604. _trackingInstances: function() {
  10605. var instances = this.document.data( "ui-dialog-instances" );
  10606. if ( !instances ) {
  10607. instances = [];
  10608. this.document.data( "ui-dialog-instances", instances );
  10609. }
  10610. return instances;
  10611. },
  10612. _minHeight: function() {
  10613. var options = this.options;
  10614. return options.height === "auto" ?
  10615. options.minHeight :
  10616. Math.min( options.minHeight, options.height );
  10617. },
  10618. _position: function() {
  10619. // Need to show the dialog to get the actual offset in the position plugin
  10620. var isVisible = this.uiDialog.is( ":visible" );
  10621. if ( !isVisible ) {
  10622. this.uiDialog.show();
  10623. }
  10624. this.uiDialog.position( this.options.position );
  10625. if ( !isVisible ) {
  10626. this.uiDialog.hide();
  10627. }
  10628. },
  10629. _setOptions: function( options ) {
  10630. var that = this,
  10631. resize = false,
  10632. resizableOptions = {};
  10633. $.each( options, function( key, value ) {
  10634. that._setOption( key, value );
  10635. if ( key in that.sizeRelatedOptions ) {
  10636. resize = true;
  10637. }
  10638. if ( key in that.resizableRelatedOptions ) {
  10639. resizableOptions[ key ] = value;
  10640. }
  10641. } );
  10642. if ( resize ) {
  10643. this._size();
  10644. this._position();
  10645. }
  10646. if ( this.uiDialog.is( ":data(ui-resizable)" ) ) {
  10647. this.uiDialog.resizable( "option", resizableOptions );
  10648. }
  10649. },
  10650. _setOption: function( key, value ) {
  10651. var isDraggable, isResizable,
  10652. uiDialog = this.uiDialog;
  10653. if ( key === "disabled" ) {
  10654. return;
  10655. }
  10656. this._super( key, value );
  10657. if ( key === "appendTo" ) {
  10658. this.uiDialog.appendTo( this._appendTo() );
  10659. }
  10660. if ( key === "buttons" ) {
  10661. this._createButtons();
  10662. }
  10663. if ( key === "closeText" ) {
  10664. this.uiDialogTitlebarClose.button( {
  10665. // Ensure that we always pass a string
  10666. label: $( "<a>" ).text( "" + this.options.closeText ).html()
  10667. } );
  10668. }
  10669. if ( key === "draggable" ) {
  10670. isDraggable = uiDialog.is( ":data(ui-draggable)" );
  10671. if ( isDraggable && !value ) {
  10672. uiDialog.draggable( "destroy" );
  10673. }
  10674. if ( !isDraggable && value ) {
  10675. this._makeDraggable();
  10676. }
  10677. }
  10678. if ( key === "position" ) {
  10679. this._position();
  10680. }
  10681. if ( key === "resizable" ) {
  10682. // currently resizable, becoming non-resizable
  10683. isResizable = uiDialog.is( ":data(ui-resizable)" );
  10684. if ( isResizable && !value ) {
  10685. uiDialog.resizable( "destroy" );
  10686. }
  10687. // Currently resizable, changing handles
  10688. if ( isResizable && typeof value === "string" ) {
  10689. uiDialog.resizable( "option", "handles", value );
  10690. }
  10691. // Currently non-resizable, becoming resizable
  10692. if ( !isResizable && value !== false ) {
  10693. this._makeResizable();
  10694. }
  10695. }
  10696. if ( key === "title" ) {
  10697. this._title( this.uiDialogTitlebar.find( ".ui-dialog-title" ) );
  10698. }
  10699. },
  10700. _size: function() {
  10701. // If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
  10702. // divs will both have width and height set, so we need to reset them
  10703. var nonContentHeight, minContentHeight, maxContentHeight,
  10704. options = this.options;
  10705. // Reset content sizing
  10706. this.element.show().css( {
  10707. width: "auto",
  10708. minHeight: 0,
  10709. maxHeight: "none",
  10710. height: 0
  10711. } );
  10712. if ( options.minWidth > options.width ) {
  10713. options.width = options.minWidth;
  10714. }
  10715. // Reset wrapper sizing
  10716. // determine the height of all the non-content elements
  10717. nonContentHeight = this.uiDialog.css( {
  10718. height: "auto",
  10719. width: options.width
  10720. } )
  10721. .outerHeight();
  10722. minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
  10723. maxContentHeight = typeof options.maxHeight === "number" ?
  10724. Math.max( 0, options.maxHeight - nonContentHeight ) :
  10725. "none";
  10726. if ( options.height === "auto" ) {
  10727. this.element.css( {
  10728. minHeight: minContentHeight,
  10729. maxHeight: maxContentHeight,
  10730. height: "auto"
  10731. } );
  10732. } else {
  10733. this.element.height( Math.max( 0, options.height - nonContentHeight ) );
  10734. }
  10735. if ( this.uiDialog.is( ":data(ui-resizable)" ) ) {
  10736. this.uiDialog.resizable( "option", "minHeight", this._minHeight() );
  10737. }
  10738. },
  10739. _blockFrames: function() {
  10740. this.iframeBlocks = this.document.find( "iframe" ).map( function() {
  10741. var iframe = $( this );
  10742. return $( "<div>" )
  10743. .css( {
  10744. position: "absolute",
  10745. width: iframe.outerWidth(),
  10746. height: iframe.outerHeight()
  10747. } )
  10748. .appendTo( iframe.parent() )
  10749. .offset( iframe.offset() )[ 0 ];
  10750. } );
  10751. },
  10752. _unblockFrames: function() {
  10753. if ( this.iframeBlocks ) {
  10754. this.iframeBlocks.remove();
  10755. delete this.iframeBlocks;
  10756. }
  10757. },
  10758. _allowInteraction: function( event ) {
  10759. if ( $( event.target ).closest( ".ui-dialog" ).length ) {
  10760. return true;
  10761. }
  10762. // TODO: Remove hack when datepicker implements
  10763. // the .ui-front logic (#8989)
  10764. return !!$( event.target ).closest( ".ui-datepicker" ).length;
  10765. },
  10766. _createOverlay: function() {
  10767. if ( !this.options.modal ) {
  10768. return;
  10769. }
  10770. var jqMinor = $.fn.jquery.substring( 0, 4 );
  10771. // We use a delay in case the overlay is created from an
  10772. // event that we're going to be cancelling (#2804)
  10773. var isOpening = true;
  10774. this._delay( function() {
  10775. isOpening = false;
  10776. } );
  10777. if ( !this.document.data( "ui-dialog-overlays" ) ) {
  10778. // Prevent use of anchors and inputs
  10779. // This doesn't use `_on()` because it is a shared event handler
  10780. // across all open modal dialogs.
  10781. this.document.on( "focusin.ui-dialog", function( event ) {
  10782. if ( isOpening ) {
  10783. return;
  10784. }
  10785. var instance = this._trackingInstances()[ 0 ];
  10786. if ( !instance._allowInteraction( event ) ) {
  10787. event.preventDefault();
  10788. instance._focusTabbable();
  10789. // Support: jQuery >=3.4 <3.6 only
  10790. // Focus re-triggering in jQuery 3.4/3.5 makes the original element
  10791. // have its focus event propagated last, breaking the re-targeting.
  10792. // Trigger focus in a delay in addition if needed to avoid the issue
  10793. // See https://github.com/jquery/jquery/issues/4382
  10794. if ( jqMinor === "3.4." || jqMinor === "3.5." ) {
  10795. instance._delay( instance._restoreTabbableFocus );
  10796. }
  10797. }
  10798. }.bind( this ) );
  10799. }
  10800. this.overlay = $( "<div>" )
  10801. .appendTo( this._appendTo() );
  10802. this._addClass( this.overlay, null, "ui-widget-overlay ui-front" );
  10803. this._on( this.overlay, {
  10804. mousedown: "_keepFocus"
  10805. } );
  10806. this.document.data( "ui-dialog-overlays",
  10807. ( this.document.data( "ui-dialog-overlays" ) || 0 ) + 1 );
  10808. },
  10809. _destroyOverlay: function() {
  10810. if ( !this.options.modal ) {
  10811. return;
  10812. }
  10813. if ( this.overlay ) {
  10814. var overlays = this.document.data( "ui-dialog-overlays" ) - 1;
  10815. if ( !overlays ) {
  10816. this.document.off( "focusin.ui-dialog" );
  10817. this.document.removeData( "ui-dialog-overlays" );
  10818. } else {
  10819. this.document.data( "ui-dialog-overlays", overlays );
  10820. }
  10821. this.overlay.remove();
  10822. this.overlay = null;
  10823. }
  10824. }
  10825. } );
  10826. // DEPRECATED
  10827. // TODO: switch return back to widget declaration at top of file when this is removed
  10828. if ( $.uiBackCompat !== false ) {
  10829. // Backcompat for dialogClass option
  10830. $.widget( "ui.dialog", $.ui.dialog, {
  10831. options: {
  10832. dialogClass: ""
  10833. },
  10834. _createWrapper: function() {
  10835. this._super();
  10836. this.uiDialog.addClass( this.options.dialogClass );
  10837. },
  10838. _setOption: function( key, value ) {
  10839. if ( key === "dialogClass" ) {
  10840. this.uiDialog
  10841. .removeClass( this.options.dialogClass )
  10842. .addClass( value );
  10843. }
  10844. this._superApply( arguments );
  10845. }
  10846. } );
  10847. }
  10848. var widgetsDialog = $.ui.dialog;
  10849. /*!
  10850. * jQuery UI Progressbar 1.13.0
  10851. * http://jqueryui.com
  10852. *
  10853. * Copyright jQuery Foundation and other contributors
  10854. * Released under the MIT license.
  10855. * http://jquery.org/license
  10856. */
  10857. //>>label: Progressbar
  10858. //>>group: Widgets
  10859. /* eslint-disable max-len */
  10860. //>>description: Displays a status indicator for loading state, standard percentage, and other progress indicators.
  10861. /* eslint-enable max-len */
  10862. //>>docs: http://api.jqueryui.com/progressbar/
  10863. //>>demos: http://jqueryui.com/progressbar/
  10864. //>>css.structure: ../../themes/base/core.css
  10865. //>>css.structure: ../../themes/base/progressbar.css
  10866. //>>css.theme: ../../themes/base/theme.css
  10867. var widgetsProgressbar = $.widget( "ui.progressbar", {
  10868. version: "1.13.0",
  10869. options: {
  10870. classes: {
  10871. "ui-progressbar": "ui-corner-all",
  10872. "ui-progressbar-value": "ui-corner-left",
  10873. "ui-progressbar-complete": "ui-corner-right"
  10874. },
  10875. max: 100,
  10876. value: 0,
  10877. change: null,
  10878. complete: null
  10879. },
  10880. min: 0,
  10881. _create: function() {
  10882. // Constrain initial value
  10883. this.oldValue = this.options.value = this._constrainedValue();
  10884. this.element.attr( {
  10885. // Only set static values; aria-valuenow and aria-valuemax are
  10886. // set inside _refreshValue()
  10887. role: "progressbar",
  10888. "aria-valuemin": this.min
  10889. } );
  10890. this._addClass( "ui-progressbar", "ui-widget ui-widget-content" );
  10891. this.valueDiv = $( "<div>" ).appendTo( this.element );
  10892. this._addClass( this.valueDiv, "ui-progressbar-value", "ui-widget-header" );
  10893. this._refreshValue();
  10894. },
  10895. _destroy: function() {
  10896. this.element.removeAttr( "role aria-valuemin aria-valuemax aria-valuenow" );
  10897. this.valueDiv.remove();
  10898. },
  10899. value: function( newValue ) {
  10900. if ( newValue === undefined ) {
  10901. return this.options.value;
  10902. }
  10903. this.options.value = this._constrainedValue( newValue );
  10904. this._refreshValue();
  10905. },
  10906. _constrainedValue: function( newValue ) {
  10907. if ( newValue === undefined ) {
  10908. newValue = this.options.value;
  10909. }
  10910. this.indeterminate = newValue === false;
  10911. // Sanitize value
  10912. if ( typeof newValue !== "number" ) {
  10913. newValue = 0;
  10914. }
  10915. return this.indeterminate ? false :
  10916. Math.min( this.options.max, Math.max( this.min, newValue ) );
  10917. },
  10918. _setOptions: function( options ) {
  10919. // Ensure "value" option is set after other values (like max)
  10920. var value = options.value;
  10921. delete options.value;
  10922. this._super( options );
  10923. this.options.value = this._constrainedValue( value );
  10924. this._refreshValue();
  10925. },
  10926. _setOption: function( key, value ) {
  10927. if ( key === "max" ) {
  10928. // Don't allow a max less than min
  10929. value = Math.max( this.min, value );
  10930. }
  10931. this._super( key, value );
  10932. },
  10933. _setOptionDisabled: function( value ) {
  10934. this._super( value );
  10935. this.element.attr( "aria-disabled", value );
  10936. this._toggleClass( null, "ui-state-disabled", !!value );
  10937. },
  10938. _percentage: function() {
  10939. return this.indeterminate ?
  10940. 100 :
  10941. 100 * ( this.options.value - this.min ) / ( this.options.max - this.min );
  10942. },
  10943. _refreshValue: function() {
  10944. var value = this.options.value,
  10945. percentage = this._percentage();
  10946. this.valueDiv
  10947. .toggle( this.indeterminate || value > this.min )
  10948. .width( percentage.toFixed( 0 ) + "%" );
  10949. this
  10950. ._toggleClass( this.valueDiv, "ui-progressbar-complete", null,
  10951. value === this.options.max )
  10952. ._toggleClass( "ui-progressbar-indeterminate", null, this.indeterminate );
  10953. if ( this.indeterminate ) {
  10954. this.element.removeAttr( "aria-valuenow" );
  10955. if ( !this.overlayDiv ) {
  10956. this.overlayDiv = $( "<div>" ).appendTo( this.valueDiv );
  10957. this._addClass( this.overlayDiv, "ui-progressbar-overlay" );
  10958. }
  10959. } else {
  10960. this.element.attr( {
  10961. "aria-valuemax": this.options.max,
  10962. "aria-valuenow": value
  10963. } );
  10964. if ( this.overlayDiv ) {
  10965. this.overlayDiv.remove();
  10966. this.overlayDiv = null;
  10967. }
  10968. }
  10969. if ( this.oldValue !== value ) {
  10970. this.oldValue = value;
  10971. this._trigger( "change" );
  10972. }
  10973. if ( value === this.options.max ) {
  10974. this._trigger( "complete" );
  10975. }
  10976. }
  10977. } );
  10978. /*!
  10979. * jQuery UI Selectmenu 1.13.0
  10980. * http://jqueryui.com
  10981. *
  10982. * Copyright jQuery Foundation and other contributors
  10983. * Released under the MIT license.
  10984. * http://jquery.org/license
  10985. */
  10986. //>>label: Selectmenu
  10987. //>>group: Widgets
  10988. /* eslint-disable max-len */
  10989. //>>description: Duplicates and extends the functionality of a native HTML select element, allowing it to be customizable in behavior and appearance far beyond the limitations of a native select.
  10990. /* eslint-enable max-len */
  10991. //>>docs: http://api.jqueryui.com/selectmenu/
  10992. //>>demos: http://jqueryui.com/selectmenu/
  10993. //>>css.structure: ../../themes/base/core.css
  10994. //>>css.structure: ../../themes/base/selectmenu.css, ../../themes/base/button.css
  10995. //>>css.theme: ../../themes/base/theme.css
  10996. var widgetsSelectmenu = $.widget( "ui.selectmenu", [ $.ui.formResetMixin, {
  10997. version: "1.13.0",
  10998. defaultElement: "<select>",
  10999. options: {
  11000. appendTo: null,
  11001. classes: {
  11002. "ui-selectmenu-button-open": "ui-corner-top",
  11003. "ui-selectmenu-button-closed": "ui-corner-all"
  11004. },
  11005. disabled: null,
  11006. icons: {
  11007. button: "ui-icon-triangle-1-s"
  11008. },
  11009. position: {
  11010. my: "left top",
  11011. at: "left bottom",
  11012. collision: "none"
  11013. },
  11014. width: false,
  11015. // Callbacks
  11016. change: null,
  11017. close: null,
  11018. focus: null,
  11019. open: null,
  11020. select: null
  11021. },
  11022. _create: function() {
  11023. var selectmenuId = this.element.uniqueId().attr( "id" );
  11024. this.ids = {
  11025. element: selectmenuId,
  11026. button: selectmenuId + "-button",
  11027. menu: selectmenuId + "-menu"
  11028. };
  11029. this._drawButton();
  11030. this._drawMenu();
  11031. this._bindFormResetHandler();
  11032. this._rendered = false;
  11033. this.menuItems = $();
  11034. },
  11035. _drawButton: function() {
  11036. var icon,
  11037. that = this,
  11038. item = this._parseOption(
  11039. this.element.find( "option:selected" ),
  11040. this.element[ 0 ].selectedIndex
  11041. );
  11042. // Associate existing label with the new button
  11043. this.labels = this.element.labels().attr( "for", this.ids.button );
  11044. this._on( this.labels, {
  11045. click: function( event ) {
  11046. this.button.trigger( "focus" );
  11047. event.preventDefault();
  11048. }
  11049. } );
  11050. // Hide original select element
  11051. this.element.hide();
  11052. // Create button
  11053. this.button = $( "<span>", {
  11054. tabindex: this.options.disabled ? -1 : 0,
  11055. id: this.ids.button,
  11056. role: "combobox",
  11057. "aria-expanded": "false",
  11058. "aria-autocomplete": "list",
  11059. "aria-owns": this.ids.menu,
  11060. "aria-haspopup": "true",
  11061. title: this.element.attr( "title" )
  11062. } )
  11063. .insertAfter( this.element );
  11064. this._addClass( this.button, "ui-selectmenu-button ui-selectmenu-button-closed",
  11065. "ui-button ui-widget" );
  11066. icon = $( "<span>" ).appendTo( this.button );
  11067. this._addClass( icon, "ui-selectmenu-icon", "ui-icon " + this.options.icons.button );
  11068. this.buttonItem = this._renderButtonItem( item )
  11069. .appendTo( this.button );
  11070. if ( this.options.width !== false ) {
  11071. this._resizeButton();
  11072. }
  11073. this._on( this.button, this._buttonEvents );
  11074. this.button.one( "focusin", function() {
  11075. // Delay rendering the menu items until the button receives focus.
  11076. // The menu may have already been rendered via a programmatic open.
  11077. if ( !that._rendered ) {
  11078. that._refreshMenu();
  11079. }
  11080. } );
  11081. },
  11082. _drawMenu: function() {
  11083. var that = this;
  11084. // Create menu
  11085. this.menu = $( "<ul>", {
  11086. "aria-hidden": "true",
  11087. "aria-labelledby": this.ids.button,
  11088. id: this.ids.menu
  11089. } );
  11090. // Wrap menu
  11091. this.menuWrap = $( "<div>" ).append( this.menu );
  11092. this._addClass( this.menuWrap, "ui-selectmenu-menu", "ui-front" );
  11093. this.menuWrap.appendTo( this._appendTo() );
  11094. // Initialize menu widget
  11095. this.menuInstance = this.menu
  11096. .menu( {
  11097. classes: {
  11098. "ui-menu": "ui-corner-bottom"
  11099. },
  11100. role: "listbox",
  11101. select: function( event, ui ) {
  11102. event.preventDefault();
  11103. // Support: IE8
  11104. // If the item was selected via a click, the text selection
  11105. // will be destroyed in IE
  11106. that._setSelection();
  11107. that._select( ui.item.data( "ui-selectmenu-item" ), event );
  11108. },
  11109. focus: function( event, ui ) {
  11110. var item = ui.item.data( "ui-selectmenu-item" );
  11111. // Prevent inital focus from firing and check if its a newly focused item
  11112. if ( that.focusIndex != null && item.index !== that.focusIndex ) {
  11113. that._trigger( "focus", event, { item: item } );
  11114. if ( !that.isOpen ) {
  11115. that._select( item, event );
  11116. }
  11117. }
  11118. that.focusIndex = item.index;
  11119. that.button.attr( "aria-activedescendant",
  11120. that.menuItems.eq( item.index ).attr( "id" ) );
  11121. }
  11122. } )
  11123. .menu( "instance" );
  11124. // Don't close the menu on mouseleave
  11125. this.menuInstance._off( this.menu, "mouseleave" );
  11126. // Cancel the menu's collapseAll on document click
  11127. this.menuInstance._closeOnDocumentClick = function() {
  11128. return false;
  11129. };
  11130. // Selects often contain empty items, but never contain dividers
  11131. this.menuInstance._isDivider = function() {
  11132. return false;
  11133. };
  11134. },
  11135. refresh: function() {
  11136. this._refreshMenu();
  11137. this.buttonItem.replaceWith(
  11138. this.buttonItem = this._renderButtonItem(
  11139. // Fall back to an empty object in case there are no options
  11140. this._getSelectedItem().data( "ui-selectmenu-item" ) || {}
  11141. )
  11142. );
  11143. if ( this.options.width === null ) {
  11144. this._resizeButton();
  11145. }
  11146. },
  11147. _refreshMenu: function() {
  11148. var item,
  11149. options = this.element.find( "option" );
  11150. this.menu.empty();
  11151. this._parseOptions( options );
  11152. this._renderMenu( this.menu, this.items );
  11153. this.menuInstance.refresh();
  11154. this.menuItems = this.menu.find( "li" )
  11155. .not( ".ui-selectmenu-optgroup" )
  11156. .find( ".ui-menu-item-wrapper" );
  11157. this._rendered = true;
  11158. if ( !options.length ) {
  11159. return;
  11160. }
  11161. item = this._getSelectedItem();
  11162. // Update the menu to have the correct item focused
  11163. this.menuInstance.focus( null, item );
  11164. this._setAria( item.data( "ui-selectmenu-item" ) );
  11165. // Set disabled state
  11166. this._setOption( "disabled", this.element.prop( "disabled" ) );
  11167. },
  11168. open: function( event ) {
  11169. if ( this.options.disabled ) {
  11170. return;
  11171. }
  11172. // If this is the first time the menu is being opened, render the items
  11173. if ( !this._rendered ) {
  11174. this._refreshMenu();
  11175. } else {
  11176. // Menu clears focus on close, reset focus to selected item
  11177. this._removeClass( this.menu.find( ".ui-state-active" ), null, "ui-state-active" );
  11178. this.menuInstance.focus( null, this._getSelectedItem() );
  11179. }
  11180. // If there are no options, don't open the menu
  11181. if ( !this.menuItems.length ) {
  11182. return;
  11183. }
  11184. this.isOpen = true;
  11185. this._toggleAttr();
  11186. this._resizeMenu();
  11187. this._position();
  11188. this._on( this.document, this._documentClick );
  11189. this._trigger( "open", event );
  11190. },
  11191. _position: function() {
  11192. this.menuWrap.position( $.extend( { of: this.button }, this.options.position ) );
  11193. },
  11194. close: function( event ) {
  11195. if ( !this.isOpen ) {
  11196. return;
  11197. }
  11198. this.isOpen = false;
  11199. this._toggleAttr();
  11200. this.range = null;
  11201. this._off( this.document );
  11202. this._trigger( "close", event );
  11203. },
  11204. widget: function() {
  11205. return this.button;
  11206. },
  11207. menuWidget: function() {
  11208. return this.menu;
  11209. },
  11210. _renderButtonItem: function( item ) {
  11211. var buttonItem = $( "<span>" );
  11212. this._setText( buttonItem, item.label );
  11213. this._addClass( buttonItem, "ui-selectmenu-text" );
  11214. return buttonItem;
  11215. },
  11216. _renderMenu: function( ul, items ) {
  11217. var that = this,
  11218. currentOptgroup = "";
  11219. $.each( items, function( index, item ) {
  11220. var li;
  11221. if ( item.optgroup !== currentOptgroup ) {
  11222. li = $( "<li>", {
  11223. text: item.optgroup
  11224. } );
  11225. that._addClass( li, "ui-selectmenu-optgroup", "ui-menu-divider" +
  11226. ( item.element.parent( "optgroup" ).prop( "disabled" ) ?
  11227. " ui-state-disabled" :
  11228. "" ) );
  11229. li.appendTo( ul );
  11230. currentOptgroup = item.optgroup;
  11231. }
  11232. that._renderItemData( ul, item );
  11233. } );
  11234. },
  11235. _renderItemData: function( ul, item ) {
  11236. return this._renderItem( ul, item ).data( "ui-selectmenu-item", item );
  11237. },
  11238. _renderItem: function( ul, item ) {
  11239. var li = $( "<li>" ),
  11240. wrapper = $( "<div>", {
  11241. title: item.element.attr( "title" )
  11242. } );
  11243. if ( item.disabled ) {
  11244. this._addClass( li, null, "ui-state-disabled" );
  11245. }
  11246. this._setText( wrapper, item.label );
  11247. return li.append( wrapper ).appendTo( ul );
  11248. },
  11249. _setText: function( element, value ) {
  11250. if ( value ) {
  11251. element.text( value );
  11252. } else {
  11253. element.html( "&#160;" );
  11254. }
  11255. },
  11256. _move: function( direction, event ) {
  11257. var item, next,
  11258. filter = ".ui-menu-item";
  11259. if ( this.isOpen ) {
  11260. item = this.menuItems.eq( this.focusIndex ).parent( "li" );
  11261. } else {
  11262. item = this.menuItems.eq( this.element[ 0 ].selectedIndex ).parent( "li" );
  11263. filter += ":not(.ui-state-disabled)";
  11264. }
  11265. if ( direction === "first" || direction === "last" ) {
  11266. next = item[ direction === "first" ? "prevAll" : "nextAll" ]( filter ).eq( -1 );
  11267. } else {
  11268. next = item[ direction + "All" ]( filter ).eq( 0 );
  11269. }
  11270. if ( next.length ) {
  11271. this.menuInstance.focus( event, next );
  11272. }
  11273. },
  11274. _getSelectedItem: function() {
  11275. return this.menuItems.eq( this.element[ 0 ].selectedIndex ).parent( "li" );
  11276. },
  11277. _toggle: function( event ) {
  11278. this[ this.isOpen ? "close" : "open" ]( event );
  11279. },
  11280. _setSelection: function() {
  11281. var selection;
  11282. if ( !this.range ) {
  11283. return;
  11284. }
  11285. if ( window.getSelection ) {
  11286. selection = window.getSelection();
  11287. selection.removeAllRanges();
  11288. selection.addRange( this.range );
  11289. // Support: IE8
  11290. } else {
  11291. this.range.select();
  11292. }
  11293. // Support: IE
  11294. // Setting the text selection kills the button focus in IE, but
  11295. // restoring the focus doesn't kill the selection.
  11296. this.button.focus();
  11297. },
  11298. _documentClick: {
  11299. mousedown: function( event ) {
  11300. if ( !this.isOpen ) {
  11301. return;
  11302. }
  11303. if ( !$( event.target ).closest( ".ui-selectmenu-menu, #" +
  11304. $.escapeSelector( this.ids.button ) ).length ) {
  11305. this.close( event );
  11306. }
  11307. }
  11308. },
  11309. _buttonEvents: {
  11310. // Prevent text selection from being reset when interacting with the selectmenu (#10144)
  11311. mousedown: function() {
  11312. var selection;
  11313. if ( window.getSelection ) {
  11314. selection = window.getSelection();
  11315. if ( selection.rangeCount ) {
  11316. this.range = selection.getRangeAt( 0 );
  11317. }
  11318. // Support: IE8
  11319. } else {
  11320. this.range = document.selection.createRange();
  11321. }
  11322. },
  11323. click: function( event ) {
  11324. this._setSelection();
  11325. this._toggle( event );
  11326. },
  11327. keydown: function( event ) {
  11328. var preventDefault = true;
  11329. switch ( event.keyCode ) {
  11330. case $.ui.keyCode.TAB:
  11331. case $.ui.keyCode.ESCAPE:
  11332. this.close( event );
  11333. preventDefault = false;
  11334. break;
  11335. case $.ui.keyCode.ENTER:
  11336. if ( this.isOpen ) {
  11337. this._selectFocusedItem( event );
  11338. }
  11339. break;
  11340. case $.ui.keyCode.UP:
  11341. if ( event.altKey ) {
  11342. this._toggle( event );
  11343. } else {
  11344. this._move( "prev", event );
  11345. }
  11346. break;
  11347. case $.ui.keyCode.DOWN:
  11348. if ( event.altKey ) {
  11349. this._toggle( event );
  11350. } else {
  11351. this._move( "next", event );
  11352. }
  11353. break;
  11354. case $.ui.keyCode.SPACE:
  11355. if ( this.isOpen ) {
  11356. this._selectFocusedItem( event );
  11357. } else {
  11358. this._toggle( event );
  11359. }
  11360. break;
  11361. case $.ui.keyCode.LEFT:
  11362. this._move( "prev", event );
  11363. break;
  11364. case $.ui.keyCode.RIGHT:
  11365. this._move( "next", event );
  11366. break;
  11367. case $.ui.keyCode.HOME:
  11368. case $.ui.keyCode.PAGE_UP:
  11369. this._move( "first", event );
  11370. break;
  11371. case $.ui.keyCode.END:
  11372. case $.ui.keyCode.PAGE_DOWN:
  11373. this._move( "last", event );
  11374. break;
  11375. default:
  11376. this.menu.trigger( event );
  11377. preventDefault = false;
  11378. }
  11379. if ( preventDefault ) {
  11380. event.preventDefault();
  11381. }
  11382. }
  11383. },
  11384. _selectFocusedItem: function( event ) {
  11385. var item = this.menuItems.eq( this.focusIndex ).parent( "li" );
  11386. if ( !item.hasClass( "ui-state-disabled" ) ) {
  11387. this._select( item.data( "ui-selectmenu-item" ), event );
  11388. }
  11389. },
  11390. _select: function( item, event ) {
  11391. var oldIndex = this.element[ 0 ].selectedIndex;
  11392. // Change native select element
  11393. this.element[ 0 ].selectedIndex = item.index;
  11394. this.buttonItem.replaceWith( this.buttonItem = this._renderButtonItem( item ) );
  11395. this._setAria( item );
  11396. this._trigger( "select", event, { item: item } );
  11397. if ( item.index !== oldIndex ) {
  11398. this._trigger( "change", event, { item: item } );
  11399. }
  11400. this.close( event );
  11401. },
  11402. _setAria: function( item ) {
  11403. var id = this.menuItems.eq( item.index ).attr( "id" );
  11404. this.button.attr( {
  11405. "aria-labelledby": id,
  11406. "aria-activedescendant": id
  11407. } );
  11408. this.menu.attr( "aria-activedescendant", id );
  11409. },
  11410. _setOption: function( key, value ) {
  11411. if ( key === "icons" ) {
  11412. var icon = this.button.find( "span.ui-icon" );
  11413. this._removeClass( icon, null, this.options.icons.button )
  11414. ._addClass( icon, null, value.button );
  11415. }
  11416. this._super( key, value );
  11417. if ( key === "appendTo" ) {
  11418. this.menuWrap.appendTo( this._appendTo() );
  11419. }
  11420. if ( key === "width" ) {
  11421. this._resizeButton();
  11422. }
  11423. },
  11424. _setOptionDisabled: function( value ) {
  11425. this._super( value );
  11426. this.menuInstance.option( "disabled", value );
  11427. this.button.attr( "aria-disabled", value );
  11428. this._toggleClass( this.button, null, "ui-state-disabled", value );
  11429. this.element.prop( "disabled", value );
  11430. if ( value ) {
  11431. this.button.attr( "tabindex", -1 );
  11432. this.close();
  11433. } else {
  11434. this.button.attr( "tabindex", 0 );
  11435. }
  11436. },
  11437. _appendTo: function() {
  11438. var element = this.options.appendTo;
  11439. if ( element ) {
  11440. element = element.jquery || element.nodeType ?
  11441. $( element ) :
  11442. this.document.find( element ).eq( 0 );
  11443. }
  11444. if ( !element || !element[ 0 ] ) {
  11445. element = this.element.closest( ".ui-front, dialog" );
  11446. }
  11447. if ( !element.length ) {
  11448. element = this.document[ 0 ].body;
  11449. }
  11450. return element;
  11451. },
  11452. _toggleAttr: function() {
  11453. this.button.attr( "aria-expanded", this.isOpen );
  11454. // We can't use two _toggleClass() calls here, because we need to make sure
  11455. // we always remove classes first and add them second, otherwise if both classes have the
  11456. // same theme class, it will be removed after we add it.
  11457. this._removeClass( this.button, "ui-selectmenu-button-" +
  11458. ( this.isOpen ? "closed" : "open" ) )
  11459. ._addClass( this.button, "ui-selectmenu-button-" +
  11460. ( this.isOpen ? "open" : "closed" ) )
  11461. ._toggleClass( this.menuWrap, "ui-selectmenu-open", null, this.isOpen );
  11462. this.menu.attr( "aria-hidden", !this.isOpen );
  11463. },
  11464. _resizeButton: function() {
  11465. var width = this.options.width;
  11466. // For `width: false`, just remove inline style and stop
  11467. if ( width === false ) {
  11468. this.button.css( "width", "" );
  11469. return;
  11470. }
  11471. // For `width: null`, match the width of the original element
  11472. if ( width === null ) {
  11473. width = this.element.show().outerWidth();
  11474. this.element.hide();
  11475. }
  11476. this.button.outerWidth( width );
  11477. },
  11478. _resizeMenu: function() {
  11479. this.menu.outerWidth( Math.max(
  11480. this.button.outerWidth(),
  11481. // Support: IE10
  11482. // IE10 wraps long text (possibly a rounding bug)
  11483. // so we add 1px to avoid the wrapping
  11484. this.menu.width( "" ).outerWidth() + 1
  11485. ) );
  11486. },
  11487. _getCreateOptions: function() {
  11488. var options = this._super();
  11489. options.disabled = this.element.prop( "disabled" );
  11490. return options;
  11491. },
  11492. _parseOptions: function( options ) {
  11493. var that = this,
  11494. data = [];
  11495. options.each( function( index, item ) {
  11496. if ( item.hidden ) {
  11497. return;
  11498. }
  11499. data.push( that._parseOption( $( item ), index ) );
  11500. } );
  11501. this.items = data;
  11502. },
  11503. _parseOption: function( option, index ) {
  11504. var optgroup = option.parent( "optgroup" );
  11505. return {
  11506. element: option,
  11507. index: index,
  11508. value: option.val(),
  11509. label: option.text(),
  11510. optgroup: optgroup.attr( "label" ) || "",
  11511. disabled: optgroup.prop( "disabled" ) || option.prop( "disabled" )
  11512. };
  11513. },
  11514. _destroy: function() {
  11515. this._unbindFormResetHandler();
  11516. this.menuWrap.remove();
  11517. this.button.remove();
  11518. this.element.show();
  11519. this.element.removeUniqueId();
  11520. this.labels.attr( "for", this.ids.element );
  11521. }
  11522. } ] );
  11523. /*!
  11524. * jQuery UI Slider 1.13.0
  11525. * http://jqueryui.com
  11526. *
  11527. * Copyright jQuery Foundation and other contributors
  11528. * Released under the MIT license.
  11529. * http://jquery.org/license
  11530. */
  11531. //>>label: Slider
  11532. //>>group: Widgets
  11533. //>>description: Displays a flexible slider with ranges and accessibility via keyboard.
  11534. //>>docs: http://api.jqueryui.com/slider/
  11535. //>>demos: http://jqueryui.com/slider/
  11536. //>>css.structure: ../../themes/base/core.css
  11537. //>>css.structure: ../../themes/base/slider.css
  11538. //>>css.theme: ../../themes/base/theme.css
  11539. var widgetsSlider = $.widget( "ui.slider", $.ui.mouse, {
  11540. version: "1.13.0",
  11541. widgetEventPrefix: "slide",
  11542. options: {
  11543. animate: false,
  11544. classes: {
  11545. "ui-slider": "ui-corner-all",
  11546. "ui-slider-handle": "ui-corner-all",
  11547. // Note: ui-widget-header isn't the most fittingly semantic framework class for this
  11548. // element, but worked best visually with a variety of themes
  11549. "ui-slider-range": "ui-corner-all ui-widget-header"
  11550. },
  11551. distance: 0,
  11552. max: 100,
  11553. min: 0,
  11554. orientation: "horizontal",
  11555. range: false,
  11556. step: 1,
  11557. value: 0,
  11558. values: null,
  11559. // Callbacks
  11560. change: null,
  11561. slide: null,
  11562. start: null,
  11563. stop: null
  11564. },
  11565. // Number of pages in a slider
  11566. // (how many times can you page up/down to go through the whole range)
  11567. numPages: 5,
  11568. _create: function() {
  11569. this._keySliding = false;
  11570. this._mouseSliding = false;
  11571. this._animateOff = true;
  11572. this._handleIndex = null;
  11573. this._detectOrientation();
  11574. this._mouseInit();
  11575. this._calculateNewMax();
  11576. this._addClass( "ui-slider ui-slider-" + this.orientation,
  11577. "ui-widget ui-widget-content" );
  11578. this._refresh();
  11579. this._animateOff = false;
  11580. },
  11581. _refresh: function() {
  11582. this._createRange();
  11583. this._createHandles();
  11584. this._setupEvents();
  11585. this._refreshValue();
  11586. },
  11587. _createHandles: function() {
  11588. var i, handleCount,
  11589. options = this.options,
  11590. existingHandles = this.element.find( ".ui-slider-handle" ),
  11591. handle = "<span tabindex='0'></span>",
  11592. handles = [];
  11593. handleCount = ( options.values && options.values.length ) || 1;
  11594. if ( existingHandles.length > handleCount ) {
  11595. existingHandles.slice( handleCount ).remove();
  11596. existingHandles = existingHandles.slice( 0, handleCount );
  11597. }
  11598. for ( i = existingHandles.length; i < handleCount; i++ ) {
  11599. handles.push( handle );
  11600. }
  11601. this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );
  11602. this._addClass( this.handles, "ui-slider-handle", "ui-state-default" );
  11603. this.handle = this.handles.eq( 0 );
  11604. this.handles.each( function( i ) {
  11605. $( this )
  11606. .data( "ui-slider-handle-index", i )
  11607. .attr( "tabIndex", 0 );
  11608. } );
  11609. },
  11610. _createRange: function() {
  11611. var options = this.options;
  11612. if ( options.range ) {
  11613. if ( options.range === true ) {
  11614. if ( !options.values ) {
  11615. options.values = [ this._valueMin(), this._valueMin() ];
  11616. } else if ( options.values.length && options.values.length !== 2 ) {
  11617. options.values = [ options.values[ 0 ], options.values[ 0 ] ];
  11618. } else if ( Array.isArray( options.values ) ) {
  11619. options.values = options.values.slice( 0 );
  11620. }
  11621. }
  11622. if ( !this.range || !this.range.length ) {
  11623. this.range = $( "<div>" )
  11624. .appendTo( this.element );
  11625. this._addClass( this.range, "ui-slider-range" );
  11626. } else {
  11627. this._removeClass( this.range, "ui-slider-range-min ui-slider-range-max" );
  11628. // Handle range switching from true to min/max
  11629. this.range.css( {
  11630. "left": "",
  11631. "bottom": ""
  11632. } );
  11633. }
  11634. if ( options.range === "min" || options.range === "max" ) {
  11635. this._addClass( this.range, "ui-slider-range-" + options.range );
  11636. }
  11637. } else {
  11638. if ( this.range ) {
  11639. this.range.remove();
  11640. }
  11641. this.range = null;
  11642. }
  11643. },
  11644. _setupEvents: function() {
  11645. this._off( this.handles );
  11646. this._on( this.handles, this._handleEvents );
  11647. this._hoverable( this.handles );
  11648. this._focusable( this.handles );
  11649. },
  11650. _destroy: function() {
  11651. this.handles.remove();
  11652. if ( this.range ) {
  11653. this.range.remove();
  11654. }
  11655. this._mouseDestroy();
  11656. },
  11657. _mouseCapture: function( event ) {
  11658. var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
  11659. that = this,
  11660. o = this.options;
  11661. if ( o.disabled ) {
  11662. return false;
  11663. }
  11664. this.elementSize = {
  11665. width: this.element.outerWidth(),
  11666. height: this.element.outerHeight()
  11667. };
  11668. this.elementOffset = this.element.offset();
  11669. position = { x: event.pageX, y: event.pageY };
  11670. normValue = this._normValueFromMouse( position );
  11671. distance = this._valueMax() - this._valueMin() + 1;
  11672. this.handles.each( function( i ) {
  11673. var thisDistance = Math.abs( normValue - that.values( i ) );
  11674. if ( ( distance > thisDistance ) ||
  11675. ( distance === thisDistance &&
  11676. ( i === that._lastChangedValue || that.values( i ) === o.min ) ) ) {
  11677. distance = thisDistance;
  11678. closestHandle = $( this );
  11679. index = i;
  11680. }
  11681. } );
  11682. allowed = this._start( event, index );
  11683. if ( allowed === false ) {
  11684. return false;
  11685. }
  11686. this._mouseSliding = true;
  11687. this._handleIndex = index;
  11688. this._addClass( closestHandle, null, "ui-state-active" );
  11689. closestHandle.trigger( "focus" );
  11690. offset = closestHandle.offset();
  11691. mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" );
  11692. this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
  11693. left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
  11694. top: event.pageY - offset.top -
  11695. ( closestHandle.height() / 2 ) -
  11696. ( parseInt( closestHandle.css( "borderTopWidth" ), 10 ) || 0 ) -
  11697. ( parseInt( closestHandle.css( "borderBottomWidth" ), 10 ) || 0 ) +
  11698. ( parseInt( closestHandle.css( "marginTop" ), 10 ) || 0 )
  11699. };
  11700. if ( !this.handles.hasClass( "ui-state-hover" ) ) {
  11701. this._slide( event, index, normValue );
  11702. }
  11703. this._animateOff = true;
  11704. return true;
  11705. },
  11706. _mouseStart: function() {
  11707. return true;
  11708. },
  11709. _mouseDrag: function( event ) {
  11710. var position = { x: event.pageX, y: event.pageY },
  11711. normValue = this._normValueFromMouse( position );
  11712. this._slide( event, this._handleIndex, normValue );
  11713. return false;
  11714. },
  11715. _mouseStop: function( event ) {
  11716. this._removeClass( this.handles, null, "ui-state-active" );
  11717. this._mouseSliding = false;
  11718. this._stop( event, this._handleIndex );
  11719. this._change( event, this._handleIndex );
  11720. this._handleIndex = null;
  11721. this._clickOffset = null;
  11722. this._animateOff = false;
  11723. return false;
  11724. },
  11725. _detectOrientation: function() {
  11726. this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
  11727. },
  11728. _normValueFromMouse: function( position ) {
  11729. var pixelTotal,
  11730. pixelMouse,
  11731. percentMouse,
  11732. valueTotal,
  11733. valueMouse;
  11734. if ( this.orientation === "horizontal" ) {
  11735. pixelTotal = this.elementSize.width;
  11736. pixelMouse = position.x - this.elementOffset.left -
  11737. ( this._clickOffset ? this._clickOffset.left : 0 );
  11738. } else {
  11739. pixelTotal = this.elementSize.height;
  11740. pixelMouse = position.y - this.elementOffset.top -
  11741. ( this._clickOffset ? this._clickOffset.top : 0 );
  11742. }
  11743. percentMouse = ( pixelMouse / pixelTotal );
  11744. if ( percentMouse > 1 ) {
  11745. percentMouse = 1;
  11746. }
  11747. if ( percentMouse < 0 ) {
  11748. percentMouse = 0;
  11749. }
  11750. if ( this.orientation === "vertical" ) {
  11751. percentMouse = 1 - percentMouse;
  11752. }
  11753. valueTotal = this._valueMax() - this._valueMin();
  11754. valueMouse = this._valueMin() + percentMouse * valueTotal;
  11755. return this._trimAlignValue( valueMouse );
  11756. },
  11757. _uiHash: function( index, value, values ) {
  11758. var uiHash = {
  11759. handle: this.handles[ index ],
  11760. handleIndex: index,
  11761. value: value !== undefined ? value : this.value()
  11762. };
  11763. if ( this._hasMultipleValues() ) {
  11764. uiHash.value = value !== undefined ? value : this.values( index );
  11765. uiHash.values = values || this.values();
  11766. }
  11767. return uiHash;
  11768. },
  11769. _hasMultipleValues: function() {
  11770. return this.options.values && this.options.values.length;
  11771. },
  11772. _start: function( event, index ) {
  11773. return this._trigger( "start", event, this._uiHash( index ) );
  11774. },
  11775. _slide: function( event, index, newVal ) {
  11776. var allowed, otherVal,
  11777. currentValue = this.value(),
  11778. newValues = this.values();
  11779. if ( this._hasMultipleValues() ) {
  11780. otherVal = this.values( index ? 0 : 1 );
  11781. currentValue = this.values( index );
  11782. if ( this.options.values.length === 2 && this.options.range === true ) {
  11783. newVal = index === 0 ? Math.min( otherVal, newVal ) : Math.max( otherVal, newVal );
  11784. }
  11785. newValues[ index ] = newVal;
  11786. }
  11787. if ( newVal === currentValue ) {
  11788. return;
  11789. }
  11790. allowed = this._trigger( "slide", event, this._uiHash( index, newVal, newValues ) );
  11791. // A slide can be canceled by returning false from the slide callback
  11792. if ( allowed === false ) {
  11793. return;
  11794. }
  11795. if ( this._hasMultipleValues() ) {
  11796. this.values( index, newVal );
  11797. } else {
  11798. this.value( newVal );
  11799. }
  11800. },
  11801. _stop: function( event, index ) {
  11802. this._trigger( "stop", event, this._uiHash( index ) );
  11803. },
  11804. _change: function( event, index ) {
  11805. if ( !this._keySliding && !this._mouseSliding ) {
  11806. //store the last changed value index for reference when handles overlap
  11807. this._lastChangedValue = index;
  11808. this._trigger( "change", event, this._uiHash( index ) );
  11809. }
  11810. },
  11811. value: function( newValue ) {
  11812. if ( arguments.length ) {
  11813. this.options.value = this._trimAlignValue( newValue );
  11814. this._refreshValue();
  11815. this._change( null, 0 );
  11816. return;
  11817. }
  11818. return this._value();
  11819. },
  11820. values: function( index, newValue ) {
  11821. var vals,
  11822. newValues,
  11823. i;
  11824. if ( arguments.length > 1 ) {
  11825. this.options.values[ index ] = this._trimAlignValue( newValue );
  11826. this._refreshValue();
  11827. this._change( null, index );
  11828. return;
  11829. }
  11830. if ( arguments.length ) {
  11831. if ( Array.isArray( arguments[ 0 ] ) ) {
  11832. vals = this.options.values;
  11833. newValues = arguments[ 0 ];
  11834. for ( i = 0; i < vals.length; i += 1 ) {
  11835. vals[ i ] = this._trimAlignValue( newValues[ i ] );
  11836. this._change( null, i );
  11837. }
  11838. this._refreshValue();
  11839. } else {
  11840. if ( this._hasMultipleValues() ) {
  11841. return this._values( index );
  11842. } else {
  11843. return this.value();
  11844. }
  11845. }
  11846. } else {
  11847. return this._values();
  11848. }
  11849. },
  11850. _setOption: function( key, value ) {
  11851. var i,
  11852. valsLength = 0;
  11853. if ( key === "range" && this.options.range === true ) {
  11854. if ( value === "min" ) {
  11855. this.options.value = this._values( 0 );
  11856. this.options.values = null;
  11857. } else if ( value === "max" ) {
  11858. this.options.value = this._values( this.options.values.length - 1 );
  11859. this.options.values = null;
  11860. }
  11861. }
  11862. if ( Array.isArray( this.options.values ) ) {
  11863. valsLength = this.options.values.length;
  11864. }
  11865. this._super( key, value );
  11866. switch ( key ) {
  11867. case "orientation":
  11868. this._detectOrientation();
  11869. this._removeClass( "ui-slider-horizontal ui-slider-vertical" )
  11870. ._addClass( "ui-slider-" + this.orientation );
  11871. this._refreshValue();
  11872. if ( this.options.range ) {
  11873. this._refreshRange( value );
  11874. }
  11875. // Reset positioning from previous orientation
  11876. this.handles.css( value === "horizontal" ? "bottom" : "left", "" );
  11877. break;
  11878. case "value":
  11879. this._animateOff = true;
  11880. this._refreshValue();
  11881. this._change( null, 0 );
  11882. this._animateOff = false;
  11883. break;
  11884. case "values":
  11885. this._animateOff = true;
  11886. this._refreshValue();
  11887. // Start from the last handle to prevent unreachable handles (#9046)
  11888. for ( i = valsLength - 1; i >= 0; i-- ) {
  11889. this._change( null, i );
  11890. }
  11891. this._animateOff = false;
  11892. break;
  11893. case "step":
  11894. case "min":
  11895. case "max":
  11896. this._animateOff = true;
  11897. this._calculateNewMax();
  11898. this._refreshValue();
  11899. this._animateOff = false;
  11900. break;
  11901. case "range":
  11902. this._animateOff = true;
  11903. this._refresh();
  11904. this._animateOff = false;
  11905. break;
  11906. }
  11907. },
  11908. _setOptionDisabled: function( value ) {
  11909. this._super( value );
  11910. this._toggleClass( null, "ui-state-disabled", !!value );
  11911. },
  11912. //internal value getter
  11913. // _value() returns value trimmed by min and max, aligned by step
  11914. _value: function() {
  11915. var val = this.options.value;
  11916. val = this._trimAlignValue( val );
  11917. return val;
  11918. },
  11919. //internal values getter
  11920. // _values() returns array of values trimmed by min and max, aligned by step
  11921. // _values( index ) returns single value trimmed by min and max, aligned by step
  11922. _values: function( index ) {
  11923. var val,
  11924. vals,
  11925. i;
  11926. if ( arguments.length ) {
  11927. val = this.options.values[ index ];
  11928. val = this._trimAlignValue( val );
  11929. return val;
  11930. } else if ( this._hasMultipleValues() ) {
  11931. // .slice() creates a copy of the array
  11932. // this copy gets trimmed by min and max and then returned
  11933. vals = this.options.values.slice();
  11934. for ( i = 0; i < vals.length; i += 1 ) {
  11935. vals[ i ] = this._trimAlignValue( vals[ i ] );
  11936. }
  11937. return vals;
  11938. } else {
  11939. return [];
  11940. }
  11941. },
  11942. // Returns the step-aligned value that val is closest to, between (inclusive) min and max
  11943. _trimAlignValue: function( val ) {
  11944. if ( val <= this._valueMin() ) {
  11945. return this._valueMin();
  11946. }
  11947. if ( val >= this._valueMax() ) {
  11948. return this._valueMax();
  11949. }
  11950. var step = ( this.options.step > 0 ) ? this.options.step : 1,
  11951. valModStep = ( val - this._valueMin() ) % step,
  11952. alignValue = val - valModStep;
  11953. if ( Math.abs( valModStep ) * 2 >= step ) {
  11954. alignValue += ( valModStep > 0 ) ? step : ( -step );
  11955. }
  11956. // Since JavaScript has problems with large floats, round
  11957. // the final value to 5 digits after the decimal point (see #4124)
  11958. return parseFloat( alignValue.toFixed( 5 ) );
  11959. },
  11960. _calculateNewMax: function() {
  11961. var max = this.options.max,
  11962. min = this._valueMin(),
  11963. step = this.options.step,
  11964. aboveMin = Math.round( ( max - min ) / step ) * step;
  11965. max = aboveMin + min;
  11966. if ( max > this.options.max ) {
  11967. //If max is not divisible by step, rounding off may increase its value
  11968. max -= step;
  11969. }
  11970. this.max = parseFloat( max.toFixed( this._precision() ) );
  11971. },
  11972. _precision: function() {
  11973. var precision = this._precisionOf( this.options.step );
  11974. if ( this.options.min !== null ) {
  11975. precision = Math.max( precision, this._precisionOf( this.options.min ) );
  11976. }
  11977. return precision;
  11978. },
  11979. _precisionOf: function( num ) {
  11980. var str = num.toString(),
  11981. decimal = str.indexOf( "." );
  11982. return decimal === -1 ? 0 : str.length - decimal - 1;
  11983. },
  11984. _valueMin: function() {
  11985. return this.options.min;
  11986. },
  11987. _valueMax: function() {
  11988. return this.max;
  11989. },
  11990. _refreshRange: function( orientation ) {
  11991. if ( orientation === "vertical" ) {
  11992. this.range.css( { "width": "", "left": "" } );
  11993. }
  11994. if ( orientation === "horizontal" ) {
  11995. this.range.css( { "height": "", "bottom": "" } );
  11996. }
  11997. },
  11998. _refreshValue: function() {
  11999. var lastValPercent, valPercent, value, valueMin, valueMax,
  12000. oRange = this.options.range,
  12001. o = this.options,
  12002. that = this,
  12003. animate = ( !this._animateOff ) ? o.animate : false,
  12004. _set = {};
  12005. if ( this._hasMultipleValues() ) {
  12006. this.handles.each( function( i ) {
  12007. valPercent = ( that.values( i ) - that._valueMin() ) / ( that._valueMax() -
  12008. that._valueMin() ) * 100;
  12009. _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  12010. $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  12011. if ( that.options.range === true ) {
  12012. if ( that.orientation === "horizontal" ) {
  12013. if ( i === 0 ) {
  12014. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
  12015. left: valPercent + "%"
  12016. }, o.animate );
  12017. }
  12018. if ( i === 1 ) {
  12019. that.range[ animate ? "animate" : "css" ]( {
  12020. width: ( valPercent - lastValPercent ) + "%"
  12021. }, {
  12022. queue: false,
  12023. duration: o.animate
  12024. } );
  12025. }
  12026. } else {
  12027. if ( i === 0 ) {
  12028. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
  12029. bottom: ( valPercent ) + "%"
  12030. }, o.animate );
  12031. }
  12032. if ( i === 1 ) {
  12033. that.range[ animate ? "animate" : "css" ]( {
  12034. height: ( valPercent - lastValPercent ) + "%"
  12035. }, {
  12036. queue: false,
  12037. duration: o.animate
  12038. } );
  12039. }
  12040. }
  12041. }
  12042. lastValPercent = valPercent;
  12043. } );
  12044. } else {
  12045. value = this.value();
  12046. valueMin = this._valueMin();
  12047. valueMax = this._valueMax();
  12048. valPercent = ( valueMax !== valueMin ) ?
  12049. ( value - valueMin ) / ( valueMax - valueMin ) * 100 :
  12050. 0;
  12051. _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  12052. this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  12053. if ( oRange === "min" && this.orientation === "horizontal" ) {
  12054. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
  12055. width: valPercent + "%"
  12056. }, o.animate );
  12057. }
  12058. if ( oRange === "max" && this.orientation === "horizontal" ) {
  12059. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
  12060. width: ( 100 - valPercent ) + "%"
  12061. }, o.animate );
  12062. }
  12063. if ( oRange === "min" && this.orientation === "vertical" ) {
  12064. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
  12065. height: valPercent + "%"
  12066. }, o.animate );
  12067. }
  12068. if ( oRange === "max" && this.orientation === "vertical" ) {
  12069. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
  12070. height: ( 100 - valPercent ) + "%"
  12071. }, o.animate );
  12072. }
  12073. }
  12074. },
  12075. _handleEvents: {
  12076. keydown: function( event ) {
  12077. var allowed, curVal, newVal, step,
  12078. index = $( event.target ).data( "ui-slider-handle-index" );
  12079. switch ( event.keyCode ) {
  12080. case $.ui.keyCode.HOME:
  12081. case $.ui.keyCode.END:
  12082. case $.ui.keyCode.PAGE_UP:
  12083. case $.ui.keyCode.PAGE_DOWN:
  12084. case $.ui.keyCode.UP:
  12085. case $.ui.keyCode.RIGHT:
  12086. case $.ui.keyCode.DOWN:
  12087. case $.ui.keyCode.LEFT:
  12088. event.preventDefault();
  12089. if ( !this._keySliding ) {
  12090. this._keySliding = true;
  12091. this._addClass( $( event.target ), null, "ui-state-active" );
  12092. allowed = this._start( event, index );
  12093. if ( allowed === false ) {
  12094. return;
  12095. }
  12096. }
  12097. break;
  12098. }
  12099. step = this.options.step;
  12100. if ( this._hasMultipleValues() ) {
  12101. curVal = newVal = this.values( index );
  12102. } else {
  12103. curVal = newVal = this.value();
  12104. }
  12105. switch ( event.keyCode ) {
  12106. case $.ui.keyCode.HOME:
  12107. newVal = this._valueMin();
  12108. break;
  12109. case $.ui.keyCode.END:
  12110. newVal = this._valueMax();
  12111. break;
  12112. case $.ui.keyCode.PAGE_UP:
  12113. newVal = this._trimAlignValue(
  12114. curVal + ( ( this._valueMax() - this._valueMin() ) / this.numPages )
  12115. );
  12116. break;
  12117. case $.ui.keyCode.PAGE_DOWN:
  12118. newVal = this._trimAlignValue(
  12119. curVal - ( ( this._valueMax() - this._valueMin() ) / this.numPages ) );
  12120. break;
  12121. case $.ui.keyCode.UP:
  12122. case $.ui.keyCode.RIGHT:
  12123. if ( curVal === this._valueMax() ) {
  12124. return;
  12125. }
  12126. newVal = this._trimAlignValue( curVal + step );
  12127. break;
  12128. case $.ui.keyCode.DOWN:
  12129. case $.ui.keyCode.LEFT:
  12130. if ( curVal === this._valueMin() ) {
  12131. return;
  12132. }
  12133. newVal = this._trimAlignValue( curVal - step );
  12134. break;
  12135. }
  12136. this._slide( event, index, newVal );
  12137. },
  12138. keyup: function( event ) {
  12139. var index = $( event.target ).data( "ui-slider-handle-index" );
  12140. if ( this._keySliding ) {
  12141. this._keySliding = false;
  12142. this._stop( event, index );
  12143. this._change( event, index );
  12144. this._removeClass( $( event.target ), null, "ui-state-active" );
  12145. }
  12146. }
  12147. }
  12148. } );
  12149. /*!
  12150. * jQuery UI Spinner 1.13.0
  12151. * http://jqueryui.com
  12152. *
  12153. * Copyright jQuery Foundation and other contributors
  12154. * Released under the MIT license.
  12155. * http://jquery.org/license
  12156. */
  12157. //>>label: Spinner
  12158. //>>group: Widgets
  12159. //>>description: Displays buttons to easily input numbers via the keyboard or mouse.
  12160. //>>docs: http://api.jqueryui.com/spinner/
  12161. //>>demos: http://jqueryui.com/spinner/
  12162. //>>css.structure: ../../themes/base/core.css
  12163. //>>css.structure: ../../themes/base/spinner.css
  12164. //>>css.theme: ../../themes/base/theme.css
  12165. function spinnerModifier( fn ) {
  12166. return function() {
  12167. var previous = this.element.val();
  12168. fn.apply( this, arguments );
  12169. this._refresh();
  12170. if ( previous !== this.element.val() ) {
  12171. this._trigger( "change" );
  12172. }
  12173. };
  12174. }
  12175. $.widget( "ui.spinner", {
  12176. version: "1.13.0",
  12177. defaultElement: "<input>",
  12178. widgetEventPrefix: "spin",
  12179. options: {
  12180. classes: {
  12181. "ui-spinner": "ui-corner-all",
  12182. "ui-spinner-down": "ui-corner-br",
  12183. "ui-spinner-up": "ui-corner-tr"
  12184. },
  12185. culture: null,
  12186. icons: {
  12187. down: "ui-icon-triangle-1-s",
  12188. up: "ui-icon-triangle-1-n"
  12189. },
  12190. incremental: true,
  12191. max: null,
  12192. min: null,
  12193. numberFormat: null,
  12194. page: 10,
  12195. step: 1,
  12196. change: null,
  12197. spin: null,
  12198. start: null,
  12199. stop: null
  12200. },
  12201. _create: function() {
  12202. // handle string values that need to be parsed
  12203. this._setOption( "max", this.options.max );
  12204. this._setOption( "min", this.options.min );
  12205. this._setOption( "step", this.options.step );
  12206. // Only format if there is a value, prevents the field from being marked
  12207. // as invalid in Firefox, see #9573.
  12208. if ( this.value() !== "" ) {
  12209. // Format the value, but don't constrain.
  12210. this._value( this.element.val(), true );
  12211. }
  12212. this._draw();
  12213. this._on( this._events );
  12214. this._refresh();
  12215. // Turning off autocomplete prevents the browser from remembering the
  12216. // value when navigating through history, so we re-enable autocomplete
  12217. // if the page is unloaded before the widget is destroyed. #7790
  12218. this._on( this.window, {
  12219. beforeunload: function() {
  12220. this.element.removeAttr( "autocomplete" );
  12221. }
  12222. } );
  12223. },
  12224. _getCreateOptions: function() {
  12225. var options = this._super();
  12226. var element = this.element;
  12227. $.each( [ "min", "max", "step" ], function( i, option ) {
  12228. var value = element.attr( option );
  12229. if ( value != null && value.length ) {
  12230. options[ option ] = value;
  12231. }
  12232. } );
  12233. return options;
  12234. },
  12235. _events: {
  12236. keydown: function( event ) {
  12237. if ( this._start( event ) && this._keydown( event ) ) {
  12238. event.preventDefault();
  12239. }
  12240. },
  12241. keyup: "_stop",
  12242. focus: function() {
  12243. this.previous = this.element.val();
  12244. },
  12245. blur: function( event ) {
  12246. if ( this.cancelBlur ) {
  12247. delete this.cancelBlur;
  12248. return;
  12249. }
  12250. this._stop();
  12251. this._refresh();
  12252. if ( this.previous !== this.element.val() ) {
  12253. this._trigger( "change", event );
  12254. }
  12255. },
  12256. mousewheel: function( event, delta ) {
  12257. var activeElement = $.ui.safeActiveElement( this.document[ 0 ] );
  12258. var isActive = this.element[ 0 ] === activeElement;
  12259. if ( !isActive || !delta ) {
  12260. return;
  12261. }
  12262. if ( !this.spinning && !this._start( event ) ) {
  12263. return false;
  12264. }
  12265. this._spin( ( delta > 0 ? 1 : -1 ) * this.options.step, event );
  12266. clearTimeout( this.mousewheelTimer );
  12267. this.mousewheelTimer = this._delay( function() {
  12268. if ( this.spinning ) {
  12269. this._stop( event );
  12270. }
  12271. }, 100 );
  12272. event.preventDefault();
  12273. },
  12274. "mousedown .ui-spinner-button": function( event ) {
  12275. var previous;
  12276. // We never want the buttons to have focus; whenever the user is
  12277. // interacting with the spinner, the focus should be on the input.
  12278. // If the input is focused then this.previous is properly set from
  12279. // when the input first received focus. If the input is not focused
  12280. // then we need to set this.previous based on the value before spinning.
  12281. previous = this.element[ 0 ] === $.ui.safeActiveElement( this.document[ 0 ] ) ?
  12282. this.previous : this.element.val();
  12283. function checkFocus() {
  12284. var isActive = this.element[ 0 ] === $.ui.safeActiveElement( this.document[ 0 ] );
  12285. if ( !isActive ) {
  12286. this.element.trigger( "focus" );
  12287. this.previous = previous;
  12288. // support: IE
  12289. // IE sets focus asynchronously, so we need to check if focus
  12290. // moved off of the input because the user clicked on the button.
  12291. this._delay( function() {
  12292. this.previous = previous;
  12293. } );
  12294. }
  12295. }
  12296. // Ensure focus is on (or stays on) the text field
  12297. event.preventDefault();
  12298. checkFocus.call( this );
  12299. // Support: IE
  12300. // IE doesn't prevent moving focus even with event.preventDefault()
  12301. // so we set a flag to know when we should ignore the blur event
  12302. // and check (again) if focus moved off of the input.
  12303. this.cancelBlur = true;
  12304. this._delay( function() {
  12305. delete this.cancelBlur;
  12306. checkFocus.call( this );
  12307. } );
  12308. if ( this._start( event ) === false ) {
  12309. return;
  12310. }
  12311. this._repeat( null, $( event.currentTarget )
  12312. .hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  12313. },
  12314. "mouseup .ui-spinner-button": "_stop",
  12315. "mouseenter .ui-spinner-button": function( event ) {
  12316. // button will add ui-state-active if mouse was down while mouseleave and kept down
  12317. if ( !$( event.currentTarget ).hasClass( "ui-state-active" ) ) {
  12318. return;
  12319. }
  12320. if ( this._start( event ) === false ) {
  12321. return false;
  12322. }
  12323. this._repeat( null, $( event.currentTarget )
  12324. .hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  12325. },
  12326. // TODO: do we really want to consider this a stop?
  12327. // shouldn't we just stop the repeater and wait until mouseup before
  12328. // we trigger the stop event?
  12329. "mouseleave .ui-spinner-button": "_stop"
  12330. },
  12331. // Support mobile enhanced option and make backcompat more sane
  12332. _enhance: function() {
  12333. this.uiSpinner = this.element
  12334. .attr( "autocomplete", "off" )
  12335. .wrap( "<span>" )
  12336. .parent()
  12337. // Add buttons
  12338. .append(
  12339. "<a></a><a></a>"
  12340. );
  12341. },
  12342. _draw: function() {
  12343. this._enhance();
  12344. this._addClass( this.uiSpinner, "ui-spinner", "ui-widget ui-widget-content" );
  12345. this._addClass( "ui-spinner-input" );
  12346. this.element.attr( "role", "spinbutton" );
  12347. // Button bindings
  12348. this.buttons = this.uiSpinner.children( "a" )
  12349. .attr( "tabIndex", -1 )
  12350. .attr( "aria-hidden", true )
  12351. .button( {
  12352. classes: {
  12353. "ui-button": ""
  12354. }
  12355. } );
  12356. // TODO: Right now button does not support classes this is already updated in button PR
  12357. this._removeClass( this.buttons, "ui-corner-all" );
  12358. this._addClass( this.buttons.first(), "ui-spinner-button ui-spinner-up" );
  12359. this._addClass( this.buttons.last(), "ui-spinner-button ui-spinner-down" );
  12360. this.buttons.first().button( {
  12361. "icon": this.options.icons.up,
  12362. "showLabel": false
  12363. } );
  12364. this.buttons.last().button( {
  12365. "icon": this.options.icons.down,
  12366. "showLabel": false
  12367. } );
  12368. // IE 6 doesn't understand height: 50% for the buttons
  12369. // unless the wrapper has an explicit height
  12370. if ( this.buttons.height() > Math.ceil( this.uiSpinner.height() * 0.5 ) &&
  12371. this.uiSpinner.height() > 0 ) {
  12372. this.uiSpinner.height( this.uiSpinner.height() );
  12373. }
  12374. },
  12375. _keydown: function( event ) {
  12376. var options = this.options,
  12377. keyCode = $.ui.keyCode;
  12378. switch ( event.keyCode ) {
  12379. case keyCode.UP:
  12380. this._repeat( null, 1, event );
  12381. return true;
  12382. case keyCode.DOWN:
  12383. this._repeat( null, -1, event );
  12384. return true;
  12385. case keyCode.PAGE_UP:
  12386. this._repeat( null, options.page, event );
  12387. return true;
  12388. case keyCode.PAGE_DOWN:
  12389. this._repeat( null, -options.page, event );
  12390. return true;
  12391. }
  12392. return false;
  12393. },
  12394. _start: function( event ) {
  12395. if ( !this.spinning && this._trigger( "start", event ) === false ) {
  12396. return false;
  12397. }
  12398. if ( !this.counter ) {
  12399. this.counter = 1;
  12400. }
  12401. this.spinning = true;
  12402. return true;
  12403. },
  12404. _repeat: function( i, steps, event ) {
  12405. i = i || 500;
  12406. clearTimeout( this.timer );
  12407. this.timer = this._delay( function() {
  12408. this._repeat( 40, steps, event );
  12409. }, i );
  12410. this._spin( steps * this.options.step, event );
  12411. },
  12412. _spin: function( step, event ) {
  12413. var value = this.value() || 0;
  12414. if ( !this.counter ) {
  12415. this.counter = 1;
  12416. }
  12417. value = this._adjustValue( value + step * this._increment( this.counter ) );
  12418. if ( !this.spinning || this._trigger( "spin", event, { value: value } ) !== false ) {
  12419. this._value( value );
  12420. this.counter++;
  12421. }
  12422. },
  12423. _increment: function( i ) {
  12424. var incremental = this.options.incremental;
  12425. if ( incremental ) {
  12426. return typeof incremental === "function" ?
  12427. incremental( i ) :
  12428. Math.floor( i * i * i / 50000 - i * i / 500 + 17 * i / 200 + 1 );
  12429. }
  12430. return 1;
  12431. },
  12432. _precision: function() {
  12433. var precision = this._precisionOf( this.options.step );
  12434. if ( this.options.min !== null ) {
  12435. precision = Math.max( precision, this._precisionOf( this.options.min ) );
  12436. }
  12437. return precision;
  12438. },
  12439. _precisionOf: function( num ) {
  12440. var str = num.toString(),
  12441. decimal = str.indexOf( "." );
  12442. return decimal === -1 ? 0 : str.length - decimal - 1;
  12443. },
  12444. _adjustValue: function( value ) {
  12445. var base, aboveMin,
  12446. options = this.options;
  12447. // Make sure we're at a valid step
  12448. // - find out where we are relative to the base (min or 0)
  12449. base = options.min !== null ? options.min : 0;
  12450. aboveMin = value - base;
  12451. // - round to the nearest step
  12452. aboveMin = Math.round( aboveMin / options.step ) * options.step;
  12453. // - rounding is based on 0, so adjust back to our base
  12454. value = base + aboveMin;
  12455. // Fix precision from bad JS floating point math
  12456. value = parseFloat( value.toFixed( this._precision() ) );
  12457. // Clamp the value
  12458. if ( options.max !== null && value > options.max ) {
  12459. return options.max;
  12460. }
  12461. if ( options.min !== null && value < options.min ) {
  12462. return options.min;
  12463. }
  12464. return value;
  12465. },
  12466. _stop: function( event ) {
  12467. if ( !this.spinning ) {
  12468. return;
  12469. }
  12470. clearTimeout( this.timer );
  12471. clearTimeout( this.mousewheelTimer );
  12472. this.counter = 0;
  12473. this.spinning = false;
  12474. this._trigger( "stop", event );
  12475. },
  12476. _setOption: function( key, value ) {
  12477. var prevValue, first, last;
  12478. if ( key === "culture" || key === "numberFormat" ) {
  12479. prevValue = this._parse( this.element.val() );
  12480. this.options[ key ] = value;
  12481. this.element.val( this._format( prevValue ) );
  12482. return;
  12483. }
  12484. if ( key === "max" || key === "min" || key === "step" ) {
  12485. if ( typeof value === "string" ) {
  12486. value = this._parse( value );
  12487. }
  12488. }
  12489. if ( key === "icons" ) {
  12490. first = this.buttons.first().find( ".ui-icon" );
  12491. this._removeClass( first, null, this.options.icons.up );
  12492. this._addClass( first, null, value.up );
  12493. last = this.buttons.last().find( ".ui-icon" );
  12494. this._removeClass( last, null, this.options.icons.down );
  12495. this._addClass( last, null, value.down );
  12496. }
  12497. this._super( key, value );
  12498. },
  12499. _setOptionDisabled: function( value ) {
  12500. this._super( value );
  12501. this._toggleClass( this.uiSpinner, null, "ui-state-disabled", !!value );
  12502. this.element.prop( "disabled", !!value );
  12503. this.buttons.button( value ? "disable" : "enable" );
  12504. },
  12505. _setOptions: spinnerModifier( function( options ) {
  12506. this._super( options );
  12507. } ),
  12508. _parse: function( val ) {
  12509. if ( typeof val === "string" && val !== "" ) {
  12510. val = window.Globalize && this.options.numberFormat ?
  12511. Globalize.parseFloat( val, 10, this.options.culture ) : +val;
  12512. }
  12513. return val === "" || isNaN( val ) ? null : val;
  12514. },
  12515. _format: function( value ) {
  12516. if ( value === "" ) {
  12517. return "";
  12518. }
  12519. return window.Globalize && this.options.numberFormat ?
  12520. Globalize.format( value, this.options.numberFormat, this.options.culture ) :
  12521. value;
  12522. },
  12523. _refresh: function() {
  12524. this.element.attr( {
  12525. "aria-valuemin": this.options.min,
  12526. "aria-valuemax": this.options.max,
  12527. // TODO: what should we do with values that can't be parsed?
  12528. "aria-valuenow": this._parse( this.element.val() )
  12529. } );
  12530. },
  12531. isValid: function() {
  12532. var value = this.value();
  12533. // Null is invalid
  12534. if ( value === null ) {
  12535. return false;
  12536. }
  12537. // If value gets adjusted, it's invalid
  12538. return value === this._adjustValue( value );
  12539. },
  12540. // Update the value without triggering change
  12541. _value: function( value, allowAny ) {
  12542. var parsed;
  12543. if ( value !== "" ) {
  12544. parsed = this._parse( value );
  12545. if ( parsed !== null ) {
  12546. if ( !allowAny ) {
  12547. parsed = this._adjustValue( parsed );
  12548. }
  12549. value = this._format( parsed );
  12550. }
  12551. }
  12552. this.element.val( value );
  12553. this._refresh();
  12554. },
  12555. _destroy: function() {
  12556. this.element
  12557. .prop( "disabled", false )
  12558. .removeAttr( "autocomplete role aria-valuemin aria-valuemax aria-valuenow" );
  12559. this.uiSpinner.replaceWith( this.element );
  12560. },
  12561. stepUp: spinnerModifier( function( steps ) {
  12562. this._stepUp( steps );
  12563. } ),
  12564. _stepUp: function( steps ) {
  12565. if ( this._start() ) {
  12566. this._spin( ( steps || 1 ) * this.options.step );
  12567. this._stop();
  12568. }
  12569. },
  12570. stepDown: spinnerModifier( function( steps ) {
  12571. this._stepDown( steps );
  12572. } ),
  12573. _stepDown: function( steps ) {
  12574. if ( this._start() ) {
  12575. this._spin( ( steps || 1 ) * -this.options.step );
  12576. this._stop();
  12577. }
  12578. },
  12579. pageUp: spinnerModifier( function( pages ) {
  12580. this._stepUp( ( pages || 1 ) * this.options.page );
  12581. } ),
  12582. pageDown: spinnerModifier( function( pages ) {
  12583. this._stepDown( ( pages || 1 ) * this.options.page );
  12584. } ),
  12585. value: function( newVal ) {
  12586. if ( !arguments.length ) {
  12587. return this._parse( this.element.val() );
  12588. }
  12589. spinnerModifier( this._value ).call( this, newVal );
  12590. },
  12591. widget: function() {
  12592. return this.uiSpinner;
  12593. }
  12594. } );
  12595. // DEPRECATED
  12596. // TODO: switch return back to widget declaration at top of file when this is removed
  12597. if ( $.uiBackCompat !== false ) {
  12598. // Backcompat for spinner html extension points
  12599. $.widget( "ui.spinner", $.ui.spinner, {
  12600. _enhance: function() {
  12601. this.uiSpinner = this.element
  12602. .attr( "autocomplete", "off" )
  12603. .wrap( this._uiSpinnerHtml() )
  12604. .parent()
  12605. // Add buttons
  12606. .append( this._buttonHtml() );
  12607. },
  12608. _uiSpinnerHtml: function() {
  12609. return "<span>";
  12610. },
  12611. _buttonHtml: function() {
  12612. return "<a></a><a></a>";
  12613. }
  12614. } );
  12615. }
  12616. var widgetsSpinner = $.ui.spinner;
  12617. /*!
  12618. * jQuery UI Tabs 1.13.0
  12619. * http://jqueryui.com
  12620. *
  12621. * Copyright jQuery Foundation and other contributors
  12622. * Released under the MIT license.
  12623. * http://jquery.org/license
  12624. */
  12625. //>>label: Tabs
  12626. //>>group: Widgets
  12627. //>>description: Transforms a set of container elements into a tab structure.
  12628. //>>docs: http://api.jqueryui.com/tabs/
  12629. //>>demos: http://jqueryui.com/tabs/
  12630. //>>css.structure: ../../themes/base/core.css
  12631. //>>css.structure: ../../themes/base/tabs.css
  12632. //>>css.theme: ../../themes/base/theme.css
  12633. $.widget( "ui.tabs", {
  12634. version: "1.13.0",
  12635. delay: 300,
  12636. options: {
  12637. active: null,
  12638. classes: {
  12639. "ui-tabs": "ui-corner-all",
  12640. "ui-tabs-nav": "ui-corner-all",
  12641. "ui-tabs-panel": "ui-corner-bottom",
  12642. "ui-tabs-tab": "ui-corner-top"
  12643. },
  12644. collapsible: false,
  12645. event: "click",
  12646. heightStyle: "content",
  12647. hide: null,
  12648. show: null,
  12649. // Callbacks
  12650. activate: null,
  12651. beforeActivate: null,
  12652. beforeLoad: null,
  12653. load: null
  12654. },
  12655. _isLocal: ( function() {
  12656. var rhash = /#.*$/;
  12657. return function( anchor ) {
  12658. var anchorUrl, locationUrl;
  12659. anchorUrl = anchor.href.replace( rhash, "" );
  12660. locationUrl = location.href.replace( rhash, "" );
  12661. // Decoding may throw an error if the URL isn't UTF-8 (#9518)
  12662. try {
  12663. anchorUrl = decodeURIComponent( anchorUrl );
  12664. } catch ( error ) {}
  12665. try {
  12666. locationUrl = decodeURIComponent( locationUrl );
  12667. } catch ( error ) {}
  12668. return anchor.hash.length > 1 && anchorUrl === locationUrl;
  12669. };
  12670. } )(),
  12671. _create: function() {
  12672. var that = this,
  12673. options = this.options;
  12674. this.running = false;
  12675. this._addClass( "ui-tabs", "ui-widget ui-widget-content" );
  12676. this._toggleClass( "ui-tabs-collapsible", null, options.collapsible );
  12677. this._processTabs();
  12678. options.active = this._initialActive();
  12679. // Take disabling tabs via class attribute from HTML
  12680. // into account and update option properly.
  12681. if ( Array.isArray( options.disabled ) ) {
  12682. options.disabled = $.uniqueSort( options.disabled.concat(
  12683. $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
  12684. return that.tabs.index( li );
  12685. } )
  12686. ) ).sort();
  12687. }
  12688. // Check for length avoids error when initializing empty list
  12689. if ( this.options.active !== false && this.anchors.length ) {
  12690. this.active = this._findActive( options.active );
  12691. } else {
  12692. this.active = $();
  12693. }
  12694. this._refresh();
  12695. if ( this.active.length ) {
  12696. this.load( options.active );
  12697. }
  12698. },
  12699. _initialActive: function() {
  12700. var active = this.options.active,
  12701. collapsible = this.options.collapsible,
  12702. locationHash = location.hash.substring( 1 );
  12703. if ( active === null ) {
  12704. // check the fragment identifier in the URL
  12705. if ( locationHash ) {
  12706. this.tabs.each( function( i, tab ) {
  12707. if ( $( tab ).attr( "aria-controls" ) === locationHash ) {
  12708. active = i;
  12709. return false;
  12710. }
  12711. } );
  12712. }
  12713. // Check for a tab marked active via a class
  12714. if ( active === null ) {
  12715. active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) );
  12716. }
  12717. // No active tab, set to false
  12718. if ( active === null || active === -1 ) {
  12719. active = this.tabs.length ? 0 : false;
  12720. }
  12721. }
  12722. // Handle numbers: negative, out of range
  12723. if ( active !== false ) {
  12724. active = this.tabs.index( this.tabs.eq( active ) );
  12725. if ( active === -1 ) {
  12726. active = collapsible ? false : 0;
  12727. }
  12728. }
  12729. // Don't allow collapsible: false and active: false
  12730. if ( !collapsible && active === false && this.anchors.length ) {
  12731. active = 0;
  12732. }
  12733. return active;
  12734. },
  12735. _getCreateEventData: function() {
  12736. return {
  12737. tab: this.active,
  12738. panel: !this.active.length ? $() : this._getPanelForTab( this.active )
  12739. };
  12740. },
  12741. _tabKeydown: function( event ) {
  12742. var focusedTab = $( $.ui.safeActiveElement( this.document[ 0 ] ) ).closest( "li" ),
  12743. selectedIndex = this.tabs.index( focusedTab ),
  12744. goingForward = true;
  12745. if ( this._handlePageNav( event ) ) {
  12746. return;
  12747. }
  12748. switch ( event.keyCode ) {
  12749. case $.ui.keyCode.RIGHT:
  12750. case $.ui.keyCode.DOWN:
  12751. selectedIndex++;
  12752. break;
  12753. case $.ui.keyCode.UP:
  12754. case $.ui.keyCode.LEFT:
  12755. goingForward = false;
  12756. selectedIndex--;
  12757. break;
  12758. case $.ui.keyCode.END:
  12759. selectedIndex = this.anchors.length - 1;
  12760. break;
  12761. case $.ui.keyCode.HOME:
  12762. selectedIndex = 0;
  12763. break;
  12764. case $.ui.keyCode.SPACE:
  12765. // Activate only, no collapsing
  12766. event.preventDefault();
  12767. clearTimeout( this.activating );
  12768. this._activate( selectedIndex );
  12769. return;
  12770. case $.ui.keyCode.ENTER:
  12771. // Toggle (cancel delayed activation, allow collapsing)
  12772. event.preventDefault();
  12773. clearTimeout( this.activating );
  12774. // Determine if we should collapse or activate
  12775. this._activate( selectedIndex === this.options.active ? false : selectedIndex );
  12776. return;
  12777. default:
  12778. return;
  12779. }
  12780. // Focus the appropriate tab, based on which key was pressed
  12781. event.preventDefault();
  12782. clearTimeout( this.activating );
  12783. selectedIndex = this._focusNextTab( selectedIndex, goingForward );
  12784. // Navigating with control/command key will prevent automatic activation
  12785. if ( !event.ctrlKey && !event.metaKey ) {
  12786. // Update aria-selected immediately so that AT think the tab is already selected.
  12787. // Otherwise AT may confuse the user by stating that they need to activate the tab,
  12788. // but the tab will already be activated by the time the announcement finishes.
  12789. focusedTab.attr( "aria-selected", "false" );
  12790. this.tabs.eq( selectedIndex ).attr( "aria-selected", "true" );
  12791. this.activating = this._delay( function() {
  12792. this.option( "active", selectedIndex );
  12793. }, this.delay );
  12794. }
  12795. },
  12796. _panelKeydown: function( event ) {
  12797. if ( this._handlePageNav( event ) ) {
  12798. return;
  12799. }
  12800. // Ctrl+up moves focus to the current tab
  12801. if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) {
  12802. event.preventDefault();
  12803. this.active.trigger( "focus" );
  12804. }
  12805. },
  12806. // Alt+page up/down moves focus to the previous/next tab (and activates)
  12807. _handlePageNav: function( event ) {
  12808. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP ) {
  12809. this._activate( this._focusNextTab( this.options.active - 1, false ) );
  12810. return true;
  12811. }
  12812. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN ) {
  12813. this._activate( this._focusNextTab( this.options.active + 1, true ) );
  12814. return true;
  12815. }
  12816. },
  12817. _findNextTab: function( index, goingForward ) {
  12818. var lastTabIndex = this.tabs.length - 1;
  12819. function constrain() {
  12820. if ( index > lastTabIndex ) {
  12821. index = 0;
  12822. }
  12823. if ( index < 0 ) {
  12824. index = lastTabIndex;
  12825. }
  12826. return index;
  12827. }
  12828. while ( $.inArray( constrain(), this.options.disabled ) !== -1 ) {
  12829. index = goingForward ? index + 1 : index - 1;
  12830. }
  12831. return index;
  12832. },
  12833. _focusNextTab: function( index, goingForward ) {
  12834. index = this._findNextTab( index, goingForward );
  12835. this.tabs.eq( index ).trigger( "focus" );
  12836. return index;
  12837. },
  12838. _setOption: function( key, value ) {
  12839. if ( key === "active" ) {
  12840. // _activate() will handle invalid values and update this.options
  12841. this._activate( value );
  12842. return;
  12843. }
  12844. this._super( key, value );
  12845. if ( key === "collapsible" ) {
  12846. this._toggleClass( "ui-tabs-collapsible", null, value );
  12847. // Setting collapsible: false while collapsed; open first panel
  12848. if ( !value && this.options.active === false ) {
  12849. this._activate( 0 );
  12850. }
  12851. }
  12852. if ( key === "event" ) {
  12853. this._setupEvents( value );
  12854. }
  12855. if ( key === "heightStyle" ) {
  12856. this._setupHeightStyle( value );
  12857. }
  12858. },
  12859. _sanitizeSelector: function( hash ) {
  12860. return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
  12861. },
  12862. refresh: function() {
  12863. var options = this.options,
  12864. lis = this.tablist.children( ":has(a[href])" );
  12865. // Get disabled tabs from class attribute from HTML
  12866. // this will get converted to a boolean if needed in _refresh()
  12867. options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) {
  12868. return lis.index( tab );
  12869. } );
  12870. this._processTabs();
  12871. // Was collapsed or no tabs
  12872. if ( options.active === false || !this.anchors.length ) {
  12873. options.active = false;
  12874. this.active = $();
  12875. // was active, but active tab is gone
  12876. } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) {
  12877. // all remaining tabs are disabled
  12878. if ( this.tabs.length === options.disabled.length ) {
  12879. options.active = false;
  12880. this.active = $();
  12881. // activate previous tab
  12882. } else {
  12883. this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) );
  12884. }
  12885. // was active, active tab still exists
  12886. } else {
  12887. // make sure active index is correct
  12888. options.active = this.tabs.index( this.active );
  12889. }
  12890. this._refresh();
  12891. },
  12892. _refresh: function() {
  12893. this._setOptionDisabled( this.options.disabled );
  12894. this._setupEvents( this.options.event );
  12895. this._setupHeightStyle( this.options.heightStyle );
  12896. this.tabs.not( this.active ).attr( {
  12897. "aria-selected": "false",
  12898. "aria-expanded": "false",
  12899. tabIndex: -1
  12900. } );
  12901. this.panels.not( this._getPanelForTab( this.active ) )
  12902. .hide()
  12903. .attr( {
  12904. "aria-hidden": "true"
  12905. } );
  12906. // Make sure one tab is in the tab order
  12907. if ( !this.active.length ) {
  12908. this.tabs.eq( 0 ).attr( "tabIndex", 0 );
  12909. } else {
  12910. this.active
  12911. .attr( {
  12912. "aria-selected": "true",
  12913. "aria-expanded": "true",
  12914. tabIndex: 0
  12915. } );
  12916. this._addClass( this.active, "ui-tabs-active", "ui-state-active" );
  12917. this._getPanelForTab( this.active )
  12918. .show()
  12919. .attr( {
  12920. "aria-hidden": "false"
  12921. } );
  12922. }
  12923. },
  12924. _processTabs: function() {
  12925. var that = this,
  12926. prevTabs = this.tabs,
  12927. prevAnchors = this.anchors,
  12928. prevPanels = this.panels;
  12929. this.tablist = this._getList().attr( "role", "tablist" );
  12930. this._addClass( this.tablist, "ui-tabs-nav",
  12931. "ui-helper-reset ui-helper-clearfix ui-widget-header" );
  12932. // Prevent users from focusing disabled tabs via click
  12933. this.tablist
  12934. .on( "mousedown" + this.eventNamespace, "> li", function( event ) {
  12935. if ( $( this ).is( ".ui-state-disabled" ) ) {
  12936. event.preventDefault();
  12937. }
  12938. } )
  12939. // Support: IE <9
  12940. // Preventing the default action in mousedown doesn't prevent IE
  12941. // from focusing the element, so if the anchor gets focused, blur.
  12942. // We don't have to worry about focusing the previously focused
  12943. // element since clicking on a non-focusable element should focus
  12944. // the body anyway.
  12945. .on( "focus" + this.eventNamespace, ".ui-tabs-anchor", function() {
  12946. if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) {
  12947. this.blur();
  12948. }
  12949. } );
  12950. this.tabs = this.tablist.find( "> li:has(a[href])" )
  12951. .attr( {
  12952. role: "tab",
  12953. tabIndex: -1
  12954. } );
  12955. this._addClass( this.tabs, "ui-tabs-tab", "ui-state-default" );
  12956. this.anchors = this.tabs.map( function() {
  12957. return $( "a", this )[ 0 ];
  12958. } )
  12959. .attr( {
  12960. tabIndex: -1
  12961. } );
  12962. this._addClass( this.anchors, "ui-tabs-anchor" );
  12963. this.panels = $();
  12964. this.anchors.each( function( i, anchor ) {
  12965. var selector, panel, panelId,
  12966. anchorId = $( anchor ).uniqueId().attr( "id" ),
  12967. tab = $( anchor ).closest( "li" ),
  12968. originalAriaControls = tab.attr( "aria-controls" );
  12969. // Inline tab
  12970. if ( that._isLocal( anchor ) ) {
  12971. selector = anchor.hash;
  12972. panelId = selector.substring( 1 );
  12973. panel = that.element.find( that._sanitizeSelector( selector ) );
  12974. // remote tab
  12975. } else {
  12976. // If the tab doesn't already have aria-controls,
  12977. // generate an id by using a throw-away element
  12978. panelId = tab.attr( "aria-controls" ) || $( {} ).uniqueId()[ 0 ].id;
  12979. selector = "#" + panelId;
  12980. panel = that.element.find( selector );
  12981. if ( !panel.length ) {
  12982. panel = that._createPanel( panelId );
  12983. panel.insertAfter( that.panels[ i - 1 ] || that.tablist );
  12984. }
  12985. panel.attr( "aria-live", "polite" );
  12986. }
  12987. if ( panel.length ) {
  12988. that.panels = that.panels.add( panel );
  12989. }
  12990. if ( originalAriaControls ) {
  12991. tab.data( "ui-tabs-aria-controls", originalAriaControls );
  12992. }
  12993. tab.attr( {
  12994. "aria-controls": panelId,
  12995. "aria-labelledby": anchorId
  12996. } );
  12997. panel.attr( "aria-labelledby", anchorId );
  12998. } );
  12999. this.panels.attr( "role", "tabpanel" );
  13000. this._addClass( this.panels, "ui-tabs-panel", "ui-widget-content" );
  13001. // Avoid memory leaks (#10056)
  13002. if ( prevTabs ) {
  13003. this._off( prevTabs.not( this.tabs ) );
  13004. this._off( prevAnchors.not( this.anchors ) );
  13005. this._off( prevPanels.not( this.panels ) );
  13006. }
  13007. },
  13008. // Allow overriding how to find the list for rare usage scenarios (#7715)
  13009. _getList: function() {
  13010. return this.tablist || this.element.find( "ol, ul" ).eq( 0 );
  13011. },
  13012. _createPanel: function( id ) {
  13013. return $( "<div>" )
  13014. .attr( "id", id )
  13015. .data( "ui-tabs-destroy", true );
  13016. },
  13017. _setOptionDisabled: function( disabled ) {
  13018. var currentItem, li, i;
  13019. if ( Array.isArray( disabled ) ) {
  13020. if ( !disabled.length ) {
  13021. disabled = false;
  13022. } else if ( disabled.length === this.anchors.length ) {
  13023. disabled = true;
  13024. }
  13025. }
  13026. // Disable tabs
  13027. for ( i = 0; ( li = this.tabs[ i ] ); i++ ) {
  13028. currentItem = $( li );
  13029. if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
  13030. currentItem.attr( "aria-disabled", "true" );
  13031. this._addClass( currentItem, null, "ui-state-disabled" );
  13032. } else {
  13033. currentItem.removeAttr( "aria-disabled" );
  13034. this._removeClass( currentItem, null, "ui-state-disabled" );
  13035. }
  13036. }
  13037. this.options.disabled = disabled;
  13038. this._toggleClass( this.widget(), this.widgetFullName + "-disabled", null,
  13039. disabled === true );
  13040. },
  13041. _setupEvents: function( event ) {
  13042. var events = {};
  13043. if ( event ) {
  13044. $.each( event.split( " " ), function( index, eventName ) {
  13045. events[ eventName ] = "_eventHandler";
  13046. } );
  13047. }
  13048. this._off( this.anchors.add( this.tabs ).add( this.panels ) );
  13049. // Always prevent the default action, even when disabled
  13050. this._on( true, this.anchors, {
  13051. click: function( event ) {
  13052. event.preventDefault();
  13053. }
  13054. } );
  13055. this._on( this.anchors, events );
  13056. this._on( this.tabs, { keydown: "_tabKeydown" } );
  13057. this._on( this.panels, { keydown: "_panelKeydown" } );
  13058. this._focusable( this.tabs );
  13059. this._hoverable( this.tabs );
  13060. },
  13061. _setupHeightStyle: function( heightStyle ) {
  13062. var maxHeight,
  13063. parent = this.element.parent();
  13064. if ( heightStyle === "fill" ) {
  13065. maxHeight = parent.height();
  13066. maxHeight -= this.element.outerHeight() - this.element.height();
  13067. this.element.siblings( ":visible" ).each( function() {
  13068. var elem = $( this ),
  13069. position = elem.css( "position" );
  13070. if ( position === "absolute" || position === "fixed" ) {
  13071. return;
  13072. }
  13073. maxHeight -= elem.outerHeight( true );
  13074. } );
  13075. this.element.children().not( this.panels ).each( function() {
  13076. maxHeight -= $( this ).outerHeight( true );
  13077. } );
  13078. this.panels.each( function() {
  13079. $( this ).height( Math.max( 0, maxHeight -
  13080. $( this ).innerHeight() + $( this ).height() ) );
  13081. } )
  13082. .css( "overflow", "auto" );
  13083. } else if ( heightStyle === "auto" ) {
  13084. maxHeight = 0;
  13085. this.panels.each( function() {
  13086. maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
  13087. } ).height( maxHeight );
  13088. }
  13089. },
  13090. _eventHandler: function( event ) {
  13091. var options = this.options,
  13092. active = this.active,
  13093. anchor = $( event.currentTarget ),
  13094. tab = anchor.closest( "li" ),
  13095. clickedIsActive = tab[ 0 ] === active[ 0 ],
  13096. collapsing = clickedIsActive && options.collapsible,
  13097. toShow = collapsing ? $() : this._getPanelForTab( tab ),
  13098. toHide = !active.length ? $() : this._getPanelForTab( active ),
  13099. eventData = {
  13100. oldTab: active,
  13101. oldPanel: toHide,
  13102. newTab: collapsing ? $() : tab,
  13103. newPanel: toShow
  13104. };
  13105. event.preventDefault();
  13106. if ( tab.hasClass( "ui-state-disabled" ) ||
  13107. // tab is already loading
  13108. tab.hasClass( "ui-tabs-loading" ) ||
  13109. // can't switch durning an animation
  13110. this.running ||
  13111. // click on active header, but not collapsible
  13112. ( clickedIsActive && !options.collapsible ) ||
  13113. // allow canceling activation
  13114. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  13115. return;
  13116. }
  13117. options.active = collapsing ? false : this.tabs.index( tab );
  13118. this.active = clickedIsActive ? $() : tab;
  13119. if ( this.xhr ) {
  13120. this.xhr.abort();
  13121. }
  13122. if ( !toHide.length && !toShow.length ) {
  13123. $.error( "jQuery UI Tabs: Mismatching fragment identifier." );
  13124. }
  13125. if ( toShow.length ) {
  13126. this.load( this.tabs.index( tab ), event );
  13127. }
  13128. this._toggle( event, eventData );
  13129. },
  13130. // Handles show/hide for selecting tabs
  13131. _toggle: function( event, eventData ) {
  13132. var that = this,
  13133. toShow = eventData.newPanel,
  13134. toHide = eventData.oldPanel;
  13135. this.running = true;
  13136. function complete() {
  13137. that.running = false;
  13138. that._trigger( "activate", event, eventData );
  13139. }
  13140. function show() {
  13141. that._addClass( eventData.newTab.closest( "li" ), "ui-tabs-active", "ui-state-active" );
  13142. if ( toShow.length && that.options.show ) {
  13143. that._show( toShow, that.options.show, complete );
  13144. } else {
  13145. toShow.show();
  13146. complete();
  13147. }
  13148. }
  13149. // Start out by hiding, then showing, then completing
  13150. if ( toHide.length && this.options.hide ) {
  13151. this._hide( toHide, this.options.hide, function() {
  13152. that._removeClass( eventData.oldTab.closest( "li" ),
  13153. "ui-tabs-active", "ui-state-active" );
  13154. show();
  13155. } );
  13156. } else {
  13157. this._removeClass( eventData.oldTab.closest( "li" ),
  13158. "ui-tabs-active", "ui-state-active" );
  13159. toHide.hide();
  13160. show();
  13161. }
  13162. toHide.attr( "aria-hidden", "true" );
  13163. eventData.oldTab.attr( {
  13164. "aria-selected": "false",
  13165. "aria-expanded": "false"
  13166. } );
  13167. // If we're switching tabs, remove the old tab from the tab order.
  13168. // If we're opening from collapsed state, remove the previous tab from the tab order.
  13169. // If we're collapsing, then keep the collapsing tab in the tab order.
  13170. if ( toShow.length && toHide.length ) {
  13171. eventData.oldTab.attr( "tabIndex", -1 );
  13172. } else if ( toShow.length ) {
  13173. this.tabs.filter( function() {
  13174. return $( this ).attr( "tabIndex" ) === 0;
  13175. } )
  13176. .attr( "tabIndex", -1 );
  13177. }
  13178. toShow.attr( "aria-hidden", "false" );
  13179. eventData.newTab.attr( {
  13180. "aria-selected": "true",
  13181. "aria-expanded": "true",
  13182. tabIndex: 0
  13183. } );
  13184. },
  13185. _activate: function( index ) {
  13186. var anchor,
  13187. active = this._findActive( index );
  13188. // Trying to activate the already active panel
  13189. if ( active[ 0 ] === this.active[ 0 ] ) {
  13190. return;
  13191. }
  13192. // Trying to collapse, simulate a click on the current active header
  13193. if ( !active.length ) {
  13194. active = this.active;
  13195. }
  13196. anchor = active.find( ".ui-tabs-anchor" )[ 0 ];
  13197. this._eventHandler( {
  13198. target: anchor,
  13199. currentTarget: anchor,
  13200. preventDefault: $.noop
  13201. } );
  13202. },
  13203. _findActive: function( index ) {
  13204. return index === false ? $() : this.tabs.eq( index );
  13205. },
  13206. _getIndex: function( index ) {
  13207. // meta-function to give users option to provide a href string instead of a numerical index.
  13208. if ( typeof index === "string" ) {
  13209. index = this.anchors.index( this.anchors.filter( "[href$='" +
  13210. $.escapeSelector( index ) + "']" ) );
  13211. }
  13212. return index;
  13213. },
  13214. _destroy: function() {
  13215. if ( this.xhr ) {
  13216. this.xhr.abort();
  13217. }
  13218. this.tablist
  13219. .removeAttr( "role" )
  13220. .off( this.eventNamespace );
  13221. this.anchors
  13222. .removeAttr( "role tabIndex" )
  13223. .removeUniqueId();
  13224. this.tabs.add( this.panels ).each( function() {
  13225. if ( $.data( this, "ui-tabs-destroy" ) ) {
  13226. $( this ).remove();
  13227. } else {
  13228. $( this ).removeAttr( "role tabIndex " +
  13229. "aria-live aria-busy aria-selected aria-labelledby aria-hidden aria-expanded" );
  13230. }
  13231. } );
  13232. this.tabs.each( function() {
  13233. var li = $( this ),
  13234. prev = li.data( "ui-tabs-aria-controls" );
  13235. if ( prev ) {
  13236. li
  13237. .attr( "aria-controls", prev )
  13238. .removeData( "ui-tabs-aria-controls" );
  13239. } else {
  13240. li.removeAttr( "aria-controls" );
  13241. }
  13242. } );
  13243. this.panels.show();
  13244. if ( this.options.heightStyle !== "content" ) {
  13245. this.panels.css( "height", "" );
  13246. }
  13247. },
  13248. enable: function( index ) {
  13249. var disabled = this.options.disabled;
  13250. if ( disabled === false ) {
  13251. return;
  13252. }
  13253. if ( index === undefined ) {
  13254. disabled = false;
  13255. } else {
  13256. index = this._getIndex( index );
  13257. if ( Array.isArray( disabled ) ) {
  13258. disabled = $.map( disabled, function( num ) {
  13259. return num !== index ? num : null;
  13260. } );
  13261. } else {
  13262. disabled = $.map( this.tabs, function( li, num ) {
  13263. return num !== index ? num : null;
  13264. } );
  13265. }
  13266. }
  13267. this._setOptionDisabled( disabled );
  13268. },
  13269. disable: function( index ) {
  13270. var disabled = this.options.disabled;
  13271. if ( disabled === true ) {
  13272. return;
  13273. }
  13274. if ( index === undefined ) {
  13275. disabled = true;
  13276. } else {
  13277. index = this._getIndex( index );
  13278. if ( $.inArray( index, disabled ) !== -1 ) {
  13279. return;
  13280. }
  13281. if ( Array.isArray( disabled ) ) {
  13282. disabled = $.merge( [ index ], disabled ).sort();
  13283. } else {
  13284. disabled = [ index ];
  13285. }
  13286. }
  13287. this._setOptionDisabled( disabled );
  13288. },
  13289. load: function( index, event ) {
  13290. index = this._getIndex( index );
  13291. var that = this,
  13292. tab = this.tabs.eq( index ),
  13293. anchor = tab.find( ".ui-tabs-anchor" ),
  13294. panel = this._getPanelForTab( tab ),
  13295. eventData = {
  13296. tab: tab,
  13297. panel: panel
  13298. },
  13299. complete = function( jqXHR, status ) {
  13300. if ( status === "abort" ) {
  13301. that.panels.stop( false, true );
  13302. }
  13303. that._removeClass( tab, "ui-tabs-loading" );
  13304. panel.removeAttr( "aria-busy" );
  13305. if ( jqXHR === that.xhr ) {
  13306. delete that.xhr;
  13307. }
  13308. };
  13309. // Not remote
  13310. if ( this._isLocal( anchor[ 0 ] ) ) {
  13311. return;
  13312. }
  13313. this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
  13314. // Support: jQuery <1.8
  13315. // jQuery <1.8 returns false if the request is canceled in beforeSend,
  13316. // but as of 1.8, $.ajax() always returns a jqXHR object.
  13317. if ( this.xhr && this.xhr.statusText !== "canceled" ) {
  13318. this._addClass( tab, "ui-tabs-loading" );
  13319. panel.attr( "aria-busy", "true" );
  13320. this.xhr
  13321. .done( function( response, status, jqXHR ) {
  13322. // support: jQuery <1.8
  13323. // http://bugs.jquery.com/ticket/11778
  13324. setTimeout( function() {
  13325. panel.html( response );
  13326. that._trigger( "load", event, eventData );
  13327. complete( jqXHR, status );
  13328. }, 1 );
  13329. } )
  13330. .fail( function( jqXHR, status ) {
  13331. // support: jQuery <1.8
  13332. // http://bugs.jquery.com/ticket/11778
  13333. setTimeout( function() {
  13334. complete( jqXHR, status );
  13335. }, 1 );
  13336. } );
  13337. }
  13338. },
  13339. _ajaxSettings: function( anchor, event, eventData ) {
  13340. var that = this;
  13341. return {
  13342. // Support: IE <11 only
  13343. // Strip any hash that exists to prevent errors with the Ajax request
  13344. url: anchor.attr( "href" ).replace( /#.*$/, "" ),
  13345. beforeSend: function( jqXHR, settings ) {
  13346. return that._trigger( "beforeLoad", event,
  13347. $.extend( { jqXHR: jqXHR, ajaxSettings: settings }, eventData ) );
  13348. }
  13349. };
  13350. },
  13351. _getPanelForTab: function( tab ) {
  13352. var id = $( tab ).attr( "aria-controls" );
  13353. return this.element.find( this._sanitizeSelector( "#" + id ) );
  13354. }
  13355. } );
  13356. // DEPRECATED
  13357. // TODO: Switch return back to widget declaration at top of file when this is removed
  13358. if ( $.uiBackCompat !== false ) {
  13359. // Backcompat for ui-tab class (now ui-tabs-tab)
  13360. $.widget( "ui.tabs", $.ui.tabs, {
  13361. _processTabs: function() {
  13362. this._superApply( arguments );
  13363. this._addClass( this.tabs, "ui-tab" );
  13364. }
  13365. } );
  13366. }
  13367. var widgetsTabs = $.ui.tabs;
  13368. /*!
  13369. * jQuery UI Tooltip 1.13.0
  13370. * http://jqueryui.com
  13371. *
  13372. * Copyright jQuery Foundation and other contributors
  13373. * Released under the MIT license.
  13374. * http://jquery.org/license
  13375. */
  13376. //>>label: Tooltip
  13377. //>>group: Widgets
  13378. //>>description: Shows additional information for any element on hover or focus.
  13379. //>>docs: http://api.jqueryui.com/tooltip/
  13380. //>>demos: http://jqueryui.com/tooltip/
  13381. //>>css.structure: ../../themes/base/core.css
  13382. //>>css.structure: ../../themes/base/tooltip.css
  13383. //>>css.theme: ../../themes/base/theme.css
  13384. $.widget( "ui.tooltip", {
  13385. version: "1.13.0",
  13386. options: {
  13387. classes: {
  13388. "ui-tooltip": "ui-corner-all ui-widget-shadow"
  13389. },
  13390. content: function() {
  13391. var title = $( this ).attr( "title" );
  13392. // Escape title, since we're going from an attribute to raw HTML
  13393. return $( "<a>" ).text( title ).html();
  13394. },
  13395. hide: true,
  13396. // Disabled elements have inconsistent behavior across browsers (#8661)
  13397. items: "[title]:not([disabled])",
  13398. position: {
  13399. my: "left top+15",
  13400. at: "left bottom",
  13401. collision: "flipfit flip"
  13402. },
  13403. show: true,
  13404. track: false,
  13405. // Callbacks
  13406. close: null,
  13407. open: null
  13408. },
  13409. _addDescribedBy: function( elem, id ) {
  13410. var describedby = ( elem.attr( "aria-describedby" ) || "" ).split( /\s+/ );
  13411. describedby.push( id );
  13412. elem
  13413. .data( "ui-tooltip-id", id )
  13414. .attr( "aria-describedby", String.prototype.trim.call( describedby.join( " " ) ) );
  13415. },
  13416. _removeDescribedBy: function( elem ) {
  13417. var id = elem.data( "ui-tooltip-id" ),
  13418. describedby = ( elem.attr( "aria-describedby" ) || "" ).split( /\s+/ ),
  13419. index = $.inArray( id, describedby );
  13420. if ( index !== -1 ) {
  13421. describedby.splice( index, 1 );
  13422. }
  13423. elem.removeData( "ui-tooltip-id" );
  13424. describedby = String.prototype.trim.call( describedby.join( " " ) );
  13425. if ( describedby ) {
  13426. elem.attr( "aria-describedby", describedby );
  13427. } else {
  13428. elem.removeAttr( "aria-describedby" );
  13429. }
  13430. },
  13431. _create: function() {
  13432. this._on( {
  13433. mouseover: "open",
  13434. focusin: "open"
  13435. } );
  13436. // IDs of generated tooltips, needed for destroy
  13437. this.tooltips = {};
  13438. // IDs of parent tooltips where we removed the title attribute
  13439. this.parents = {};
  13440. // Append the aria-live region so tooltips announce correctly
  13441. this.liveRegion = $( "<div>" )
  13442. .attr( {
  13443. role: "log",
  13444. "aria-live": "assertive",
  13445. "aria-relevant": "additions"
  13446. } )
  13447. .appendTo( this.document[ 0 ].body );
  13448. this._addClass( this.liveRegion, null, "ui-helper-hidden-accessible" );
  13449. this.disabledTitles = $( [] );
  13450. },
  13451. _setOption: function( key, value ) {
  13452. var that = this;
  13453. this._super( key, value );
  13454. if ( key === "content" ) {
  13455. $.each( this.tooltips, function( id, tooltipData ) {
  13456. that._updateContent( tooltipData.element );
  13457. } );
  13458. }
  13459. },
  13460. _setOptionDisabled: function( value ) {
  13461. this[ value ? "_disable" : "_enable" ]();
  13462. },
  13463. _disable: function() {
  13464. var that = this;
  13465. // Close open tooltips
  13466. $.each( this.tooltips, function( id, tooltipData ) {
  13467. var event = $.Event( "blur" );
  13468. event.target = event.currentTarget = tooltipData.element[ 0 ];
  13469. that.close( event, true );
  13470. } );
  13471. // Remove title attributes to prevent native tooltips
  13472. this.disabledTitles = this.disabledTitles.add(
  13473. this.element.find( this.options.items ).addBack()
  13474. .filter( function() {
  13475. var element = $( this );
  13476. if ( element.is( "[title]" ) ) {
  13477. return element
  13478. .data( "ui-tooltip-title", element.attr( "title" ) )
  13479. .removeAttr( "title" );
  13480. }
  13481. } )
  13482. );
  13483. },
  13484. _enable: function() {
  13485. // restore title attributes
  13486. this.disabledTitles.each( function() {
  13487. var element = $( this );
  13488. if ( element.data( "ui-tooltip-title" ) ) {
  13489. element.attr( "title", element.data( "ui-tooltip-title" ) );
  13490. }
  13491. } );
  13492. this.disabledTitles = $( [] );
  13493. },
  13494. open: function( event ) {
  13495. var that = this,
  13496. target = $( event ? event.target : this.element )
  13497. // we need closest here due to mouseover bubbling,
  13498. // but always pointing at the same event target
  13499. .closest( this.options.items );
  13500. // No element to show a tooltip for or the tooltip is already open
  13501. if ( !target.length || target.data( "ui-tooltip-id" ) ) {
  13502. return;
  13503. }
  13504. if ( target.attr( "title" ) ) {
  13505. target.data( "ui-tooltip-title", target.attr( "title" ) );
  13506. }
  13507. target.data( "ui-tooltip-open", true );
  13508. // Kill parent tooltips, custom or native, for hover
  13509. if ( event && event.type === "mouseover" ) {
  13510. target.parents().each( function() {
  13511. var parent = $( this ),
  13512. blurEvent;
  13513. if ( parent.data( "ui-tooltip-open" ) ) {
  13514. blurEvent = $.Event( "blur" );
  13515. blurEvent.target = blurEvent.currentTarget = this;
  13516. that.close( blurEvent, true );
  13517. }
  13518. if ( parent.attr( "title" ) ) {
  13519. parent.uniqueId();
  13520. that.parents[ this.id ] = {
  13521. element: this,
  13522. title: parent.attr( "title" )
  13523. };
  13524. parent.attr( "title", "" );
  13525. }
  13526. } );
  13527. }
  13528. this._registerCloseHandlers( event, target );
  13529. this._updateContent( target, event );
  13530. },
  13531. _updateContent: function( target, event ) {
  13532. var content,
  13533. contentOption = this.options.content,
  13534. that = this,
  13535. eventType = event ? event.type : null;
  13536. if ( typeof contentOption === "string" || contentOption.nodeType ||
  13537. contentOption.jquery ) {
  13538. return this._open( event, target, contentOption );
  13539. }
  13540. content = contentOption.call( target[ 0 ], function( response ) {
  13541. // IE may instantly serve a cached response for ajax requests
  13542. // delay this call to _open so the other call to _open runs first
  13543. that._delay( function() {
  13544. // Ignore async response if tooltip was closed already
  13545. if ( !target.data( "ui-tooltip-open" ) ) {
  13546. return;
  13547. }
  13548. // JQuery creates a special event for focusin when it doesn't
  13549. // exist natively. To improve performance, the native event
  13550. // object is reused and the type is changed. Therefore, we can't
  13551. // rely on the type being correct after the event finished
  13552. // bubbling, so we set it back to the previous value. (#8740)
  13553. if ( event ) {
  13554. event.type = eventType;
  13555. }
  13556. this._open( event, target, response );
  13557. } );
  13558. } );
  13559. if ( content ) {
  13560. this._open( event, target, content );
  13561. }
  13562. },
  13563. _open: function( event, target, content ) {
  13564. var tooltipData, tooltip, delayedShow, a11yContent,
  13565. positionOption = $.extend( {}, this.options.position );
  13566. if ( !content ) {
  13567. return;
  13568. }
  13569. // Content can be updated multiple times. If the tooltip already
  13570. // exists, then just update the content and bail.
  13571. tooltipData = this._find( target );
  13572. if ( tooltipData ) {
  13573. tooltipData.tooltip.find( ".ui-tooltip-content" ).html( content );
  13574. return;
  13575. }
  13576. // If we have a title, clear it to prevent the native tooltip
  13577. // we have to check first to avoid defining a title if none exists
  13578. // (we don't want to cause an element to start matching [title])
  13579. //
  13580. // We use removeAttr only for key events, to allow IE to export the correct
  13581. // accessible attributes. For mouse events, set to empty string to avoid
  13582. // native tooltip showing up (happens only when removing inside mouseover).
  13583. if ( target.is( "[title]" ) ) {
  13584. if ( event && event.type === "mouseover" ) {
  13585. target.attr( "title", "" );
  13586. } else {
  13587. target.removeAttr( "title" );
  13588. }
  13589. }
  13590. tooltipData = this._tooltip( target );
  13591. tooltip = tooltipData.tooltip;
  13592. this._addDescribedBy( target, tooltip.attr( "id" ) );
  13593. tooltip.find( ".ui-tooltip-content" ).html( content );
  13594. // Support: Voiceover on OS X, JAWS on IE <= 9
  13595. // JAWS announces deletions even when aria-relevant="additions"
  13596. // Voiceover will sometimes re-read the entire log region's contents from the beginning
  13597. this.liveRegion.children().hide();
  13598. a11yContent = $( "<div>" ).html( tooltip.find( ".ui-tooltip-content" ).html() );
  13599. a11yContent.removeAttr( "name" ).find( "[name]" ).removeAttr( "name" );
  13600. a11yContent.removeAttr( "id" ).find( "[id]" ).removeAttr( "id" );
  13601. a11yContent.appendTo( this.liveRegion );
  13602. function position( event ) {
  13603. positionOption.of = event;
  13604. if ( tooltip.is( ":hidden" ) ) {
  13605. return;
  13606. }
  13607. tooltip.position( positionOption );
  13608. }
  13609. if ( this.options.track && event && /^mouse/.test( event.type ) ) {
  13610. this._on( this.document, {
  13611. mousemove: position
  13612. } );
  13613. // trigger once to override element-relative positioning
  13614. position( event );
  13615. } else {
  13616. tooltip.position( $.extend( {
  13617. of: target
  13618. }, this.options.position ) );
  13619. }
  13620. tooltip.hide();
  13621. this._show( tooltip, this.options.show );
  13622. // Handle tracking tooltips that are shown with a delay (#8644). As soon
  13623. // as the tooltip is visible, position the tooltip using the most recent
  13624. // event.
  13625. // Adds the check to add the timers only when both delay and track options are set (#14682)
  13626. if ( this.options.track && this.options.show && this.options.show.delay ) {
  13627. delayedShow = this.delayedShow = setInterval( function() {
  13628. if ( tooltip.is( ":visible" ) ) {
  13629. position( positionOption.of );
  13630. clearInterval( delayedShow );
  13631. }
  13632. }, 13 );
  13633. }
  13634. this._trigger( "open", event, { tooltip: tooltip } );
  13635. },
  13636. _registerCloseHandlers: function( event, target ) {
  13637. var events = {
  13638. keyup: function( event ) {
  13639. if ( event.keyCode === $.ui.keyCode.ESCAPE ) {
  13640. var fakeEvent = $.Event( event );
  13641. fakeEvent.currentTarget = target[ 0 ];
  13642. this.close( fakeEvent, true );
  13643. }
  13644. }
  13645. };
  13646. // Only bind remove handler for delegated targets. Non-delegated
  13647. // tooltips will handle this in destroy.
  13648. if ( target[ 0 ] !== this.element[ 0 ] ) {
  13649. events.remove = function() {
  13650. this._removeTooltip( this._find( target ).tooltip );
  13651. };
  13652. }
  13653. if ( !event || event.type === "mouseover" ) {
  13654. events.mouseleave = "close";
  13655. }
  13656. if ( !event || event.type === "focusin" ) {
  13657. events.focusout = "close";
  13658. }
  13659. this._on( true, target, events );
  13660. },
  13661. close: function( event ) {
  13662. var tooltip,
  13663. that = this,
  13664. target = $( event ? event.currentTarget : this.element ),
  13665. tooltipData = this._find( target );
  13666. // The tooltip may already be closed
  13667. if ( !tooltipData ) {
  13668. // We set ui-tooltip-open immediately upon open (in open()), but only set the
  13669. // additional data once there's actually content to show (in _open()). So even if the
  13670. // tooltip doesn't have full data, we always remove ui-tooltip-open in case we're in
  13671. // the period between open() and _open().
  13672. target.removeData( "ui-tooltip-open" );
  13673. return;
  13674. }
  13675. tooltip = tooltipData.tooltip;
  13676. // Disabling closes the tooltip, so we need to track when we're closing
  13677. // to avoid an infinite loop in case the tooltip becomes disabled on close
  13678. if ( tooltipData.closing ) {
  13679. return;
  13680. }
  13681. // Clear the interval for delayed tracking tooltips
  13682. clearInterval( this.delayedShow );
  13683. // Only set title if we had one before (see comment in _open())
  13684. // If the title attribute has changed since open(), don't restore
  13685. if ( target.data( "ui-tooltip-title" ) && !target.attr( "title" ) ) {
  13686. target.attr( "title", target.data( "ui-tooltip-title" ) );
  13687. }
  13688. this._removeDescribedBy( target );
  13689. tooltipData.hiding = true;
  13690. tooltip.stop( true );
  13691. this._hide( tooltip, this.options.hide, function() {
  13692. that._removeTooltip( $( this ) );
  13693. } );
  13694. target.removeData( "ui-tooltip-open" );
  13695. this._off( target, "mouseleave focusout keyup" );
  13696. // Remove 'remove' binding only on delegated targets
  13697. if ( target[ 0 ] !== this.element[ 0 ] ) {
  13698. this._off( target, "remove" );
  13699. }
  13700. this._off( this.document, "mousemove" );
  13701. if ( event && event.type === "mouseleave" ) {
  13702. $.each( this.parents, function( id, parent ) {
  13703. $( parent.element ).attr( "title", parent.title );
  13704. delete that.parents[ id ];
  13705. } );
  13706. }
  13707. tooltipData.closing = true;
  13708. this._trigger( "close", event, { tooltip: tooltip } );
  13709. if ( !tooltipData.hiding ) {
  13710. tooltipData.closing = false;
  13711. }
  13712. },
  13713. _tooltip: function( element ) {
  13714. var tooltip = $( "<div>" ).attr( "role", "tooltip" ),
  13715. content = $( "<div>" ).appendTo( tooltip ),
  13716. id = tooltip.uniqueId().attr( "id" );
  13717. this._addClass( content, "ui-tooltip-content" );
  13718. this._addClass( tooltip, "ui-tooltip", "ui-widget ui-widget-content" );
  13719. tooltip.appendTo( this._appendTo( element ) );
  13720. return this.tooltips[ id ] = {
  13721. element: element,
  13722. tooltip: tooltip
  13723. };
  13724. },
  13725. _find: function( target ) {
  13726. var id = target.data( "ui-tooltip-id" );
  13727. return id ? this.tooltips[ id ] : null;
  13728. },
  13729. _removeTooltip: function( tooltip ) {
  13730. // Clear the interval for delayed tracking tooltips
  13731. clearInterval( this.delayedShow );
  13732. tooltip.remove();
  13733. delete this.tooltips[ tooltip.attr( "id" ) ];
  13734. },
  13735. _appendTo: function( target ) {
  13736. var element = target.closest( ".ui-front, dialog" );
  13737. if ( !element.length ) {
  13738. element = this.document[ 0 ].body;
  13739. }
  13740. return element;
  13741. },
  13742. _destroy: function() {
  13743. var that = this;
  13744. // Close open tooltips
  13745. $.each( this.tooltips, function( id, tooltipData ) {
  13746. // Delegate to close method to handle common cleanup
  13747. var event = $.Event( "blur" ),
  13748. element = tooltipData.element;
  13749. event.target = event.currentTarget = element[ 0 ];
  13750. that.close( event, true );
  13751. // Remove immediately; destroying an open tooltip doesn't use the
  13752. // hide animation
  13753. $( "#" + id ).remove();
  13754. // Restore the title
  13755. if ( element.data( "ui-tooltip-title" ) ) {
  13756. // If the title attribute has changed since open(), don't restore
  13757. if ( !element.attr( "title" ) ) {
  13758. element.attr( "title", element.data( "ui-tooltip-title" ) );
  13759. }
  13760. element.removeData( "ui-tooltip-title" );
  13761. }
  13762. } );
  13763. this.liveRegion.remove();
  13764. }
  13765. } );
  13766. // DEPRECATED
  13767. // TODO: Switch return back to widget declaration at top of file when this is removed
  13768. if ( $.uiBackCompat !== false ) {
  13769. // Backcompat for tooltipClass option
  13770. $.widget( "ui.tooltip", $.ui.tooltip, {
  13771. options: {
  13772. tooltipClass: null
  13773. },
  13774. _tooltip: function() {
  13775. var tooltipData = this._superApply( arguments );
  13776. if ( this.options.tooltipClass ) {
  13777. tooltipData.tooltip.addClass( this.options.tooltipClass );
  13778. }
  13779. return tooltipData;
  13780. }
  13781. } );
  13782. }
  13783. var widgetsTooltip = $.ui.tooltip;
  13784. // Create a local jQuery because jQuery Color relies on it and the
  13785. // global may not exist with AMD and a custom build (#10199).
  13786. // This module is a noop if used as a regular AMD module.
  13787. // eslint-disable-next-line no-unused-vars
  13788. var jQuery = $;
  13789. /*!
  13790. * jQuery Color Animations v2.2.0
  13791. * https://github.com/jquery/jquery-color
  13792. *
  13793. * Copyright OpenJS Foundation and other contributors
  13794. * Released under the MIT license.
  13795. * http://jquery.org/license
  13796. *
  13797. * Date: Sun May 10 09:02:36 2020 +0200
  13798. */
  13799. var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor " +
  13800. "borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
  13801. class2type = {},
  13802. toString = class2type.toString,
  13803. // plusequals test for += 100 -= 100
  13804. rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
  13805. // a set of RE's that can match strings and generate color tuples.
  13806. stringParsers = [ {
  13807. re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  13808. parse: function( execResult ) {
  13809. return [
  13810. execResult[ 1 ],
  13811. execResult[ 2 ],
  13812. execResult[ 3 ],
  13813. execResult[ 4 ]
  13814. ];
  13815. }
  13816. }, {
  13817. re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  13818. parse: function( execResult ) {
  13819. return [
  13820. execResult[ 1 ] * 2.55,
  13821. execResult[ 2 ] * 2.55,
  13822. execResult[ 3 ] * 2.55,
  13823. execResult[ 4 ]
  13824. ];
  13825. }
  13826. }, {
  13827. // this regex ignores A-F because it's compared against an already lowercased string
  13828. re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})?/,
  13829. parse: function( execResult ) {
  13830. return [
  13831. parseInt( execResult[ 1 ], 16 ),
  13832. parseInt( execResult[ 2 ], 16 ),
  13833. parseInt( execResult[ 3 ], 16 ),
  13834. execResult[ 4 ] ?
  13835. ( parseInt( execResult[ 4 ], 16 ) / 255 ).toFixed( 2 ) :
  13836. 1
  13837. ];
  13838. }
  13839. }, {
  13840. // this regex ignores A-F because it's compared against an already lowercased string
  13841. re: /#([a-f0-9])([a-f0-9])([a-f0-9])([a-f0-9])?/,
  13842. parse: function( execResult ) {
  13843. return [
  13844. parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
  13845. parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
  13846. parseInt( execResult[ 3 ] + execResult[ 3 ], 16 ),
  13847. execResult[ 4 ] ?
  13848. ( parseInt( execResult[ 4 ] + execResult[ 4 ], 16 ) / 255 )
  13849. .toFixed( 2 ) :
  13850. 1
  13851. ];
  13852. }
  13853. }, {
  13854. re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  13855. space: "hsla",
  13856. parse: function( execResult ) {
  13857. return [
  13858. execResult[ 1 ],
  13859. execResult[ 2 ] / 100,
  13860. execResult[ 3 ] / 100,
  13861. execResult[ 4 ]
  13862. ];
  13863. }
  13864. } ],
  13865. // jQuery.Color( )
  13866. color = jQuery.Color = function( color, green, blue, alpha ) {
  13867. return new jQuery.Color.fn.parse( color, green, blue, alpha );
  13868. },
  13869. spaces = {
  13870. rgba: {
  13871. props: {
  13872. red: {
  13873. idx: 0,
  13874. type: "byte"
  13875. },
  13876. green: {
  13877. idx: 1,
  13878. type: "byte"
  13879. },
  13880. blue: {
  13881. idx: 2,
  13882. type: "byte"
  13883. }
  13884. }
  13885. },
  13886. hsla: {
  13887. props: {
  13888. hue: {
  13889. idx: 0,
  13890. type: "degrees"
  13891. },
  13892. saturation: {
  13893. idx: 1,
  13894. type: "percent"
  13895. },
  13896. lightness: {
  13897. idx: 2,
  13898. type: "percent"
  13899. }
  13900. }
  13901. }
  13902. },
  13903. propTypes = {
  13904. "byte": {
  13905. floor: true,
  13906. max: 255
  13907. },
  13908. "percent": {
  13909. max: 1
  13910. },
  13911. "degrees": {
  13912. mod: 360,
  13913. floor: true
  13914. }
  13915. },
  13916. support = color.support = {},
  13917. // element for support tests
  13918. supportElem = jQuery( "<p>" )[ 0 ],
  13919. // colors = jQuery.Color.names
  13920. colors,
  13921. // local aliases of functions called often
  13922. each = jQuery.each;
  13923. // determine rgba support immediately
  13924. supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
  13925. support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
  13926. // define cache name and alpha properties
  13927. // for rgba and hsla spaces
  13928. each( spaces, function( spaceName, space ) {
  13929. space.cache = "_" + spaceName;
  13930. space.props.alpha = {
  13931. idx: 3,
  13932. type: "percent",
  13933. def: 1
  13934. };
  13935. } );
  13936. // Populate the class2type map
  13937. jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
  13938. function( _i, name ) {
  13939. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  13940. } );
  13941. function getType( obj ) {
  13942. if ( obj == null ) {
  13943. return obj + "";
  13944. }
  13945. return typeof obj === "object" ?
  13946. class2type[ toString.call( obj ) ] || "object" :
  13947. typeof obj;
  13948. }
  13949. function clamp( value, prop, allowEmpty ) {
  13950. var type = propTypes[ prop.type ] || {};
  13951. if ( value == null ) {
  13952. return ( allowEmpty || !prop.def ) ? null : prop.def;
  13953. }
  13954. // ~~ is an short way of doing floor for positive numbers
  13955. value = type.floor ? ~~value : parseFloat( value );
  13956. // IE will pass in empty strings as value for alpha,
  13957. // which will hit this case
  13958. if ( isNaN( value ) ) {
  13959. return prop.def;
  13960. }
  13961. if ( type.mod ) {
  13962. // we add mod before modding to make sure that negatives values
  13963. // get converted properly: -10 -> 350
  13964. return ( value + type.mod ) % type.mod;
  13965. }
  13966. // for now all property types without mod have min and max
  13967. return Math.min( type.max, Math.max( 0, value ) );
  13968. }
  13969. function stringParse( string ) {
  13970. var inst = color(),
  13971. rgba = inst._rgba = [];
  13972. string = string.toLowerCase();
  13973. each( stringParsers, function( _i, parser ) {
  13974. var parsed,
  13975. match = parser.re.exec( string ),
  13976. values = match && parser.parse( match ),
  13977. spaceName = parser.space || "rgba";
  13978. if ( values ) {
  13979. parsed = inst[ spaceName ]( values );
  13980. // if this was an rgba parse the assignment might happen twice
  13981. // oh well....
  13982. inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
  13983. rgba = inst._rgba = parsed._rgba;
  13984. // exit each( stringParsers ) here because we matched
  13985. return false;
  13986. }
  13987. } );
  13988. // Found a stringParser that handled it
  13989. if ( rgba.length ) {
  13990. // if this came from a parsed string, force "transparent" when alpha is 0
  13991. // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
  13992. if ( rgba.join() === "0,0,0,0" ) {
  13993. jQuery.extend( rgba, colors.transparent );
  13994. }
  13995. return inst;
  13996. }
  13997. // named colors
  13998. return colors[ string ];
  13999. }
  14000. color.fn = jQuery.extend( color.prototype, {
  14001. parse: function( red, green, blue, alpha ) {
  14002. if ( red === undefined ) {
  14003. this._rgba = [ null, null, null, null ];
  14004. return this;
  14005. }
  14006. if ( red.jquery || red.nodeType ) {
  14007. red = jQuery( red ).css( green );
  14008. green = undefined;
  14009. }
  14010. var inst = this,
  14011. type = getType( red ),
  14012. rgba = this._rgba = [];
  14013. // more than 1 argument specified - assume ( red, green, blue, alpha )
  14014. if ( green !== undefined ) {
  14015. red = [ red, green, blue, alpha ];
  14016. type = "array";
  14017. }
  14018. if ( type === "string" ) {
  14019. return this.parse( stringParse( red ) || colors._default );
  14020. }
  14021. if ( type === "array" ) {
  14022. each( spaces.rgba.props, function( _key, prop ) {
  14023. rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
  14024. } );
  14025. return this;
  14026. }
  14027. if ( type === "object" ) {
  14028. if ( red instanceof color ) {
  14029. each( spaces, function( _spaceName, space ) {
  14030. if ( red[ space.cache ] ) {
  14031. inst[ space.cache ] = red[ space.cache ].slice();
  14032. }
  14033. } );
  14034. } else {
  14035. each( spaces, function( _spaceName, space ) {
  14036. var cache = space.cache;
  14037. each( space.props, function( key, prop ) {
  14038. // if the cache doesn't exist, and we know how to convert
  14039. if ( !inst[ cache ] && space.to ) {
  14040. // if the value was null, we don't need to copy it
  14041. // if the key was alpha, we don't need to copy it either
  14042. if ( key === "alpha" || red[ key ] == null ) {
  14043. return;
  14044. }
  14045. inst[ cache ] = space.to( inst._rgba );
  14046. }
  14047. // this is the only case where we allow nulls for ALL properties.
  14048. // call clamp with alwaysAllowEmpty
  14049. inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
  14050. } );
  14051. // everything defined but alpha?
  14052. if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
  14053. // use the default of 1
  14054. if ( inst[ cache ][ 3 ] == null ) {
  14055. inst[ cache ][ 3 ] = 1;
  14056. }
  14057. if ( space.from ) {
  14058. inst._rgba = space.from( inst[ cache ] );
  14059. }
  14060. }
  14061. } );
  14062. }
  14063. return this;
  14064. }
  14065. },
  14066. is: function( compare ) {
  14067. var is = color( compare ),
  14068. same = true,
  14069. inst = this;
  14070. each( spaces, function( _, space ) {
  14071. var localCache,
  14072. isCache = is[ space.cache ];
  14073. if ( isCache ) {
  14074. localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
  14075. each( space.props, function( _, prop ) {
  14076. if ( isCache[ prop.idx ] != null ) {
  14077. same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
  14078. return same;
  14079. }
  14080. } );
  14081. }
  14082. return same;
  14083. } );
  14084. return same;
  14085. },
  14086. _space: function() {
  14087. var used = [],
  14088. inst = this;
  14089. each( spaces, function( spaceName, space ) {
  14090. if ( inst[ space.cache ] ) {
  14091. used.push( spaceName );
  14092. }
  14093. } );
  14094. return used.pop();
  14095. },
  14096. transition: function( other, distance ) {
  14097. var end = color( other ),
  14098. spaceName = end._space(),
  14099. space = spaces[ spaceName ],
  14100. startColor = this.alpha() === 0 ? color( "transparent" ) : this,
  14101. start = startColor[ space.cache ] || space.to( startColor._rgba ),
  14102. result = start.slice();
  14103. end = end[ space.cache ];
  14104. each( space.props, function( _key, prop ) {
  14105. var index = prop.idx,
  14106. startValue = start[ index ],
  14107. endValue = end[ index ],
  14108. type = propTypes[ prop.type ] || {};
  14109. // if null, don't override start value
  14110. if ( endValue === null ) {
  14111. return;
  14112. }
  14113. // if null - use end
  14114. if ( startValue === null ) {
  14115. result[ index ] = endValue;
  14116. } else {
  14117. if ( type.mod ) {
  14118. if ( endValue - startValue > type.mod / 2 ) {
  14119. startValue += type.mod;
  14120. } else if ( startValue - endValue > type.mod / 2 ) {
  14121. startValue -= type.mod;
  14122. }
  14123. }
  14124. result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
  14125. }
  14126. } );
  14127. return this[ spaceName ]( result );
  14128. },
  14129. blend: function( opaque ) {
  14130. // if we are already opaque - return ourself
  14131. if ( this._rgba[ 3 ] === 1 ) {
  14132. return this;
  14133. }
  14134. var rgb = this._rgba.slice(),
  14135. a = rgb.pop(),
  14136. blend = color( opaque )._rgba;
  14137. return color( jQuery.map( rgb, function( v, i ) {
  14138. return ( 1 - a ) * blend[ i ] + a * v;
  14139. } ) );
  14140. },
  14141. toRgbaString: function() {
  14142. var prefix = "rgba(",
  14143. rgba = jQuery.map( this._rgba, function( v, i ) {
  14144. if ( v != null ) {
  14145. return v;
  14146. }
  14147. return i > 2 ? 1 : 0;
  14148. } );
  14149. if ( rgba[ 3 ] === 1 ) {
  14150. rgba.pop();
  14151. prefix = "rgb(";
  14152. }
  14153. return prefix + rgba.join() + ")";
  14154. },
  14155. toHslaString: function() {
  14156. var prefix = "hsla(",
  14157. hsla = jQuery.map( this.hsla(), function( v, i ) {
  14158. if ( v == null ) {
  14159. v = i > 2 ? 1 : 0;
  14160. }
  14161. // catch 1 and 2
  14162. if ( i && i < 3 ) {
  14163. v = Math.round( v * 100 ) + "%";
  14164. }
  14165. return v;
  14166. } );
  14167. if ( hsla[ 3 ] === 1 ) {
  14168. hsla.pop();
  14169. prefix = "hsl(";
  14170. }
  14171. return prefix + hsla.join() + ")";
  14172. },
  14173. toHexString: function( includeAlpha ) {
  14174. var rgba = this._rgba.slice(),
  14175. alpha = rgba.pop();
  14176. if ( includeAlpha ) {
  14177. rgba.push( ~~( alpha * 255 ) );
  14178. }
  14179. return "#" + jQuery.map( rgba, function( v ) {
  14180. // default to 0 when nulls exist
  14181. v = ( v || 0 ).toString( 16 );
  14182. return v.length === 1 ? "0" + v : v;
  14183. } ).join( "" );
  14184. },
  14185. toString: function() {
  14186. return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
  14187. }
  14188. } );
  14189. color.fn.parse.prototype = color.fn;
  14190. // hsla conversions adapted from:
  14191. // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
  14192. function hue2rgb( p, q, h ) {
  14193. h = ( h + 1 ) % 1;
  14194. if ( h * 6 < 1 ) {
  14195. return p + ( q - p ) * h * 6;
  14196. }
  14197. if ( h * 2 < 1 ) {
  14198. return q;
  14199. }
  14200. if ( h * 3 < 2 ) {
  14201. return p + ( q - p ) * ( ( 2 / 3 ) - h ) * 6;
  14202. }
  14203. return p;
  14204. }
  14205. spaces.hsla.to = function( rgba ) {
  14206. if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
  14207. return [ null, null, null, rgba[ 3 ] ];
  14208. }
  14209. var r = rgba[ 0 ] / 255,
  14210. g = rgba[ 1 ] / 255,
  14211. b = rgba[ 2 ] / 255,
  14212. a = rgba[ 3 ],
  14213. max = Math.max( r, g, b ),
  14214. min = Math.min( r, g, b ),
  14215. diff = max - min,
  14216. add = max + min,
  14217. l = add * 0.5,
  14218. h, s;
  14219. if ( min === max ) {
  14220. h = 0;
  14221. } else if ( r === max ) {
  14222. h = ( 60 * ( g - b ) / diff ) + 360;
  14223. } else if ( g === max ) {
  14224. h = ( 60 * ( b - r ) / diff ) + 120;
  14225. } else {
  14226. h = ( 60 * ( r - g ) / diff ) + 240;
  14227. }
  14228. // chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
  14229. // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
  14230. if ( diff === 0 ) {
  14231. s = 0;
  14232. } else if ( l <= 0.5 ) {
  14233. s = diff / add;
  14234. } else {
  14235. s = diff / ( 2 - add );
  14236. }
  14237. return [ Math.round( h ) % 360, s, l, a == null ? 1 : a ];
  14238. };
  14239. spaces.hsla.from = function( hsla ) {
  14240. if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
  14241. return [ null, null, null, hsla[ 3 ] ];
  14242. }
  14243. var h = hsla[ 0 ] / 360,
  14244. s = hsla[ 1 ],
  14245. l = hsla[ 2 ],
  14246. a = hsla[ 3 ],
  14247. q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
  14248. p = 2 * l - q;
  14249. return [
  14250. Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
  14251. Math.round( hue2rgb( p, q, h ) * 255 ),
  14252. Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
  14253. a
  14254. ];
  14255. };
  14256. each( spaces, function( spaceName, space ) {
  14257. var props = space.props,
  14258. cache = space.cache,
  14259. to = space.to,
  14260. from = space.from;
  14261. // makes rgba() and hsla()
  14262. color.fn[ spaceName ] = function( value ) {
  14263. // generate a cache for this space if it doesn't exist
  14264. if ( to && !this[ cache ] ) {
  14265. this[ cache ] = to( this._rgba );
  14266. }
  14267. if ( value === undefined ) {
  14268. return this[ cache ].slice();
  14269. }
  14270. var ret,
  14271. type = getType( value ),
  14272. arr = ( type === "array" || type === "object" ) ? value : arguments,
  14273. local = this[ cache ].slice();
  14274. each( props, function( key, prop ) {
  14275. var val = arr[ type === "object" ? key : prop.idx ];
  14276. if ( val == null ) {
  14277. val = local[ prop.idx ];
  14278. }
  14279. local[ prop.idx ] = clamp( val, prop );
  14280. } );
  14281. if ( from ) {
  14282. ret = color( from( local ) );
  14283. ret[ cache ] = local;
  14284. return ret;
  14285. } else {
  14286. return color( local );
  14287. }
  14288. };
  14289. // makes red() green() blue() alpha() hue() saturation() lightness()
  14290. each( props, function( key, prop ) {
  14291. // alpha is included in more than one space
  14292. if ( color.fn[ key ] ) {
  14293. return;
  14294. }
  14295. color.fn[ key ] = function( value ) {
  14296. var local, cur, match, fn,
  14297. vtype = getType( value );
  14298. if ( key === "alpha" ) {
  14299. fn = this._hsla ? "hsla" : "rgba";
  14300. } else {
  14301. fn = spaceName;
  14302. }
  14303. local = this[ fn ]();
  14304. cur = local[ prop.idx ];
  14305. if ( vtype === "undefined" ) {
  14306. return cur;
  14307. }
  14308. if ( vtype === "function" ) {
  14309. value = value.call( this, cur );
  14310. vtype = getType( value );
  14311. }
  14312. if ( value == null && prop.empty ) {
  14313. return this;
  14314. }
  14315. if ( vtype === "string" ) {
  14316. match = rplusequals.exec( value );
  14317. if ( match ) {
  14318. value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
  14319. }
  14320. }
  14321. local[ prop.idx ] = value;
  14322. return this[ fn ]( local );
  14323. };
  14324. } );
  14325. } );
  14326. // add cssHook and .fx.step function for each named hook.
  14327. // accept a space separated string of properties
  14328. color.hook = function( hook ) {
  14329. var hooks = hook.split( " " );
  14330. each( hooks, function( _i, hook ) {
  14331. jQuery.cssHooks[ hook ] = {
  14332. set: function( elem, value ) {
  14333. var parsed, curElem,
  14334. backgroundColor = "";
  14335. if ( value !== "transparent" && ( getType( value ) !== "string" || ( parsed = stringParse( value ) ) ) ) {
  14336. value = color( parsed || value );
  14337. if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
  14338. curElem = hook === "backgroundColor" ? elem.parentNode : elem;
  14339. while (
  14340. ( backgroundColor === "" || backgroundColor === "transparent" ) &&
  14341. curElem && curElem.style
  14342. ) {
  14343. try {
  14344. backgroundColor = jQuery.css( curElem, "backgroundColor" );
  14345. curElem = curElem.parentNode;
  14346. } catch ( e ) {
  14347. }
  14348. }
  14349. value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
  14350. backgroundColor :
  14351. "_default" );
  14352. }
  14353. value = value.toRgbaString();
  14354. }
  14355. try {
  14356. elem.style[ hook ] = value;
  14357. } catch ( e ) {
  14358. // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
  14359. }
  14360. }
  14361. };
  14362. jQuery.fx.step[ hook ] = function( fx ) {
  14363. if ( !fx.colorInit ) {
  14364. fx.start = color( fx.elem, hook );
  14365. fx.end = color( fx.end );
  14366. fx.colorInit = true;
  14367. }
  14368. jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
  14369. };
  14370. } );
  14371. };
  14372. color.hook( stepHooks );
  14373. jQuery.cssHooks.borderColor = {
  14374. expand: function( value ) {
  14375. var expanded = {};
  14376. each( [ "Top", "Right", "Bottom", "Left" ], function( _i, part ) {
  14377. expanded[ "border" + part + "Color" ] = value;
  14378. } );
  14379. return expanded;
  14380. }
  14381. };
  14382. // Basic color names only.
  14383. // Usage of any of the other color names requires adding yourself or including
  14384. // jquery.color.svg-names.js.
  14385. colors = jQuery.Color.names = {
  14386. // 4.1. Basic color keywords
  14387. aqua: "#00ffff",
  14388. black: "#000000",
  14389. blue: "#0000ff",
  14390. fuchsia: "#ff00ff",
  14391. gray: "#808080",
  14392. green: "#008000",
  14393. lime: "#00ff00",
  14394. maroon: "#800000",
  14395. navy: "#000080",
  14396. olive: "#808000",
  14397. purple: "#800080",
  14398. red: "#ff0000",
  14399. silver: "#c0c0c0",
  14400. teal: "#008080",
  14401. white: "#ffffff",
  14402. yellow: "#ffff00",
  14403. // 4.2.3. "transparent" color keyword
  14404. transparent: [ null, null, null, 0 ],
  14405. _default: "#ffffff"
  14406. };
  14407. /*!
  14408. * jQuery UI Effects 1.13.0
  14409. * http://jqueryui.com
  14410. *
  14411. * Copyright jQuery Foundation and other contributors
  14412. * Released under the MIT license.
  14413. * http://jquery.org/license
  14414. */
  14415. //>>label: Effects Core
  14416. //>>group: Effects
  14417. /* eslint-disable max-len */
  14418. //>>description: Extends the internal jQuery effects. Includes morphing and easing. Required by all other effects.
  14419. /* eslint-enable max-len */
  14420. //>>docs: http://api.jqueryui.com/category/effects-core/
  14421. //>>demos: http://jqueryui.com/effect/
  14422. var dataSpace = "ui-effects-",
  14423. dataSpaceStyle = "ui-effects-style",
  14424. dataSpaceAnimated = "ui-effects-animated";
  14425. $.effects = {
  14426. effect: {}
  14427. };
  14428. /******************************************************************************/
  14429. /****************************** CLASS ANIMATIONS ******************************/
  14430. /******************************************************************************/
  14431. ( function() {
  14432. var classAnimationActions = [ "add", "remove", "toggle" ],
  14433. shorthandStyles = {
  14434. border: 1,
  14435. borderBottom: 1,
  14436. borderColor: 1,
  14437. borderLeft: 1,
  14438. borderRight: 1,
  14439. borderTop: 1,
  14440. borderWidth: 1,
  14441. margin: 1,
  14442. padding: 1
  14443. };
  14444. $.each(
  14445. [ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ],
  14446. function( _, prop ) {
  14447. $.fx.step[ prop ] = function( fx ) {
  14448. if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
  14449. jQuery.style( fx.elem, prop, fx.end );
  14450. fx.setAttr = true;
  14451. }
  14452. };
  14453. }
  14454. );
  14455. function camelCase( string ) {
  14456. return string.replace( /-([\da-z])/gi, function( all, letter ) {
  14457. return letter.toUpperCase();
  14458. } );
  14459. }
  14460. function getElementStyles( elem ) {
  14461. var key, len,
  14462. style = elem.ownerDocument.defaultView ?
  14463. elem.ownerDocument.defaultView.getComputedStyle( elem, null ) :
  14464. elem.currentStyle,
  14465. styles = {};
  14466. if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
  14467. len = style.length;
  14468. while ( len-- ) {
  14469. key = style[ len ];
  14470. if ( typeof style[ key ] === "string" ) {
  14471. styles[ camelCase( key ) ] = style[ key ];
  14472. }
  14473. }
  14474. // Support: Opera, IE <9
  14475. } else {
  14476. for ( key in style ) {
  14477. if ( typeof style[ key ] === "string" ) {
  14478. styles[ key ] = style[ key ];
  14479. }
  14480. }
  14481. }
  14482. return styles;
  14483. }
  14484. function styleDifference( oldStyle, newStyle ) {
  14485. var diff = {},
  14486. name, value;
  14487. for ( name in newStyle ) {
  14488. value = newStyle[ name ];
  14489. if ( oldStyle[ name ] !== value ) {
  14490. if ( !shorthandStyles[ name ] ) {
  14491. if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
  14492. diff[ name ] = value;
  14493. }
  14494. }
  14495. }
  14496. }
  14497. return diff;
  14498. }
  14499. // Support: jQuery <1.8
  14500. if ( !$.fn.addBack ) {
  14501. $.fn.addBack = function( selector ) {
  14502. return this.add( selector == null ?
  14503. this.prevObject : this.prevObject.filter( selector )
  14504. );
  14505. };
  14506. }
  14507. $.effects.animateClass = function( value, duration, easing, callback ) {
  14508. var o = $.speed( duration, easing, callback );
  14509. return this.queue( function() {
  14510. var animated = $( this ),
  14511. baseClass = animated.attr( "class" ) || "",
  14512. applyClassChange,
  14513. allAnimations = o.children ? animated.find( "*" ).addBack() : animated;
  14514. // Map the animated objects to store the original styles.
  14515. allAnimations = allAnimations.map( function() {
  14516. var el = $( this );
  14517. return {
  14518. el: el,
  14519. start: getElementStyles( this )
  14520. };
  14521. } );
  14522. // Apply class change
  14523. applyClassChange = function() {
  14524. $.each( classAnimationActions, function( i, action ) {
  14525. if ( value[ action ] ) {
  14526. animated[ action + "Class" ]( value[ action ] );
  14527. }
  14528. } );
  14529. };
  14530. applyClassChange();
  14531. // Map all animated objects again - calculate new styles and diff
  14532. allAnimations = allAnimations.map( function() {
  14533. this.end = getElementStyles( this.el[ 0 ] );
  14534. this.diff = styleDifference( this.start, this.end );
  14535. return this;
  14536. } );
  14537. // Apply original class
  14538. animated.attr( "class", baseClass );
  14539. // Map all animated objects again - this time collecting a promise
  14540. allAnimations = allAnimations.map( function() {
  14541. var styleInfo = this,
  14542. dfd = $.Deferred(),
  14543. opts = $.extend( {}, o, {
  14544. queue: false,
  14545. complete: function() {
  14546. dfd.resolve( styleInfo );
  14547. }
  14548. } );
  14549. this.el.animate( this.diff, opts );
  14550. return dfd.promise();
  14551. } );
  14552. // Once all animations have completed:
  14553. $.when.apply( $, allAnimations.get() ).done( function() {
  14554. // Set the final class
  14555. applyClassChange();
  14556. // For each animated element,
  14557. // clear all css properties that were animated
  14558. $.each( arguments, function() {
  14559. var el = this.el;
  14560. $.each( this.diff, function( key ) {
  14561. el.css( key, "" );
  14562. } );
  14563. } );
  14564. // This is guarnteed to be there if you use jQuery.speed()
  14565. // it also handles dequeuing the next anim...
  14566. o.complete.call( animated[ 0 ] );
  14567. } );
  14568. } );
  14569. };
  14570. $.fn.extend( {
  14571. addClass: ( function( orig ) {
  14572. return function( classNames, speed, easing, callback ) {
  14573. return speed ?
  14574. $.effects.animateClass.call( this,
  14575. { add: classNames }, speed, easing, callback ) :
  14576. orig.apply( this, arguments );
  14577. };
  14578. } )( $.fn.addClass ),
  14579. removeClass: ( function( orig ) {
  14580. return function( classNames, speed, easing, callback ) {
  14581. return arguments.length > 1 ?
  14582. $.effects.animateClass.call( this,
  14583. { remove: classNames }, speed, easing, callback ) :
  14584. orig.apply( this, arguments );
  14585. };
  14586. } )( $.fn.removeClass ),
  14587. toggleClass: ( function( orig ) {
  14588. return function( classNames, force, speed, easing, callback ) {
  14589. if ( typeof force === "boolean" || force === undefined ) {
  14590. if ( !speed ) {
  14591. // Without speed parameter
  14592. return orig.apply( this, arguments );
  14593. } else {
  14594. return $.effects.animateClass.call( this,
  14595. ( force ? { add: classNames } : { remove: classNames } ),
  14596. speed, easing, callback );
  14597. }
  14598. } else {
  14599. // Without force parameter
  14600. return $.effects.animateClass.call( this,
  14601. { toggle: classNames }, force, speed, easing );
  14602. }
  14603. };
  14604. } )( $.fn.toggleClass ),
  14605. switchClass: function( remove, add, speed, easing, callback ) {
  14606. return $.effects.animateClass.call( this, {
  14607. add: add,
  14608. remove: remove
  14609. }, speed, easing, callback );
  14610. }
  14611. } );
  14612. } )();
  14613. /******************************************************************************/
  14614. /*********************************** EFFECTS **********************************/
  14615. /******************************************************************************/
  14616. ( function() {
  14617. if ( $.expr && $.expr.pseudos && $.expr.pseudos.animated ) {
  14618. $.expr.pseudos.animated = ( function( orig ) {
  14619. return function( elem ) {
  14620. return !!$( elem ).data( dataSpaceAnimated ) || orig( elem );
  14621. };
  14622. } )( $.expr.pseudos.animated );
  14623. }
  14624. if ( $.uiBackCompat !== false ) {
  14625. $.extend( $.effects, {
  14626. // Saves a set of properties in a data storage
  14627. save: function( element, set ) {
  14628. var i = 0, length = set.length;
  14629. for ( ; i < length; i++ ) {
  14630. if ( set[ i ] !== null ) {
  14631. element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
  14632. }
  14633. }
  14634. },
  14635. // Restores a set of previously saved properties from a data storage
  14636. restore: function( element, set ) {
  14637. var val, i = 0, length = set.length;
  14638. for ( ; i < length; i++ ) {
  14639. if ( set[ i ] !== null ) {
  14640. val = element.data( dataSpace + set[ i ] );
  14641. element.css( set[ i ], val );
  14642. }
  14643. }
  14644. },
  14645. setMode: function( el, mode ) {
  14646. if ( mode === "toggle" ) {
  14647. mode = el.is( ":hidden" ) ? "show" : "hide";
  14648. }
  14649. return mode;
  14650. },
  14651. // Wraps the element around a wrapper that copies position properties
  14652. createWrapper: function( element ) {
  14653. // If the element is already wrapped, return it
  14654. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  14655. return element.parent();
  14656. }
  14657. // Wrap the element
  14658. var props = {
  14659. width: element.outerWidth( true ),
  14660. height: element.outerHeight( true ),
  14661. "float": element.css( "float" )
  14662. },
  14663. wrapper = $( "<div></div>" )
  14664. .addClass( "ui-effects-wrapper" )
  14665. .css( {
  14666. fontSize: "100%",
  14667. background: "transparent",
  14668. border: "none",
  14669. margin: 0,
  14670. padding: 0
  14671. } ),
  14672. // Store the size in case width/height are defined in % - Fixes #5245
  14673. size = {
  14674. width: element.width(),
  14675. height: element.height()
  14676. },
  14677. active = document.activeElement;
  14678. // Support: Firefox
  14679. // Firefox incorrectly exposes anonymous content
  14680. // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
  14681. try {
  14682. // eslint-disable-next-line no-unused-expressions
  14683. active.id;
  14684. } catch ( e ) {
  14685. active = document.body;
  14686. }
  14687. element.wrap( wrapper );
  14688. // Fixes #7595 - Elements lose focus when wrapped.
  14689. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  14690. $( active ).trigger( "focus" );
  14691. }
  14692. // Hotfix for jQuery 1.4 since some change in wrap() seems to actually
  14693. // lose the reference to the wrapped element
  14694. wrapper = element.parent();
  14695. // Transfer positioning properties to the wrapper
  14696. if ( element.css( "position" ) === "static" ) {
  14697. wrapper.css( { position: "relative" } );
  14698. element.css( { position: "relative" } );
  14699. } else {
  14700. $.extend( props, {
  14701. position: element.css( "position" ),
  14702. zIndex: element.css( "z-index" )
  14703. } );
  14704. $.each( [ "top", "left", "bottom", "right" ], function( i, pos ) {
  14705. props[ pos ] = element.css( pos );
  14706. if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
  14707. props[ pos ] = "auto";
  14708. }
  14709. } );
  14710. element.css( {
  14711. position: "relative",
  14712. top: 0,
  14713. left: 0,
  14714. right: "auto",
  14715. bottom: "auto"
  14716. } );
  14717. }
  14718. element.css( size );
  14719. return wrapper.css( props ).show();
  14720. },
  14721. removeWrapper: function( element ) {
  14722. var active = document.activeElement;
  14723. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  14724. element.parent().replaceWith( element );
  14725. // Fixes #7595 - Elements lose focus when wrapped.
  14726. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  14727. $( active ).trigger( "focus" );
  14728. }
  14729. }
  14730. return element;
  14731. }
  14732. } );
  14733. }
  14734. $.extend( $.effects, {
  14735. version: "1.13.0",
  14736. define: function( name, mode, effect ) {
  14737. if ( !effect ) {
  14738. effect = mode;
  14739. mode = "effect";
  14740. }
  14741. $.effects.effect[ name ] = effect;
  14742. $.effects.effect[ name ].mode = mode;
  14743. return effect;
  14744. },
  14745. scaledDimensions: function( element, percent, direction ) {
  14746. if ( percent === 0 ) {
  14747. return {
  14748. height: 0,
  14749. width: 0,
  14750. outerHeight: 0,
  14751. outerWidth: 0
  14752. };
  14753. }
  14754. var x = direction !== "horizontal" ? ( ( percent || 100 ) / 100 ) : 1,
  14755. y = direction !== "vertical" ? ( ( percent || 100 ) / 100 ) : 1;
  14756. return {
  14757. height: element.height() * y,
  14758. width: element.width() * x,
  14759. outerHeight: element.outerHeight() * y,
  14760. outerWidth: element.outerWidth() * x
  14761. };
  14762. },
  14763. clipToBox: function( animation ) {
  14764. return {
  14765. width: animation.clip.right - animation.clip.left,
  14766. height: animation.clip.bottom - animation.clip.top,
  14767. left: animation.clip.left,
  14768. top: animation.clip.top
  14769. };
  14770. },
  14771. // Injects recently queued functions to be first in line (after "inprogress")
  14772. unshift: function( element, queueLength, count ) {
  14773. var queue = element.queue();
  14774. if ( queueLength > 1 ) {
  14775. queue.splice.apply( queue,
  14776. [ 1, 0 ].concat( queue.splice( queueLength, count ) ) );
  14777. }
  14778. element.dequeue();
  14779. },
  14780. saveStyle: function( element ) {
  14781. element.data( dataSpaceStyle, element[ 0 ].style.cssText );
  14782. },
  14783. restoreStyle: function( element ) {
  14784. element[ 0 ].style.cssText = element.data( dataSpaceStyle ) || "";
  14785. element.removeData( dataSpaceStyle );
  14786. },
  14787. mode: function( element, mode ) {
  14788. var hidden = element.is( ":hidden" );
  14789. if ( mode === "toggle" ) {
  14790. mode = hidden ? "show" : "hide";
  14791. }
  14792. if ( hidden ? mode === "hide" : mode === "show" ) {
  14793. mode = "none";
  14794. }
  14795. return mode;
  14796. },
  14797. // Translates a [top,left] array into a baseline value
  14798. getBaseline: function( origin, original ) {
  14799. var y, x;
  14800. switch ( origin[ 0 ] ) {
  14801. case "top":
  14802. y = 0;
  14803. break;
  14804. case "middle":
  14805. y = 0.5;
  14806. break;
  14807. case "bottom":
  14808. y = 1;
  14809. break;
  14810. default:
  14811. y = origin[ 0 ] / original.height;
  14812. }
  14813. switch ( origin[ 1 ] ) {
  14814. case "left":
  14815. x = 0;
  14816. break;
  14817. case "center":
  14818. x = 0.5;
  14819. break;
  14820. case "right":
  14821. x = 1;
  14822. break;
  14823. default:
  14824. x = origin[ 1 ] / original.width;
  14825. }
  14826. return {
  14827. x: x,
  14828. y: y
  14829. };
  14830. },
  14831. // Creates a placeholder element so that the original element can be made absolute
  14832. createPlaceholder: function( element ) {
  14833. var placeholder,
  14834. cssPosition = element.css( "position" ),
  14835. position = element.position();
  14836. // Lock in margins first to account for form elements, which
  14837. // will change margin if you explicitly set height
  14838. // see: http://jsfiddle.net/JZSMt/3/ https://bugs.webkit.org/show_bug.cgi?id=107380
  14839. // Support: Safari
  14840. element.css( {
  14841. marginTop: element.css( "marginTop" ),
  14842. marginBottom: element.css( "marginBottom" ),
  14843. marginLeft: element.css( "marginLeft" ),
  14844. marginRight: element.css( "marginRight" )
  14845. } )
  14846. .outerWidth( element.outerWidth() )
  14847. .outerHeight( element.outerHeight() );
  14848. if ( /^(static|relative)/.test( cssPosition ) ) {
  14849. cssPosition = "absolute";
  14850. placeholder = $( "<" + element[ 0 ].nodeName + ">" ).insertAfter( element ).css( {
  14851. // Convert inline to inline block to account for inline elements
  14852. // that turn to inline block based on content (like img)
  14853. display: /^(inline|ruby)/.test( element.css( "display" ) ) ?
  14854. "inline-block" :
  14855. "block",
  14856. visibility: "hidden",
  14857. // Margins need to be set to account for margin collapse
  14858. marginTop: element.css( "marginTop" ),
  14859. marginBottom: element.css( "marginBottom" ),
  14860. marginLeft: element.css( "marginLeft" ),
  14861. marginRight: element.css( "marginRight" ),
  14862. "float": element.css( "float" )
  14863. } )
  14864. .outerWidth( element.outerWidth() )
  14865. .outerHeight( element.outerHeight() )
  14866. .addClass( "ui-effects-placeholder" );
  14867. element.data( dataSpace + "placeholder", placeholder );
  14868. }
  14869. element.css( {
  14870. position: cssPosition,
  14871. left: position.left,
  14872. top: position.top
  14873. } );
  14874. return placeholder;
  14875. },
  14876. removePlaceholder: function( element ) {
  14877. var dataKey = dataSpace + "placeholder",
  14878. placeholder = element.data( dataKey );
  14879. if ( placeholder ) {
  14880. placeholder.remove();
  14881. element.removeData( dataKey );
  14882. }
  14883. },
  14884. // Removes a placeholder if it exists and restores
  14885. // properties that were modified during placeholder creation
  14886. cleanUp: function( element ) {
  14887. $.effects.restoreStyle( element );
  14888. $.effects.removePlaceholder( element );
  14889. },
  14890. setTransition: function( element, list, factor, value ) {
  14891. value = value || {};
  14892. $.each( list, function( i, x ) {
  14893. var unit = element.cssUnit( x );
  14894. if ( unit[ 0 ] > 0 ) {
  14895. value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
  14896. }
  14897. } );
  14898. return value;
  14899. }
  14900. } );
  14901. // Return an effect options object for the given parameters:
  14902. function _normalizeArguments( effect, options, speed, callback ) {
  14903. // Allow passing all options as the first parameter
  14904. if ( $.isPlainObject( effect ) ) {
  14905. options = effect;
  14906. effect = effect.effect;
  14907. }
  14908. // Convert to an object
  14909. effect = { effect: effect };
  14910. // Catch (effect, null, ...)
  14911. if ( options == null ) {
  14912. options = {};
  14913. }
  14914. // Catch (effect, callback)
  14915. if ( typeof options === "function" ) {
  14916. callback = options;
  14917. speed = null;
  14918. options = {};
  14919. }
  14920. // Catch (effect, speed, ?)
  14921. if ( typeof options === "number" || $.fx.speeds[ options ] ) {
  14922. callback = speed;
  14923. speed = options;
  14924. options = {};
  14925. }
  14926. // Catch (effect, options, callback)
  14927. if ( typeof speed === "function" ) {
  14928. callback = speed;
  14929. speed = null;
  14930. }
  14931. // Add options to effect
  14932. if ( options ) {
  14933. $.extend( effect, options );
  14934. }
  14935. speed = speed || options.duration;
  14936. effect.duration = $.fx.off ? 0 :
  14937. typeof speed === "number" ? speed :
  14938. speed in $.fx.speeds ? $.fx.speeds[ speed ] :
  14939. $.fx.speeds._default;
  14940. effect.complete = callback || options.complete;
  14941. return effect;
  14942. }
  14943. function standardAnimationOption( option ) {
  14944. // Valid standard speeds (nothing, number, named speed)
  14945. if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) {
  14946. return true;
  14947. }
  14948. // Invalid strings - treat as "normal" speed
  14949. if ( typeof option === "string" && !$.effects.effect[ option ] ) {
  14950. return true;
  14951. }
  14952. // Complete callback
  14953. if ( typeof option === "function" ) {
  14954. return true;
  14955. }
  14956. // Options hash (but not naming an effect)
  14957. if ( typeof option === "object" && !option.effect ) {
  14958. return true;
  14959. }
  14960. // Didn't match any standard API
  14961. return false;
  14962. }
  14963. $.fn.extend( {
  14964. effect: function( /* effect, options, speed, callback */ ) {
  14965. var args = _normalizeArguments.apply( this, arguments ),
  14966. effectMethod = $.effects.effect[ args.effect ],
  14967. defaultMode = effectMethod.mode,
  14968. queue = args.queue,
  14969. queueName = queue || "fx",
  14970. complete = args.complete,
  14971. mode = args.mode,
  14972. modes = [],
  14973. prefilter = function( next ) {
  14974. var el = $( this ),
  14975. normalizedMode = $.effects.mode( el, mode ) || defaultMode;
  14976. // Sentinel for duck-punching the :animated pseudo-selector
  14977. el.data( dataSpaceAnimated, true );
  14978. // Save effect mode for later use,
  14979. // we can't just call $.effects.mode again later,
  14980. // as the .show() below destroys the initial state
  14981. modes.push( normalizedMode );
  14982. // See $.uiBackCompat inside of run() for removal of defaultMode in 1.14
  14983. if ( defaultMode && ( normalizedMode === "show" ||
  14984. ( normalizedMode === defaultMode && normalizedMode === "hide" ) ) ) {
  14985. el.show();
  14986. }
  14987. if ( !defaultMode || normalizedMode !== "none" ) {
  14988. $.effects.saveStyle( el );
  14989. }
  14990. if ( typeof next === "function" ) {
  14991. next();
  14992. }
  14993. };
  14994. if ( $.fx.off || !effectMethod ) {
  14995. // Delegate to the original method (e.g., .show()) if possible
  14996. if ( mode ) {
  14997. return this[ mode ]( args.duration, complete );
  14998. } else {
  14999. return this.each( function() {
  15000. if ( complete ) {
  15001. complete.call( this );
  15002. }
  15003. } );
  15004. }
  15005. }
  15006. function run( next ) {
  15007. var elem = $( this );
  15008. function cleanup() {
  15009. elem.removeData( dataSpaceAnimated );
  15010. $.effects.cleanUp( elem );
  15011. if ( args.mode === "hide" ) {
  15012. elem.hide();
  15013. }
  15014. done();
  15015. }
  15016. function done() {
  15017. if ( typeof complete === "function" ) {
  15018. complete.call( elem[ 0 ] );
  15019. }
  15020. if ( typeof next === "function" ) {
  15021. next();
  15022. }
  15023. }
  15024. // Override mode option on a per element basis,
  15025. // as toggle can be either show or hide depending on element state
  15026. args.mode = modes.shift();
  15027. if ( $.uiBackCompat !== false && !defaultMode ) {
  15028. if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
  15029. // Call the core method to track "olddisplay" properly
  15030. elem[ mode ]();
  15031. done();
  15032. } else {
  15033. effectMethod.call( elem[ 0 ], args, done );
  15034. }
  15035. } else {
  15036. if ( args.mode === "none" ) {
  15037. // Call the core method to track "olddisplay" properly
  15038. elem[ mode ]();
  15039. done();
  15040. } else {
  15041. effectMethod.call( elem[ 0 ], args, cleanup );
  15042. }
  15043. }
  15044. }
  15045. // Run prefilter on all elements first to ensure that
  15046. // any showing or hiding happens before placeholder creation,
  15047. // which ensures that any layout changes are correctly captured.
  15048. return queue === false ?
  15049. this.each( prefilter ).each( run ) :
  15050. this.queue( queueName, prefilter ).queue( queueName, run );
  15051. },
  15052. show: ( function( orig ) {
  15053. return function( option ) {
  15054. if ( standardAnimationOption( option ) ) {
  15055. return orig.apply( this, arguments );
  15056. } else {
  15057. var args = _normalizeArguments.apply( this, arguments );
  15058. args.mode = "show";
  15059. return this.effect.call( this, args );
  15060. }
  15061. };
  15062. } )( $.fn.show ),
  15063. hide: ( function( orig ) {
  15064. return function( option ) {
  15065. if ( standardAnimationOption( option ) ) {
  15066. return orig.apply( this, arguments );
  15067. } else {
  15068. var args = _normalizeArguments.apply( this, arguments );
  15069. args.mode = "hide";
  15070. return this.effect.call( this, args );
  15071. }
  15072. };
  15073. } )( $.fn.hide ),
  15074. toggle: ( function( orig ) {
  15075. return function( option ) {
  15076. if ( standardAnimationOption( option ) || typeof option === "boolean" ) {
  15077. return orig.apply( this, arguments );
  15078. } else {
  15079. var args = _normalizeArguments.apply( this, arguments );
  15080. args.mode = "toggle";
  15081. return this.effect.call( this, args );
  15082. }
  15083. };
  15084. } )( $.fn.toggle ),
  15085. cssUnit: function( key ) {
  15086. var style = this.css( key ),
  15087. val = [];
  15088. $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
  15089. if ( style.indexOf( unit ) > 0 ) {
  15090. val = [ parseFloat( style ), unit ];
  15091. }
  15092. } );
  15093. return val;
  15094. },
  15095. cssClip: function( clipObj ) {
  15096. if ( clipObj ) {
  15097. return this.css( "clip", "rect(" + clipObj.top + "px " + clipObj.right + "px " +
  15098. clipObj.bottom + "px " + clipObj.left + "px)" );
  15099. }
  15100. return parseClip( this.css( "clip" ), this );
  15101. },
  15102. transfer: function( options, done ) {
  15103. var element = $( this ),
  15104. target = $( options.to ),
  15105. targetFixed = target.css( "position" ) === "fixed",
  15106. body = $( "body" ),
  15107. fixTop = targetFixed ? body.scrollTop() : 0,
  15108. fixLeft = targetFixed ? body.scrollLeft() : 0,
  15109. endPosition = target.offset(),
  15110. animation = {
  15111. top: endPosition.top - fixTop,
  15112. left: endPosition.left - fixLeft,
  15113. height: target.innerHeight(),
  15114. width: target.innerWidth()
  15115. },
  15116. startPosition = element.offset(),
  15117. transfer = $( "<div class='ui-effects-transfer'></div>" );
  15118. transfer
  15119. .appendTo( "body" )
  15120. .addClass( options.className )
  15121. .css( {
  15122. top: startPosition.top - fixTop,
  15123. left: startPosition.left - fixLeft,
  15124. height: element.innerHeight(),
  15125. width: element.innerWidth(),
  15126. position: targetFixed ? "fixed" : "absolute"
  15127. } )
  15128. .animate( animation, options.duration, options.easing, function() {
  15129. transfer.remove();
  15130. if ( typeof done === "function" ) {
  15131. done();
  15132. }
  15133. } );
  15134. }
  15135. } );
  15136. function parseClip( str, element ) {
  15137. var outerWidth = element.outerWidth(),
  15138. outerHeight = element.outerHeight(),
  15139. clipRegex = /^rect\((-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto)\)$/,
  15140. values = clipRegex.exec( str ) || [ "", 0, outerWidth, outerHeight, 0 ];
  15141. return {
  15142. top: parseFloat( values[ 1 ] ) || 0,
  15143. right: values[ 2 ] === "auto" ? outerWidth : parseFloat( values[ 2 ] ),
  15144. bottom: values[ 3 ] === "auto" ? outerHeight : parseFloat( values[ 3 ] ),
  15145. left: parseFloat( values[ 4 ] ) || 0
  15146. };
  15147. }
  15148. $.fx.step.clip = function( fx ) {
  15149. if ( !fx.clipInit ) {
  15150. fx.start = $( fx.elem ).cssClip();
  15151. if ( typeof fx.end === "string" ) {
  15152. fx.end = parseClip( fx.end, fx.elem );
  15153. }
  15154. fx.clipInit = true;
  15155. }
  15156. $( fx.elem ).cssClip( {
  15157. top: fx.pos * ( fx.end.top - fx.start.top ) + fx.start.top,
  15158. right: fx.pos * ( fx.end.right - fx.start.right ) + fx.start.right,
  15159. bottom: fx.pos * ( fx.end.bottom - fx.start.bottom ) + fx.start.bottom,
  15160. left: fx.pos * ( fx.end.left - fx.start.left ) + fx.start.left
  15161. } );
  15162. };
  15163. } )();
  15164. /******************************************************************************/
  15165. /*********************************** EASING ***********************************/
  15166. /******************************************************************************/
  15167. ( function() {
  15168. // Based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
  15169. var baseEasings = {};
  15170. $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
  15171. baseEasings[ name ] = function( p ) {
  15172. return Math.pow( p, i + 2 );
  15173. };
  15174. } );
  15175. $.extend( baseEasings, {
  15176. Sine: function( p ) {
  15177. return 1 - Math.cos( p * Math.PI / 2 );
  15178. },
  15179. Circ: function( p ) {
  15180. return 1 - Math.sqrt( 1 - p * p );
  15181. },
  15182. Elastic: function( p ) {
  15183. return p === 0 || p === 1 ? p :
  15184. -Math.pow( 2, 8 * ( p - 1 ) ) * Math.sin( ( ( p - 1 ) * 80 - 7.5 ) * Math.PI / 15 );
  15185. },
  15186. Back: function( p ) {
  15187. return p * p * ( 3 * p - 2 );
  15188. },
  15189. Bounce: function( p ) {
  15190. var pow2,
  15191. bounce = 4;
  15192. while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
  15193. return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
  15194. }
  15195. } );
  15196. $.each( baseEasings, function( name, easeIn ) {
  15197. $.easing[ "easeIn" + name ] = easeIn;
  15198. $.easing[ "easeOut" + name ] = function( p ) {
  15199. return 1 - easeIn( 1 - p );
  15200. };
  15201. $.easing[ "easeInOut" + name ] = function( p ) {
  15202. return p < 0.5 ?
  15203. easeIn( p * 2 ) / 2 :
  15204. 1 - easeIn( p * -2 + 2 ) / 2;
  15205. };
  15206. } );
  15207. } )();
  15208. var effect = $.effects;
  15209. /*!
  15210. * jQuery UI Effects Blind 1.13.0
  15211. * http://jqueryui.com
  15212. *
  15213. * Copyright jQuery Foundation and other contributors
  15214. * Released under the MIT license.
  15215. * http://jquery.org/license
  15216. */
  15217. //>>label: Blind Effect
  15218. //>>group: Effects
  15219. //>>description: Blinds the element.
  15220. //>>docs: http://api.jqueryui.com/blind-effect/
  15221. //>>demos: http://jqueryui.com/effect/
  15222. var effectsEffectBlind = $.effects.define( "blind", "hide", function( options, done ) {
  15223. var map = {
  15224. up: [ "bottom", "top" ],
  15225. vertical: [ "bottom", "top" ],
  15226. down: [ "top", "bottom" ],
  15227. left: [ "right", "left" ],
  15228. horizontal: [ "right", "left" ],
  15229. right: [ "left", "right" ]
  15230. },
  15231. element = $( this ),
  15232. direction = options.direction || "up",
  15233. start = element.cssClip(),
  15234. animate = { clip: $.extend( {}, start ) },
  15235. placeholder = $.effects.createPlaceholder( element );
  15236. animate.clip[ map[ direction ][ 0 ] ] = animate.clip[ map[ direction ][ 1 ] ];
  15237. if ( options.mode === "show" ) {
  15238. element.cssClip( animate.clip );
  15239. if ( placeholder ) {
  15240. placeholder.css( $.effects.clipToBox( animate ) );
  15241. }
  15242. animate.clip = start;
  15243. }
  15244. if ( placeholder ) {
  15245. placeholder.animate( $.effects.clipToBox( animate ), options.duration, options.easing );
  15246. }
  15247. element.animate( animate, {
  15248. queue: false,
  15249. duration: options.duration,
  15250. easing: options.easing,
  15251. complete: done
  15252. } );
  15253. } );
  15254. /*!
  15255. * jQuery UI Effects Bounce 1.13.0
  15256. * http://jqueryui.com
  15257. *
  15258. * Copyright jQuery Foundation and other contributors
  15259. * Released under the MIT license.
  15260. * http://jquery.org/license
  15261. */
  15262. //>>label: Bounce Effect
  15263. //>>group: Effects
  15264. //>>description: Bounces an element horizontally or vertically n times.
  15265. //>>docs: http://api.jqueryui.com/bounce-effect/
  15266. //>>demos: http://jqueryui.com/effect/
  15267. var effectsEffectBounce = $.effects.define( "bounce", function( options, done ) {
  15268. var upAnim, downAnim, refValue,
  15269. element = $( this ),
  15270. // Defaults:
  15271. mode = options.mode,
  15272. hide = mode === "hide",
  15273. show = mode === "show",
  15274. direction = options.direction || "up",
  15275. distance = options.distance,
  15276. times = options.times || 5,
  15277. // Number of internal animations
  15278. anims = times * 2 + ( show || hide ? 1 : 0 ),
  15279. speed = options.duration / anims,
  15280. easing = options.easing,
  15281. // Utility:
  15282. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  15283. motion = ( direction === "up" || direction === "left" ),
  15284. i = 0,
  15285. queuelen = element.queue().length;
  15286. $.effects.createPlaceholder( element );
  15287. refValue = element.css( ref );
  15288. // Default distance for the BIGGEST bounce is the outer Distance / 3
  15289. if ( !distance ) {
  15290. distance = element[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
  15291. }
  15292. if ( show ) {
  15293. downAnim = { opacity: 1 };
  15294. downAnim[ ref ] = refValue;
  15295. // If we are showing, force opacity 0 and set the initial position
  15296. // then do the "first" animation
  15297. element
  15298. .css( "opacity", 0 )
  15299. .css( ref, motion ? -distance * 2 : distance * 2 )
  15300. .animate( downAnim, speed, easing );
  15301. }
  15302. // Start at the smallest distance if we are hiding
  15303. if ( hide ) {
  15304. distance = distance / Math.pow( 2, times - 1 );
  15305. }
  15306. downAnim = {};
  15307. downAnim[ ref ] = refValue;
  15308. // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
  15309. for ( ; i < times; i++ ) {
  15310. upAnim = {};
  15311. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  15312. element
  15313. .animate( upAnim, speed, easing )
  15314. .animate( downAnim, speed, easing );
  15315. distance = hide ? distance * 2 : distance / 2;
  15316. }
  15317. // Last Bounce when Hiding
  15318. if ( hide ) {
  15319. upAnim = { opacity: 0 };
  15320. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  15321. element.animate( upAnim, speed, easing );
  15322. }
  15323. element.queue( done );
  15324. $.effects.unshift( element, queuelen, anims + 1 );
  15325. } );
  15326. /*!
  15327. * jQuery UI Effects Clip 1.13.0
  15328. * http://jqueryui.com
  15329. *
  15330. * Copyright jQuery Foundation and other contributors
  15331. * Released under the MIT license.
  15332. * http://jquery.org/license
  15333. */
  15334. //>>label: Clip Effect
  15335. //>>group: Effects
  15336. //>>description: Clips the element on and off like an old TV.
  15337. //>>docs: http://api.jqueryui.com/clip-effect/
  15338. //>>demos: http://jqueryui.com/effect/
  15339. var effectsEffectClip = $.effects.define( "clip", "hide", function( options, done ) {
  15340. var start,
  15341. animate = {},
  15342. element = $( this ),
  15343. direction = options.direction || "vertical",
  15344. both = direction === "both",
  15345. horizontal = both || direction === "horizontal",
  15346. vertical = both || direction === "vertical";
  15347. start = element.cssClip();
  15348. animate.clip = {
  15349. top: vertical ? ( start.bottom - start.top ) / 2 : start.top,
  15350. right: horizontal ? ( start.right - start.left ) / 2 : start.right,
  15351. bottom: vertical ? ( start.bottom - start.top ) / 2 : start.bottom,
  15352. left: horizontal ? ( start.right - start.left ) / 2 : start.left
  15353. };
  15354. $.effects.createPlaceholder( element );
  15355. if ( options.mode === "show" ) {
  15356. element.cssClip( animate.clip );
  15357. animate.clip = start;
  15358. }
  15359. element.animate( animate, {
  15360. queue: false,
  15361. duration: options.duration,
  15362. easing: options.easing,
  15363. complete: done
  15364. } );
  15365. } );
  15366. /*!
  15367. * jQuery UI Effects Drop 1.13.0
  15368. * http://jqueryui.com
  15369. *
  15370. * Copyright jQuery Foundation and other contributors
  15371. * Released under the MIT license.
  15372. * http://jquery.org/license
  15373. */
  15374. //>>label: Drop Effect
  15375. //>>group: Effects
  15376. //>>description: Moves an element in one direction and hides it at the same time.
  15377. //>>docs: http://api.jqueryui.com/drop-effect/
  15378. //>>demos: http://jqueryui.com/effect/
  15379. var effectsEffectDrop = $.effects.define( "drop", "hide", function( options, done ) {
  15380. var distance,
  15381. element = $( this ),
  15382. mode = options.mode,
  15383. show = mode === "show",
  15384. direction = options.direction || "left",
  15385. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  15386. motion = ( direction === "up" || direction === "left" ) ? "-=" : "+=",
  15387. oppositeMotion = ( motion === "+=" ) ? "-=" : "+=",
  15388. animation = {
  15389. opacity: 0
  15390. };
  15391. $.effects.createPlaceholder( element );
  15392. distance = options.distance ||
  15393. element[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ) / 2;
  15394. animation[ ref ] = motion + distance;
  15395. if ( show ) {
  15396. element.css( animation );
  15397. animation[ ref ] = oppositeMotion + distance;
  15398. animation.opacity = 1;
  15399. }
  15400. // Animate
  15401. element.animate( animation, {
  15402. queue: false,
  15403. duration: options.duration,
  15404. easing: options.easing,
  15405. complete: done
  15406. } );
  15407. } );
  15408. /*!
  15409. * jQuery UI Effects Explode 1.13.0
  15410. * http://jqueryui.com
  15411. *
  15412. * Copyright jQuery Foundation and other contributors
  15413. * Released under the MIT license.
  15414. * http://jquery.org/license
  15415. */
  15416. //>>label: Explode Effect
  15417. //>>group: Effects
  15418. /* eslint-disable max-len */
  15419. //>>description: Explodes an element in all directions into n pieces. Implodes an element to its original wholeness.
  15420. /* eslint-enable max-len */
  15421. //>>docs: http://api.jqueryui.com/explode-effect/
  15422. //>>demos: http://jqueryui.com/effect/
  15423. var effectsEffectExplode = $.effects.define( "explode", "hide", function( options, done ) {
  15424. var i, j, left, top, mx, my,
  15425. rows = options.pieces ? Math.round( Math.sqrt( options.pieces ) ) : 3,
  15426. cells = rows,
  15427. element = $( this ),
  15428. mode = options.mode,
  15429. show = mode === "show",
  15430. // Show and then visibility:hidden the element before calculating offset
  15431. offset = element.show().css( "visibility", "hidden" ).offset(),
  15432. // Width and height of a piece
  15433. width = Math.ceil( element.outerWidth() / cells ),
  15434. height = Math.ceil( element.outerHeight() / rows ),
  15435. pieces = [];
  15436. // Children animate complete:
  15437. function childComplete() {
  15438. pieces.push( this );
  15439. if ( pieces.length === rows * cells ) {
  15440. animComplete();
  15441. }
  15442. }
  15443. // Clone the element for each row and cell.
  15444. for ( i = 0; i < rows; i++ ) { // ===>
  15445. top = offset.top + i * height;
  15446. my = i - ( rows - 1 ) / 2;
  15447. for ( j = 0; j < cells; j++ ) { // |||
  15448. left = offset.left + j * width;
  15449. mx = j - ( cells - 1 ) / 2;
  15450. // Create a clone of the now hidden main element that will be absolute positioned
  15451. // within a wrapper div off the -left and -top equal to size of our pieces
  15452. element
  15453. .clone()
  15454. .appendTo( "body" )
  15455. .wrap( "<div></div>" )
  15456. .css( {
  15457. position: "absolute",
  15458. visibility: "visible",
  15459. left: -j * width,
  15460. top: -i * height
  15461. } )
  15462. // Select the wrapper - make it overflow: hidden and absolute positioned based on
  15463. // where the original was located +left and +top equal to the size of pieces
  15464. .parent()
  15465. .addClass( "ui-effects-explode" )
  15466. .css( {
  15467. position: "absolute",
  15468. overflow: "hidden",
  15469. width: width,
  15470. height: height,
  15471. left: left + ( show ? mx * width : 0 ),
  15472. top: top + ( show ? my * height : 0 ),
  15473. opacity: show ? 0 : 1
  15474. } )
  15475. .animate( {
  15476. left: left + ( show ? 0 : mx * width ),
  15477. top: top + ( show ? 0 : my * height ),
  15478. opacity: show ? 1 : 0
  15479. }, options.duration || 500, options.easing, childComplete );
  15480. }
  15481. }
  15482. function animComplete() {
  15483. element.css( {
  15484. visibility: "visible"
  15485. } );
  15486. $( pieces ).remove();
  15487. done();
  15488. }
  15489. } );
  15490. /*!
  15491. * jQuery UI Effects Fade 1.13.0
  15492. * http://jqueryui.com
  15493. *
  15494. * Copyright jQuery Foundation and other contributors
  15495. * Released under the MIT license.
  15496. * http://jquery.org/license
  15497. */
  15498. //>>label: Fade Effect
  15499. //>>group: Effects
  15500. //>>description: Fades the element.
  15501. //>>docs: http://api.jqueryui.com/fade-effect/
  15502. //>>demos: http://jqueryui.com/effect/
  15503. var effectsEffectFade = $.effects.define( "fade", "toggle", function( options, done ) {
  15504. var show = options.mode === "show";
  15505. $( this )
  15506. .css( "opacity", show ? 0 : 1 )
  15507. .animate( {
  15508. opacity: show ? 1 : 0
  15509. }, {
  15510. queue: false,
  15511. duration: options.duration,
  15512. easing: options.easing,
  15513. complete: done
  15514. } );
  15515. } );
  15516. /*!
  15517. * jQuery UI Effects Fold 1.13.0
  15518. * http://jqueryui.com
  15519. *
  15520. * Copyright jQuery Foundation and other contributors
  15521. * Released under the MIT license.
  15522. * http://jquery.org/license
  15523. */
  15524. //>>label: Fold Effect
  15525. //>>group: Effects
  15526. //>>description: Folds an element first horizontally and then vertically.
  15527. //>>docs: http://api.jqueryui.com/fold-effect/
  15528. //>>demos: http://jqueryui.com/effect/
  15529. var effectsEffectFold = $.effects.define( "fold", "hide", function( options, done ) {
  15530. // Create element
  15531. var element = $( this ),
  15532. mode = options.mode,
  15533. show = mode === "show",
  15534. hide = mode === "hide",
  15535. size = options.size || 15,
  15536. percent = /([0-9]+)%/.exec( size ),
  15537. horizFirst = !!options.horizFirst,
  15538. ref = horizFirst ? [ "right", "bottom" ] : [ "bottom", "right" ],
  15539. duration = options.duration / 2,
  15540. placeholder = $.effects.createPlaceholder( element ),
  15541. start = element.cssClip(),
  15542. animation1 = { clip: $.extend( {}, start ) },
  15543. animation2 = { clip: $.extend( {}, start ) },
  15544. distance = [ start[ ref[ 0 ] ], start[ ref[ 1 ] ] ],
  15545. queuelen = element.queue().length;
  15546. if ( percent ) {
  15547. size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
  15548. }
  15549. animation1.clip[ ref[ 0 ] ] = size;
  15550. animation2.clip[ ref[ 0 ] ] = size;
  15551. animation2.clip[ ref[ 1 ] ] = 0;
  15552. if ( show ) {
  15553. element.cssClip( animation2.clip );
  15554. if ( placeholder ) {
  15555. placeholder.css( $.effects.clipToBox( animation2 ) );
  15556. }
  15557. animation2.clip = start;
  15558. }
  15559. // Animate
  15560. element
  15561. .queue( function( next ) {
  15562. if ( placeholder ) {
  15563. placeholder
  15564. .animate( $.effects.clipToBox( animation1 ), duration, options.easing )
  15565. .animate( $.effects.clipToBox( animation2 ), duration, options.easing );
  15566. }
  15567. next();
  15568. } )
  15569. .animate( animation1, duration, options.easing )
  15570. .animate( animation2, duration, options.easing )
  15571. .queue( done );
  15572. $.effects.unshift( element, queuelen, 4 );
  15573. } );
  15574. /*!
  15575. * jQuery UI Effects Highlight 1.13.0
  15576. * http://jqueryui.com
  15577. *
  15578. * Copyright jQuery Foundation and other contributors
  15579. * Released under the MIT license.
  15580. * http://jquery.org/license
  15581. */
  15582. //>>label: Highlight Effect
  15583. //>>group: Effects
  15584. //>>description: Highlights the background of an element in a defined color for a custom duration.
  15585. //>>docs: http://api.jqueryui.com/highlight-effect/
  15586. //>>demos: http://jqueryui.com/effect/
  15587. var effectsEffectHighlight = $.effects.define( "highlight", "show", function( options, done ) {
  15588. var element = $( this ),
  15589. animation = {
  15590. backgroundColor: element.css( "backgroundColor" )
  15591. };
  15592. if ( options.mode === "hide" ) {
  15593. animation.opacity = 0;
  15594. }
  15595. $.effects.saveStyle( element );
  15596. element
  15597. .css( {
  15598. backgroundImage: "none",
  15599. backgroundColor: options.color || "#ffff99"
  15600. } )
  15601. .animate( animation, {
  15602. queue: false,
  15603. duration: options.duration,
  15604. easing: options.easing,
  15605. complete: done
  15606. } );
  15607. } );
  15608. /*!
  15609. * jQuery UI Effects Size 1.13.0
  15610. * http://jqueryui.com
  15611. *
  15612. * Copyright jQuery Foundation and other contributors
  15613. * Released under the MIT license.
  15614. * http://jquery.org/license
  15615. */
  15616. //>>label: Size Effect
  15617. //>>group: Effects
  15618. //>>description: Resize an element to a specified width and height.
  15619. //>>docs: http://api.jqueryui.com/size-effect/
  15620. //>>demos: http://jqueryui.com/effect/
  15621. var effectsEffectSize = $.effects.define( "size", function( options, done ) {
  15622. // Create element
  15623. var baseline, factor, temp,
  15624. element = $( this ),
  15625. // Copy for children
  15626. cProps = [ "fontSize" ],
  15627. vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ],
  15628. hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ],
  15629. // Set options
  15630. mode = options.mode,
  15631. restore = mode !== "effect",
  15632. scale = options.scale || "both",
  15633. origin = options.origin || [ "middle", "center" ],
  15634. position = element.css( "position" ),
  15635. pos = element.position(),
  15636. original = $.effects.scaledDimensions( element ),
  15637. from = options.from || original,
  15638. to = options.to || $.effects.scaledDimensions( element, 0 );
  15639. $.effects.createPlaceholder( element );
  15640. if ( mode === "show" ) {
  15641. temp = from;
  15642. from = to;
  15643. to = temp;
  15644. }
  15645. // Set scaling factor
  15646. factor = {
  15647. from: {
  15648. y: from.height / original.height,
  15649. x: from.width / original.width
  15650. },
  15651. to: {
  15652. y: to.height / original.height,
  15653. x: to.width / original.width
  15654. }
  15655. };
  15656. // Scale the css box
  15657. if ( scale === "box" || scale === "both" ) {
  15658. // Vertical props scaling
  15659. if ( factor.from.y !== factor.to.y ) {
  15660. from = $.effects.setTransition( element, vProps, factor.from.y, from );
  15661. to = $.effects.setTransition( element, vProps, factor.to.y, to );
  15662. }
  15663. // Horizontal props scaling
  15664. if ( factor.from.x !== factor.to.x ) {
  15665. from = $.effects.setTransition( element, hProps, factor.from.x, from );
  15666. to = $.effects.setTransition( element, hProps, factor.to.x, to );
  15667. }
  15668. }
  15669. // Scale the content
  15670. if ( scale === "content" || scale === "both" ) {
  15671. // Vertical props scaling
  15672. if ( factor.from.y !== factor.to.y ) {
  15673. from = $.effects.setTransition( element, cProps, factor.from.y, from );
  15674. to = $.effects.setTransition( element, cProps, factor.to.y, to );
  15675. }
  15676. }
  15677. // Adjust the position properties based on the provided origin points
  15678. if ( origin ) {
  15679. baseline = $.effects.getBaseline( origin, original );
  15680. from.top = ( original.outerHeight - from.outerHeight ) * baseline.y + pos.top;
  15681. from.left = ( original.outerWidth - from.outerWidth ) * baseline.x + pos.left;
  15682. to.top = ( original.outerHeight - to.outerHeight ) * baseline.y + pos.top;
  15683. to.left = ( original.outerWidth - to.outerWidth ) * baseline.x + pos.left;
  15684. }
  15685. delete from.outerHeight;
  15686. delete from.outerWidth;
  15687. element.css( from );
  15688. // Animate the children if desired
  15689. if ( scale === "content" || scale === "both" ) {
  15690. vProps = vProps.concat( [ "marginTop", "marginBottom" ] ).concat( cProps );
  15691. hProps = hProps.concat( [ "marginLeft", "marginRight" ] );
  15692. // Only animate children with width attributes specified
  15693. // TODO: is this right? should we include anything with css width specified as well
  15694. element.find( "*[width]" ).each( function() {
  15695. var child = $( this ),
  15696. childOriginal = $.effects.scaledDimensions( child ),
  15697. childFrom = {
  15698. height: childOriginal.height * factor.from.y,
  15699. width: childOriginal.width * factor.from.x,
  15700. outerHeight: childOriginal.outerHeight * factor.from.y,
  15701. outerWidth: childOriginal.outerWidth * factor.from.x
  15702. },
  15703. childTo = {
  15704. height: childOriginal.height * factor.to.y,
  15705. width: childOriginal.width * factor.to.x,
  15706. outerHeight: childOriginal.height * factor.to.y,
  15707. outerWidth: childOriginal.width * factor.to.x
  15708. };
  15709. // Vertical props scaling
  15710. if ( factor.from.y !== factor.to.y ) {
  15711. childFrom = $.effects.setTransition( child, vProps, factor.from.y, childFrom );
  15712. childTo = $.effects.setTransition( child, vProps, factor.to.y, childTo );
  15713. }
  15714. // Horizontal props scaling
  15715. if ( factor.from.x !== factor.to.x ) {
  15716. childFrom = $.effects.setTransition( child, hProps, factor.from.x, childFrom );
  15717. childTo = $.effects.setTransition( child, hProps, factor.to.x, childTo );
  15718. }
  15719. if ( restore ) {
  15720. $.effects.saveStyle( child );
  15721. }
  15722. // Animate children
  15723. child.css( childFrom );
  15724. child.animate( childTo, options.duration, options.easing, function() {
  15725. // Restore children
  15726. if ( restore ) {
  15727. $.effects.restoreStyle( child );
  15728. }
  15729. } );
  15730. } );
  15731. }
  15732. // Animate
  15733. element.animate( to, {
  15734. queue: false,
  15735. duration: options.duration,
  15736. easing: options.easing,
  15737. complete: function() {
  15738. var offset = element.offset();
  15739. if ( to.opacity === 0 ) {
  15740. element.css( "opacity", from.opacity );
  15741. }
  15742. if ( !restore ) {
  15743. element
  15744. .css( "position", position === "static" ? "relative" : position )
  15745. .offset( offset );
  15746. // Need to save style here so that automatic style restoration
  15747. // doesn't restore to the original styles from before the animation.
  15748. $.effects.saveStyle( element );
  15749. }
  15750. done();
  15751. }
  15752. } );
  15753. } );
  15754. /*!
  15755. * jQuery UI Effects Scale 1.13.0
  15756. * http://jqueryui.com
  15757. *
  15758. * Copyright jQuery Foundation and other contributors
  15759. * Released under the MIT license.
  15760. * http://jquery.org/license
  15761. */
  15762. //>>label: Scale Effect
  15763. //>>group: Effects
  15764. //>>description: Grows or shrinks an element and its content.
  15765. //>>docs: http://api.jqueryui.com/scale-effect/
  15766. //>>demos: http://jqueryui.com/effect/
  15767. var effectsEffectScale = $.effects.define( "scale", function( options, done ) {
  15768. // Create element
  15769. var el = $( this ),
  15770. mode = options.mode,
  15771. percent = parseInt( options.percent, 10 ) ||
  15772. ( parseInt( options.percent, 10 ) === 0 ? 0 : ( mode !== "effect" ? 0 : 100 ) ),
  15773. newOptions = $.extend( true, {
  15774. from: $.effects.scaledDimensions( el ),
  15775. to: $.effects.scaledDimensions( el, percent, options.direction || "both" ),
  15776. origin: options.origin || [ "middle", "center" ]
  15777. }, options );
  15778. // Fade option to support puff
  15779. if ( options.fade ) {
  15780. newOptions.from.opacity = 1;
  15781. newOptions.to.opacity = 0;
  15782. }
  15783. $.effects.effect.size.call( this, newOptions, done );
  15784. } );
  15785. /*!
  15786. * jQuery UI Effects Puff 1.13.0
  15787. * http://jqueryui.com
  15788. *
  15789. * Copyright jQuery Foundation and other contributors
  15790. * Released under the MIT license.
  15791. * http://jquery.org/license
  15792. */
  15793. //>>label: Puff Effect
  15794. //>>group: Effects
  15795. //>>description: Creates a puff effect by scaling the element up and hiding it at the same time.
  15796. //>>docs: http://api.jqueryui.com/puff-effect/
  15797. //>>demos: http://jqueryui.com/effect/
  15798. var effectsEffectPuff = $.effects.define( "puff", "hide", function( options, done ) {
  15799. var newOptions = $.extend( true, {}, options, {
  15800. fade: true,
  15801. percent: parseInt( options.percent, 10 ) || 150
  15802. } );
  15803. $.effects.effect.scale.call( this, newOptions, done );
  15804. } );
  15805. /*!
  15806. * jQuery UI Effects Pulsate 1.13.0
  15807. * http://jqueryui.com
  15808. *
  15809. * Copyright jQuery Foundation and other contributors
  15810. * Released under the MIT license.
  15811. * http://jquery.org/license
  15812. */
  15813. //>>label: Pulsate Effect
  15814. //>>group: Effects
  15815. //>>description: Pulsates an element n times by changing the opacity to zero and back.
  15816. //>>docs: http://api.jqueryui.com/pulsate-effect/
  15817. //>>demos: http://jqueryui.com/effect/
  15818. var effectsEffectPulsate = $.effects.define( "pulsate", "show", function( options, done ) {
  15819. var element = $( this ),
  15820. mode = options.mode,
  15821. show = mode === "show",
  15822. hide = mode === "hide",
  15823. showhide = show || hide,
  15824. // Showing or hiding leaves off the "last" animation
  15825. anims = ( ( options.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
  15826. duration = options.duration / anims,
  15827. animateTo = 0,
  15828. i = 1,
  15829. queuelen = element.queue().length;
  15830. if ( show || !element.is( ":visible" ) ) {
  15831. element.css( "opacity", 0 ).show();
  15832. animateTo = 1;
  15833. }
  15834. // Anims - 1 opacity "toggles"
  15835. for ( ; i < anims; i++ ) {
  15836. element.animate( { opacity: animateTo }, duration, options.easing );
  15837. animateTo = 1 - animateTo;
  15838. }
  15839. element.animate( { opacity: animateTo }, duration, options.easing );
  15840. element.queue( done );
  15841. $.effects.unshift( element, queuelen, anims + 1 );
  15842. } );
  15843. /*!
  15844. * jQuery UI Effects Shake 1.13.0
  15845. * http://jqueryui.com
  15846. *
  15847. * Copyright jQuery Foundation and other contributors
  15848. * Released under the MIT license.
  15849. * http://jquery.org/license
  15850. */
  15851. //>>label: Shake Effect
  15852. //>>group: Effects
  15853. //>>description: Shakes an element horizontally or vertically n times.
  15854. //>>docs: http://api.jqueryui.com/shake-effect/
  15855. //>>demos: http://jqueryui.com/effect/
  15856. var effectsEffectShake = $.effects.define( "shake", function( options, done ) {
  15857. var i = 1,
  15858. element = $( this ),
  15859. direction = options.direction || "left",
  15860. distance = options.distance || 20,
  15861. times = options.times || 3,
  15862. anims = times * 2 + 1,
  15863. speed = Math.round( options.duration / anims ),
  15864. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  15865. positiveMotion = ( direction === "up" || direction === "left" ),
  15866. animation = {},
  15867. animation1 = {},
  15868. animation2 = {},
  15869. queuelen = element.queue().length;
  15870. $.effects.createPlaceholder( element );
  15871. // Animation
  15872. animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance;
  15873. animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2;
  15874. animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2;
  15875. // Animate
  15876. element.animate( animation, speed, options.easing );
  15877. // Shakes
  15878. for ( ; i < times; i++ ) {
  15879. element
  15880. .animate( animation1, speed, options.easing )
  15881. .animate( animation2, speed, options.easing );
  15882. }
  15883. element
  15884. .animate( animation1, speed, options.easing )
  15885. .animate( animation, speed / 2, options.easing )
  15886. .queue( done );
  15887. $.effects.unshift( element, queuelen, anims + 1 );
  15888. } );
  15889. /*!
  15890. * jQuery UI Effects Slide 1.13.0
  15891. * http://jqueryui.com
  15892. *
  15893. * Copyright jQuery Foundation and other contributors
  15894. * Released under the MIT license.
  15895. * http://jquery.org/license
  15896. */
  15897. //>>label: Slide Effect
  15898. //>>group: Effects
  15899. //>>description: Slides an element in and out of the viewport.
  15900. //>>docs: http://api.jqueryui.com/slide-effect/
  15901. //>>demos: http://jqueryui.com/effect/
  15902. var effectsEffectSlide = $.effects.define( "slide", "show", function( options, done ) {
  15903. var startClip, startRef,
  15904. element = $( this ),
  15905. map = {
  15906. up: [ "bottom", "top" ],
  15907. down: [ "top", "bottom" ],
  15908. left: [ "right", "left" ],
  15909. right: [ "left", "right" ]
  15910. },
  15911. mode = options.mode,
  15912. direction = options.direction || "left",
  15913. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  15914. positiveMotion = ( direction === "up" || direction === "left" ),
  15915. distance = options.distance ||
  15916. element[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ),
  15917. animation = {};
  15918. $.effects.createPlaceholder( element );
  15919. startClip = element.cssClip();
  15920. startRef = element.position()[ ref ];
  15921. // Define hide animation
  15922. animation[ ref ] = ( positiveMotion ? -1 : 1 ) * distance + startRef;
  15923. animation.clip = element.cssClip();
  15924. animation.clip[ map[ direction ][ 1 ] ] = animation.clip[ map[ direction ][ 0 ] ];
  15925. // Reverse the animation if we're showing
  15926. if ( mode === "show" ) {
  15927. element.cssClip( animation.clip );
  15928. element.css( ref, animation[ ref ] );
  15929. animation.clip = startClip;
  15930. animation[ ref ] = startRef;
  15931. }
  15932. // Actually animate
  15933. element.animate( animation, {
  15934. queue: false,
  15935. duration: options.duration,
  15936. easing: options.easing,
  15937. complete: done
  15938. } );
  15939. } );
  15940. /*!
  15941. * jQuery UI Effects Transfer 1.13.0
  15942. * http://jqueryui.com
  15943. *
  15944. * Copyright jQuery Foundation and other contributors
  15945. * Released under the MIT license.
  15946. * http://jquery.org/license
  15947. */
  15948. //>>label: Transfer Effect
  15949. //>>group: Effects
  15950. //>>description: Displays a transfer effect from one element to another.
  15951. //>>docs: http://api.jqueryui.com/transfer-effect/
  15952. //>>demos: http://jqueryui.com/effect/
  15953. var effect;
  15954. if ( $.uiBackCompat !== false ) {
  15955. effect = $.effects.define( "transfer", function( options, done ) {
  15956. $( this ).transfer( options, done );
  15957. } );
  15958. }
  15959. var effectsEffectTransfer = effect;
  15960. } );