1
0

jquery-ui.js 509 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706
  1. /*! jQuery UI - v1.12.1 - 2016-09-14
  2. * http://jqueryui.com
  3. * Includes: widget.js, position.js, data.js, disable-selection.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, focusable.js, form-reset-mixin.js, jquery-1-7.js, keycode.js, labels.js, scroll-parent.js, tabbable.js, unique-id.js, widgets/accordion.js, widgets/autocomplete.js, widgets/button.js, widgets/checkboxradio.js, widgets/controlgroup.js, widgets/datepicker.js, widgets/dialog.js, widgets/draggable.js, widgets/droppable.js, widgets/menu.js, widgets/mouse.js, widgets/progressbar.js, widgets/resizable.js, widgets/selectable.js, widgets/selectmenu.js, widgets/slider.js, widgets/sortable.js, widgets/spinner.js, widgets/tabs.js, widgets/tooltip.js
  4. * Copyright jQuery Foundation and other contributors; Licensed MIT */
  5. (function( factory ) {
  6. if ( typeof define === "function" && define.amd ) {
  7. // AMD. Register as an anonymous module.
  8. define([ "jquery" ], factory );
  9. } else {
  10. // Browser globals
  11. factory( jQuery );
  12. }
  13. }(function( $ ) {
  14. $.ui = $.ui || {};
  15. var version = $.ui.version = "1.12.1";
  16. /*!
  17. * jQuery UI Widget 1.12.1
  18. * http://jqueryui.com
  19. *
  20. * Copyright jQuery Foundation and other contributors
  21. * Released under the MIT license.
  22. * http://jquery.org/license
  23. */
  24. //>>label: Widget
  25. //>>group: Core
  26. //>>description: Provides a factory for creating stateful widgets with a common API.
  27. //>>docs: http://api.jqueryui.com/jQuery.widget/
  28. //>>demos: http://jqueryui.com/widget/
  29. var widgetUuid = 0;
  30. var widgetSlice = Array.prototype.slice;
  31. $.cleanData = ( function( orig ) {
  32. return function( elems ) {
  33. var events, elem, i;
  34. for ( i = 0; ( elem = elems[ i ] ) != null; i++ ) {
  35. try {
  36. // Only trigger remove when necessary to save time
  37. events = $._data( elem, "events" );
  38. if ( events && events.remove ) {
  39. $( elem ).triggerHandler( "remove" );
  40. }
  41. // Http://bugs.jquery.com/ticket/8235
  42. } catch ( e ) {}
  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 ( $.isArray( prototype ) ) {
  60. prototype = $.extend.apply( null, [ {} ].concat( prototype ) );
  61. }
  62. // Create selector for plugin
  63. $.expr[ ":" ][ 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 ( !$.isFunction( value ) ) {
  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 ( input[ inputIndex ].hasOwnProperty( 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 ( !$.isFunction( instance[ options ] ) || options.charAt( 0 ) === "_" ) {
  201. return $.error( "no such method '" + options + "' for " + name +
  202. " widget instance" );
  203. }
  204. methodValue = instance[ options ].apply( instance, args );
  205. if ( methodValue !== instance && methodValue !== undefined ) {
  206. returnValue = methodValue && methodValue.jquery ?
  207. returnValue.pushStack( methodValue.get() ) :
  208. methodValue;
  209. return false;
  210. }
  211. } );
  212. }
  213. } else {
  214. // Allow multiple hashes to be passed on init
  215. if ( args.length ) {
  216. options = $.widget.extend.apply( null, [ options ].concat( args ) );
  217. }
  218. this.each( function() {
  219. var instance = $.data( this, fullName );
  220. if ( instance ) {
  221. instance.option( options || {} );
  222. if ( instance._init ) {
  223. instance._init();
  224. }
  225. } else {
  226. $.data( this, fullName, new object( options, this ) );
  227. }
  228. } );
  229. }
  230. return returnValue;
  231. };
  232. };
  233. $.Widget = function( /* options, element */ ) {};
  234. $.Widget._childConstructors = [];
  235. $.Widget.prototype = {
  236. widgetName: "widget",
  237. widgetEventPrefix: "",
  238. defaultElement: "<div>",
  239. options: {
  240. classes: {},
  241. disabled: false,
  242. // Callbacks
  243. create: null
  244. },
  245. _createWidget: function( options, element ) {
  246. element = $( element || this.defaultElement || this )[ 0 ];
  247. this.element = $( element );
  248. this.uuid = widgetUuid++;
  249. this.eventNamespace = "." + this.widgetName + this.uuid;
  250. this.bindings = $();
  251. this.hoverable = $();
  252. this.focusable = $();
  253. this.classesElementLookup = {};
  254. if ( element !== this ) {
  255. $.data( element, this.widgetFullName, this );
  256. this._on( true, this.element, {
  257. remove: function( event ) {
  258. if ( event.target === element ) {
  259. this.destroy();
  260. }
  261. }
  262. } );
  263. this.document = $( element.style ?
  264. // Element within the document
  265. element.ownerDocument :
  266. // Element is window or document
  267. element.document || element );
  268. this.window = $( this.document[ 0 ].defaultView || this.document[ 0 ].parentWindow );
  269. }
  270. this.options = $.widget.extend( {},
  271. this.options,
  272. this._getCreateOptions(),
  273. options );
  274. this._create();
  275. if ( this.options.disabled ) {
  276. this._setOptionDisabled( this.options.disabled );
  277. }
  278. this._trigger( "create", null, this._getCreateEventData() );
  279. this._init();
  280. },
  281. _getCreateOptions: function() {
  282. return {};
  283. },
  284. _getCreateEventData: $.noop,
  285. _create: $.noop,
  286. _init: $.noop,
  287. destroy: function() {
  288. var that = this;
  289. this._destroy();
  290. $.each( this.classesElementLookup, function( key, value ) {
  291. that._removeClass( value, key );
  292. } );
  293. // We can probably remove the unbind calls in 2.0
  294. // all event bindings should go through this._on()
  295. this.element
  296. .off( this.eventNamespace )
  297. .removeData( this.widgetFullName );
  298. this.widget()
  299. .off( this.eventNamespace )
  300. .removeAttr( "aria-disabled" );
  301. // Clean up events and states
  302. this.bindings.off( this.eventNamespace );
  303. },
  304. _destroy: $.noop,
  305. widget: function() {
  306. return this.element;
  307. },
  308. option: function( key, value ) {
  309. var options = key;
  310. var parts;
  311. var curOption;
  312. var i;
  313. if ( arguments.length === 0 ) {
  314. // Don't return a reference to the internal hash
  315. return $.widget.extend( {}, this.options );
  316. }
  317. if ( typeof key === "string" ) {
  318. // Handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
  319. options = {};
  320. parts = key.split( "." );
  321. key = parts.shift();
  322. if ( parts.length ) {
  323. curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
  324. for ( i = 0; i < parts.length - 1; i++ ) {
  325. curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
  326. curOption = curOption[ parts[ i ] ];
  327. }
  328. key = parts.pop();
  329. if ( arguments.length === 1 ) {
  330. return curOption[ key ] === undefined ? null : curOption[ key ];
  331. }
  332. curOption[ key ] = value;
  333. } else {
  334. if ( arguments.length === 1 ) {
  335. return this.options[ key ] === undefined ? null : this.options[ key ];
  336. }
  337. options[ key ] = value;
  338. }
  339. }
  340. this._setOptions( options );
  341. return this;
  342. },
  343. _setOptions: function( options ) {
  344. var key;
  345. for ( key in options ) {
  346. this._setOption( key, options[ key ] );
  347. }
  348. return this;
  349. },
  350. _setOption: function( key, value ) {
  351. if ( key === "classes" ) {
  352. this._setOptionClasses( value );
  353. }
  354. this.options[ key ] = value;
  355. if ( key === "disabled" ) {
  356. this._setOptionDisabled( value );
  357. }
  358. return this;
  359. },
  360. _setOptionClasses: function( value ) {
  361. var classKey, elements, currentElements;
  362. for ( classKey in value ) {
  363. currentElements = this.classesElementLookup[ classKey ];
  364. if ( value[ classKey ] === this.options.classes[ classKey ] ||
  365. !currentElements ||
  366. !currentElements.length ) {
  367. continue;
  368. }
  369. // We are doing this to create a new jQuery object because the _removeClass() call
  370. // on the next line is going to destroy the reference to the current elements being
  371. // tracked. We need to save a copy of this collection so that we can add the new classes
  372. // below.
  373. elements = $( currentElements.get() );
  374. this._removeClass( currentElements, classKey );
  375. // We don't use _addClass() here, because that uses this.options.classes
  376. // for generating the string of classes. We want to use the value passed in from
  377. // _setOption(), this is the new value of the classes option which was passed to
  378. // _setOption(). We pass this value directly to _classes().
  379. elements.addClass( this._classes( {
  380. element: elements,
  381. keys: classKey,
  382. classes: value,
  383. add: true
  384. } ) );
  385. }
  386. },
  387. _setOptionDisabled: function( value ) {
  388. this._toggleClass( this.widget(), this.widgetFullName + "-disabled", null, !!value );
  389. // If the widget is becoming disabled, then nothing is interactive
  390. if ( value ) {
  391. this._removeClass( this.hoverable, null, "ui-state-hover" );
  392. this._removeClass( this.focusable, null, "ui-state-focus" );
  393. }
  394. },
  395. enable: function() {
  396. return this._setOptions( { disabled: false } );
  397. },
  398. disable: function() {
  399. return this._setOptions( { disabled: true } );
  400. },
  401. _classes: function( options ) {
  402. var full = [];
  403. var that = this;
  404. options = $.extend( {
  405. element: this.element,
  406. classes: this.options.classes || {}
  407. }, options );
  408. function processClassString( classes, checkOption ) {
  409. var current, i;
  410. for ( i = 0; i < classes.length; i++ ) {
  411. current = that.classesElementLookup[ classes[ i ] ] || $();
  412. if ( options.add ) {
  413. current = $( $.unique( current.get().concat( options.element.get() ) ) );
  414. } else {
  415. current = $( current.not( options.element ).get() );
  416. }
  417. that.classesElementLookup[ classes[ i ] ] = current;
  418. full.push( classes[ i ] );
  419. if ( checkOption && options.classes[ classes[ i ] ] ) {
  420. full.push( options.classes[ classes[ i ] ] );
  421. }
  422. }
  423. }
  424. this._on( options.element, {
  425. "remove": "_untrackClassesElement"
  426. } );
  427. if ( options.keys ) {
  428. processClassString( options.keys.match( /\S+/g ) || [], true );
  429. }
  430. if ( options.extra ) {
  431. processClassString( options.extra.match( /\S+/g ) || [] );
  432. }
  433. return full.join( " " );
  434. },
  435. _untrackClassesElement: function( event ) {
  436. var that = this;
  437. $.each( that.classesElementLookup, function( key, value ) {
  438. if ( $.inArray( event.target, value ) !== -1 ) {
  439. that.classesElementLookup[ key ] = $( value.not( event.target ).get() );
  440. }
  441. } );
  442. },
  443. _removeClass: function( element, keys, extra ) {
  444. return this._toggleClass( element, keys, extra, false );
  445. },
  446. _addClass: function( element, keys, extra ) {
  447. return this._toggleClass( element, keys, extra, true );
  448. },
  449. _toggleClass: function( element, keys, extra, add ) {
  450. add = ( typeof add === "boolean" ) ? add : extra;
  451. var shift = ( typeof element === "string" || element === null ),
  452. options = {
  453. extra: shift ? keys : extra,
  454. keys: shift ? element : keys,
  455. element: shift ? this.element : element,
  456. add: add
  457. };
  458. options.element.toggleClass( this._classes( options ), add );
  459. return this;
  460. },
  461. _on: function( suppressDisabledCheck, element, handlers ) {
  462. var delegateElement;
  463. var instance = this;
  464. // No suppressDisabledCheck flag, shuffle arguments
  465. if ( typeof suppressDisabledCheck !== "boolean" ) {
  466. handlers = element;
  467. element = suppressDisabledCheck;
  468. suppressDisabledCheck = false;
  469. }
  470. // No element argument, shuffle and use this.element
  471. if ( !handlers ) {
  472. handlers = element;
  473. element = this.element;
  474. delegateElement = this.widget();
  475. } else {
  476. element = delegateElement = $( element );
  477. this.bindings = this.bindings.add( element );
  478. }
  479. $.each( handlers, function( event, handler ) {
  480. function handlerProxy() {
  481. // Allow widgets to customize the disabled handling
  482. // - disabled as an array instead of boolean
  483. // - disabled class as method for disabling individual parts
  484. if ( !suppressDisabledCheck &&
  485. ( instance.options.disabled === true ||
  486. $( this ).hasClass( "ui-state-disabled" ) ) ) {
  487. return;
  488. }
  489. return ( typeof handler === "string" ? instance[ handler ] : handler )
  490. .apply( instance, arguments );
  491. }
  492. // Copy the guid so direct unbinding works
  493. if ( typeof handler !== "string" ) {
  494. handlerProxy.guid = handler.guid =
  495. handler.guid || handlerProxy.guid || $.guid++;
  496. }
  497. var match = event.match( /^([\w:-]*)\s*(.*)$/ );
  498. var eventName = match[ 1 ] + instance.eventNamespace;
  499. var selector = match[ 2 ];
  500. if ( selector ) {
  501. delegateElement.on( eventName, selector, handlerProxy );
  502. } else {
  503. element.on( eventName, handlerProxy );
  504. }
  505. } );
  506. },
  507. _off: function( element, eventName ) {
  508. eventName = ( eventName || "" ).split( " " ).join( this.eventNamespace + " " ) +
  509. this.eventNamespace;
  510. element.off( eventName ).off( eventName );
  511. // Clear the stack to avoid memory leaks (#10056)
  512. this.bindings = $( this.bindings.not( element ).get() );
  513. this.focusable = $( this.focusable.not( element ).get() );
  514. this.hoverable = $( this.hoverable.not( element ).get() );
  515. },
  516. _delay: function( handler, delay ) {
  517. function handlerProxy() {
  518. return ( typeof handler === "string" ? instance[ handler ] : handler )
  519. .apply( instance, arguments );
  520. }
  521. var instance = this;
  522. return setTimeout( handlerProxy, delay || 0 );
  523. },
  524. _hoverable: function( element ) {
  525. this.hoverable = this.hoverable.add( element );
  526. this._on( element, {
  527. mouseenter: function( event ) {
  528. this._addClass( $( event.currentTarget ), null, "ui-state-hover" );
  529. },
  530. mouseleave: function( event ) {
  531. this._removeClass( $( event.currentTarget ), null, "ui-state-hover" );
  532. }
  533. } );
  534. },
  535. _focusable: function( element ) {
  536. this.focusable = this.focusable.add( element );
  537. this._on( element, {
  538. focusin: function( event ) {
  539. this._addClass( $( event.currentTarget ), null, "ui-state-focus" );
  540. },
  541. focusout: function( event ) {
  542. this._removeClass( $( event.currentTarget ), null, "ui-state-focus" );
  543. }
  544. } );
  545. },
  546. _trigger: function( type, event, data ) {
  547. var prop, orig;
  548. var callback = this.options[ type ];
  549. data = data || {};
  550. event = $.Event( event );
  551. event.type = ( type === this.widgetEventPrefix ?
  552. type :
  553. this.widgetEventPrefix + type ).toLowerCase();
  554. // The original event may come from any element
  555. // so we need to reset the target on the new event
  556. event.target = this.element[ 0 ];
  557. // Copy original event properties over to the new event
  558. orig = event.originalEvent;
  559. if ( orig ) {
  560. for ( prop in orig ) {
  561. if ( !( prop in event ) ) {
  562. event[ prop ] = orig[ prop ];
  563. }
  564. }
  565. }
  566. this.element.trigger( event, data );
  567. return !( $.isFunction( callback ) &&
  568. callback.apply( this.element[ 0 ], [ event ].concat( data ) ) === false ||
  569. event.isDefaultPrevented() );
  570. }
  571. };
  572. $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
  573. $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
  574. if ( typeof options === "string" ) {
  575. options = { effect: options };
  576. }
  577. var hasOptions;
  578. var effectName = !options ?
  579. method :
  580. options === true || typeof options === "number" ?
  581. defaultEffect :
  582. options.effect || defaultEffect;
  583. options = options || {};
  584. if ( typeof options === "number" ) {
  585. options = { duration: options };
  586. }
  587. hasOptions = !$.isEmptyObject( options );
  588. options.complete = callback;
  589. if ( options.delay ) {
  590. element.delay( options.delay );
  591. }
  592. if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
  593. element[ method ]( options );
  594. } else if ( effectName !== method && element[ effectName ] ) {
  595. element[ effectName ]( options.duration, options.easing, callback );
  596. } else {
  597. element.queue( function( next ) {
  598. $( this )[ method ]();
  599. if ( callback ) {
  600. callback.call( element[ 0 ] );
  601. }
  602. next();
  603. } );
  604. }
  605. };
  606. } );
  607. var widget = $.widget;
  608. /*!
  609. * jQuery UI Position 1.12.1
  610. * http://jqueryui.com
  611. *
  612. * Copyright jQuery Foundation and other contributors
  613. * Released under the MIT license.
  614. * http://jquery.org/license
  615. *
  616. * http://api.jqueryui.com/position/
  617. */
  618. //>>label: Position
  619. //>>group: Core
  620. //>>description: Positions elements relative to other elements.
  621. //>>docs: http://api.jqueryui.com/position/
  622. //>>demos: http://jqueryui.com/position/
  623. ( function() {
  624. var cachedScrollbarWidth,
  625. max = Math.max,
  626. abs = Math.abs,
  627. rhorizontal = /left|center|right/,
  628. rvertical = /top|center|bottom/,
  629. roffset = /[\+\-]\d+(\.[\d]+)?%?/,
  630. rposition = /^\w+/,
  631. rpercent = /%$/,
  632. _position = $.fn.position;
  633. function getOffsets( offsets, width, height ) {
  634. return [
  635. parseFloat( offsets[ 0 ] ) * ( rpercent.test( offsets[ 0 ] ) ? width / 100 : 1 ),
  636. parseFloat( offsets[ 1 ] ) * ( rpercent.test( offsets[ 1 ] ) ? height / 100 : 1 )
  637. ];
  638. }
  639. function parseCss( element, property ) {
  640. return parseInt( $.css( element, property ), 10 ) || 0;
  641. }
  642. function getDimensions( elem ) {
  643. var raw = elem[ 0 ];
  644. if ( raw.nodeType === 9 ) {
  645. return {
  646. width: elem.width(),
  647. height: elem.height(),
  648. offset: { top: 0, left: 0 }
  649. };
  650. }
  651. if ( $.isWindow( raw ) ) {
  652. return {
  653. width: elem.width(),
  654. height: elem.height(),
  655. offset: { top: elem.scrollTop(), left: elem.scrollLeft() }
  656. };
  657. }
  658. if ( raw.preventDefault ) {
  659. return {
  660. width: 0,
  661. height: 0,
  662. offset: { top: raw.pageY, left: raw.pageX }
  663. };
  664. }
  665. return {
  666. width: elem.outerWidth(),
  667. height: elem.outerHeight(),
  668. offset: elem.offset()
  669. };
  670. }
  671. $.position = {
  672. scrollbarWidth: function() {
  673. if ( cachedScrollbarWidth !== undefined ) {
  674. return cachedScrollbarWidth;
  675. }
  676. var w1, w2,
  677. div = $( "<div " +
  678. "style='display:block;position:absolute;width:50px;height:50px;overflow:hidden;'>" +
  679. "<div style='height:100px;width:auto;'></div></div>" ),
  680. innerDiv = div.children()[ 0 ];
  681. $( "body" ).append( div );
  682. w1 = innerDiv.offsetWidth;
  683. div.css( "overflow", "scroll" );
  684. w2 = innerDiv.offsetWidth;
  685. if ( w1 === w2 ) {
  686. w2 = div[ 0 ].clientWidth;
  687. }
  688. div.remove();
  689. return ( cachedScrollbarWidth = w1 - w2 );
  690. },
  691. getScrollInfo: function( within ) {
  692. var overflowX = within.isWindow || within.isDocument ? "" :
  693. within.element.css( "overflow-x" ),
  694. overflowY = within.isWindow || within.isDocument ? "" :
  695. within.element.css( "overflow-y" ),
  696. hasOverflowX = overflowX === "scroll" ||
  697. ( overflowX === "auto" && within.width < within.element[ 0 ].scrollWidth ),
  698. hasOverflowY = overflowY === "scroll" ||
  699. ( overflowY === "auto" && within.height < within.element[ 0 ].scrollHeight );
  700. return {
  701. width: hasOverflowY ? $.position.scrollbarWidth() : 0,
  702. height: hasOverflowX ? $.position.scrollbarWidth() : 0
  703. };
  704. },
  705. getWithinInfo: function( element ) {
  706. var withinElement = $( element || window ),
  707. isWindow = $.isWindow( withinElement[ 0 ] ),
  708. isDocument = !!withinElement[ 0 ] && withinElement[ 0 ].nodeType === 9,
  709. hasOffset = !isWindow && !isDocument;
  710. return {
  711. element: withinElement,
  712. isWindow: isWindow,
  713. isDocument: isDocument,
  714. offset: hasOffset ? $( element ).offset() : { left: 0, top: 0 },
  715. scrollLeft: withinElement.scrollLeft(),
  716. scrollTop: withinElement.scrollTop(),
  717. width: withinElement.outerWidth(),
  718. height: withinElement.outerHeight()
  719. };
  720. }
  721. };
  722. $.fn.position = function( options ) {
  723. if ( !options || !options.of ) {
  724. return _position.apply( this, arguments );
  725. }
  726. // Make a copy, we don't want to modify arguments
  727. options = $.extend( {}, options );
  728. var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
  729. target = $( options.of ),
  730. within = $.position.getWithinInfo( options.within ),
  731. scrollInfo = $.position.getScrollInfo( within ),
  732. collision = ( options.collision || "flip" ).split( " " ),
  733. offsets = {};
  734. dimensions = getDimensions( target );
  735. if ( target[ 0 ].preventDefault ) {
  736. // Force left top to allow flipping
  737. options.at = "left top";
  738. }
  739. targetWidth = dimensions.width;
  740. targetHeight = dimensions.height;
  741. targetOffset = dimensions.offset;
  742. // Clone to reuse original targetOffset later
  743. basePosition = $.extend( {}, targetOffset );
  744. // Force my and at to have valid horizontal and vertical positions
  745. // if a value is missing or invalid, it will be converted to center
  746. $.each( [ "my", "at" ], function() {
  747. var pos = ( options[ this ] || "" ).split( " " ),
  748. horizontalOffset,
  749. verticalOffset;
  750. if ( pos.length === 1 ) {
  751. pos = rhorizontal.test( pos[ 0 ] ) ?
  752. pos.concat( [ "center" ] ) :
  753. rvertical.test( pos[ 0 ] ) ?
  754. [ "center" ].concat( pos ) :
  755. [ "center", "center" ];
  756. }
  757. pos[ 0 ] = rhorizontal.test( pos[ 0 ] ) ? pos[ 0 ] : "center";
  758. pos[ 1 ] = rvertical.test( pos[ 1 ] ) ? pos[ 1 ] : "center";
  759. // Calculate offsets
  760. horizontalOffset = roffset.exec( pos[ 0 ] );
  761. verticalOffset = roffset.exec( pos[ 1 ] );
  762. offsets[ this ] = [
  763. horizontalOffset ? horizontalOffset[ 0 ] : 0,
  764. verticalOffset ? verticalOffset[ 0 ] : 0
  765. ];
  766. // Reduce to just the positions without the offsets
  767. options[ this ] = [
  768. rposition.exec( pos[ 0 ] )[ 0 ],
  769. rposition.exec( pos[ 1 ] )[ 0 ]
  770. ];
  771. } );
  772. // Normalize collision option
  773. if ( collision.length === 1 ) {
  774. collision[ 1 ] = collision[ 0 ];
  775. }
  776. if ( options.at[ 0 ] === "right" ) {
  777. basePosition.left += targetWidth;
  778. } else if ( options.at[ 0 ] === "center" ) {
  779. basePosition.left += targetWidth / 2;
  780. }
  781. if ( options.at[ 1 ] === "bottom" ) {
  782. basePosition.top += targetHeight;
  783. } else if ( options.at[ 1 ] === "center" ) {
  784. basePosition.top += targetHeight / 2;
  785. }
  786. atOffset = getOffsets( offsets.at, targetWidth, targetHeight );
  787. basePosition.left += atOffset[ 0 ];
  788. basePosition.top += atOffset[ 1 ];
  789. return this.each( function() {
  790. var collisionPosition, using,
  791. elem = $( this ),
  792. elemWidth = elem.outerWidth(),
  793. elemHeight = elem.outerHeight(),
  794. marginLeft = parseCss( this, "marginLeft" ),
  795. marginTop = parseCss( this, "marginTop" ),
  796. collisionWidth = elemWidth + marginLeft + parseCss( this, "marginRight" ) +
  797. scrollInfo.width,
  798. collisionHeight = elemHeight + marginTop + parseCss( this, "marginBottom" ) +
  799. scrollInfo.height,
  800. position = $.extend( {}, basePosition ),
  801. myOffset = getOffsets( offsets.my, elem.outerWidth(), elem.outerHeight() );
  802. if ( options.my[ 0 ] === "right" ) {
  803. position.left -= elemWidth;
  804. } else if ( options.my[ 0 ] === "center" ) {
  805. position.left -= elemWidth / 2;
  806. }
  807. if ( options.my[ 1 ] === "bottom" ) {
  808. position.top -= elemHeight;
  809. } else if ( options.my[ 1 ] === "center" ) {
  810. position.top -= elemHeight / 2;
  811. }
  812. position.left += myOffset[ 0 ];
  813. position.top += myOffset[ 1 ];
  814. collisionPosition = {
  815. marginLeft: marginLeft,
  816. marginTop: marginTop
  817. };
  818. $.each( [ "left", "top" ], function( i, dir ) {
  819. if ( $.ui.position[ collision[ i ] ] ) {
  820. $.ui.position[ collision[ i ] ][ dir ]( position, {
  821. targetWidth: targetWidth,
  822. targetHeight: targetHeight,
  823. elemWidth: elemWidth,
  824. elemHeight: elemHeight,
  825. collisionPosition: collisionPosition,
  826. collisionWidth: collisionWidth,
  827. collisionHeight: collisionHeight,
  828. offset: [ atOffset[ 0 ] + myOffset[ 0 ], atOffset [ 1 ] + myOffset[ 1 ] ],
  829. my: options.my,
  830. at: options.at,
  831. within: within,
  832. elem: elem
  833. } );
  834. }
  835. } );
  836. if ( options.using ) {
  837. // Adds feedback as second argument to using callback, if present
  838. using = function( props ) {
  839. var left = targetOffset.left - position.left,
  840. right = left + targetWidth - elemWidth,
  841. top = targetOffset.top - position.top,
  842. bottom = top + targetHeight - elemHeight,
  843. feedback = {
  844. target: {
  845. element: target,
  846. left: targetOffset.left,
  847. top: targetOffset.top,
  848. width: targetWidth,
  849. height: targetHeight
  850. },
  851. element: {
  852. element: elem,
  853. left: position.left,
  854. top: position.top,
  855. width: elemWidth,
  856. height: elemHeight
  857. },
  858. horizontal: right < 0 ? "left" : left > 0 ? "right" : "center",
  859. vertical: bottom < 0 ? "top" : top > 0 ? "bottom" : "middle"
  860. };
  861. if ( targetWidth < elemWidth && abs( left + right ) < targetWidth ) {
  862. feedback.horizontal = "center";
  863. }
  864. if ( targetHeight < elemHeight && abs( top + bottom ) < targetHeight ) {
  865. feedback.vertical = "middle";
  866. }
  867. if ( max( abs( left ), abs( right ) ) > max( abs( top ), abs( bottom ) ) ) {
  868. feedback.important = "horizontal";
  869. } else {
  870. feedback.important = "vertical";
  871. }
  872. options.using.call( this, props, feedback );
  873. };
  874. }
  875. elem.offset( $.extend( position, { using: using } ) );
  876. } );
  877. };
  878. $.ui.position = {
  879. fit: {
  880. left: function( position, data ) {
  881. var within = data.within,
  882. withinOffset = within.isWindow ? within.scrollLeft : within.offset.left,
  883. outerWidth = within.width,
  884. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  885. overLeft = withinOffset - collisionPosLeft,
  886. overRight = collisionPosLeft + data.collisionWidth - outerWidth - withinOffset,
  887. newOverRight;
  888. // Element is wider than within
  889. if ( data.collisionWidth > outerWidth ) {
  890. // Element is initially over the left side of within
  891. if ( overLeft > 0 && overRight <= 0 ) {
  892. newOverRight = position.left + overLeft + data.collisionWidth - outerWidth -
  893. withinOffset;
  894. position.left += overLeft - newOverRight;
  895. // Element is initially over right side of within
  896. } else if ( overRight > 0 && overLeft <= 0 ) {
  897. position.left = withinOffset;
  898. // Element is initially over both left and right sides of within
  899. } else {
  900. if ( overLeft > overRight ) {
  901. position.left = withinOffset + outerWidth - data.collisionWidth;
  902. } else {
  903. position.left = withinOffset;
  904. }
  905. }
  906. // Too far left -> align with left edge
  907. } else if ( overLeft > 0 ) {
  908. position.left += overLeft;
  909. // Too far right -> align with right edge
  910. } else if ( overRight > 0 ) {
  911. position.left -= overRight;
  912. // Adjust based on position and margin
  913. } else {
  914. position.left = max( position.left - collisionPosLeft, position.left );
  915. }
  916. },
  917. top: function( position, data ) {
  918. var within = data.within,
  919. withinOffset = within.isWindow ? within.scrollTop : within.offset.top,
  920. outerHeight = data.within.height,
  921. collisionPosTop = position.top - data.collisionPosition.marginTop,
  922. overTop = withinOffset - collisionPosTop,
  923. overBottom = collisionPosTop + data.collisionHeight - outerHeight - withinOffset,
  924. newOverBottom;
  925. // Element is taller than within
  926. if ( data.collisionHeight > outerHeight ) {
  927. // Element is initially over the top of within
  928. if ( overTop > 0 && overBottom <= 0 ) {
  929. newOverBottom = position.top + overTop + data.collisionHeight - outerHeight -
  930. withinOffset;
  931. position.top += overTop - newOverBottom;
  932. // Element is initially over bottom of within
  933. } else if ( overBottom > 0 && overTop <= 0 ) {
  934. position.top = withinOffset;
  935. // Element is initially over both top and bottom of within
  936. } else {
  937. if ( overTop > overBottom ) {
  938. position.top = withinOffset + outerHeight - data.collisionHeight;
  939. } else {
  940. position.top = withinOffset;
  941. }
  942. }
  943. // Too far up -> align with top
  944. } else if ( overTop > 0 ) {
  945. position.top += overTop;
  946. // Too far down -> align with bottom edge
  947. } else if ( overBottom > 0 ) {
  948. position.top -= overBottom;
  949. // Adjust based on position and margin
  950. } else {
  951. position.top = max( position.top - collisionPosTop, position.top );
  952. }
  953. }
  954. },
  955. flip: {
  956. left: function( position, data ) {
  957. var within = data.within,
  958. withinOffset = within.offset.left + within.scrollLeft,
  959. outerWidth = within.width,
  960. offsetLeft = within.isWindow ? within.scrollLeft : within.offset.left,
  961. collisionPosLeft = position.left - data.collisionPosition.marginLeft,
  962. overLeft = collisionPosLeft - offsetLeft,
  963. overRight = collisionPosLeft + data.collisionWidth - outerWidth - offsetLeft,
  964. myOffset = data.my[ 0 ] === "left" ?
  965. -data.elemWidth :
  966. data.my[ 0 ] === "right" ?
  967. data.elemWidth :
  968. 0,
  969. atOffset = data.at[ 0 ] === "left" ?
  970. data.targetWidth :
  971. data.at[ 0 ] === "right" ?
  972. -data.targetWidth :
  973. 0,
  974. offset = -2 * data.offset[ 0 ],
  975. newOverRight,
  976. newOverLeft;
  977. if ( overLeft < 0 ) {
  978. newOverRight = position.left + myOffset + atOffset + offset + data.collisionWidth -
  979. outerWidth - withinOffset;
  980. if ( newOverRight < 0 || newOverRight < abs( overLeft ) ) {
  981. position.left += myOffset + atOffset + offset;
  982. }
  983. } else if ( overRight > 0 ) {
  984. newOverLeft = position.left - data.collisionPosition.marginLeft + myOffset +
  985. atOffset + offset - offsetLeft;
  986. if ( newOverLeft > 0 || abs( newOverLeft ) < overRight ) {
  987. position.left += myOffset + atOffset + offset;
  988. }
  989. }
  990. },
  991. top: function( position, data ) {
  992. var within = data.within,
  993. withinOffset = within.offset.top + within.scrollTop,
  994. outerHeight = within.height,
  995. offsetTop = within.isWindow ? within.scrollTop : within.offset.top,
  996. collisionPosTop = position.top - data.collisionPosition.marginTop,
  997. overTop = collisionPosTop - offsetTop,
  998. overBottom = collisionPosTop + data.collisionHeight - outerHeight - offsetTop,
  999. top = data.my[ 1 ] === "top",
  1000. myOffset = top ?
  1001. -data.elemHeight :
  1002. data.my[ 1 ] === "bottom" ?
  1003. data.elemHeight :
  1004. 0,
  1005. atOffset = data.at[ 1 ] === "top" ?
  1006. data.targetHeight :
  1007. data.at[ 1 ] === "bottom" ?
  1008. -data.targetHeight :
  1009. 0,
  1010. offset = -2 * data.offset[ 1 ],
  1011. newOverTop,
  1012. newOverBottom;
  1013. if ( overTop < 0 ) {
  1014. newOverBottom = position.top + myOffset + atOffset + offset + data.collisionHeight -
  1015. outerHeight - withinOffset;
  1016. if ( newOverBottom < 0 || newOverBottom < abs( overTop ) ) {
  1017. position.top += myOffset + atOffset + offset;
  1018. }
  1019. } else if ( overBottom > 0 ) {
  1020. newOverTop = position.top - data.collisionPosition.marginTop + myOffset + atOffset +
  1021. offset - offsetTop;
  1022. if ( newOverTop > 0 || abs( newOverTop ) < overBottom ) {
  1023. position.top += myOffset + atOffset + offset;
  1024. }
  1025. }
  1026. }
  1027. },
  1028. flipfit: {
  1029. left: function() {
  1030. $.ui.position.flip.left.apply( this, arguments );
  1031. $.ui.position.fit.left.apply( this, arguments );
  1032. },
  1033. top: function() {
  1034. $.ui.position.flip.top.apply( this, arguments );
  1035. $.ui.position.fit.top.apply( this, arguments );
  1036. }
  1037. }
  1038. };
  1039. } )();
  1040. var position = $.ui.position;
  1041. /*!
  1042. * jQuery UI :data 1.12.1
  1043. * http://jqueryui.com
  1044. *
  1045. * Copyright jQuery Foundation and other contributors
  1046. * Released under the MIT license.
  1047. * http://jquery.org/license
  1048. */
  1049. //>>label: :data Selector
  1050. //>>group: Core
  1051. //>>description: Selects elements which have data stored under the specified key.
  1052. //>>docs: http://api.jqueryui.com/data-selector/
  1053. var data = $.extend( $.expr[ ":" ], {
  1054. data: $.expr.createPseudo ?
  1055. $.expr.createPseudo( function( dataName ) {
  1056. return function( elem ) {
  1057. return !!$.data( elem, dataName );
  1058. };
  1059. } ) :
  1060. // Support: jQuery <1.8
  1061. function( elem, i, match ) {
  1062. return !!$.data( elem, match[ 3 ] );
  1063. }
  1064. } );
  1065. /*!
  1066. * jQuery UI Disable Selection 1.12.1
  1067. * http://jqueryui.com
  1068. *
  1069. * Copyright jQuery Foundation and other contributors
  1070. * Released under the MIT license.
  1071. * http://jquery.org/license
  1072. */
  1073. //>>label: disableSelection
  1074. //>>group: Core
  1075. //>>description: Disable selection of text content within the set of matched elements.
  1076. //>>docs: http://api.jqueryui.com/disableSelection/
  1077. // This file is deprecated
  1078. var disableSelection = $.fn.extend( {
  1079. disableSelection: ( function() {
  1080. var eventType = "onselectstart" in document.createElement( "div" ) ?
  1081. "selectstart" :
  1082. "mousedown";
  1083. return function() {
  1084. return this.on( eventType + ".ui-disableSelection", function( event ) {
  1085. event.preventDefault();
  1086. } );
  1087. };
  1088. } )(),
  1089. enableSelection: function() {
  1090. return this.off( ".ui-disableSelection" );
  1091. }
  1092. } );
  1093. /*!
  1094. * jQuery UI Effects 1.12.1
  1095. * http://jqueryui.com
  1096. *
  1097. * Copyright jQuery Foundation and other contributors
  1098. * Released under the MIT license.
  1099. * http://jquery.org/license
  1100. */
  1101. //>>label: Effects Core
  1102. //>>group: Effects
  1103. // jscs:disable maximumLineLength
  1104. //>>description: Extends the internal jQuery effects. Includes morphing and easing. Required by all other effects.
  1105. // jscs:enable maximumLineLength
  1106. //>>docs: http://api.jqueryui.com/category/effects-core/
  1107. //>>demos: http://jqueryui.com/effect/
  1108. var dataSpace = "ui-effects-",
  1109. dataSpaceStyle = "ui-effects-style",
  1110. dataSpaceAnimated = "ui-effects-animated",
  1111. // Create a local jQuery because jQuery Color relies on it and the
  1112. // global may not exist with AMD and a custom build (#10199)
  1113. jQuery = $;
  1114. $.effects = {
  1115. effect: {}
  1116. };
  1117. /*!
  1118. * jQuery Color Animations v2.1.2
  1119. * https://github.com/jquery/jquery-color
  1120. *
  1121. * Copyright 2014 jQuery Foundation and other contributors
  1122. * Released under the MIT license.
  1123. * http://jquery.org/license
  1124. *
  1125. * Date: Wed Jan 16 08:47:09 2013 -0600
  1126. */
  1127. ( function( jQuery, undefined ) {
  1128. var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor " +
  1129. "borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
  1130. // Plusequals test for += 100 -= 100
  1131. rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
  1132. // A set of RE's that can match strings and generate color tuples.
  1133. stringParsers = [ {
  1134. re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  1135. parse: function( execResult ) {
  1136. return [
  1137. execResult[ 1 ],
  1138. execResult[ 2 ],
  1139. execResult[ 3 ],
  1140. execResult[ 4 ]
  1141. ];
  1142. }
  1143. }, {
  1144. re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  1145. parse: function( execResult ) {
  1146. return [
  1147. execResult[ 1 ] * 2.55,
  1148. execResult[ 2 ] * 2.55,
  1149. execResult[ 3 ] * 2.55,
  1150. execResult[ 4 ]
  1151. ];
  1152. }
  1153. }, {
  1154. // This regex ignores A-F because it's compared against an already lowercased string
  1155. re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
  1156. parse: function( execResult ) {
  1157. return [
  1158. parseInt( execResult[ 1 ], 16 ),
  1159. parseInt( execResult[ 2 ], 16 ),
  1160. parseInt( execResult[ 3 ], 16 )
  1161. ];
  1162. }
  1163. }, {
  1164. // This regex ignores A-F because it's compared against an already lowercased string
  1165. re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
  1166. parse: function( execResult ) {
  1167. return [
  1168. parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
  1169. parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
  1170. parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
  1171. ];
  1172. }
  1173. }, {
  1174. re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  1175. space: "hsla",
  1176. parse: function( execResult ) {
  1177. return [
  1178. execResult[ 1 ],
  1179. execResult[ 2 ] / 100,
  1180. execResult[ 3 ] / 100,
  1181. execResult[ 4 ]
  1182. ];
  1183. }
  1184. } ],
  1185. // JQuery.Color( )
  1186. color = jQuery.Color = function( color, green, blue, alpha ) {
  1187. return new jQuery.Color.fn.parse( color, green, blue, alpha );
  1188. },
  1189. spaces = {
  1190. rgba: {
  1191. props: {
  1192. red: {
  1193. idx: 0,
  1194. type: "byte"
  1195. },
  1196. green: {
  1197. idx: 1,
  1198. type: "byte"
  1199. },
  1200. blue: {
  1201. idx: 2,
  1202. type: "byte"
  1203. }
  1204. }
  1205. },
  1206. hsla: {
  1207. props: {
  1208. hue: {
  1209. idx: 0,
  1210. type: "degrees"
  1211. },
  1212. saturation: {
  1213. idx: 1,
  1214. type: "percent"
  1215. },
  1216. lightness: {
  1217. idx: 2,
  1218. type: "percent"
  1219. }
  1220. }
  1221. }
  1222. },
  1223. propTypes = {
  1224. "byte": {
  1225. floor: true,
  1226. max: 255
  1227. },
  1228. "percent": {
  1229. max: 1
  1230. },
  1231. "degrees": {
  1232. mod: 360,
  1233. floor: true
  1234. }
  1235. },
  1236. support = color.support = {},
  1237. // Element for support tests
  1238. supportElem = jQuery( "<p>" )[ 0 ],
  1239. // Colors = jQuery.Color.names
  1240. colors,
  1241. // Local aliases of functions called often
  1242. each = jQuery.each;
  1243. // Determine rgba support immediately
  1244. supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
  1245. support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
  1246. // Define cache name and alpha properties
  1247. // for rgba and hsla spaces
  1248. each( spaces, function( spaceName, space ) {
  1249. space.cache = "_" + spaceName;
  1250. space.props.alpha = {
  1251. idx: 3,
  1252. type: "percent",
  1253. def: 1
  1254. };
  1255. } );
  1256. function clamp( value, prop, allowEmpty ) {
  1257. var type = propTypes[ prop.type ] || {};
  1258. if ( value == null ) {
  1259. return ( allowEmpty || !prop.def ) ? null : prop.def;
  1260. }
  1261. // ~~ is an short way of doing floor for positive numbers
  1262. value = type.floor ? ~~value : parseFloat( value );
  1263. // IE will pass in empty strings as value for alpha,
  1264. // which will hit this case
  1265. if ( isNaN( value ) ) {
  1266. return prop.def;
  1267. }
  1268. if ( type.mod ) {
  1269. // We add mod before modding to make sure that negatives values
  1270. // get converted properly: -10 -> 350
  1271. return ( value + type.mod ) % type.mod;
  1272. }
  1273. // For now all property types without mod have min and max
  1274. return 0 > value ? 0 : type.max < value ? type.max : value;
  1275. }
  1276. function stringParse( string ) {
  1277. var inst = color(),
  1278. rgba = inst._rgba = [];
  1279. string = string.toLowerCase();
  1280. each( stringParsers, function( i, parser ) {
  1281. var parsed,
  1282. match = parser.re.exec( string ),
  1283. values = match && parser.parse( match ),
  1284. spaceName = parser.space || "rgba";
  1285. if ( values ) {
  1286. parsed = inst[ spaceName ]( values );
  1287. // If this was an rgba parse the assignment might happen twice
  1288. // oh well....
  1289. inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
  1290. rgba = inst._rgba = parsed._rgba;
  1291. // Exit each( stringParsers ) here because we matched
  1292. return false;
  1293. }
  1294. } );
  1295. // Found a stringParser that handled it
  1296. if ( rgba.length ) {
  1297. // If this came from a parsed string, force "transparent" when alpha is 0
  1298. // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
  1299. if ( rgba.join() === "0,0,0,0" ) {
  1300. jQuery.extend( rgba, colors.transparent );
  1301. }
  1302. return inst;
  1303. }
  1304. // Named colors
  1305. return colors[ string ];
  1306. }
  1307. color.fn = jQuery.extend( color.prototype, {
  1308. parse: function( red, green, blue, alpha ) {
  1309. if ( red === undefined ) {
  1310. this._rgba = [ null, null, null, null ];
  1311. return this;
  1312. }
  1313. if ( red.jquery || red.nodeType ) {
  1314. red = jQuery( red ).css( green );
  1315. green = undefined;
  1316. }
  1317. var inst = this,
  1318. type = jQuery.type( red ),
  1319. rgba = this._rgba = [];
  1320. // More than 1 argument specified - assume ( red, green, blue, alpha )
  1321. if ( green !== undefined ) {
  1322. red = [ red, green, blue, alpha ];
  1323. type = "array";
  1324. }
  1325. if ( type === "string" ) {
  1326. return this.parse( stringParse( red ) || colors._default );
  1327. }
  1328. if ( type === "array" ) {
  1329. each( spaces.rgba.props, function( key, prop ) {
  1330. rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
  1331. } );
  1332. return this;
  1333. }
  1334. if ( type === "object" ) {
  1335. if ( red instanceof color ) {
  1336. each( spaces, function( spaceName, space ) {
  1337. if ( red[ space.cache ] ) {
  1338. inst[ space.cache ] = red[ space.cache ].slice();
  1339. }
  1340. } );
  1341. } else {
  1342. each( spaces, function( spaceName, space ) {
  1343. var cache = space.cache;
  1344. each( space.props, function( key, prop ) {
  1345. // If the cache doesn't exist, and we know how to convert
  1346. if ( !inst[ cache ] && space.to ) {
  1347. // If the value was null, we don't need to copy it
  1348. // if the key was alpha, we don't need to copy it either
  1349. if ( key === "alpha" || red[ key ] == null ) {
  1350. return;
  1351. }
  1352. inst[ cache ] = space.to( inst._rgba );
  1353. }
  1354. // This is the only case where we allow nulls for ALL properties.
  1355. // call clamp with alwaysAllowEmpty
  1356. inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
  1357. } );
  1358. // Everything defined but alpha?
  1359. if ( inst[ cache ] &&
  1360. jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
  1361. // Use the default of 1
  1362. inst[ cache ][ 3 ] = 1;
  1363. if ( space.from ) {
  1364. inst._rgba = space.from( inst[ cache ] );
  1365. }
  1366. }
  1367. } );
  1368. }
  1369. return this;
  1370. }
  1371. },
  1372. is: function( compare ) {
  1373. var is = color( compare ),
  1374. same = true,
  1375. inst = this;
  1376. each( spaces, function( _, space ) {
  1377. var localCache,
  1378. isCache = is[ space.cache ];
  1379. if ( isCache ) {
  1380. localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
  1381. each( space.props, function( _, prop ) {
  1382. if ( isCache[ prop.idx ] != null ) {
  1383. same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
  1384. return same;
  1385. }
  1386. } );
  1387. }
  1388. return same;
  1389. } );
  1390. return same;
  1391. },
  1392. _space: function() {
  1393. var used = [],
  1394. inst = this;
  1395. each( spaces, function( spaceName, space ) {
  1396. if ( inst[ space.cache ] ) {
  1397. used.push( spaceName );
  1398. }
  1399. } );
  1400. return used.pop();
  1401. },
  1402. transition: function( other, distance ) {
  1403. var end = color( other ),
  1404. spaceName = end._space(),
  1405. space = spaces[ spaceName ],
  1406. startColor = this.alpha() === 0 ? color( "transparent" ) : this,
  1407. start = startColor[ space.cache ] || space.to( startColor._rgba ),
  1408. result = start.slice();
  1409. end = end[ space.cache ];
  1410. each( space.props, function( key, prop ) {
  1411. var index = prop.idx,
  1412. startValue = start[ index ],
  1413. endValue = end[ index ],
  1414. type = propTypes[ prop.type ] || {};
  1415. // If null, don't override start value
  1416. if ( endValue === null ) {
  1417. return;
  1418. }
  1419. // If null - use end
  1420. if ( startValue === null ) {
  1421. result[ index ] = endValue;
  1422. } else {
  1423. if ( type.mod ) {
  1424. if ( endValue - startValue > type.mod / 2 ) {
  1425. startValue += type.mod;
  1426. } else if ( startValue - endValue > type.mod / 2 ) {
  1427. startValue -= type.mod;
  1428. }
  1429. }
  1430. result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
  1431. }
  1432. } );
  1433. return this[ spaceName ]( result );
  1434. },
  1435. blend: function( opaque ) {
  1436. // If we are already opaque - return ourself
  1437. if ( this._rgba[ 3 ] === 1 ) {
  1438. return this;
  1439. }
  1440. var rgb = this._rgba.slice(),
  1441. a = rgb.pop(),
  1442. blend = color( opaque )._rgba;
  1443. return color( jQuery.map( rgb, function( v, i ) {
  1444. return ( 1 - a ) * blend[ i ] + a * v;
  1445. } ) );
  1446. },
  1447. toRgbaString: function() {
  1448. var prefix = "rgba(",
  1449. rgba = jQuery.map( this._rgba, function( v, i ) {
  1450. return v == null ? ( i > 2 ? 1 : 0 ) : v;
  1451. } );
  1452. if ( rgba[ 3 ] === 1 ) {
  1453. rgba.pop();
  1454. prefix = "rgb(";
  1455. }
  1456. return prefix + rgba.join() + ")";
  1457. },
  1458. toHslaString: function() {
  1459. var prefix = "hsla(",
  1460. hsla = jQuery.map( this.hsla(), function( v, i ) {
  1461. if ( v == null ) {
  1462. v = i > 2 ? 1 : 0;
  1463. }
  1464. // Catch 1 and 2
  1465. if ( i && i < 3 ) {
  1466. v = Math.round( v * 100 ) + "%";
  1467. }
  1468. return v;
  1469. } );
  1470. if ( hsla[ 3 ] === 1 ) {
  1471. hsla.pop();
  1472. prefix = "hsl(";
  1473. }
  1474. return prefix + hsla.join() + ")";
  1475. },
  1476. toHexString: function( includeAlpha ) {
  1477. var rgba = this._rgba.slice(),
  1478. alpha = rgba.pop();
  1479. if ( includeAlpha ) {
  1480. rgba.push( ~~( alpha * 255 ) );
  1481. }
  1482. return "#" + jQuery.map( rgba, function( v ) {
  1483. // Default to 0 when nulls exist
  1484. v = ( v || 0 ).toString( 16 );
  1485. return v.length === 1 ? "0" + v : v;
  1486. } ).join( "" );
  1487. },
  1488. toString: function() {
  1489. return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
  1490. }
  1491. } );
  1492. color.fn.parse.prototype = color.fn;
  1493. // Hsla conversions adapted from:
  1494. // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
  1495. function hue2rgb( p, q, h ) {
  1496. h = ( h + 1 ) % 1;
  1497. if ( h * 6 < 1 ) {
  1498. return p + ( q - p ) * h * 6;
  1499. }
  1500. if ( h * 2 < 1 ) {
  1501. return q;
  1502. }
  1503. if ( h * 3 < 2 ) {
  1504. return p + ( q - p ) * ( ( 2 / 3 ) - h ) * 6;
  1505. }
  1506. return p;
  1507. }
  1508. spaces.hsla.to = function( rgba ) {
  1509. if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
  1510. return [ null, null, null, rgba[ 3 ] ];
  1511. }
  1512. var r = rgba[ 0 ] / 255,
  1513. g = rgba[ 1 ] / 255,
  1514. b = rgba[ 2 ] / 255,
  1515. a = rgba[ 3 ],
  1516. max = Math.max( r, g, b ),
  1517. min = Math.min( r, g, b ),
  1518. diff = max - min,
  1519. add = max + min,
  1520. l = add * 0.5,
  1521. h, s;
  1522. if ( min === max ) {
  1523. h = 0;
  1524. } else if ( r === max ) {
  1525. h = ( 60 * ( g - b ) / diff ) + 360;
  1526. } else if ( g === max ) {
  1527. h = ( 60 * ( b - r ) / diff ) + 120;
  1528. } else {
  1529. h = ( 60 * ( r - g ) / diff ) + 240;
  1530. }
  1531. // Chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
  1532. // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
  1533. if ( diff === 0 ) {
  1534. s = 0;
  1535. } else if ( l <= 0.5 ) {
  1536. s = diff / add;
  1537. } else {
  1538. s = diff / ( 2 - add );
  1539. }
  1540. return [ Math.round( h ) % 360, s, l, a == null ? 1 : a ];
  1541. };
  1542. spaces.hsla.from = function( hsla ) {
  1543. if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
  1544. return [ null, null, null, hsla[ 3 ] ];
  1545. }
  1546. var h = hsla[ 0 ] / 360,
  1547. s = hsla[ 1 ],
  1548. l = hsla[ 2 ],
  1549. a = hsla[ 3 ],
  1550. q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
  1551. p = 2 * l - q;
  1552. return [
  1553. Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
  1554. Math.round( hue2rgb( p, q, h ) * 255 ),
  1555. Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
  1556. a
  1557. ];
  1558. };
  1559. each( spaces, function( spaceName, space ) {
  1560. var props = space.props,
  1561. cache = space.cache,
  1562. to = space.to,
  1563. from = space.from;
  1564. // Makes rgba() and hsla()
  1565. color.fn[ spaceName ] = function( value ) {
  1566. // Generate a cache for this space if it doesn't exist
  1567. if ( to && !this[ cache ] ) {
  1568. this[ cache ] = to( this._rgba );
  1569. }
  1570. if ( value === undefined ) {
  1571. return this[ cache ].slice();
  1572. }
  1573. var ret,
  1574. type = jQuery.type( value ),
  1575. arr = ( type === "array" || type === "object" ) ? value : arguments,
  1576. local = this[ cache ].slice();
  1577. each( props, function( key, prop ) {
  1578. var val = arr[ type === "object" ? key : prop.idx ];
  1579. if ( val == null ) {
  1580. val = local[ prop.idx ];
  1581. }
  1582. local[ prop.idx ] = clamp( val, prop );
  1583. } );
  1584. if ( from ) {
  1585. ret = color( from( local ) );
  1586. ret[ cache ] = local;
  1587. return ret;
  1588. } else {
  1589. return color( local );
  1590. }
  1591. };
  1592. // Makes red() green() blue() alpha() hue() saturation() lightness()
  1593. each( props, function( key, prop ) {
  1594. // Alpha is included in more than one space
  1595. if ( color.fn[ key ] ) {
  1596. return;
  1597. }
  1598. color.fn[ key ] = function( value ) {
  1599. var vtype = jQuery.type( value ),
  1600. fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
  1601. local = this[ fn ](),
  1602. cur = local[ prop.idx ],
  1603. match;
  1604. if ( vtype === "undefined" ) {
  1605. return cur;
  1606. }
  1607. if ( vtype === "function" ) {
  1608. value = value.call( this, cur );
  1609. vtype = jQuery.type( value );
  1610. }
  1611. if ( value == null && prop.empty ) {
  1612. return this;
  1613. }
  1614. if ( vtype === "string" ) {
  1615. match = rplusequals.exec( value );
  1616. if ( match ) {
  1617. value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
  1618. }
  1619. }
  1620. local[ prop.idx ] = value;
  1621. return this[ fn ]( local );
  1622. };
  1623. } );
  1624. } );
  1625. // Add cssHook and .fx.step function for each named hook.
  1626. // accept a space separated string of properties
  1627. color.hook = function( hook ) {
  1628. var hooks = hook.split( " " );
  1629. each( hooks, function( i, hook ) {
  1630. jQuery.cssHooks[ hook ] = {
  1631. set: function( elem, value ) {
  1632. var parsed, curElem,
  1633. backgroundColor = "";
  1634. if ( value !== "transparent" && ( jQuery.type( value ) !== "string" ||
  1635. ( parsed = stringParse( value ) ) ) ) {
  1636. value = color( parsed || value );
  1637. if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
  1638. curElem = hook === "backgroundColor" ? elem.parentNode : elem;
  1639. while (
  1640. ( backgroundColor === "" || backgroundColor === "transparent" ) &&
  1641. curElem && curElem.style
  1642. ) {
  1643. try {
  1644. backgroundColor = jQuery.css( curElem, "backgroundColor" );
  1645. curElem = curElem.parentNode;
  1646. } catch ( e ) {
  1647. }
  1648. }
  1649. value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
  1650. backgroundColor :
  1651. "_default" );
  1652. }
  1653. value = value.toRgbaString();
  1654. }
  1655. try {
  1656. elem.style[ hook ] = value;
  1657. } catch ( e ) {
  1658. // Wrapped to prevent IE from throwing errors on "invalid" values like
  1659. // 'auto' or 'inherit'
  1660. }
  1661. }
  1662. };
  1663. jQuery.fx.step[ hook ] = function( fx ) {
  1664. if ( !fx.colorInit ) {
  1665. fx.start = color( fx.elem, hook );
  1666. fx.end = color( fx.end );
  1667. fx.colorInit = true;
  1668. }
  1669. jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
  1670. };
  1671. } );
  1672. };
  1673. color.hook( stepHooks );
  1674. jQuery.cssHooks.borderColor = {
  1675. expand: function( value ) {
  1676. var expanded = {};
  1677. each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
  1678. expanded[ "border" + part + "Color" ] = value;
  1679. } );
  1680. return expanded;
  1681. }
  1682. };
  1683. // Basic color names only.
  1684. // Usage of any of the other color names requires adding yourself or including
  1685. // jquery.color.svg-names.js.
  1686. colors = jQuery.Color.names = {
  1687. // 4.1. Basic color keywords
  1688. aqua: "#00ffff",
  1689. black: "#000000",
  1690. blue: "#0000ff",
  1691. fuchsia: "#ff00ff",
  1692. gray: "#808080",
  1693. green: "#008000",
  1694. lime: "#00ff00",
  1695. maroon: "#800000",
  1696. navy: "#000080",
  1697. olive: "#808000",
  1698. purple: "#800080",
  1699. red: "#ff0000",
  1700. silver: "#c0c0c0",
  1701. teal: "#008080",
  1702. white: "#ffffff",
  1703. yellow: "#ffff00",
  1704. // 4.2.3. "transparent" color keyword
  1705. transparent: [ null, null, null, 0 ],
  1706. _default: "#ffffff"
  1707. };
  1708. } )( jQuery );
  1709. /******************************************************************************/
  1710. /****************************** CLASS ANIMATIONS ******************************/
  1711. /******************************************************************************/
  1712. ( function() {
  1713. var classAnimationActions = [ "add", "remove", "toggle" ],
  1714. shorthandStyles = {
  1715. border: 1,
  1716. borderBottom: 1,
  1717. borderColor: 1,
  1718. borderLeft: 1,
  1719. borderRight: 1,
  1720. borderTop: 1,
  1721. borderWidth: 1,
  1722. margin: 1,
  1723. padding: 1
  1724. };
  1725. $.each(
  1726. [ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ],
  1727. function( _, prop ) {
  1728. $.fx.step[ prop ] = function( fx ) {
  1729. if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
  1730. jQuery.style( fx.elem, prop, fx.end );
  1731. fx.setAttr = true;
  1732. }
  1733. };
  1734. }
  1735. );
  1736. function getElementStyles( elem ) {
  1737. var key, len,
  1738. style = elem.ownerDocument.defaultView ?
  1739. elem.ownerDocument.defaultView.getComputedStyle( elem, null ) :
  1740. elem.currentStyle,
  1741. styles = {};
  1742. if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
  1743. len = style.length;
  1744. while ( len-- ) {
  1745. key = style[ len ];
  1746. if ( typeof style[ key ] === "string" ) {
  1747. styles[ $.camelCase( key ) ] = style[ key ];
  1748. }
  1749. }
  1750. // Support: Opera, IE <9
  1751. } else {
  1752. for ( key in style ) {
  1753. if ( typeof style[ key ] === "string" ) {
  1754. styles[ key ] = style[ key ];
  1755. }
  1756. }
  1757. }
  1758. return styles;
  1759. }
  1760. function styleDifference( oldStyle, newStyle ) {
  1761. var diff = {},
  1762. name, value;
  1763. for ( name in newStyle ) {
  1764. value = newStyle[ name ];
  1765. if ( oldStyle[ name ] !== value ) {
  1766. if ( !shorthandStyles[ name ] ) {
  1767. if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
  1768. diff[ name ] = value;
  1769. }
  1770. }
  1771. }
  1772. }
  1773. return diff;
  1774. }
  1775. // Support: jQuery <1.8
  1776. if ( !$.fn.addBack ) {
  1777. $.fn.addBack = function( selector ) {
  1778. return this.add( selector == null ?
  1779. this.prevObject : this.prevObject.filter( selector )
  1780. );
  1781. };
  1782. }
  1783. $.effects.animateClass = function( value, duration, easing, callback ) {
  1784. var o = $.speed( duration, easing, callback );
  1785. return this.queue( function() {
  1786. var animated = $( this ),
  1787. baseClass = animated.attr( "class" ) || "",
  1788. applyClassChange,
  1789. allAnimations = o.children ? animated.find( "*" ).addBack() : animated;
  1790. // Map the animated objects to store the original styles.
  1791. allAnimations = allAnimations.map( function() {
  1792. var el = $( this );
  1793. return {
  1794. el: el,
  1795. start: getElementStyles( this )
  1796. };
  1797. } );
  1798. // Apply class change
  1799. applyClassChange = function() {
  1800. $.each( classAnimationActions, function( i, action ) {
  1801. if ( value[ action ] ) {
  1802. animated[ action + "Class" ]( value[ action ] );
  1803. }
  1804. } );
  1805. };
  1806. applyClassChange();
  1807. // Map all animated objects again - calculate new styles and diff
  1808. allAnimations = allAnimations.map( function() {
  1809. this.end = getElementStyles( this.el[ 0 ] );
  1810. this.diff = styleDifference( this.start, this.end );
  1811. return this;
  1812. } );
  1813. // Apply original class
  1814. animated.attr( "class", baseClass );
  1815. // Map all animated objects again - this time collecting a promise
  1816. allAnimations = allAnimations.map( function() {
  1817. var styleInfo = this,
  1818. dfd = $.Deferred(),
  1819. opts = $.extend( {}, o, {
  1820. queue: false,
  1821. complete: function() {
  1822. dfd.resolve( styleInfo );
  1823. }
  1824. } );
  1825. this.el.animate( this.diff, opts );
  1826. return dfd.promise();
  1827. } );
  1828. // Once all animations have completed:
  1829. $.when.apply( $, allAnimations.get() ).done( function() {
  1830. // Set the final class
  1831. applyClassChange();
  1832. // For each animated element,
  1833. // clear all css properties that were animated
  1834. $.each( arguments, function() {
  1835. var el = this.el;
  1836. $.each( this.diff, function( key ) {
  1837. el.css( key, "" );
  1838. } );
  1839. } );
  1840. // This is guarnteed to be there if you use jQuery.speed()
  1841. // it also handles dequeuing the next anim...
  1842. o.complete.call( animated[ 0 ] );
  1843. } );
  1844. } );
  1845. };
  1846. $.fn.extend( {
  1847. addClass: ( function( orig ) {
  1848. return function( classNames, speed, easing, callback ) {
  1849. return speed ?
  1850. $.effects.animateClass.call( this,
  1851. { add: classNames }, speed, easing, callback ) :
  1852. orig.apply( this, arguments );
  1853. };
  1854. } )( $.fn.addClass ),
  1855. removeClass: ( function( orig ) {
  1856. return function( classNames, speed, easing, callback ) {
  1857. return arguments.length > 1 ?
  1858. $.effects.animateClass.call( this,
  1859. { remove: classNames }, speed, easing, callback ) :
  1860. orig.apply( this, arguments );
  1861. };
  1862. } )( $.fn.removeClass ),
  1863. toggleClass: ( function( orig ) {
  1864. return function( classNames, force, speed, easing, callback ) {
  1865. if ( typeof force === "boolean" || force === undefined ) {
  1866. if ( !speed ) {
  1867. // Without speed parameter
  1868. return orig.apply( this, arguments );
  1869. } else {
  1870. return $.effects.animateClass.call( this,
  1871. ( force ? { add: classNames } : { remove: classNames } ),
  1872. speed, easing, callback );
  1873. }
  1874. } else {
  1875. // Without force parameter
  1876. return $.effects.animateClass.call( this,
  1877. { toggle: classNames }, force, speed, easing );
  1878. }
  1879. };
  1880. } )( $.fn.toggleClass ),
  1881. switchClass: function( remove, add, speed, easing, callback ) {
  1882. return $.effects.animateClass.call( this, {
  1883. add: add,
  1884. remove: remove
  1885. }, speed, easing, callback );
  1886. }
  1887. } );
  1888. } )();
  1889. /******************************************************************************/
  1890. /*********************************** EFFECTS **********************************/
  1891. /******************************************************************************/
  1892. ( function() {
  1893. if ( $.expr && $.expr.filters && $.expr.filters.animated ) {
  1894. $.expr.filters.animated = ( function( orig ) {
  1895. return function( elem ) {
  1896. return !!$( elem ).data( dataSpaceAnimated ) || orig( elem );
  1897. };
  1898. } )( $.expr.filters.animated );
  1899. }
  1900. if ( $.uiBackCompat !== false ) {
  1901. $.extend( $.effects, {
  1902. // Saves a set of properties in a data storage
  1903. save: function( element, set ) {
  1904. var i = 0, length = set.length;
  1905. for ( ; i < length; i++ ) {
  1906. if ( set[ i ] !== null ) {
  1907. element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
  1908. }
  1909. }
  1910. },
  1911. // Restores a set of previously saved properties from a data storage
  1912. restore: function( element, set ) {
  1913. var val, i = 0, length = set.length;
  1914. for ( ; i < length; i++ ) {
  1915. if ( set[ i ] !== null ) {
  1916. val = element.data( dataSpace + set[ i ] );
  1917. element.css( set[ i ], val );
  1918. }
  1919. }
  1920. },
  1921. setMode: function( el, mode ) {
  1922. if ( mode === "toggle" ) {
  1923. mode = el.is( ":hidden" ) ? "show" : "hide";
  1924. }
  1925. return mode;
  1926. },
  1927. // Wraps the element around a wrapper that copies position properties
  1928. createWrapper: function( element ) {
  1929. // If the element is already wrapped, return it
  1930. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  1931. return element.parent();
  1932. }
  1933. // Wrap the element
  1934. var props = {
  1935. width: element.outerWidth( true ),
  1936. height: element.outerHeight( true ),
  1937. "float": element.css( "float" )
  1938. },
  1939. wrapper = $( "<div></div>" )
  1940. .addClass( "ui-effects-wrapper" )
  1941. .css( {
  1942. fontSize: "100%",
  1943. background: "transparent",
  1944. border: "none",
  1945. margin: 0,
  1946. padding: 0
  1947. } ),
  1948. // Store the size in case width/height are defined in % - Fixes #5245
  1949. size = {
  1950. width: element.width(),
  1951. height: element.height()
  1952. },
  1953. active = document.activeElement;
  1954. // Support: Firefox
  1955. // Firefox incorrectly exposes anonymous content
  1956. // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
  1957. try {
  1958. active.id;
  1959. } catch ( e ) {
  1960. active = document.body;
  1961. }
  1962. element.wrap( wrapper );
  1963. // Fixes #7595 - Elements lose focus when wrapped.
  1964. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  1965. $( active ).trigger( "focus" );
  1966. }
  1967. // Hotfix for jQuery 1.4 since some change in wrap() seems to actually
  1968. // lose the reference to the wrapped element
  1969. wrapper = element.parent();
  1970. // Transfer positioning properties to the wrapper
  1971. if ( element.css( "position" ) === "static" ) {
  1972. wrapper.css( { position: "relative" } );
  1973. element.css( { position: "relative" } );
  1974. } else {
  1975. $.extend( props, {
  1976. position: element.css( "position" ),
  1977. zIndex: element.css( "z-index" )
  1978. } );
  1979. $.each( [ "top", "left", "bottom", "right" ], function( i, pos ) {
  1980. props[ pos ] = element.css( pos );
  1981. if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
  1982. props[ pos ] = "auto";
  1983. }
  1984. } );
  1985. element.css( {
  1986. position: "relative",
  1987. top: 0,
  1988. left: 0,
  1989. right: "auto",
  1990. bottom: "auto"
  1991. } );
  1992. }
  1993. element.css( size );
  1994. return wrapper.css( props ).show();
  1995. },
  1996. removeWrapper: function( element ) {
  1997. var active = document.activeElement;
  1998. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  1999. element.parent().replaceWith( element );
  2000. // Fixes #7595 - Elements lose focus when wrapped.
  2001. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  2002. $( active ).trigger( "focus" );
  2003. }
  2004. }
  2005. return element;
  2006. }
  2007. } );
  2008. }
  2009. $.extend( $.effects, {
  2010. version: "1.12.1",
  2011. define: function( name, mode, effect ) {
  2012. if ( !effect ) {
  2013. effect = mode;
  2014. mode = "effect";
  2015. }
  2016. $.effects.effect[ name ] = effect;
  2017. $.effects.effect[ name ].mode = mode;
  2018. return effect;
  2019. },
  2020. scaledDimensions: function( element, percent, direction ) {
  2021. if ( percent === 0 ) {
  2022. return {
  2023. height: 0,
  2024. width: 0,
  2025. outerHeight: 0,
  2026. outerWidth: 0
  2027. };
  2028. }
  2029. var x = direction !== "horizontal" ? ( ( percent || 100 ) / 100 ) : 1,
  2030. y = direction !== "vertical" ? ( ( percent || 100 ) / 100 ) : 1;
  2031. return {
  2032. height: element.height() * y,
  2033. width: element.width() * x,
  2034. outerHeight: element.outerHeight() * y,
  2035. outerWidth: element.outerWidth() * x
  2036. };
  2037. },
  2038. clipToBox: function( animation ) {
  2039. return {
  2040. width: animation.clip.right - animation.clip.left,
  2041. height: animation.clip.bottom - animation.clip.top,
  2042. left: animation.clip.left,
  2043. top: animation.clip.top
  2044. };
  2045. },
  2046. // Injects recently queued functions to be first in line (after "inprogress")
  2047. unshift: function( element, queueLength, count ) {
  2048. var queue = element.queue();
  2049. if ( queueLength > 1 ) {
  2050. queue.splice.apply( queue,
  2051. [ 1, 0 ].concat( queue.splice( queueLength, count ) ) );
  2052. }
  2053. element.dequeue();
  2054. },
  2055. saveStyle: function( element ) {
  2056. element.data( dataSpaceStyle, element[ 0 ].style.cssText );
  2057. },
  2058. restoreStyle: function( element ) {
  2059. element[ 0 ].style.cssText = element.data( dataSpaceStyle ) || "";
  2060. element.removeData( dataSpaceStyle );
  2061. },
  2062. mode: function( element, mode ) {
  2063. var hidden = element.is( ":hidden" );
  2064. if ( mode === "toggle" ) {
  2065. mode = hidden ? "show" : "hide";
  2066. }
  2067. if ( hidden ? mode === "hide" : mode === "show" ) {
  2068. mode = "none";
  2069. }
  2070. return mode;
  2071. },
  2072. // Translates a [top,left] array into a baseline value
  2073. getBaseline: function( origin, original ) {
  2074. var y, x;
  2075. switch ( origin[ 0 ] ) {
  2076. case "top":
  2077. y = 0;
  2078. break;
  2079. case "middle":
  2080. y = 0.5;
  2081. break;
  2082. case "bottom":
  2083. y = 1;
  2084. break;
  2085. default:
  2086. y = origin[ 0 ] / original.height;
  2087. }
  2088. switch ( origin[ 1 ] ) {
  2089. case "left":
  2090. x = 0;
  2091. break;
  2092. case "center":
  2093. x = 0.5;
  2094. break;
  2095. case "right":
  2096. x = 1;
  2097. break;
  2098. default:
  2099. x = origin[ 1 ] / original.width;
  2100. }
  2101. return {
  2102. x: x,
  2103. y: y
  2104. };
  2105. },
  2106. // Creates a placeholder element so that the original element can be made absolute
  2107. createPlaceholder: function( element ) {
  2108. var placeholder,
  2109. cssPosition = element.css( "position" ),
  2110. position = element.position();
  2111. // Lock in margins first to account for form elements, which
  2112. // will change margin if you explicitly set height
  2113. // see: http://jsfiddle.net/JZSMt/3/ https://bugs.webkit.org/show_bug.cgi?id=107380
  2114. // Support: Safari
  2115. element.css( {
  2116. marginTop: element.css( "marginTop" ),
  2117. marginBottom: element.css( "marginBottom" ),
  2118. marginLeft: element.css( "marginLeft" ),
  2119. marginRight: element.css( "marginRight" )
  2120. } )
  2121. .outerWidth( element.outerWidth() )
  2122. .outerHeight( element.outerHeight() );
  2123. if ( /^(static|relative)/.test( cssPosition ) ) {
  2124. cssPosition = "absolute";
  2125. placeholder = $( "<" + element[ 0 ].nodeName + ">" ).insertAfter( element ).css( {
  2126. // Convert inline to inline block to account for inline elements
  2127. // that turn to inline block based on content (like img)
  2128. display: /^(inline|ruby)/.test( element.css( "display" ) ) ?
  2129. "inline-block" :
  2130. "block",
  2131. visibility: "hidden",
  2132. // Margins need to be set to account for margin collapse
  2133. marginTop: element.css( "marginTop" ),
  2134. marginBottom: element.css( "marginBottom" ),
  2135. marginLeft: element.css( "marginLeft" ),
  2136. marginRight: element.css( "marginRight" ),
  2137. "float": element.css( "float" )
  2138. } )
  2139. .outerWidth( element.outerWidth() )
  2140. .outerHeight( element.outerHeight() )
  2141. .addClass( "ui-effects-placeholder" );
  2142. element.data( dataSpace + "placeholder", placeholder );
  2143. }
  2144. element.css( {
  2145. position: cssPosition,
  2146. left: position.left,
  2147. top: position.top
  2148. } );
  2149. return placeholder;
  2150. },
  2151. removePlaceholder: function( element ) {
  2152. var dataKey = dataSpace + "placeholder",
  2153. placeholder = element.data( dataKey );
  2154. if ( placeholder ) {
  2155. placeholder.remove();
  2156. element.removeData( dataKey );
  2157. }
  2158. },
  2159. // Removes a placeholder if it exists and restores
  2160. // properties that were modified during placeholder creation
  2161. cleanUp: function( element ) {
  2162. $.effects.restoreStyle( element );
  2163. $.effects.removePlaceholder( element );
  2164. },
  2165. setTransition: function( element, list, factor, value ) {
  2166. value = value || {};
  2167. $.each( list, function( i, x ) {
  2168. var unit = element.cssUnit( x );
  2169. if ( unit[ 0 ] > 0 ) {
  2170. value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
  2171. }
  2172. } );
  2173. return value;
  2174. }
  2175. } );
  2176. // Return an effect options object for the given parameters:
  2177. function _normalizeArguments( effect, options, speed, callback ) {
  2178. // Allow passing all options as the first parameter
  2179. if ( $.isPlainObject( effect ) ) {
  2180. options = effect;
  2181. effect = effect.effect;
  2182. }
  2183. // Convert to an object
  2184. effect = { effect: effect };
  2185. // Catch (effect, null, ...)
  2186. if ( options == null ) {
  2187. options = {};
  2188. }
  2189. // Catch (effect, callback)
  2190. if ( $.isFunction( options ) ) {
  2191. callback = options;
  2192. speed = null;
  2193. options = {};
  2194. }
  2195. // Catch (effect, speed, ?)
  2196. if ( typeof options === "number" || $.fx.speeds[ options ] ) {
  2197. callback = speed;
  2198. speed = options;
  2199. options = {};
  2200. }
  2201. // Catch (effect, options, callback)
  2202. if ( $.isFunction( speed ) ) {
  2203. callback = speed;
  2204. speed = null;
  2205. }
  2206. // Add options to effect
  2207. if ( options ) {
  2208. $.extend( effect, options );
  2209. }
  2210. speed = speed || options.duration;
  2211. effect.duration = $.fx.off ? 0 :
  2212. typeof speed === "number" ? speed :
  2213. speed in $.fx.speeds ? $.fx.speeds[ speed ] :
  2214. $.fx.speeds._default;
  2215. effect.complete = callback || options.complete;
  2216. return effect;
  2217. }
  2218. function standardAnimationOption( option ) {
  2219. // Valid standard speeds (nothing, number, named speed)
  2220. if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) {
  2221. return true;
  2222. }
  2223. // Invalid strings - treat as "normal" speed
  2224. if ( typeof option === "string" && !$.effects.effect[ option ] ) {
  2225. return true;
  2226. }
  2227. // Complete callback
  2228. if ( $.isFunction( option ) ) {
  2229. return true;
  2230. }
  2231. // Options hash (but not naming an effect)
  2232. if ( typeof option === "object" && !option.effect ) {
  2233. return true;
  2234. }
  2235. // Didn't match any standard API
  2236. return false;
  2237. }
  2238. $.fn.extend( {
  2239. effect: function( /* effect, options, speed, callback */ ) {
  2240. var args = _normalizeArguments.apply( this, arguments ),
  2241. effectMethod = $.effects.effect[ args.effect ],
  2242. defaultMode = effectMethod.mode,
  2243. queue = args.queue,
  2244. queueName = queue || "fx",
  2245. complete = args.complete,
  2246. mode = args.mode,
  2247. modes = [],
  2248. prefilter = function( next ) {
  2249. var el = $( this ),
  2250. normalizedMode = $.effects.mode( el, mode ) || defaultMode;
  2251. // Sentinel for duck-punching the :animated psuedo-selector
  2252. el.data( dataSpaceAnimated, true );
  2253. // Save effect mode for later use,
  2254. // we can't just call $.effects.mode again later,
  2255. // as the .show() below destroys the initial state
  2256. modes.push( normalizedMode );
  2257. // See $.uiBackCompat inside of run() for removal of defaultMode in 1.13
  2258. if ( defaultMode && ( normalizedMode === "show" ||
  2259. ( normalizedMode === defaultMode && normalizedMode === "hide" ) ) ) {
  2260. el.show();
  2261. }
  2262. if ( !defaultMode || normalizedMode !== "none" ) {
  2263. $.effects.saveStyle( el );
  2264. }
  2265. if ( $.isFunction( next ) ) {
  2266. next();
  2267. }
  2268. };
  2269. if ( $.fx.off || !effectMethod ) {
  2270. // Delegate to the original method (e.g., .show()) if possible
  2271. if ( mode ) {
  2272. return this[ mode ]( args.duration, complete );
  2273. } else {
  2274. return this.each( function() {
  2275. if ( complete ) {
  2276. complete.call( this );
  2277. }
  2278. } );
  2279. }
  2280. }
  2281. function run( next ) {
  2282. var elem = $( this );
  2283. function cleanup() {
  2284. elem.removeData( dataSpaceAnimated );
  2285. $.effects.cleanUp( elem );
  2286. if ( args.mode === "hide" ) {
  2287. elem.hide();
  2288. }
  2289. done();
  2290. }
  2291. function done() {
  2292. if ( $.isFunction( complete ) ) {
  2293. complete.call( elem[ 0 ] );
  2294. }
  2295. if ( $.isFunction( next ) ) {
  2296. next();
  2297. }
  2298. }
  2299. // Override mode option on a per element basis,
  2300. // as toggle can be either show or hide depending on element state
  2301. args.mode = modes.shift();
  2302. if ( $.uiBackCompat !== false && !defaultMode ) {
  2303. if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
  2304. // Call the core method to track "olddisplay" properly
  2305. elem[ mode ]();
  2306. done();
  2307. } else {
  2308. effectMethod.call( elem[ 0 ], args, done );
  2309. }
  2310. } else {
  2311. if ( args.mode === "none" ) {
  2312. // Call the core method to track "olddisplay" properly
  2313. elem[ mode ]();
  2314. done();
  2315. } else {
  2316. effectMethod.call( elem[ 0 ], args, cleanup );
  2317. }
  2318. }
  2319. }
  2320. // Run prefilter on all elements first to ensure that
  2321. // any showing or hiding happens before placeholder creation,
  2322. // which ensures that any layout changes are correctly captured.
  2323. return queue === false ?
  2324. this.each( prefilter ).each( run ) :
  2325. this.queue( queueName, prefilter ).queue( queueName, run );
  2326. },
  2327. show: ( function( orig ) {
  2328. return function( option ) {
  2329. if ( standardAnimationOption( option ) ) {
  2330. return orig.apply( this, arguments );
  2331. } else {
  2332. var args = _normalizeArguments.apply( this, arguments );
  2333. args.mode = "show";
  2334. return this.effect.call( this, args );
  2335. }
  2336. };
  2337. } )( $.fn.show ),
  2338. hide: ( function( orig ) {
  2339. return function( option ) {
  2340. if ( standardAnimationOption( option ) ) {
  2341. return orig.apply( this, arguments );
  2342. } else {
  2343. var args = _normalizeArguments.apply( this, arguments );
  2344. args.mode = "hide";
  2345. return this.effect.call( this, args );
  2346. }
  2347. };
  2348. } )( $.fn.hide ),
  2349. toggle: ( function( orig ) {
  2350. return function( option ) {
  2351. if ( standardAnimationOption( option ) || typeof option === "boolean" ) {
  2352. return orig.apply( this, arguments );
  2353. } else {
  2354. var args = _normalizeArguments.apply( this, arguments );
  2355. args.mode = "toggle";
  2356. return this.effect.call( this, args );
  2357. }
  2358. };
  2359. } )( $.fn.toggle ),
  2360. cssUnit: function( key ) {
  2361. var style = this.css( key ),
  2362. val = [];
  2363. $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
  2364. if ( style.indexOf( unit ) > 0 ) {
  2365. val = [ parseFloat( style ), unit ];
  2366. }
  2367. } );
  2368. return val;
  2369. },
  2370. cssClip: function( clipObj ) {
  2371. if ( clipObj ) {
  2372. return this.css( "clip", "rect(" + clipObj.top + "px " + clipObj.right + "px " +
  2373. clipObj.bottom + "px " + clipObj.left + "px)" );
  2374. }
  2375. return parseClip( this.css( "clip" ), this );
  2376. },
  2377. transfer: function( options, done ) {
  2378. var element = $( this ),
  2379. target = $( options.to ),
  2380. targetFixed = target.css( "position" ) === "fixed",
  2381. body = $( "body" ),
  2382. fixTop = targetFixed ? body.scrollTop() : 0,
  2383. fixLeft = targetFixed ? body.scrollLeft() : 0,
  2384. endPosition = target.offset(),
  2385. animation = {
  2386. top: endPosition.top - fixTop,
  2387. left: endPosition.left - fixLeft,
  2388. height: target.innerHeight(),
  2389. width: target.innerWidth()
  2390. },
  2391. startPosition = element.offset(),
  2392. transfer = $( "<div class='ui-effects-transfer'></div>" )
  2393. .appendTo( "body" )
  2394. .addClass( options.className )
  2395. .css( {
  2396. top: startPosition.top - fixTop,
  2397. left: startPosition.left - fixLeft,
  2398. height: element.innerHeight(),
  2399. width: element.innerWidth(),
  2400. position: targetFixed ? "fixed" : "absolute"
  2401. } )
  2402. .animate( animation, options.duration, options.easing, function() {
  2403. transfer.remove();
  2404. if ( $.isFunction( done ) ) {
  2405. done();
  2406. }
  2407. } );
  2408. }
  2409. } );
  2410. function parseClip( str, element ) {
  2411. var outerWidth = element.outerWidth(),
  2412. outerHeight = element.outerHeight(),
  2413. 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)\)$/,
  2414. values = clipRegex.exec( str ) || [ "", 0, outerWidth, outerHeight, 0 ];
  2415. return {
  2416. top: parseFloat( values[ 1 ] ) || 0,
  2417. right: values[ 2 ] === "auto" ? outerWidth : parseFloat( values[ 2 ] ),
  2418. bottom: values[ 3 ] === "auto" ? outerHeight : parseFloat( values[ 3 ] ),
  2419. left: parseFloat( values[ 4 ] ) || 0
  2420. };
  2421. }
  2422. $.fx.step.clip = function( fx ) {
  2423. if ( !fx.clipInit ) {
  2424. fx.start = $( fx.elem ).cssClip();
  2425. if ( typeof fx.end === "string" ) {
  2426. fx.end = parseClip( fx.end, fx.elem );
  2427. }
  2428. fx.clipInit = true;
  2429. }
  2430. $( fx.elem ).cssClip( {
  2431. top: fx.pos * ( fx.end.top - fx.start.top ) + fx.start.top,
  2432. right: fx.pos * ( fx.end.right - fx.start.right ) + fx.start.right,
  2433. bottom: fx.pos * ( fx.end.bottom - fx.start.bottom ) + fx.start.bottom,
  2434. left: fx.pos * ( fx.end.left - fx.start.left ) + fx.start.left
  2435. } );
  2436. };
  2437. } )();
  2438. /******************************************************************************/
  2439. /*********************************** EASING ***********************************/
  2440. /******************************************************************************/
  2441. ( function() {
  2442. // Based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
  2443. var baseEasings = {};
  2444. $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
  2445. baseEasings[ name ] = function( p ) {
  2446. return Math.pow( p, i + 2 );
  2447. };
  2448. } );
  2449. $.extend( baseEasings, {
  2450. Sine: function( p ) {
  2451. return 1 - Math.cos( p * Math.PI / 2 );
  2452. },
  2453. Circ: function( p ) {
  2454. return 1 - Math.sqrt( 1 - p * p );
  2455. },
  2456. Elastic: function( p ) {
  2457. return p === 0 || p === 1 ? p :
  2458. -Math.pow( 2, 8 * ( p - 1 ) ) * Math.sin( ( ( p - 1 ) * 80 - 7.5 ) * Math.PI / 15 );
  2459. },
  2460. Back: function( p ) {
  2461. return p * p * ( 3 * p - 2 );
  2462. },
  2463. Bounce: function( p ) {
  2464. var pow2,
  2465. bounce = 4;
  2466. while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
  2467. return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
  2468. }
  2469. } );
  2470. $.each( baseEasings, function( name, easeIn ) {
  2471. $.easing[ "easeIn" + name ] = easeIn;
  2472. $.easing[ "easeOut" + name ] = function( p ) {
  2473. return 1 - easeIn( 1 - p );
  2474. };
  2475. $.easing[ "easeInOut" + name ] = function( p ) {
  2476. return p < 0.5 ?
  2477. easeIn( p * 2 ) / 2 :
  2478. 1 - easeIn( p * -2 + 2 ) / 2;
  2479. };
  2480. } );
  2481. } )();
  2482. var effect = $.effects;
  2483. /*!
  2484. * jQuery UI Effects Blind 1.12.1
  2485. * http://jqueryui.com
  2486. *
  2487. * Copyright jQuery Foundation and other contributors
  2488. * Released under the MIT license.
  2489. * http://jquery.org/license
  2490. */
  2491. //>>label: Blind Effect
  2492. //>>group: Effects
  2493. //>>description: Blinds the element.
  2494. //>>docs: http://api.jqueryui.com/blind-effect/
  2495. //>>demos: http://jqueryui.com/effect/
  2496. var effectsEffectBlind = $.effects.define( "blind", "hide", function( options, done ) {
  2497. var map = {
  2498. up: [ "bottom", "top" ],
  2499. vertical: [ "bottom", "top" ],
  2500. down: [ "top", "bottom" ],
  2501. left: [ "right", "left" ],
  2502. horizontal: [ "right", "left" ],
  2503. right: [ "left", "right" ]
  2504. },
  2505. element = $( this ),
  2506. direction = options.direction || "up",
  2507. start = element.cssClip(),
  2508. animate = { clip: $.extend( {}, start ) },
  2509. placeholder = $.effects.createPlaceholder( element );
  2510. animate.clip[ map[ direction ][ 0 ] ] = animate.clip[ map[ direction ][ 1 ] ];
  2511. if ( options.mode === "show" ) {
  2512. element.cssClip( animate.clip );
  2513. if ( placeholder ) {
  2514. placeholder.css( $.effects.clipToBox( animate ) );
  2515. }
  2516. animate.clip = start;
  2517. }
  2518. if ( placeholder ) {
  2519. placeholder.animate( $.effects.clipToBox( animate ), options.duration, options.easing );
  2520. }
  2521. element.animate( animate, {
  2522. queue: false,
  2523. duration: options.duration,
  2524. easing: options.easing,
  2525. complete: done
  2526. } );
  2527. } );
  2528. /*!
  2529. * jQuery UI Effects Bounce 1.12.1
  2530. * http://jqueryui.com
  2531. *
  2532. * Copyright jQuery Foundation and other contributors
  2533. * Released under the MIT license.
  2534. * http://jquery.org/license
  2535. */
  2536. //>>label: Bounce Effect
  2537. //>>group: Effects
  2538. //>>description: Bounces an element horizontally or vertically n times.
  2539. //>>docs: http://api.jqueryui.com/bounce-effect/
  2540. //>>demos: http://jqueryui.com/effect/
  2541. var effectsEffectBounce = $.effects.define( "bounce", function( options, done ) {
  2542. var upAnim, downAnim, refValue,
  2543. element = $( this ),
  2544. // Defaults:
  2545. mode = options.mode,
  2546. hide = mode === "hide",
  2547. show = mode === "show",
  2548. direction = options.direction || "up",
  2549. distance = options.distance,
  2550. times = options.times || 5,
  2551. // Number of internal animations
  2552. anims = times * 2 + ( show || hide ? 1 : 0 ),
  2553. speed = options.duration / anims,
  2554. easing = options.easing,
  2555. // Utility:
  2556. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  2557. motion = ( direction === "up" || direction === "left" ),
  2558. i = 0,
  2559. queuelen = element.queue().length;
  2560. $.effects.createPlaceholder( element );
  2561. refValue = element.css( ref );
  2562. // Default distance for the BIGGEST bounce is the outer Distance / 3
  2563. if ( !distance ) {
  2564. distance = element[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
  2565. }
  2566. if ( show ) {
  2567. downAnim = { opacity: 1 };
  2568. downAnim[ ref ] = refValue;
  2569. // If we are showing, force opacity 0 and set the initial position
  2570. // then do the "first" animation
  2571. element
  2572. .css( "opacity", 0 )
  2573. .css( ref, motion ? -distance * 2 : distance * 2 )
  2574. .animate( downAnim, speed, easing );
  2575. }
  2576. // Start at the smallest distance if we are hiding
  2577. if ( hide ) {
  2578. distance = distance / Math.pow( 2, times - 1 );
  2579. }
  2580. downAnim = {};
  2581. downAnim[ ref ] = refValue;
  2582. // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
  2583. for ( ; i < times; i++ ) {
  2584. upAnim = {};
  2585. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  2586. element
  2587. .animate( upAnim, speed, easing )
  2588. .animate( downAnim, speed, easing );
  2589. distance = hide ? distance * 2 : distance / 2;
  2590. }
  2591. // Last Bounce when Hiding
  2592. if ( hide ) {
  2593. upAnim = { opacity: 0 };
  2594. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  2595. element.animate( upAnim, speed, easing );
  2596. }
  2597. element.queue( done );
  2598. $.effects.unshift( element, queuelen, anims + 1 );
  2599. } );
  2600. /*!
  2601. * jQuery UI Effects Clip 1.12.1
  2602. * http://jqueryui.com
  2603. *
  2604. * Copyright jQuery Foundation and other contributors
  2605. * Released under the MIT license.
  2606. * http://jquery.org/license
  2607. */
  2608. //>>label: Clip Effect
  2609. //>>group: Effects
  2610. //>>description: Clips the element on and off like an old TV.
  2611. //>>docs: http://api.jqueryui.com/clip-effect/
  2612. //>>demos: http://jqueryui.com/effect/
  2613. var effectsEffectClip = $.effects.define( "clip", "hide", function( options, done ) {
  2614. var start,
  2615. animate = {},
  2616. element = $( this ),
  2617. direction = options.direction || "vertical",
  2618. both = direction === "both",
  2619. horizontal = both || direction === "horizontal",
  2620. vertical = both || direction === "vertical";
  2621. start = element.cssClip();
  2622. animate.clip = {
  2623. top: vertical ? ( start.bottom - start.top ) / 2 : start.top,
  2624. right: horizontal ? ( start.right - start.left ) / 2 : start.right,
  2625. bottom: vertical ? ( start.bottom - start.top ) / 2 : start.bottom,
  2626. left: horizontal ? ( start.right - start.left ) / 2 : start.left
  2627. };
  2628. $.effects.createPlaceholder( element );
  2629. if ( options.mode === "show" ) {
  2630. element.cssClip( animate.clip );
  2631. animate.clip = start;
  2632. }
  2633. element.animate( animate, {
  2634. queue: false,
  2635. duration: options.duration,
  2636. easing: options.easing,
  2637. complete: done
  2638. } );
  2639. } );
  2640. /*!
  2641. * jQuery UI Effects Drop 1.12.1
  2642. * http://jqueryui.com
  2643. *
  2644. * Copyright jQuery Foundation and other contributors
  2645. * Released under the MIT license.
  2646. * http://jquery.org/license
  2647. */
  2648. //>>label: Drop Effect
  2649. //>>group: Effects
  2650. //>>description: Moves an element in one direction and hides it at the same time.
  2651. //>>docs: http://api.jqueryui.com/drop-effect/
  2652. //>>demos: http://jqueryui.com/effect/
  2653. var effectsEffectDrop = $.effects.define( "drop", "hide", function( options, done ) {
  2654. var distance,
  2655. element = $( this ),
  2656. mode = options.mode,
  2657. show = mode === "show",
  2658. direction = options.direction || "left",
  2659. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  2660. motion = ( direction === "up" || direction === "left" ) ? "-=" : "+=",
  2661. oppositeMotion = ( motion === "+=" ) ? "-=" : "+=",
  2662. animation = {
  2663. opacity: 0
  2664. };
  2665. $.effects.createPlaceholder( element );
  2666. distance = options.distance ||
  2667. element[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ) / 2;
  2668. animation[ ref ] = motion + distance;
  2669. if ( show ) {
  2670. element.css( animation );
  2671. animation[ ref ] = oppositeMotion + distance;
  2672. animation.opacity = 1;
  2673. }
  2674. // Animate
  2675. element.animate( animation, {
  2676. queue: false,
  2677. duration: options.duration,
  2678. easing: options.easing,
  2679. complete: done
  2680. } );
  2681. } );
  2682. /*!
  2683. * jQuery UI Effects Explode 1.12.1
  2684. * http://jqueryui.com
  2685. *
  2686. * Copyright jQuery Foundation and other contributors
  2687. * Released under the MIT license.
  2688. * http://jquery.org/license
  2689. */
  2690. //>>label: Explode Effect
  2691. //>>group: Effects
  2692. // jscs:disable maximumLineLength
  2693. //>>description: Explodes an element in all directions into n pieces. Implodes an element to its original wholeness.
  2694. // jscs:enable maximumLineLength
  2695. //>>docs: http://api.jqueryui.com/explode-effect/
  2696. //>>demos: http://jqueryui.com/effect/
  2697. var effectsEffectExplode = $.effects.define( "explode", "hide", function( options, done ) {
  2698. var i, j, left, top, mx, my,
  2699. rows = options.pieces ? Math.round( Math.sqrt( options.pieces ) ) : 3,
  2700. cells = rows,
  2701. element = $( this ),
  2702. mode = options.mode,
  2703. show = mode === "show",
  2704. // Show and then visibility:hidden the element before calculating offset
  2705. offset = element.show().css( "visibility", "hidden" ).offset(),
  2706. // Width and height of a piece
  2707. width = Math.ceil( element.outerWidth() / cells ),
  2708. height = Math.ceil( element.outerHeight() / rows ),
  2709. pieces = [];
  2710. // Children animate complete:
  2711. function childComplete() {
  2712. pieces.push( this );
  2713. if ( pieces.length === rows * cells ) {
  2714. animComplete();
  2715. }
  2716. }
  2717. // Clone the element for each row and cell.
  2718. for ( i = 0; i < rows; i++ ) { // ===>
  2719. top = offset.top + i * height;
  2720. my = i - ( rows - 1 ) / 2;
  2721. for ( j = 0; j < cells; j++ ) { // |||
  2722. left = offset.left + j * width;
  2723. mx = j - ( cells - 1 ) / 2;
  2724. // Create a clone of the now hidden main element that will be absolute positioned
  2725. // within a wrapper div off the -left and -top equal to size of our pieces
  2726. element
  2727. .clone()
  2728. .appendTo( "body" )
  2729. .wrap( "<div></div>" )
  2730. .css( {
  2731. position: "absolute",
  2732. visibility: "visible",
  2733. left: -j * width,
  2734. top: -i * height
  2735. } )
  2736. // Select the wrapper - make it overflow: hidden and absolute positioned based on
  2737. // where the original was located +left and +top equal to the size of pieces
  2738. .parent()
  2739. .addClass( "ui-effects-explode" )
  2740. .css( {
  2741. position: "absolute",
  2742. overflow: "hidden",
  2743. width: width,
  2744. height: height,
  2745. left: left + ( show ? mx * width : 0 ),
  2746. top: top + ( show ? my * height : 0 ),
  2747. opacity: show ? 0 : 1
  2748. } )
  2749. .animate( {
  2750. left: left + ( show ? 0 : mx * width ),
  2751. top: top + ( show ? 0 : my * height ),
  2752. opacity: show ? 1 : 0
  2753. }, options.duration || 500, options.easing, childComplete );
  2754. }
  2755. }
  2756. function animComplete() {
  2757. element.css( {
  2758. visibility: "visible"
  2759. } );
  2760. $( pieces ).remove();
  2761. done();
  2762. }
  2763. } );
  2764. /*!
  2765. * jQuery UI Effects Fade 1.12.1
  2766. * http://jqueryui.com
  2767. *
  2768. * Copyright jQuery Foundation and other contributors
  2769. * Released under the MIT license.
  2770. * http://jquery.org/license
  2771. */
  2772. //>>label: Fade Effect
  2773. //>>group: Effects
  2774. //>>description: Fades the element.
  2775. //>>docs: http://api.jqueryui.com/fade-effect/
  2776. //>>demos: http://jqueryui.com/effect/
  2777. var effectsEffectFade = $.effects.define( "fade", "toggle", function( options, done ) {
  2778. var show = options.mode === "show";
  2779. $( this )
  2780. .css( "opacity", show ? 0 : 1 )
  2781. .animate( {
  2782. opacity: show ? 1 : 0
  2783. }, {
  2784. queue: false,
  2785. duration: options.duration,
  2786. easing: options.easing,
  2787. complete: done
  2788. } );
  2789. } );
  2790. /*!
  2791. * jQuery UI Effects Fold 1.12.1
  2792. * http://jqueryui.com
  2793. *
  2794. * Copyright jQuery Foundation and other contributors
  2795. * Released under the MIT license.
  2796. * http://jquery.org/license
  2797. */
  2798. //>>label: Fold Effect
  2799. //>>group: Effects
  2800. //>>description: Folds an element first horizontally and then vertically.
  2801. //>>docs: http://api.jqueryui.com/fold-effect/
  2802. //>>demos: http://jqueryui.com/effect/
  2803. var effectsEffectFold = $.effects.define( "fold", "hide", function( options, done ) {
  2804. // Create element
  2805. var element = $( this ),
  2806. mode = options.mode,
  2807. show = mode === "show",
  2808. hide = mode === "hide",
  2809. size = options.size || 15,
  2810. percent = /([0-9]+)%/.exec( size ),
  2811. horizFirst = !!options.horizFirst,
  2812. ref = horizFirst ? [ "right", "bottom" ] : [ "bottom", "right" ],
  2813. duration = options.duration / 2,
  2814. placeholder = $.effects.createPlaceholder( element ),
  2815. start = element.cssClip(),
  2816. animation1 = { clip: $.extend( {}, start ) },
  2817. animation2 = { clip: $.extend( {}, start ) },
  2818. distance = [ start[ ref[ 0 ] ], start[ ref[ 1 ] ] ],
  2819. queuelen = element.queue().length;
  2820. if ( percent ) {
  2821. size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
  2822. }
  2823. animation1.clip[ ref[ 0 ] ] = size;
  2824. animation2.clip[ ref[ 0 ] ] = size;
  2825. animation2.clip[ ref[ 1 ] ] = 0;
  2826. if ( show ) {
  2827. element.cssClip( animation2.clip );
  2828. if ( placeholder ) {
  2829. placeholder.css( $.effects.clipToBox( animation2 ) );
  2830. }
  2831. animation2.clip = start;
  2832. }
  2833. // Animate
  2834. element
  2835. .queue( function( next ) {
  2836. if ( placeholder ) {
  2837. placeholder
  2838. .animate( $.effects.clipToBox( animation1 ), duration, options.easing )
  2839. .animate( $.effects.clipToBox( animation2 ), duration, options.easing );
  2840. }
  2841. next();
  2842. } )
  2843. .animate( animation1, duration, options.easing )
  2844. .animate( animation2, duration, options.easing )
  2845. .queue( done );
  2846. $.effects.unshift( element, queuelen, 4 );
  2847. } );
  2848. /*!
  2849. * jQuery UI Effects Highlight 1.12.1
  2850. * http://jqueryui.com
  2851. *
  2852. * Copyright jQuery Foundation and other contributors
  2853. * Released under the MIT license.
  2854. * http://jquery.org/license
  2855. */
  2856. //>>label: Highlight Effect
  2857. //>>group: Effects
  2858. //>>description: Highlights the background of an element in a defined color for a custom duration.
  2859. //>>docs: http://api.jqueryui.com/highlight-effect/
  2860. //>>demos: http://jqueryui.com/effect/
  2861. var effectsEffectHighlight = $.effects.define( "highlight", "show", function( options, done ) {
  2862. var element = $( this ),
  2863. animation = {
  2864. backgroundColor: element.css( "backgroundColor" )
  2865. };
  2866. if ( options.mode === "hide" ) {
  2867. animation.opacity = 0;
  2868. }
  2869. $.effects.saveStyle( element );
  2870. element
  2871. .css( {
  2872. backgroundImage: "none",
  2873. backgroundColor: options.color || "#ffff99"
  2874. } )
  2875. .animate( animation, {
  2876. queue: false,
  2877. duration: options.duration,
  2878. easing: options.easing,
  2879. complete: done
  2880. } );
  2881. } );
  2882. /*!
  2883. * jQuery UI Effects Size 1.12.1
  2884. * http://jqueryui.com
  2885. *
  2886. * Copyright jQuery Foundation and other contributors
  2887. * Released under the MIT license.
  2888. * http://jquery.org/license
  2889. */
  2890. //>>label: Size Effect
  2891. //>>group: Effects
  2892. //>>description: Resize an element to a specified width and height.
  2893. //>>docs: http://api.jqueryui.com/size-effect/
  2894. //>>demos: http://jqueryui.com/effect/
  2895. var effectsEffectSize = $.effects.define( "size", function( options, done ) {
  2896. // Create element
  2897. var baseline, factor, temp,
  2898. element = $( this ),
  2899. // Copy for children
  2900. cProps = [ "fontSize" ],
  2901. vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ],
  2902. hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ],
  2903. // Set options
  2904. mode = options.mode,
  2905. restore = mode !== "effect",
  2906. scale = options.scale || "both",
  2907. origin = options.origin || [ "middle", "center" ],
  2908. position = element.css( "position" ),
  2909. pos = element.position(),
  2910. original = $.effects.scaledDimensions( element ),
  2911. from = options.from || original,
  2912. to = options.to || $.effects.scaledDimensions( element, 0 );
  2913. $.effects.createPlaceholder( element );
  2914. if ( mode === "show" ) {
  2915. temp = from;
  2916. from = to;
  2917. to = temp;
  2918. }
  2919. // Set scaling factor
  2920. factor = {
  2921. from: {
  2922. y: from.height / original.height,
  2923. x: from.width / original.width
  2924. },
  2925. to: {
  2926. y: to.height / original.height,
  2927. x: to.width / original.width
  2928. }
  2929. };
  2930. // Scale the css box
  2931. if ( scale === "box" || scale === "both" ) {
  2932. // Vertical props scaling
  2933. if ( factor.from.y !== factor.to.y ) {
  2934. from = $.effects.setTransition( element, vProps, factor.from.y, from );
  2935. to = $.effects.setTransition( element, vProps, factor.to.y, to );
  2936. }
  2937. // Horizontal props scaling
  2938. if ( factor.from.x !== factor.to.x ) {
  2939. from = $.effects.setTransition( element, hProps, factor.from.x, from );
  2940. to = $.effects.setTransition( element, hProps, factor.to.x, to );
  2941. }
  2942. }
  2943. // Scale the content
  2944. if ( scale === "content" || scale === "both" ) {
  2945. // Vertical props scaling
  2946. if ( factor.from.y !== factor.to.y ) {
  2947. from = $.effects.setTransition( element, cProps, factor.from.y, from );
  2948. to = $.effects.setTransition( element, cProps, factor.to.y, to );
  2949. }
  2950. }
  2951. // Adjust the position properties based on the provided origin points
  2952. if ( origin ) {
  2953. baseline = $.effects.getBaseline( origin, original );
  2954. from.top = ( original.outerHeight - from.outerHeight ) * baseline.y + pos.top;
  2955. from.left = ( original.outerWidth - from.outerWidth ) * baseline.x + pos.left;
  2956. to.top = ( original.outerHeight - to.outerHeight ) * baseline.y + pos.top;
  2957. to.left = ( original.outerWidth - to.outerWidth ) * baseline.x + pos.left;
  2958. }
  2959. element.css( from );
  2960. // Animate the children if desired
  2961. if ( scale === "content" || scale === "both" ) {
  2962. vProps = vProps.concat( [ "marginTop", "marginBottom" ] ).concat( cProps );
  2963. hProps = hProps.concat( [ "marginLeft", "marginRight" ] );
  2964. // Only animate children with width attributes specified
  2965. // TODO: is this right? should we include anything with css width specified as well
  2966. element.find( "*[width]" ).each( function() {
  2967. var child = $( this ),
  2968. childOriginal = $.effects.scaledDimensions( child ),
  2969. childFrom = {
  2970. height: childOriginal.height * factor.from.y,
  2971. width: childOriginal.width * factor.from.x,
  2972. outerHeight: childOriginal.outerHeight * factor.from.y,
  2973. outerWidth: childOriginal.outerWidth * factor.from.x
  2974. },
  2975. childTo = {
  2976. height: childOriginal.height * factor.to.y,
  2977. width: childOriginal.width * factor.to.x,
  2978. outerHeight: childOriginal.height * factor.to.y,
  2979. outerWidth: childOriginal.width * factor.to.x
  2980. };
  2981. // Vertical props scaling
  2982. if ( factor.from.y !== factor.to.y ) {
  2983. childFrom = $.effects.setTransition( child, vProps, factor.from.y, childFrom );
  2984. childTo = $.effects.setTransition( child, vProps, factor.to.y, childTo );
  2985. }
  2986. // Horizontal props scaling
  2987. if ( factor.from.x !== factor.to.x ) {
  2988. childFrom = $.effects.setTransition( child, hProps, factor.from.x, childFrom );
  2989. childTo = $.effects.setTransition( child, hProps, factor.to.x, childTo );
  2990. }
  2991. if ( restore ) {
  2992. $.effects.saveStyle( child );
  2993. }
  2994. // Animate children
  2995. child.css( childFrom );
  2996. child.animate( childTo, options.duration, options.easing, function() {
  2997. // Restore children
  2998. if ( restore ) {
  2999. $.effects.restoreStyle( child );
  3000. }
  3001. } );
  3002. } );
  3003. }
  3004. // Animate
  3005. element.animate( to, {
  3006. queue: false,
  3007. duration: options.duration,
  3008. easing: options.easing,
  3009. complete: function() {
  3010. var offset = element.offset();
  3011. if ( to.opacity === 0 ) {
  3012. element.css( "opacity", from.opacity );
  3013. }
  3014. if ( !restore ) {
  3015. element
  3016. .css( "position", position === "static" ? "relative" : position )
  3017. .offset( offset );
  3018. // Need to save style here so that automatic style restoration
  3019. // doesn't restore to the original styles from before the animation.
  3020. $.effects.saveStyle( element );
  3021. }
  3022. done();
  3023. }
  3024. } );
  3025. } );
  3026. /*!
  3027. * jQuery UI Effects Scale 1.12.1
  3028. * http://jqueryui.com
  3029. *
  3030. * Copyright jQuery Foundation and other contributors
  3031. * Released under the MIT license.
  3032. * http://jquery.org/license
  3033. */
  3034. //>>label: Scale Effect
  3035. //>>group: Effects
  3036. //>>description: Grows or shrinks an element and its content.
  3037. //>>docs: http://api.jqueryui.com/scale-effect/
  3038. //>>demos: http://jqueryui.com/effect/
  3039. var effectsEffectScale = $.effects.define( "scale", function( options, done ) {
  3040. // Create element
  3041. var el = $( this ),
  3042. mode = options.mode,
  3043. percent = parseInt( options.percent, 10 ) ||
  3044. ( parseInt( options.percent, 10 ) === 0 ? 0 : ( mode !== "effect" ? 0 : 100 ) ),
  3045. newOptions = $.extend( true, {
  3046. from: $.effects.scaledDimensions( el ),
  3047. to: $.effects.scaledDimensions( el, percent, options.direction || "both" ),
  3048. origin: options.origin || [ "middle", "center" ]
  3049. }, options );
  3050. // Fade option to support puff
  3051. if ( options.fade ) {
  3052. newOptions.from.opacity = 1;
  3053. newOptions.to.opacity = 0;
  3054. }
  3055. $.effects.effect.size.call( this, newOptions, done );
  3056. } );
  3057. /*!
  3058. * jQuery UI Effects Puff 1.12.1
  3059. * http://jqueryui.com
  3060. *
  3061. * Copyright jQuery Foundation and other contributors
  3062. * Released under the MIT license.
  3063. * http://jquery.org/license
  3064. */
  3065. //>>label: Puff Effect
  3066. //>>group: Effects
  3067. //>>description: Creates a puff effect by scaling the element up and hiding it at the same time.
  3068. //>>docs: http://api.jqueryui.com/puff-effect/
  3069. //>>demos: http://jqueryui.com/effect/
  3070. var effectsEffectPuff = $.effects.define( "puff", "hide", function( options, done ) {
  3071. var newOptions = $.extend( true, {}, options, {
  3072. fade: true,
  3073. percent: parseInt( options.percent, 10 ) || 150
  3074. } );
  3075. $.effects.effect.scale.call( this, newOptions, done );
  3076. } );
  3077. /*!
  3078. * jQuery UI Effects Pulsate 1.12.1
  3079. * http://jqueryui.com
  3080. *
  3081. * Copyright jQuery Foundation and other contributors
  3082. * Released under the MIT license.
  3083. * http://jquery.org/license
  3084. */
  3085. //>>label: Pulsate Effect
  3086. //>>group: Effects
  3087. //>>description: Pulsates an element n times by changing the opacity to zero and back.
  3088. //>>docs: http://api.jqueryui.com/pulsate-effect/
  3089. //>>demos: http://jqueryui.com/effect/
  3090. var effectsEffectPulsate = $.effects.define( "pulsate", "show", function( options, done ) {
  3091. var element = $( this ),
  3092. mode = options.mode,
  3093. show = mode === "show",
  3094. hide = mode === "hide",
  3095. showhide = show || hide,
  3096. // Showing or hiding leaves off the "last" animation
  3097. anims = ( ( options.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
  3098. duration = options.duration / anims,
  3099. animateTo = 0,
  3100. i = 1,
  3101. queuelen = element.queue().length;
  3102. if ( show || !element.is( ":visible" ) ) {
  3103. element.css( "opacity", 0 ).show();
  3104. animateTo = 1;
  3105. }
  3106. // Anims - 1 opacity "toggles"
  3107. for ( ; i < anims; i++ ) {
  3108. element.animate( { opacity: animateTo }, duration, options.easing );
  3109. animateTo = 1 - animateTo;
  3110. }
  3111. element.animate( { opacity: animateTo }, duration, options.easing );
  3112. element.queue( done );
  3113. $.effects.unshift( element, queuelen, anims + 1 );
  3114. } );
  3115. /*!
  3116. * jQuery UI Effects Shake 1.12.1
  3117. * http://jqueryui.com
  3118. *
  3119. * Copyright jQuery Foundation and other contributors
  3120. * Released under the MIT license.
  3121. * http://jquery.org/license
  3122. */
  3123. //>>label: Shake Effect
  3124. //>>group: Effects
  3125. //>>description: Shakes an element horizontally or vertically n times.
  3126. //>>docs: http://api.jqueryui.com/shake-effect/
  3127. //>>demos: http://jqueryui.com/effect/
  3128. var effectsEffectShake = $.effects.define( "shake", function( options, done ) {
  3129. var i = 1,
  3130. element = $( this ),
  3131. direction = options.direction || "left",
  3132. distance = options.distance || 20,
  3133. times = options.times || 3,
  3134. anims = times * 2 + 1,
  3135. speed = Math.round( options.duration / anims ),
  3136. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  3137. positiveMotion = ( direction === "up" || direction === "left" ),
  3138. animation = {},
  3139. animation1 = {},
  3140. animation2 = {},
  3141. queuelen = element.queue().length;
  3142. $.effects.createPlaceholder( element );
  3143. // Animation
  3144. animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance;
  3145. animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2;
  3146. animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2;
  3147. // Animate
  3148. element.animate( animation, speed, options.easing );
  3149. // Shakes
  3150. for ( ; i < times; i++ ) {
  3151. element
  3152. .animate( animation1, speed, options.easing )
  3153. .animate( animation2, speed, options.easing );
  3154. }
  3155. element
  3156. .animate( animation1, speed, options.easing )
  3157. .animate( animation, speed / 2, options.easing )
  3158. .queue( done );
  3159. $.effects.unshift( element, queuelen, anims + 1 );
  3160. } );
  3161. /*!
  3162. * jQuery UI Effects Slide 1.12.1
  3163. * http://jqueryui.com
  3164. *
  3165. * Copyright jQuery Foundation and other contributors
  3166. * Released under the MIT license.
  3167. * http://jquery.org/license
  3168. */
  3169. //>>label: Slide Effect
  3170. //>>group: Effects
  3171. //>>description: Slides an element in and out of the viewport.
  3172. //>>docs: http://api.jqueryui.com/slide-effect/
  3173. //>>demos: http://jqueryui.com/effect/
  3174. var effectsEffectSlide = $.effects.define( "slide", "show", function( options, done ) {
  3175. var startClip, startRef,
  3176. element = $( this ),
  3177. map = {
  3178. up: [ "bottom", "top" ],
  3179. down: [ "top", "bottom" ],
  3180. left: [ "right", "left" ],
  3181. right: [ "left", "right" ]
  3182. },
  3183. mode = options.mode,
  3184. direction = options.direction || "left",
  3185. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  3186. positiveMotion = ( direction === "up" || direction === "left" ),
  3187. distance = options.distance ||
  3188. element[ ref === "top" ? "outerHeight" : "outerWidth" ]( true ),
  3189. animation = {};
  3190. $.effects.createPlaceholder( element );
  3191. startClip = element.cssClip();
  3192. startRef = element.position()[ ref ];
  3193. // Define hide animation
  3194. animation[ ref ] = ( positiveMotion ? -1 : 1 ) * distance + startRef;
  3195. animation.clip = element.cssClip();
  3196. animation.clip[ map[ direction ][ 1 ] ] = animation.clip[ map[ direction ][ 0 ] ];
  3197. // Reverse the animation if we're showing
  3198. if ( mode === "show" ) {
  3199. element.cssClip( animation.clip );
  3200. element.css( ref, animation[ ref ] );
  3201. animation.clip = startClip;
  3202. animation[ ref ] = startRef;
  3203. }
  3204. // Actually animate
  3205. element.animate( animation, {
  3206. queue: false,
  3207. duration: options.duration,
  3208. easing: options.easing,
  3209. complete: done
  3210. } );
  3211. } );
  3212. /*!
  3213. * jQuery UI Effects Transfer 1.12.1
  3214. * http://jqueryui.com
  3215. *
  3216. * Copyright jQuery Foundation and other contributors
  3217. * Released under the MIT license.
  3218. * http://jquery.org/license
  3219. */
  3220. //>>label: Transfer Effect
  3221. //>>group: Effects
  3222. //>>description: Displays a transfer effect from one element to another.
  3223. //>>docs: http://api.jqueryui.com/transfer-effect/
  3224. //>>demos: http://jqueryui.com/effect/
  3225. var effect;
  3226. if ( $.uiBackCompat !== false ) {
  3227. effect = $.effects.define( "transfer", function( options, done ) {
  3228. $( this ).transfer( options, done );
  3229. } );
  3230. }
  3231. var effectsEffectTransfer = effect;
  3232. /*!
  3233. * jQuery UI Focusable 1.12.1
  3234. * http://jqueryui.com
  3235. *
  3236. * Copyright jQuery Foundation and other contributors
  3237. * Released under the MIT license.
  3238. * http://jquery.org/license
  3239. */
  3240. //>>label: :focusable Selector
  3241. //>>group: Core
  3242. //>>description: Selects elements which can be focused.
  3243. //>>docs: http://api.jqueryui.com/focusable-selector/
  3244. // Selectors
  3245. $.ui.focusable = function( element, hasTabindex ) {
  3246. var map, mapName, img, focusableIfVisible, fieldset,
  3247. nodeName = element.nodeName.toLowerCase();
  3248. if ( "area" === nodeName ) {
  3249. map = element.parentNode;
  3250. mapName = map.name;
  3251. if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
  3252. return false;
  3253. }
  3254. img = $( "img[usemap='#" + mapName + "']" );
  3255. return img.length > 0 && img.is( ":visible" );
  3256. }
  3257. if ( /^(input|select|textarea|button|object)$/.test( nodeName ) ) {
  3258. focusableIfVisible = !element.disabled;
  3259. if ( focusableIfVisible ) {
  3260. // Form controls within a disabled fieldset are disabled.
  3261. // However, controls within the fieldset's legend do not get disabled.
  3262. // Since controls generally aren't placed inside legends, we skip
  3263. // this portion of the check.
  3264. fieldset = $( element ).closest( "fieldset" )[ 0 ];
  3265. if ( fieldset ) {
  3266. focusableIfVisible = !fieldset.disabled;
  3267. }
  3268. }
  3269. } else if ( "a" === nodeName ) {
  3270. focusableIfVisible = element.href || hasTabindex;
  3271. } else {
  3272. focusableIfVisible = hasTabindex;
  3273. }
  3274. return focusableIfVisible && $( element ).is( ":visible" ) && visible( $( element ) );
  3275. };
  3276. // Support: IE 8 only
  3277. // IE 8 doesn't resolve inherit to visible/hidden for computed values
  3278. function visible( element ) {
  3279. var visibility = element.css( "visibility" );
  3280. while ( visibility === "inherit" ) {
  3281. element = element.parent();
  3282. visibility = element.css( "visibility" );
  3283. }
  3284. return visibility !== "hidden";
  3285. }
  3286. $.extend( $.expr[ ":" ], {
  3287. focusable: function( element ) {
  3288. return $.ui.focusable( element, $.attr( element, "tabindex" ) != null );
  3289. }
  3290. } );
  3291. var focusable = $.ui.focusable;
  3292. // Support: IE8 Only
  3293. // IE8 does not support the form attribute and when it is supplied. It overwrites the form prop
  3294. // with a string, so we need to find the proper form.
  3295. var form = $.fn.form = function() {
  3296. return typeof this[ 0 ].form === "string" ? this.closest( "form" ) : $( this[ 0 ].form );
  3297. };
  3298. /*!
  3299. * jQuery UI Form Reset Mixin 1.12.1
  3300. * http://jqueryui.com
  3301. *
  3302. * Copyright jQuery Foundation and other contributors
  3303. * Released under the MIT license.
  3304. * http://jquery.org/license
  3305. */
  3306. //>>label: Form Reset Mixin
  3307. //>>group: Core
  3308. //>>description: Refresh input widgets when their form is reset
  3309. //>>docs: http://api.jqueryui.com/form-reset-mixin/
  3310. var formResetMixin = $.ui.formResetMixin = {
  3311. _formResetHandler: function() {
  3312. var form = $( this );
  3313. // Wait for the form reset to actually happen before refreshing
  3314. setTimeout( function() {
  3315. var instances = form.data( "ui-form-reset-instances" );
  3316. $.each( instances, function() {
  3317. this.refresh();
  3318. } );
  3319. } );
  3320. },
  3321. _bindFormResetHandler: function() {
  3322. this.form = this.element.form();
  3323. if ( !this.form.length ) {
  3324. return;
  3325. }
  3326. var instances = this.form.data( "ui-form-reset-instances" ) || [];
  3327. if ( !instances.length ) {
  3328. // We don't use _on() here because we use a single event handler per form
  3329. this.form.on( "reset.ui-form-reset", this._formResetHandler );
  3330. }
  3331. instances.push( this );
  3332. this.form.data( "ui-form-reset-instances", instances );
  3333. },
  3334. _unbindFormResetHandler: function() {
  3335. if ( !this.form.length ) {
  3336. return;
  3337. }
  3338. var instances = this.form.data( "ui-form-reset-instances" );
  3339. instances.splice( $.inArray( this, instances ), 1 );
  3340. if ( instances.length ) {
  3341. this.form.data( "ui-form-reset-instances", instances );
  3342. } else {
  3343. this.form
  3344. .removeData( "ui-form-reset-instances" )
  3345. .off( "reset.ui-form-reset" );
  3346. }
  3347. }
  3348. };
  3349. /*!
  3350. * jQuery UI Support for jQuery core 1.7.x 1.12.1
  3351. * http://jqueryui.com
  3352. *
  3353. * Copyright jQuery Foundation and other contributors
  3354. * Released under the MIT license.
  3355. * http://jquery.org/license
  3356. *
  3357. */
  3358. //>>label: jQuery 1.7 Support
  3359. //>>group: Core
  3360. //>>description: Support version 1.7.x of jQuery core
  3361. // Support: jQuery 1.7 only
  3362. // Not a great way to check versions, but since we only support 1.7+ and only
  3363. // need to detect <1.8, this is a simple check that should suffice. Checking
  3364. // for "1.7." would be a bit safer, but the version string is 1.7, not 1.7.0
  3365. // and we'll never reach 1.70.0 (if we do, we certainly won't be supporting
  3366. // 1.7 anymore). See #11197 for why we're not using feature detection.
  3367. if ( $.fn.jquery.substring( 0, 3 ) === "1.7" ) {
  3368. // Setters for .innerWidth(), .innerHeight(), .outerWidth(), .outerHeight()
  3369. // Unlike jQuery Core 1.8+, these only support numeric values to set the
  3370. // dimensions in pixels
  3371. $.each( [ "Width", "Height" ], function( i, name ) {
  3372. var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
  3373. type = name.toLowerCase(),
  3374. orig = {
  3375. innerWidth: $.fn.innerWidth,
  3376. innerHeight: $.fn.innerHeight,
  3377. outerWidth: $.fn.outerWidth,
  3378. outerHeight: $.fn.outerHeight
  3379. };
  3380. function reduce( elem, size, border, margin ) {
  3381. $.each( side, function() {
  3382. size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
  3383. if ( border ) {
  3384. size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
  3385. }
  3386. if ( margin ) {
  3387. size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
  3388. }
  3389. } );
  3390. return size;
  3391. }
  3392. $.fn[ "inner" + name ] = function( size ) {
  3393. if ( size === undefined ) {
  3394. return orig[ "inner" + name ].call( this );
  3395. }
  3396. return this.each( function() {
  3397. $( this ).css( type, reduce( this, size ) + "px" );
  3398. } );
  3399. };
  3400. $.fn[ "outer" + name ] = function( size, margin ) {
  3401. if ( typeof size !== "number" ) {
  3402. return orig[ "outer" + name ].call( this, size );
  3403. }
  3404. return this.each( function() {
  3405. $( this ).css( type, reduce( this, size, true, margin ) + "px" );
  3406. } );
  3407. };
  3408. } );
  3409. $.fn.addBack = function( selector ) {
  3410. return this.add( selector == null ?
  3411. this.prevObject : this.prevObject.filter( selector )
  3412. );
  3413. };
  3414. }
  3415. ;
  3416. /*!
  3417. * jQuery UI Keycode 1.12.1
  3418. * http://jqueryui.com
  3419. *
  3420. * Copyright jQuery Foundation and other contributors
  3421. * Released under the MIT license.
  3422. * http://jquery.org/license
  3423. */
  3424. //>>label: Keycode
  3425. //>>group: Core
  3426. //>>description: Provide keycodes as keynames
  3427. //>>docs: http://api.jqueryui.com/jQuery.ui.keyCode/
  3428. var keycode = $.ui.keyCode = {
  3429. BACKSPACE: 8,
  3430. COMMA: 188,
  3431. DELETE: 46,
  3432. DOWN: 40,
  3433. END: 35,
  3434. ENTER: 13,
  3435. ESCAPE: 27,
  3436. HOME: 36,
  3437. LEFT: 37,
  3438. PAGE_DOWN: 34,
  3439. PAGE_UP: 33,
  3440. PERIOD: 190,
  3441. RIGHT: 39,
  3442. SPACE: 32,
  3443. TAB: 9,
  3444. UP: 38
  3445. };
  3446. // Internal use only
  3447. var escapeSelector = $.ui.escapeSelector = ( function() {
  3448. var selectorEscape = /([!"#$%&'()*+,./:;<=>?@[\]^`{|}~])/g;
  3449. return function( selector ) {
  3450. return selector.replace( selectorEscape, "\\$1" );
  3451. };
  3452. } )();
  3453. /*!
  3454. * jQuery UI Labels 1.12.1
  3455. * http://jqueryui.com
  3456. *
  3457. * Copyright jQuery Foundation and other contributors
  3458. * Released under the MIT license.
  3459. * http://jquery.org/license
  3460. */
  3461. //>>label: labels
  3462. //>>group: Core
  3463. //>>description: Find all the labels associated with a given input
  3464. //>>docs: http://api.jqueryui.com/labels/
  3465. var labels = $.fn.labels = function() {
  3466. var ancestor, selector, id, labels, ancestors;
  3467. // Check control.labels first
  3468. if ( this[ 0 ].labels && this[ 0 ].labels.length ) {
  3469. return this.pushStack( this[ 0 ].labels );
  3470. }
  3471. // Support: IE <= 11, FF <= 37, Android <= 2.3 only
  3472. // Above browsers do not support control.labels. Everything below is to support them
  3473. // as well as document fragments. control.labels does not work on document fragments
  3474. labels = this.eq( 0 ).parents( "label" );
  3475. // Look for the label based on the id
  3476. id = this.attr( "id" );
  3477. if ( id ) {
  3478. // We don't search against the document in case the element
  3479. // is disconnected from the DOM
  3480. ancestor = this.eq( 0 ).parents().last();
  3481. // Get a full set of top level ancestors
  3482. ancestors = ancestor.add( ancestor.length ? ancestor.siblings() : this.siblings() );
  3483. // Create a selector for the label based on the id
  3484. selector = "label[for='" + $.ui.escapeSelector( id ) + "']";
  3485. labels = labels.add( ancestors.find( selector ).addBack( selector ) );
  3486. }
  3487. // Return whatever we have found for labels
  3488. return this.pushStack( labels );
  3489. };
  3490. /*!
  3491. * jQuery UI Scroll Parent 1.12.1
  3492. * http://jqueryui.com
  3493. *
  3494. * Copyright jQuery Foundation and other contributors
  3495. * Released under the MIT license.
  3496. * http://jquery.org/license
  3497. */
  3498. //>>label: scrollParent
  3499. //>>group: Core
  3500. //>>description: Get the closest ancestor element that is scrollable.
  3501. //>>docs: http://api.jqueryui.com/scrollParent/
  3502. var scrollParent = $.fn.scrollParent = function( includeHidden ) {
  3503. var position = this.css( "position" ),
  3504. excludeStaticParent = position === "absolute",
  3505. overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/,
  3506. scrollParent = this.parents().filter( function() {
  3507. var parent = $( this );
  3508. if ( excludeStaticParent && parent.css( "position" ) === "static" ) {
  3509. return false;
  3510. }
  3511. return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) +
  3512. parent.css( "overflow-x" ) );
  3513. } ).eq( 0 );
  3514. return position === "fixed" || !scrollParent.length ?
  3515. $( this[ 0 ].ownerDocument || document ) :
  3516. scrollParent;
  3517. };
  3518. /*!
  3519. * jQuery UI Tabbable 1.12.1
  3520. * http://jqueryui.com
  3521. *
  3522. * Copyright jQuery Foundation and other contributors
  3523. * Released under the MIT license.
  3524. * http://jquery.org/license
  3525. */
  3526. //>>label: :tabbable Selector
  3527. //>>group: Core
  3528. //>>description: Selects elements which can be tabbed to.
  3529. //>>docs: http://api.jqueryui.com/tabbable-selector/
  3530. var tabbable = $.extend( $.expr[ ":" ], {
  3531. tabbable: function( element ) {
  3532. var tabIndex = $.attr( element, "tabindex" ),
  3533. hasTabindex = tabIndex != null;
  3534. return ( !hasTabindex || tabIndex >= 0 ) && $.ui.focusable( element, hasTabindex );
  3535. }
  3536. } );
  3537. /*!
  3538. * jQuery UI Unique ID 1.12.1
  3539. * http://jqueryui.com
  3540. *
  3541. * Copyright jQuery Foundation and other contributors
  3542. * Released under the MIT license.
  3543. * http://jquery.org/license
  3544. */
  3545. //>>label: uniqueId
  3546. //>>group: Core
  3547. //>>description: Functions to generate and remove uniqueId's
  3548. //>>docs: http://api.jqueryui.com/uniqueId/
  3549. var uniqueId = $.fn.extend( {
  3550. uniqueId: ( function() {
  3551. var uuid = 0;
  3552. return function() {
  3553. return this.each( function() {
  3554. if ( !this.id ) {
  3555. this.id = "ui-id-" + ( ++uuid );
  3556. }
  3557. } );
  3558. };
  3559. } )(),
  3560. removeUniqueId: function() {
  3561. return this.each( function() {
  3562. if ( /^ui-id-\d+$/.test( this.id ) ) {
  3563. $( this ).removeAttr( "id" );
  3564. }
  3565. } );
  3566. }
  3567. } );
  3568. /*!
  3569. * jQuery UI Accordion 1.12.1
  3570. * http://jqueryui.com
  3571. *
  3572. * Copyright jQuery Foundation and other contributors
  3573. * Released under the MIT license.
  3574. * http://jquery.org/license
  3575. */
  3576. //>>label: Accordion
  3577. //>>group: Widgets
  3578. // jscs:disable maximumLineLength
  3579. //>>description: Displays collapsible content panels for presenting information in a limited amount of space.
  3580. // jscs:enable maximumLineLength
  3581. //>>docs: http://api.jqueryui.com/accordion/
  3582. //>>demos: http://jqueryui.com/accordion/
  3583. //>>css.structure: ../../themes/base/core.css
  3584. //>>css.structure: ../../themes/base/accordion.css
  3585. //>>css.theme: ../../themes/base/theme.css
  3586. var widgetsAccordion = $.widget( "ui.accordion", {
  3587. version: "1.12.1",
  3588. options: {
  3589. active: 0,
  3590. animate: {},
  3591. classes: {
  3592. "ui-accordion-header": "ui-corner-top",
  3593. "ui-accordion-header-collapsed": "ui-corner-all",
  3594. "ui-accordion-content": "ui-corner-bottom"
  3595. },
  3596. collapsible: false,
  3597. event: "click",
  3598. header: "> li > :first-child, > :not(li):even",
  3599. heightStyle: "auto",
  3600. icons: {
  3601. activeHeader: "ui-icon-triangle-1-s",
  3602. header: "ui-icon-triangle-1-e"
  3603. },
  3604. // Callbacks
  3605. activate: null,
  3606. beforeActivate: null
  3607. },
  3608. hideProps: {
  3609. borderTopWidth: "hide",
  3610. borderBottomWidth: "hide",
  3611. paddingTop: "hide",
  3612. paddingBottom: "hide",
  3613. height: "hide"
  3614. },
  3615. showProps: {
  3616. borderTopWidth: "show",
  3617. borderBottomWidth: "show",
  3618. paddingTop: "show",
  3619. paddingBottom: "show",
  3620. height: "show"
  3621. },
  3622. _create: function() {
  3623. var options = this.options;
  3624. this.prevShow = this.prevHide = $();
  3625. this._addClass( "ui-accordion", "ui-widget ui-helper-reset" );
  3626. this.element.attr( "role", "tablist" );
  3627. // Don't allow collapsible: false and active: false / null
  3628. if ( !options.collapsible && ( options.active === false || options.active == null ) ) {
  3629. options.active = 0;
  3630. }
  3631. this._processPanels();
  3632. // handle negative values
  3633. if ( options.active < 0 ) {
  3634. options.active += this.headers.length;
  3635. }
  3636. this._refresh();
  3637. },
  3638. _getCreateEventData: function() {
  3639. return {
  3640. header: this.active,
  3641. panel: !this.active.length ? $() : this.active.next()
  3642. };
  3643. },
  3644. _createIcons: function() {
  3645. var icon, children,
  3646. icons = this.options.icons;
  3647. if ( icons ) {
  3648. icon = $( "<span>" );
  3649. this._addClass( icon, "ui-accordion-header-icon", "ui-icon " + icons.header );
  3650. icon.prependTo( this.headers );
  3651. children = this.active.children( ".ui-accordion-header-icon" );
  3652. this._removeClass( children, icons.header )
  3653. ._addClass( children, null, icons.activeHeader )
  3654. ._addClass( this.headers, "ui-accordion-icons" );
  3655. }
  3656. },
  3657. _destroyIcons: function() {
  3658. this._removeClass( this.headers, "ui-accordion-icons" );
  3659. this.headers.children( ".ui-accordion-header-icon" ).remove();
  3660. },
  3661. _destroy: function() {
  3662. var contents;
  3663. // Clean up main element
  3664. this.element.removeAttr( "role" );
  3665. // Clean up headers
  3666. this.headers
  3667. .removeAttr( "role aria-expanded aria-selected aria-controls tabIndex" )
  3668. .removeUniqueId();
  3669. this._destroyIcons();
  3670. // Clean up content panels
  3671. contents = this.headers.next()
  3672. .css( "display", "" )
  3673. .removeAttr( "role aria-hidden aria-labelledby" )
  3674. .removeUniqueId();
  3675. if ( this.options.heightStyle !== "content" ) {
  3676. contents.css( "height", "" );
  3677. }
  3678. },
  3679. _setOption: function( key, value ) {
  3680. if ( key === "active" ) {
  3681. // _activate() will handle invalid values and update this.options
  3682. this._activate( value );
  3683. return;
  3684. }
  3685. if ( key === "event" ) {
  3686. if ( this.options.event ) {
  3687. this._off( this.headers, this.options.event );
  3688. }
  3689. this._setupEvents( value );
  3690. }
  3691. this._super( key, value );
  3692. // Setting collapsible: false while collapsed; open first panel
  3693. if ( key === "collapsible" && !value && this.options.active === false ) {
  3694. this._activate( 0 );
  3695. }
  3696. if ( key === "icons" ) {
  3697. this._destroyIcons();
  3698. if ( value ) {
  3699. this._createIcons();
  3700. }
  3701. }
  3702. },
  3703. _setOptionDisabled: function( value ) {
  3704. this._super( value );
  3705. this.element.attr( "aria-disabled", value );
  3706. // Support: IE8 Only
  3707. // #5332 / #6059 - opacity doesn't cascade to positioned elements in IE
  3708. // so we need to add the disabled class to the headers and panels
  3709. this._toggleClass( null, "ui-state-disabled", !!value );
  3710. this._toggleClass( this.headers.add( this.headers.next() ), null, "ui-state-disabled",
  3711. !!value );
  3712. },
  3713. _keydown: function( event ) {
  3714. if ( event.altKey || event.ctrlKey ) {
  3715. return;
  3716. }
  3717. var keyCode = $.ui.keyCode,
  3718. length = this.headers.length,
  3719. currentIndex = this.headers.index( event.target ),
  3720. toFocus = false;
  3721. switch ( event.keyCode ) {
  3722. case keyCode.RIGHT:
  3723. case keyCode.DOWN:
  3724. toFocus = this.headers[ ( currentIndex + 1 ) % length ];
  3725. break;
  3726. case keyCode.LEFT:
  3727. case keyCode.UP:
  3728. toFocus = this.headers[ ( currentIndex - 1 + length ) % length ];
  3729. break;
  3730. case keyCode.SPACE:
  3731. case keyCode.ENTER:
  3732. this._eventHandler( event );
  3733. break;
  3734. case keyCode.HOME:
  3735. toFocus = this.headers[ 0 ];
  3736. break;
  3737. case keyCode.END:
  3738. toFocus = this.headers[ length - 1 ];
  3739. break;
  3740. }
  3741. if ( toFocus ) {
  3742. $( event.target ).attr( "tabIndex", -1 );
  3743. $( toFocus ).attr( "tabIndex", 0 );
  3744. $( toFocus ).trigger( "focus" );
  3745. event.preventDefault();
  3746. }
  3747. },
  3748. _panelKeyDown: function( event ) {
  3749. if ( event.keyCode === $.ui.keyCode.UP && event.ctrlKey ) {
  3750. $( event.currentTarget ).prev().trigger( "focus" );
  3751. }
  3752. },
  3753. refresh: function() {
  3754. var options = this.options;
  3755. this._processPanels();
  3756. // Was collapsed or no panel
  3757. if ( ( options.active === false && options.collapsible === true ) ||
  3758. !this.headers.length ) {
  3759. options.active = false;
  3760. this.active = $();
  3761. // active false only when collapsible is true
  3762. } else if ( options.active === false ) {
  3763. this._activate( 0 );
  3764. // was active, but active panel is gone
  3765. } else if ( this.active.length && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  3766. // all remaining panel are disabled
  3767. if ( this.headers.length === this.headers.find( ".ui-state-disabled" ).length ) {
  3768. options.active = false;
  3769. this.active = $();
  3770. // activate previous panel
  3771. } else {
  3772. this._activate( Math.max( 0, options.active - 1 ) );
  3773. }
  3774. // was active, active panel still exists
  3775. } else {
  3776. // make sure active index is correct
  3777. options.active = this.headers.index( this.active );
  3778. }
  3779. this._destroyIcons();
  3780. this._refresh();
  3781. },
  3782. _processPanels: function() {
  3783. var prevHeaders = this.headers,
  3784. prevPanels = this.panels;
  3785. this.headers = this.element.find( this.options.header );
  3786. this._addClass( this.headers, "ui-accordion-header ui-accordion-header-collapsed",
  3787. "ui-state-default" );
  3788. this.panels = this.headers.next().filter( ":not(.ui-accordion-content-active)" ).hide();
  3789. this._addClass( this.panels, "ui-accordion-content", "ui-helper-reset ui-widget-content" );
  3790. // Avoid memory leaks (#10056)
  3791. if ( prevPanels ) {
  3792. this._off( prevHeaders.not( this.headers ) );
  3793. this._off( prevPanels.not( this.panels ) );
  3794. }
  3795. },
  3796. _refresh: function() {
  3797. var maxHeight,
  3798. options = this.options,
  3799. heightStyle = options.heightStyle,
  3800. parent = this.element.parent();
  3801. this.active = this._findActive( options.active );
  3802. this._addClass( this.active, "ui-accordion-header-active", "ui-state-active" )
  3803. ._removeClass( this.active, "ui-accordion-header-collapsed" );
  3804. this._addClass( this.active.next(), "ui-accordion-content-active" );
  3805. this.active.next().show();
  3806. this.headers
  3807. .attr( "role", "tab" )
  3808. .each( function() {
  3809. var header = $( this ),
  3810. headerId = header.uniqueId().attr( "id" ),
  3811. panel = header.next(),
  3812. panelId = panel.uniqueId().attr( "id" );
  3813. header.attr( "aria-controls", panelId );
  3814. panel.attr( "aria-labelledby", headerId );
  3815. } )
  3816. .next()
  3817. .attr( "role", "tabpanel" );
  3818. this.headers
  3819. .not( this.active )
  3820. .attr( {
  3821. "aria-selected": "false",
  3822. "aria-expanded": "false",
  3823. tabIndex: -1
  3824. } )
  3825. .next()
  3826. .attr( {
  3827. "aria-hidden": "true"
  3828. } )
  3829. .hide();
  3830. // Make sure at least one header is in the tab order
  3831. if ( !this.active.length ) {
  3832. this.headers.eq( 0 ).attr( "tabIndex", 0 );
  3833. } else {
  3834. this.active.attr( {
  3835. "aria-selected": "true",
  3836. "aria-expanded": "true",
  3837. tabIndex: 0
  3838. } )
  3839. .next()
  3840. .attr( {
  3841. "aria-hidden": "false"
  3842. } );
  3843. }
  3844. this._createIcons();
  3845. this._setupEvents( options.event );
  3846. if ( heightStyle === "fill" ) {
  3847. maxHeight = parent.height();
  3848. this.element.siblings( ":visible" ).each( function() {
  3849. var elem = $( this ),
  3850. position = elem.css( "position" );
  3851. if ( position === "absolute" || position === "fixed" ) {
  3852. return;
  3853. }
  3854. maxHeight -= elem.outerHeight( true );
  3855. } );
  3856. this.headers.each( function() {
  3857. maxHeight -= $( this ).outerHeight( true );
  3858. } );
  3859. this.headers.next()
  3860. .each( function() {
  3861. $( this ).height( Math.max( 0, maxHeight -
  3862. $( this ).innerHeight() + $( this ).height() ) );
  3863. } )
  3864. .css( "overflow", "auto" );
  3865. } else if ( heightStyle === "auto" ) {
  3866. maxHeight = 0;
  3867. this.headers.next()
  3868. .each( function() {
  3869. var isVisible = $( this ).is( ":visible" );
  3870. if ( !isVisible ) {
  3871. $( this ).show();
  3872. }
  3873. maxHeight = Math.max( maxHeight, $( this ).css( "height", "" ).height() );
  3874. if ( !isVisible ) {
  3875. $( this ).hide();
  3876. }
  3877. } )
  3878. .height( maxHeight );
  3879. }
  3880. },
  3881. _activate: function( index ) {
  3882. var active = this._findActive( index )[ 0 ];
  3883. // Trying to activate the already active panel
  3884. if ( active === this.active[ 0 ] ) {
  3885. return;
  3886. }
  3887. // Trying to collapse, simulate a click on the currently active header
  3888. active = active || this.active[ 0 ];
  3889. this._eventHandler( {
  3890. target: active,
  3891. currentTarget: active,
  3892. preventDefault: $.noop
  3893. } );
  3894. },
  3895. _findActive: function( selector ) {
  3896. return typeof selector === "number" ? this.headers.eq( selector ) : $();
  3897. },
  3898. _setupEvents: function( event ) {
  3899. var events = {
  3900. keydown: "_keydown"
  3901. };
  3902. if ( event ) {
  3903. $.each( event.split( " " ), function( index, eventName ) {
  3904. events[ eventName ] = "_eventHandler";
  3905. } );
  3906. }
  3907. this._off( this.headers.add( this.headers.next() ) );
  3908. this._on( this.headers, events );
  3909. this._on( this.headers.next(), { keydown: "_panelKeyDown" } );
  3910. this._hoverable( this.headers );
  3911. this._focusable( this.headers );
  3912. },
  3913. _eventHandler: function( event ) {
  3914. var activeChildren, clickedChildren,
  3915. options = this.options,
  3916. active = this.active,
  3917. clicked = $( event.currentTarget ),
  3918. clickedIsActive = clicked[ 0 ] === active[ 0 ],
  3919. collapsing = clickedIsActive && options.collapsible,
  3920. toShow = collapsing ? $() : clicked.next(),
  3921. toHide = active.next(),
  3922. eventData = {
  3923. oldHeader: active,
  3924. oldPanel: toHide,
  3925. newHeader: collapsing ? $() : clicked,
  3926. newPanel: toShow
  3927. };
  3928. event.preventDefault();
  3929. if (
  3930. // click on active header, but not collapsible
  3931. ( clickedIsActive && !options.collapsible ) ||
  3932. // allow canceling activation
  3933. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  3934. return;
  3935. }
  3936. options.active = collapsing ? false : this.headers.index( clicked );
  3937. // When the call to ._toggle() comes after the class changes
  3938. // it causes a very odd bug in IE 8 (see #6720)
  3939. this.active = clickedIsActive ? $() : clicked;
  3940. this._toggle( eventData );
  3941. // Switch classes
  3942. // corner classes on the previously active header stay after the animation
  3943. this._removeClass( active, "ui-accordion-header-active", "ui-state-active" );
  3944. if ( options.icons ) {
  3945. activeChildren = active.children( ".ui-accordion-header-icon" );
  3946. this._removeClass( activeChildren, null, options.icons.activeHeader )
  3947. ._addClass( activeChildren, null, options.icons.header );
  3948. }
  3949. if ( !clickedIsActive ) {
  3950. this._removeClass( clicked, "ui-accordion-header-collapsed" )
  3951. ._addClass( clicked, "ui-accordion-header-active", "ui-state-active" );
  3952. if ( options.icons ) {
  3953. clickedChildren = clicked.children( ".ui-accordion-header-icon" );
  3954. this._removeClass( clickedChildren, null, options.icons.header )
  3955. ._addClass( clickedChildren, null, options.icons.activeHeader );
  3956. }
  3957. this._addClass( clicked.next(), "ui-accordion-content-active" );
  3958. }
  3959. },
  3960. _toggle: function( data ) {
  3961. var toShow = data.newPanel,
  3962. toHide = this.prevShow.length ? this.prevShow : data.oldPanel;
  3963. // Handle activating a panel during the animation for another activation
  3964. this.prevShow.add( this.prevHide ).stop( true, true );
  3965. this.prevShow = toShow;
  3966. this.prevHide = toHide;
  3967. if ( this.options.animate ) {
  3968. this._animate( toShow, toHide, data );
  3969. } else {
  3970. toHide.hide();
  3971. toShow.show();
  3972. this._toggleComplete( data );
  3973. }
  3974. toHide.attr( {
  3975. "aria-hidden": "true"
  3976. } );
  3977. toHide.prev().attr( {
  3978. "aria-selected": "false",
  3979. "aria-expanded": "false"
  3980. } );
  3981. // if we're switching panels, remove the old header from the tab order
  3982. // if we're opening from collapsed state, remove the previous header from the tab order
  3983. // if we're collapsing, then keep the collapsing header in the tab order
  3984. if ( toShow.length && toHide.length ) {
  3985. toHide.prev().attr( {
  3986. "tabIndex": -1,
  3987. "aria-expanded": "false"
  3988. } );
  3989. } else if ( toShow.length ) {
  3990. this.headers.filter( function() {
  3991. return parseInt( $( this ).attr( "tabIndex" ), 10 ) === 0;
  3992. } )
  3993. .attr( "tabIndex", -1 );
  3994. }
  3995. toShow
  3996. .attr( "aria-hidden", "false" )
  3997. .prev()
  3998. .attr( {
  3999. "aria-selected": "true",
  4000. "aria-expanded": "true",
  4001. tabIndex: 0
  4002. } );
  4003. },
  4004. _animate: function( toShow, toHide, data ) {
  4005. var total, easing, duration,
  4006. that = this,
  4007. adjust = 0,
  4008. boxSizing = toShow.css( "box-sizing" ),
  4009. down = toShow.length &&
  4010. ( !toHide.length || ( toShow.index() < toHide.index() ) ),
  4011. animate = this.options.animate || {},
  4012. options = down && animate.down || animate,
  4013. complete = function() {
  4014. that._toggleComplete( data );
  4015. };
  4016. if ( typeof options === "number" ) {
  4017. duration = options;
  4018. }
  4019. if ( typeof options === "string" ) {
  4020. easing = options;
  4021. }
  4022. // fall back from options to animation in case of partial down settings
  4023. easing = easing || options.easing || animate.easing;
  4024. duration = duration || options.duration || animate.duration;
  4025. if ( !toHide.length ) {
  4026. return toShow.animate( this.showProps, duration, easing, complete );
  4027. }
  4028. if ( !toShow.length ) {
  4029. return toHide.animate( this.hideProps, duration, easing, complete );
  4030. }
  4031. total = toShow.show().outerHeight();
  4032. toHide.animate( this.hideProps, {
  4033. duration: duration,
  4034. easing: easing,
  4035. step: function( now, fx ) {
  4036. fx.now = Math.round( now );
  4037. }
  4038. } );
  4039. toShow
  4040. .hide()
  4041. .animate( this.showProps, {
  4042. duration: duration,
  4043. easing: easing,
  4044. complete: complete,
  4045. step: function( now, fx ) {
  4046. fx.now = Math.round( now );
  4047. if ( fx.prop !== "height" ) {
  4048. if ( boxSizing === "content-box" ) {
  4049. adjust += fx.now;
  4050. }
  4051. } else if ( that.options.heightStyle !== "content" ) {
  4052. fx.now = Math.round( total - toHide.outerHeight() - adjust );
  4053. adjust = 0;
  4054. }
  4055. }
  4056. } );
  4057. },
  4058. _toggleComplete: function( data ) {
  4059. var toHide = data.oldPanel,
  4060. prev = toHide.prev();
  4061. this._removeClass( toHide, "ui-accordion-content-active" );
  4062. this._removeClass( prev, "ui-accordion-header-active" )
  4063. ._addClass( prev, "ui-accordion-header-collapsed" );
  4064. // Work around for rendering bug in IE (#5421)
  4065. if ( toHide.length ) {
  4066. toHide.parent()[ 0 ].className = toHide.parent()[ 0 ].className;
  4067. }
  4068. this._trigger( "activate", null, data );
  4069. }
  4070. } );
  4071. var safeActiveElement = $.ui.safeActiveElement = function( document ) {
  4072. var activeElement;
  4073. // Support: IE 9 only
  4074. // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
  4075. try {
  4076. activeElement = document.activeElement;
  4077. } catch ( error ) {
  4078. activeElement = document.body;
  4079. }
  4080. // Support: IE 9 - 11 only
  4081. // IE may return null instead of an element
  4082. // Interestingly, this only seems to occur when NOT in an iframe
  4083. if ( !activeElement ) {
  4084. activeElement = document.body;
  4085. }
  4086. // Support: IE 11 only
  4087. // IE11 returns a seemingly empty object in some cases when accessing
  4088. // document.activeElement from an <iframe>
  4089. if ( !activeElement.nodeName ) {
  4090. activeElement = document.body;
  4091. }
  4092. return activeElement;
  4093. };
  4094. /*!
  4095. * jQuery UI Menu 1.12.1
  4096. * http://jqueryui.com
  4097. *
  4098. * Copyright jQuery Foundation and other contributors
  4099. * Released under the MIT license.
  4100. * http://jquery.org/license
  4101. */
  4102. //>>label: Menu
  4103. //>>group: Widgets
  4104. //>>description: Creates nestable menus.
  4105. //>>docs: http://api.jqueryui.com/menu/
  4106. //>>demos: http://jqueryui.com/menu/
  4107. //>>css.structure: ../../themes/base/core.css
  4108. //>>css.structure: ../../themes/base/menu.css
  4109. //>>css.theme: ../../themes/base/theme.css
  4110. var widgetsMenu = $.widget( "ui.menu", {
  4111. version: "1.12.1",
  4112. defaultElement: "<ul>",
  4113. delay: 300,
  4114. options: {
  4115. icons: {
  4116. submenu: "ui-icon-caret-1-e"
  4117. },
  4118. items: "> *",
  4119. menus: "ul",
  4120. position: {
  4121. my: "left top",
  4122. at: "right top"
  4123. },
  4124. role: "menu",
  4125. // Callbacks
  4126. blur: null,
  4127. focus: null,
  4128. select: null
  4129. },
  4130. _create: function() {
  4131. this.activeMenu = this.element;
  4132. // Flag used to prevent firing of the click handler
  4133. // as the event bubbles up through nested menus
  4134. this.mouseHandled = false;
  4135. this.element
  4136. .uniqueId()
  4137. .attr( {
  4138. role: this.options.role,
  4139. tabIndex: 0
  4140. } );
  4141. this._addClass( "ui-menu", "ui-widget ui-widget-content" );
  4142. this._on( {
  4143. // Prevent focus from sticking to links inside menu after clicking
  4144. // them (focus should always stay on UL during navigation).
  4145. "mousedown .ui-menu-item": function( event ) {
  4146. event.preventDefault();
  4147. },
  4148. "click .ui-menu-item": function( event ) {
  4149. var target = $( event.target );
  4150. var active = $( $.ui.safeActiveElement( this.document[ 0 ] ) );
  4151. if ( !this.mouseHandled && target.not( ".ui-state-disabled" ).length ) {
  4152. this.select( event );
  4153. // Only set the mouseHandled flag if the event will bubble, see #9469.
  4154. if ( !event.isPropagationStopped() ) {
  4155. this.mouseHandled = true;
  4156. }
  4157. // Open submenu on click
  4158. if ( target.has( ".ui-menu" ).length ) {
  4159. this.expand( event );
  4160. } else if ( !this.element.is( ":focus" ) &&
  4161. active.closest( ".ui-menu" ).length ) {
  4162. // Redirect focus to the menu
  4163. this.element.trigger( "focus", [ true ] );
  4164. // If the active item is on the top level, let it stay active.
  4165. // Otherwise, blur the active item since it is no longer visible.
  4166. if ( this.active && this.active.parents( ".ui-menu" ).length === 1 ) {
  4167. clearTimeout( this.timer );
  4168. }
  4169. }
  4170. }
  4171. },
  4172. "mouseenter .ui-menu-item": function( event ) {
  4173. // Ignore mouse events while typeahead is active, see #10458.
  4174. // Prevents focusing the wrong item when typeahead causes a scroll while the mouse
  4175. // is over an item in the menu
  4176. if ( this.previousFilter ) {
  4177. return;
  4178. }
  4179. var actualTarget = $( event.target ).closest( ".ui-menu-item" ),
  4180. target = $( event.currentTarget );
  4181. // Ignore bubbled events on parent items, see #11641
  4182. if ( actualTarget[ 0 ] !== target[ 0 ] ) {
  4183. return;
  4184. }
  4185. // Remove ui-state-active class from siblings of the newly focused menu item
  4186. // to avoid a jump caused by adjacent elements both having a class with a border
  4187. this._removeClass( target.siblings().children( ".ui-state-active" ),
  4188. null, "ui-state-active" );
  4189. this.focus( event, target );
  4190. },
  4191. mouseleave: "collapseAll",
  4192. "mouseleave .ui-menu": "collapseAll",
  4193. focus: function( event, keepActiveItem ) {
  4194. // If there's already an active item, keep it active
  4195. // If not, activate the first item
  4196. var item = this.active || this.element.find( this.options.items ).eq( 0 );
  4197. if ( !keepActiveItem ) {
  4198. this.focus( event, item );
  4199. }
  4200. },
  4201. blur: function( event ) {
  4202. this._delay( function() {
  4203. var notContained = !$.contains(
  4204. this.element[ 0 ],
  4205. $.ui.safeActiveElement( this.document[ 0 ] )
  4206. );
  4207. if ( notContained ) {
  4208. this.collapseAll( event );
  4209. }
  4210. } );
  4211. },
  4212. keydown: "_keydown"
  4213. } );
  4214. this.refresh();
  4215. // Clicks outside of a menu collapse any open menus
  4216. this._on( this.document, {
  4217. click: function( event ) {
  4218. if ( this._closeOnDocumentClick( event ) ) {
  4219. this.collapseAll( event );
  4220. }
  4221. // Reset the mouseHandled flag
  4222. this.mouseHandled = false;
  4223. }
  4224. } );
  4225. },
  4226. _destroy: function() {
  4227. var items = this.element.find( ".ui-menu-item" )
  4228. .removeAttr( "role aria-disabled" ),
  4229. submenus = items.children( ".ui-menu-item-wrapper" )
  4230. .removeUniqueId()
  4231. .removeAttr( "tabIndex role aria-haspopup" );
  4232. // Destroy (sub)menus
  4233. this.element
  4234. .removeAttr( "aria-activedescendant" )
  4235. .find( ".ui-menu" ).addBack()
  4236. .removeAttr( "role aria-labelledby aria-expanded aria-hidden aria-disabled " +
  4237. "tabIndex" )
  4238. .removeUniqueId()
  4239. .show();
  4240. submenus.children().each( function() {
  4241. var elem = $( this );
  4242. if ( elem.data( "ui-menu-submenu-caret" ) ) {
  4243. elem.remove();
  4244. }
  4245. } );
  4246. },
  4247. _keydown: function( event ) {
  4248. var match, prev, character, skip,
  4249. preventDefault = true;
  4250. switch ( event.keyCode ) {
  4251. case $.ui.keyCode.PAGE_UP:
  4252. this.previousPage( event );
  4253. break;
  4254. case $.ui.keyCode.PAGE_DOWN:
  4255. this.nextPage( event );
  4256. break;
  4257. case $.ui.keyCode.HOME:
  4258. this._move( "first", "first", event );
  4259. break;
  4260. case $.ui.keyCode.END:
  4261. this._move( "last", "last", event );
  4262. break;
  4263. case $.ui.keyCode.UP:
  4264. this.previous( event );
  4265. break;
  4266. case $.ui.keyCode.DOWN:
  4267. this.next( event );
  4268. break;
  4269. case $.ui.keyCode.LEFT:
  4270. this.collapse( event );
  4271. break;
  4272. case $.ui.keyCode.RIGHT:
  4273. if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
  4274. this.expand( event );
  4275. }
  4276. break;
  4277. case $.ui.keyCode.ENTER:
  4278. case $.ui.keyCode.SPACE:
  4279. this._activate( event );
  4280. break;
  4281. case $.ui.keyCode.ESCAPE:
  4282. this.collapse( event );
  4283. break;
  4284. default:
  4285. preventDefault = false;
  4286. prev = this.previousFilter || "";
  4287. skip = false;
  4288. // Support number pad values
  4289. character = event.keyCode >= 96 && event.keyCode <= 105 ?
  4290. ( event.keyCode - 96 ).toString() : String.fromCharCode( event.keyCode );
  4291. clearTimeout( this.filterTimer );
  4292. if ( character === prev ) {
  4293. skip = true;
  4294. } else {
  4295. character = prev + character;
  4296. }
  4297. match = this._filterMenuItems( character );
  4298. match = skip && match.index( this.active.next() ) !== -1 ?
  4299. this.active.nextAll( ".ui-menu-item" ) :
  4300. match;
  4301. // If no matches on the current filter, reset to the last character pressed
  4302. // to move down the menu to the first item that starts with that character
  4303. if ( !match.length ) {
  4304. character = String.fromCharCode( event.keyCode );
  4305. match = this._filterMenuItems( character );
  4306. }
  4307. if ( match.length ) {
  4308. this.focus( event, match );
  4309. this.previousFilter = character;
  4310. this.filterTimer = this._delay( function() {
  4311. delete this.previousFilter;
  4312. }, 1000 );
  4313. } else {
  4314. delete this.previousFilter;
  4315. }
  4316. }
  4317. if ( preventDefault ) {
  4318. event.preventDefault();
  4319. }
  4320. },
  4321. _activate: function( event ) {
  4322. if ( this.active && !this.active.is( ".ui-state-disabled" ) ) {
  4323. if ( this.active.children( "[aria-haspopup='true']" ).length ) {
  4324. this.expand( event );
  4325. } else {
  4326. this.select( event );
  4327. }
  4328. }
  4329. },
  4330. refresh: function() {
  4331. var menus, items, newSubmenus, newItems, newWrappers,
  4332. that = this,
  4333. icon = this.options.icons.submenu,
  4334. submenus = this.element.find( this.options.menus );
  4335. this._toggleClass( "ui-menu-icons", null, !!this.element.find( ".ui-icon" ).length );
  4336. // Initialize nested menus
  4337. newSubmenus = submenus.filter( ":not(.ui-menu)" )
  4338. .hide()
  4339. .attr( {
  4340. role: this.options.role,
  4341. "aria-hidden": "true",
  4342. "aria-expanded": "false"
  4343. } )
  4344. .each( function() {
  4345. var menu = $( this ),
  4346. item = menu.prev(),
  4347. submenuCaret = $( "<span>" ).data( "ui-menu-submenu-caret", true );
  4348. that._addClass( submenuCaret, "ui-menu-icon", "ui-icon " + icon );
  4349. item
  4350. .attr( "aria-haspopup", "true" )
  4351. .prepend( submenuCaret );
  4352. menu.attr( "aria-labelledby", item.attr( "id" ) );
  4353. } );
  4354. this._addClass( newSubmenus, "ui-menu", "ui-widget ui-widget-content ui-front" );
  4355. menus = submenus.add( this.element );
  4356. items = menus.find( this.options.items );
  4357. // Initialize menu-items containing spaces and/or dashes only as dividers
  4358. items.not( ".ui-menu-item" ).each( function() {
  4359. var item = $( this );
  4360. if ( that._isDivider( item ) ) {
  4361. that._addClass( item, "ui-menu-divider", "ui-widget-content" );
  4362. }
  4363. } );
  4364. // Don't refresh list items that are already adapted
  4365. newItems = items.not( ".ui-menu-item, .ui-menu-divider" );
  4366. newWrappers = newItems.children()
  4367. .not( ".ui-menu" )
  4368. .uniqueId()
  4369. .attr( {
  4370. tabIndex: -1,
  4371. role: this._itemRole()
  4372. } );
  4373. this._addClass( newItems, "ui-menu-item" )
  4374. ._addClass( newWrappers, "ui-menu-item-wrapper" );
  4375. // Add aria-disabled attribute to any disabled menu item
  4376. items.filter( ".ui-state-disabled" ).attr( "aria-disabled", "true" );
  4377. // If the active item has been removed, blur the menu
  4378. if ( this.active && !$.contains( this.element[ 0 ], this.active[ 0 ] ) ) {
  4379. this.blur();
  4380. }
  4381. },
  4382. _itemRole: function() {
  4383. return {
  4384. menu: "menuitem",
  4385. listbox: "option"
  4386. }[ this.options.role ];
  4387. },
  4388. _setOption: function( key, value ) {
  4389. if ( key === "icons" ) {
  4390. var icons = this.element.find( ".ui-menu-icon" );
  4391. this._removeClass( icons, null, this.options.icons.submenu )
  4392. ._addClass( icons, null, value.submenu );
  4393. }
  4394. this._super( key, value );
  4395. },
  4396. _setOptionDisabled: function( value ) {
  4397. this._super( value );
  4398. this.element.attr( "aria-disabled", String( value ) );
  4399. this._toggleClass( null, "ui-state-disabled", !!value );
  4400. },
  4401. focus: function( event, item ) {
  4402. var nested, focused, activeParent;
  4403. this.blur( event, event && event.type === "focus" );
  4404. this._scrollIntoView( item );
  4405. this.active = item.first();
  4406. focused = this.active.children( ".ui-menu-item-wrapper" );
  4407. this._addClass( focused, null, "ui-state-active" );
  4408. // Only update aria-activedescendant if there's a role
  4409. // otherwise we assume focus is managed elsewhere
  4410. if ( this.options.role ) {
  4411. this.element.attr( "aria-activedescendant", focused.attr( "id" ) );
  4412. }
  4413. // Highlight active parent menu item, if any
  4414. activeParent = this.active
  4415. .parent()
  4416. .closest( ".ui-menu-item" )
  4417. .children( ".ui-menu-item-wrapper" );
  4418. this._addClass( activeParent, null, "ui-state-active" );
  4419. if ( event && event.type === "keydown" ) {
  4420. this._close();
  4421. } else {
  4422. this.timer = this._delay( function() {
  4423. this._close();
  4424. }, this.delay );
  4425. }
  4426. nested = item.children( ".ui-menu" );
  4427. if ( nested.length && event && ( /^mouse/.test( event.type ) ) ) {
  4428. this._startOpening( nested );
  4429. }
  4430. this.activeMenu = item.parent();
  4431. this._trigger( "focus", event, { item: item } );
  4432. },
  4433. _scrollIntoView: function( item ) {
  4434. var borderTop, paddingTop, offset, scroll, elementHeight, itemHeight;
  4435. if ( this._hasScroll() ) {
  4436. borderTop = parseFloat( $.css( this.activeMenu[ 0 ], "borderTopWidth" ) ) || 0;
  4437. paddingTop = parseFloat( $.css( this.activeMenu[ 0 ], "paddingTop" ) ) || 0;
  4438. offset = item.offset().top - this.activeMenu.offset().top - borderTop - paddingTop;
  4439. scroll = this.activeMenu.scrollTop();
  4440. elementHeight = this.activeMenu.height();
  4441. itemHeight = item.outerHeight();
  4442. if ( offset < 0 ) {
  4443. this.activeMenu.scrollTop( scroll + offset );
  4444. } else if ( offset + itemHeight > elementHeight ) {
  4445. this.activeMenu.scrollTop( scroll + offset - elementHeight + itemHeight );
  4446. }
  4447. }
  4448. },
  4449. blur: function( event, fromFocus ) {
  4450. if ( !fromFocus ) {
  4451. clearTimeout( this.timer );
  4452. }
  4453. if ( !this.active ) {
  4454. return;
  4455. }
  4456. this._removeClass( this.active.children( ".ui-menu-item-wrapper" ),
  4457. null, "ui-state-active" );
  4458. this._trigger( "blur", event, { item: this.active } );
  4459. this.active = null;
  4460. },
  4461. _startOpening: function( submenu ) {
  4462. clearTimeout( this.timer );
  4463. // Don't open if already open fixes a Firefox bug that caused a .5 pixel
  4464. // shift in the submenu position when mousing over the caret icon
  4465. if ( submenu.attr( "aria-hidden" ) !== "true" ) {
  4466. return;
  4467. }
  4468. this.timer = this._delay( function() {
  4469. this._close();
  4470. this._open( submenu );
  4471. }, this.delay );
  4472. },
  4473. _open: function( submenu ) {
  4474. var position = $.extend( {
  4475. of: this.active
  4476. }, this.options.position );
  4477. clearTimeout( this.timer );
  4478. this.element.find( ".ui-menu" ).not( submenu.parents( ".ui-menu" ) )
  4479. .hide()
  4480. .attr( "aria-hidden", "true" );
  4481. submenu
  4482. .show()
  4483. .removeAttr( "aria-hidden" )
  4484. .attr( "aria-expanded", "true" )
  4485. .position( position );
  4486. },
  4487. collapseAll: function( event, all ) {
  4488. clearTimeout( this.timer );
  4489. this.timer = this._delay( function() {
  4490. // If we were passed an event, look for the submenu that contains the event
  4491. var currentMenu = all ? this.element :
  4492. $( event && event.target ).closest( this.element.find( ".ui-menu" ) );
  4493. // If we found no valid submenu ancestor, use the main menu to close all
  4494. // sub menus anyway
  4495. if ( !currentMenu.length ) {
  4496. currentMenu = this.element;
  4497. }
  4498. this._close( currentMenu );
  4499. this.blur( event );
  4500. // Work around active item staying active after menu is blurred
  4501. this._removeClass( currentMenu.find( ".ui-state-active" ), null, "ui-state-active" );
  4502. this.activeMenu = currentMenu;
  4503. }, this.delay );
  4504. },
  4505. // With no arguments, closes the currently active menu - if nothing is active
  4506. // it closes all menus. If passed an argument, it will search for menus BELOW
  4507. _close: function( startMenu ) {
  4508. if ( !startMenu ) {
  4509. startMenu = this.active ? this.active.parent() : this.element;
  4510. }
  4511. startMenu.find( ".ui-menu" )
  4512. .hide()
  4513. .attr( "aria-hidden", "true" )
  4514. .attr( "aria-expanded", "false" );
  4515. },
  4516. _closeOnDocumentClick: function( event ) {
  4517. return !$( event.target ).closest( ".ui-menu" ).length;
  4518. },
  4519. _isDivider: function( item ) {
  4520. // Match hyphen, em dash, en dash
  4521. return !/[^\-\u2014\u2013\s]/.test( item.text() );
  4522. },
  4523. collapse: function( event ) {
  4524. var newItem = this.active &&
  4525. this.active.parent().closest( ".ui-menu-item", this.element );
  4526. if ( newItem && newItem.length ) {
  4527. this._close();
  4528. this.focus( event, newItem );
  4529. }
  4530. },
  4531. expand: function( event ) {
  4532. var newItem = this.active &&
  4533. this.active
  4534. .children( ".ui-menu " )
  4535. .find( this.options.items )
  4536. .first();
  4537. if ( newItem && newItem.length ) {
  4538. this._open( newItem.parent() );
  4539. // Delay so Firefox will not hide activedescendant change in expanding submenu from AT
  4540. this._delay( function() {
  4541. this.focus( event, newItem );
  4542. } );
  4543. }
  4544. },
  4545. next: function( event ) {
  4546. this._move( "next", "first", event );
  4547. },
  4548. previous: function( event ) {
  4549. this._move( "prev", "last", event );
  4550. },
  4551. isFirstItem: function() {
  4552. return this.active && !this.active.prevAll( ".ui-menu-item" ).length;
  4553. },
  4554. isLastItem: function() {
  4555. return this.active && !this.active.nextAll( ".ui-menu-item" ).length;
  4556. },
  4557. _move: function( direction, filter, event ) {
  4558. var next;
  4559. if ( this.active ) {
  4560. if ( direction === "first" || direction === "last" ) {
  4561. next = this.active
  4562. [ direction === "first" ? "prevAll" : "nextAll" ]( ".ui-menu-item" )
  4563. .eq( -1 );
  4564. } else {
  4565. next = this.active
  4566. [ direction + "All" ]( ".ui-menu-item" )
  4567. .eq( 0 );
  4568. }
  4569. }
  4570. if ( !next || !next.length || !this.active ) {
  4571. next = this.activeMenu.find( this.options.items )[ filter ]();
  4572. }
  4573. this.focus( event, next );
  4574. },
  4575. nextPage: function( event ) {
  4576. var item, base, height;
  4577. if ( !this.active ) {
  4578. this.next( event );
  4579. return;
  4580. }
  4581. if ( this.isLastItem() ) {
  4582. return;
  4583. }
  4584. if ( this._hasScroll() ) {
  4585. base = this.active.offset().top;
  4586. height = this.element.height();
  4587. this.active.nextAll( ".ui-menu-item" ).each( function() {
  4588. item = $( this );
  4589. return item.offset().top - base - height < 0;
  4590. } );
  4591. this.focus( event, item );
  4592. } else {
  4593. this.focus( event, this.activeMenu.find( this.options.items )
  4594. [ !this.active ? "first" : "last" ]() );
  4595. }
  4596. },
  4597. previousPage: function( event ) {
  4598. var item, base, height;
  4599. if ( !this.active ) {
  4600. this.next( event );
  4601. return;
  4602. }
  4603. if ( this.isFirstItem() ) {
  4604. return;
  4605. }
  4606. if ( this._hasScroll() ) {
  4607. base = this.active.offset().top;
  4608. height = this.element.height();
  4609. this.active.prevAll( ".ui-menu-item" ).each( function() {
  4610. item = $( this );
  4611. return item.offset().top - base + height > 0;
  4612. } );
  4613. this.focus( event, item );
  4614. } else {
  4615. this.focus( event, this.activeMenu.find( this.options.items ).first() );
  4616. }
  4617. },
  4618. _hasScroll: function() {
  4619. return this.element.outerHeight() < this.element.prop( "scrollHeight" );
  4620. },
  4621. select: function( event ) {
  4622. // TODO: It should never be possible to not have an active item at this
  4623. // point, but the tests don't trigger mouseenter before click.
  4624. this.active = this.active || $( event.target ).closest( ".ui-menu-item" );
  4625. var ui = { item: this.active };
  4626. if ( !this.active.has( ".ui-menu" ).length ) {
  4627. this.collapseAll( event, true );
  4628. }
  4629. this._trigger( "select", event, ui );
  4630. },
  4631. _filterMenuItems: function( character ) {
  4632. var escapedCharacter = character.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" ),
  4633. regex = new RegExp( "^" + escapedCharacter, "i" );
  4634. return this.activeMenu
  4635. .find( this.options.items )
  4636. // Only match on items, not dividers or other content (#10571)
  4637. .filter( ".ui-menu-item" )
  4638. .filter( function() {
  4639. return regex.test(
  4640. $.trim( $( this ).children( ".ui-menu-item-wrapper" ).text() ) );
  4641. } );
  4642. }
  4643. } );
  4644. /*!
  4645. * jQuery UI Autocomplete 1.12.1
  4646. * http://jqueryui.com
  4647. *
  4648. * Copyright jQuery Foundation and other contributors
  4649. * Released under the MIT license.
  4650. * http://jquery.org/license
  4651. */
  4652. //>>label: Autocomplete
  4653. //>>group: Widgets
  4654. //>>description: Lists suggested words as the user is typing.
  4655. //>>docs: http://api.jqueryui.com/autocomplete/
  4656. //>>demos: http://jqueryui.com/autocomplete/
  4657. //>>css.structure: ../../themes/base/core.css
  4658. //>>css.structure: ../../themes/base/autocomplete.css
  4659. //>>css.theme: ../../themes/base/theme.css
  4660. $.widget( "ui.autocomplete", {
  4661. version: "1.12.1",
  4662. defaultElement: "<input>",
  4663. options: {
  4664. appendTo: null,
  4665. autoFocus: false,
  4666. delay: 300,
  4667. minLength: 1,
  4668. position: {
  4669. my: "left top",
  4670. at: "left bottom",
  4671. collision: "none"
  4672. },
  4673. source: null,
  4674. // Callbacks
  4675. change: null,
  4676. close: null,
  4677. focus: null,
  4678. open: null,
  4679. response: null,
  4680. search: null,
  4681. select: null
  4682. },
  4683. requestIndex: 0,
  4684. pending: 0,
  4685. _create: function() {
  4686. // Some browsers only repeat keydown events, not keypress events,
  4687. // so we use the suppressKeyPress flag to determine if we've already
  4688. // handled the keydown event. #7269
  4689. // Unfortunately the code for & in keypress is the same as the up arrow,
  4690. // so we use the suppressKeyPressRepeat flag to avoid handling keypress
  4691. // events when we know the keydown event was used to modify the
  4692. // search term. #7799
  4693. var suppressKeyPress, suppressKeyPressRepeat, suppressInput,
  4694. nodeName = this.element[ 0 ].nodeName.toLowerCase(),
  4695. isTextarea = nodeName === "textarea",
  4696. isInput = nodeName === "input";
  4697. // Textareas are always multi-line
  4698. // Inputs are always single-line, even if inside a contentEditable element
  4699. // IE also treats inputs as contentEditable
  4700. // All other element types are determined by whether or not they're contentEditable
  4701. this.isMultiLine = isTextarea || !isInput && this._isContentEditable( this.element );
  4702. this.valueMethod = this.element[ isTextarea || isInput ? "val" : "text" ];
  4703. this.isNewMenu = true;
  4704. this._addClass( "ui-autocomplete-input" );
  4705. this.element.attr( "autocomplete", "off" );
  4706. this._on( this.element, {
  4707. keydown: function( event ) {
  4708. if ( this.element.prop( "readOnly" ) ) {
  4709. suppressKeyPress = true;
  4710. suppressInput = true;
  4711. suppressKeyPressRepeat = true;
  4712. return;
  4713. }
  4714. suppressKeyPress = false;
  4715. suppressInput = false;
  4716. suppressKeyPressRepeat = false;
  4717. var keyCode = $.ui.keyCode;
  4718. switch ( event.keyCode ) {
  4719. case keyCode.PAGE_UP:
  4720. suppressKeyPress = true;
  4721. this._move( "previousPage", event );
  4722. break;
  4723. case keyCode.PAGE_DOWN:
  4724. suppressKeyPress = true;
  4725. this._move( "nextPage", event );
  4726. break;
  4727. case keyCode.UP:
  4728. suppressKeyPress = true;
  4729. this._keyEvent( "previous", event );
  4730. break;
  4731. case keyCode.DOWN:
  4732. suppressKeyPress = true;
  4733. this._keyEvent( "next", event );
  4734. break;
  4735. case keyCode.ENTER:
  4736. // when menu is open and has focus
  4737. if ( this.menu.active ) {
  4738. // #6055 - Opera still allows the keypress to occur
  4739. // which causes forms to submit
  4740. suppressKeyPress = true;
  4741. event.preventDefault();
  4742. this.menu.select( event );
  4743. }
  4744. break;
  4745. case keyCode.TAB:
  4746. if ( this.menu.active ) {
  4747. this.menu.select( event );
  4748. }
  4749. break;
  4750. case keyCode.ESCAPE:
  4751. if ( this.menu.element.is( ":visible" ) ) {
  4752. if ( !this.isMultiLine ) {
  4753. this._value( this.term );
  4754. }
  4755. this.close( event );
  4756. // Different browsers have different default behavior for escape
  4757. // Single press can mean undo or clear
  4758. // Double press in IE means clear the whole form
  4759. event.preventDefault();
  4760. }
  4761. break;
  4762. default:
  4763. suppressKeyPressRepeat = true;
  4764. // search timeout should be triggered before the input value is changed
  4765. this._searchTimeout( event );
  4766. break;
  4767. }
  4768. },
  4769. keypress: function( event ) {
  4770. if ( suppressKeyPress ) {
  4771. suppressKeyPress = false;
  4772. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  4773. event.preventDefault();
  4774. }
  4775. return;
  4776. }
  4777. if ( suppressKeyPressRepeat ) {
  4778. return;
  4779. }
  4780. // Replicate some key handlers to allow them to repeat in Firefox and Opera
  4781. var keyCode = $.ui.keyCode;
  4782. switch ( event.keyCode ) {
  4783. case keyCode.PAGE_UP:
  4784. this._move( "previousPage", event );
  4785. break;
  4786. case keyCode.PAGE_DOWN:
  4787. this._move( "nextPage", event );
  4788. break;
  4789. case keyCode.UP:
  4790. this._keyEvent( "previous", event );
  4791. break;
  4792. case keyCode.DOWN:
  4793. this._keyEvent( "next", event );
  4794. break;
  4795. }
  4796. },
  4797. input: function( event ) {
  4798. if ( suppressInput ) {
  4799. suppressInput = false;
  4800. event.preventDefault();
  4801. return;
  4802. }
  4803. this._searchTimeout( event );
  4804. },
  4805. focus: function() {
  4806. this.selectedItem = null;
  4807. this.previous = this._value();
  4808. },
  4809. blur: function( event ) {
  4810. if ( this.cancelBlur ) {
  4811. delete this.cancelBlur;
  4812. return;
  4813. }
  4814. clearTimeout( this.searching );
  4815. this.close( event );
  4816. this._change( event );
  4817. }
  4818. } );
  4819. this._initSource();
  4820. this.menu = $( "<ul>" )
  4821. .appendTo( this._appendTo() )
  4822. .menu( {
  4823. // disable ARIA support, the live region takes care of that
  4824. role: null
  4825. } )
  4826. .hide()
  4827. .menu( "instance" );
  4828. this._addClass( this.menu.element, "ui-autocomplete", "ui-front" );
  4829. this._on( this.menu.element, {
  4830. mousedown: function( event ) {
  4831. // prevent moving focus out of the text field
  4832. event.preventDefault();
  4833. // IE doesn't prevent moving focus even with event.preventDefault()
  4834. // so we set a flag to know when we should ignore the blur event
  4835. this.cancelBlur = true;
  4836. this._delay( function() {
  4837. delete this.cancelBlur;
  4838. // Support: IE 8 only
  4839. // Right clicking a menu item or selecting text from the menu items will
  4840. // result in focus moving out of the input. However, we've already received
  4841. // and ignored the blur event because of the cancelBlur flag set above. So
  4842. // we restore focus to ensure that the menu closes properly based on the user's
  4843. // next actions.
  4844. if ( this.element[ 0 ] !== $.ui.safeActiveElement( this.document[ 0 ] ) ) {
  4845. this.element.trigger( "focus" );
  4846. }
  4847. } );
  4848. },
  4849. menufocus: function( event, ui ) {
  4850. var label, item;
  4851. // support: Firefox
  4852. // Prevent accidental activation of menu items in Firefox (#7024 #9118)
  4853. if ( this.isNewMenu ) {
  4854. this.isNewMenu = false;
  4855. if ( event.originalEvent && /^mouse/.test( event.originalEvent.type ) ) {
  4856. this.menu.blur();
  4857. this.document.one( "mousemove", function() {
  4858. $( event.target ).trigger( event.originalEvent );
  4859. } );
  4860. return;
  4861. }
  4862. }
  4863. item = ui.item.data( "ui-autocomplete-item" );
  4864. if ( false !== this._trigger( "focus", event, { item: item } ) ) {
  4865. // use value to match what will end up in the input, if it was a key event
  4866. if ( event.originalEvent && /^key/.test( event.originalEvent.type ) ) {
  4867. this._value( item.value );
  4868. }
  4869. }
  4870. // Announce the value in the liveRegion
  4871. label = ui.item.attr( "aria-label" ) || item.value;
  4872. if ( label && $.trim( label ).length ) {
  4873. this.liveRegion.children().hide();
  4874. $( "<div>" ).text( label ).appendTo( this.liveRegion );
  4875. }
  4876. },
  4877. menuselect: function( event, ui ) {
  4878. var item = ui.item.data( "ui-autocomplete-item" ),
  4879. previous = this.previous;
  4880. // Only trigger when focus was lost (click on menu)
  4881. if ( this.element[ 0 ] !== $.ui.safeActiveElement( this.document[ 0 ] ) ) {
  4882. this.element.trigger( "focus" );
  4883. this.previous = previous;
  4884. // #6109 - IE triggers two focus events and the second
  4885. // is asynchronous, so we need to reset the previous
  4886. // term synchronously and asynchronously :-(
  4887. this._delay( function() {
  4888. this.previous = previous;
  4889. this.selectedItem = item;
  4890. } );
  4891. }
  4892. if ( false !== this._trigger( "select", event, { item: item } ) ) {
  4893. this._value( item.value );
  4894. }
  4895. // reset the term after the select event
  4896. // this allows custom select handling to work properly
  4897. this.term = this._value();
  4898. this.close( event );
  4899. this.selectedItem = item;
  4900. }
  4901. } );
  4902. this.liveRegion = $( "<div>", {
  4903. role: "status",
  4904. "aria-live": "assertive",
  4905. "aria-relevant": "additions"
  4906. } )
  4907. .appendTo( this.document[ 0 ].body );
  4908. this._addClass( this.liveRegion, null, "ui-helper-hidden-accessible" );
  4909. // Turning off autocomplete prevents the browser from remembering the
  4910. // value when navigating through history, so we re-enable autocomplete
  4911. // if the page is unloaded before the widget is destroyed. #7790
  4912. this._on( this.window, {
  4913. beforeunload: function() {
  4914. this.element.removeAttr( "autocomplete" );
  4915. }
  4916. } );
  4917. },
  4918. _destroy: function() {
  4919. clearTimeout( this.searching );
  4920. this.element.removeAttr( "autocomplete" );
  4921. this.menu.element.remove();
  4922. this.liveRegion.remove();
  4923. },
  4924. _setOption: function( key, value ) {
  4925. this._super( key, value );
  4926. if ( key === "source" ) {
  4927. this._initSource();
  4928. }
  4929. if ( key === "appendTo" ) {
  4930. this.menu.element.appendTo( this._appendTo() );
  4931. }
  4932. if ( key === "disabled" && value && this.xhr ) {
  4933. this.xhr.abort();
  4934. }
  4935. },
  4936. _isEventTargetInWidget: function( event ) {
  4937. var menuElement = this.menu.element[ 0 ];
  4938. return event.target === this.element[ 0 ] ||
  4939. event.target === menuElement ||
  4940. $.contains( menuElement, event.target );
  4941. },
  4942. _closeOnClickOutside: function( event ) {
  4943. if ( !this._isEventTargetInWidget( event ) ) {
  4944. this.close();
  4945. }
  4946. },
  4947. _appendTo: function() {
  4948. var element = this.options.appendTo;
  4949. if ( element ) {
  4950. element = element.jquery || element.nodeType ?
  4951. $( element ) :
  4952. this.document.find( element ).eq( 0 );
  4953. }
  4954. if ( !element || !element[ 0 ] ) {
  4955. element = this.element.closest( ".ui-front, dialog" );
  4956. }
  4957. if ( !element.length ) {
  4958. element = this.document[ 0 ].body;
  4959. }
  4960. return element;
  4961. },
  4962. _initSource: function() {
  4963. var array, url,
  4964. that = this;
  4965. if ( $.isArray( this.options.source ) ) {
  4966. array = this.options.source;
  4967. this.source = function( request, response ) {
  4968. response( $.ui.autocomplete.filter( array, request.term ) );
  4969. };
  4970. } else if ( typeof this.options.source === "string" ) {
  4971. url = this.options.source;
  4972. this.source = function( request, response ) {
  4973. if ( that.xhr ) {
  4974. that.xhr.abort();
  4975. }
  4976. that.xhr = $.ajax( {
  4977. url: url,
  4978. data: request,
  4979. dataType: "json",
  4980. success: function( data ) {
  4981. response( data );
  4982. },
  4983. error: function() {
  4984. response( [] );
  4985. }
  4986. } );
  4987. };
  4988. } else {
  4989. this.source = this.options.source;
  4990. }
  4991. },
  4992. _searchTimeout: function( event ) {
  4993. clearTimeout( this.searching );
  4994. this.searching = this._delay( function() {
  4995. // Search if the value has changed, or if the user retypes the same value (see #7434)
  4996. var equalValues = this.term === this._value(),
  4997. menuVisible = this.menu.element.is( ":visible" ),
  4998. modifierKey = event.altKey || event.ctrlKey || event.metaKey || event.shiftKey;
  4999. if ( !equalValues || ( equalValues && !menuVisible && !modifierKey ) ) {
  5000. this.selectedItem = null;
  5001. this.search( null, event );
  5002. }
  5003. }, this.options.delay );
  5004. },
  5005. search: function( value, event ) {
  5006. value = value != null ? value : this._value();
  5007. // Always save the actual value, not the one passed as an argument
  5008. this.term = this._value();
  5009. if ( value.length < this.options.minLength ) {
  5010. return this.close( event );
  5011. }
  5012. if ( this._trigger( "search", event ) === false ) {
  5013. return;
  5014. }
  5015. return this._search( value );
  5016. },
  5017. _search: function( value ) {
  5018. this.pending++;
  5019. this._addClass( "ui-autocomplete-loading" );
  5020. this.cancelSearch = false;
  5021. this.source( { term: value }, this._response() );
  5022. },
  5023. _response: function() {
  5024. var index = ++this.requestIndex;
  5025. return $.proxy( function( content ) {
  5026. if ( index === this.requestIndex ) {
  5027. this.__response( content );
  5028. }
  5029. this.pending--;
  5030. if ( !this.pending ) {
  5031. this._removeClass( "ui-autocomplete-loading" );
  5032. }
  5033. }, this );
  5034. },
  5035. __response: function( content ) {
  5036. if ( content ) {
  5037. content = this._normalize( content );
  5038. }
  5039. this._trigger( "response", null, { content: content } );
  5040. if ( !this.options.disabled && content && content.length && !this.cancelSearch ) {
  5041. this._suggest( content );
  5042. this._trigger( "open" );
  5043. } else {
  5044. // use ._close() instead of .close() so we don't cancel future searches
  5045. this._close();
  5046. }
  5047. },
  5048. close: function( event ) {
  5049. this.cancelSearch = true;
  5050. this._close( event );
  5051. },
  5052. _close: function( event ) {
  5053. // Remove the handler that closes the menu on outside clicks
  5054. this._off( this.document, "mousedown" );
  5055. if ( this.menu.element.is( ":visible" ) ) {
  5056. this.menu.element.hide();
  5057. this.menu.blur();
  5058. this.isNewMenu = true;
  5059. this._trigger( "close", event );
  5060. }
  5061. },
  5062. _change: function( event ) {
  5063. if ( this.previous !== this._value() ) {
  5064. this._trigger( "change", event, { item: this.selectedItem } );
  5065. }
  5066. },
  5067. _normalize: function( items ) {
  5068. // assume all items have the right format when the first item is complete
  5069. if ( items.length && items[ 0 ].label && items[ 0 ].value ) {
  5070. return items;
  5071. }
  5072. return $.map( items, function( item ) {
  5073. if ( typeof item === "string" ) {
  5074. return {
  5075. label: item,
  5076. value: item
  5077. };
  5078. }
  5079. return $.extend( {}, item, {
  5080. label: item.label || item.value,
  5081. value: item.value || item.label
  5082. } );
  5083. } );
  5084. },
  5085. _suggest: function( items ) {
  5086. var ul = this.menu.element.empty();
  5087. this._renderMenu( ul, items );
  5088. this.isNewMenu = true;
  5089. this.menu.refresh();
  5090. // Size and position menu
  5091. ul.show();
  5092. this._resizeMenu();
  5093. ul.position( $.extend( {
  5094. of: this.element
  5095. }, this.options.position ) );
  5096. if ( this.options.autoFocus ) {
  5097. this.menu.next();
  5098. }
  5099. // Listen for interactions outside of the widget (#6642)
  5100. this._on( this.document, {
  5101. mousedown: "_closeOnClickOutside"
  5102. } );
  5103. },
  5104. _resizeMenu: function() {
  5105. var ul = this.menu.element;
  5106. ul.outerWidth( Math.max(
  5107. // Firefox wraps long text (possibly a rounding bug)
  5108. // so we add 1px to avoid the wrapping (#7513)
  5109. ul.width( "" ).outerWidth() + 1,
  5110. this.element.outerWidth()
  5111. ) );
  5112. },
  5113. _renderMenu: function( ul, items ) {
  5114. var that = this;
  5115. $.each( items, function( index, item ) {
  5116. that._renderItemData( ul, item );
  5117. } );
  5118. },
  5119. _renderItemData: function( ul, item ) {
  5120. return this._renderItem( ul, item ).data( "ui-autocomplete-item", item );
  5121. },
  5122. _renderItem: function( ul, item ) {
  5123. return $( "<li>" )
  5124. .append( $( "<div>" ).text( item.label ) )
  5125. .appendTo( ul );
  5126. },
  5127. _move: function( direction, event ) {
  5128. if ( !this.menu.element.is( ":visible" ) ) {
  5129. this.search( null, event );
  5130. return;
  5131. }
  5132. if ( this.menu.isFirstItem() && /^previous/.test( direction ) ||
  5133. this.menu.isLastItem() && /^next/.test( direction ) ) {
  5134. if ( !this.isMultiLine ) {
  5135. this._value( this.term );
  5136. }
  5137. this.menu.blur();
  5138. return;
  5139. }
  5140. this.menu[ direction ]( event );
  5141. },
  5142. widget: function() {
  5143. return this.menu.element;
  5144. },
  5145. _value: function() {
  5146. return this.valueMethod.apply( this.element, arguments );
  5147. },
  5148. _keyEvent: function( keyEvent, event ) {
  5149. if ( !this.isMultiLine || this.menu.element.is( ":visible" ) ) {
  5150. this._move( keyEvent, event );
  5151. // Prevents moving cursor to beginning/end of the text field in some browsers
  5152. event.preventDefault();
  5153. }
  5154. },
  5155. // Support: Chrome <=50
  5156. // We should be able to just use this.element.prop( "isContentEditable" )
  5157. // but hidden elements always report false in Chrome.
  5158. // https://code.google.com/p/chromium/issues/detail?id=313082
  5159. _isContentEditable: function( element ) {
  5160. if ( !element.length ) {
  5161. return false;
  5162. }
  5163. var editable = element.prop( "contentEditable" );
  5164. if ( editable === "inherit" ) {
  5165. return this._isContentEditable( element.parent() );
  5166. }
  5167. return editable === "true";
  5168. }
  5169. } );
  5170. $.extend( $.ui.autocomplete, {
  5171. escapeRegex: function( value ) {
  5172. return value.replace( /[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&" );
  5173. },
  5174. filter: function( array, term ) {
  5175. var matcher = new RegExp( $.ui.autocomplete.escapeRegex( term ), "i" );
  5176. return $.grep( array, function( value ) {
  5177. return matcher.test( value.label || value.value || value );
  5178. } );
  5179. }
  5180. } );
  5181. // Live region extension, adding a `messages` option
  5182. // NOTE: This is an experimental API. We are still investigating
  5183. // a full solution for string manipulation and internationalization.
  5184. $.widget( "ui.autocomplete", $.ui.autocomplete, {
  5185. options: {
  5186. messages: {
  5187. noResults: "No search results.",
  5188. results: function( amount ) {
  5189. return amount + ( amount > 1 ? " results are" : " result is" ) +
  5190. " available, use up and down arrow keys to navigate.";
  5191. }
  5192. }
  5193. },
  5194. __response: function( content ) {
  5195. var message;
  5196. this._superApply( arguments );
  5197. if ( this.options.disabled || this.cancelSearch ) {
  5198. return;
  5199. }
  5200. if ( content && content.length ) {
  5201. message = this.options.messages.results( content.length );
  5202. } else {
  5203. message = this.options.messages.noResults;
  5204. }
  5205. this.liveRegion.children().hide();
  5206. $( "<div>" ).text( message ).appendTo( this.liveRegion );
  5207. }
  5208. } );
  5209. var widgetsAutocomplete = $.ui.autocomplete;
  5210. /*!
  5211. * jQuery UI Controlgroup 1.12.1
  5212. * http://jqueryui.com
  5213. *
  5214. * Copyright jQuery Foundation and other contributors
  5215. * Released under the MIT license.
  5216. * http://jquery.org/license
  5217. */
  5218. //>>label: Controlgroup
  5219. //>>group: Widgets
  5220. //>>description: Visually groups form control widgets
  5221. //>>docs: http://api.jqueryui.com/controlgroup/
  5222. //>>demos: http://jqueryui.com/controlgroup/
  5223. //>>css.structure: ../../themes/base/core.css
  5224. //>>css.structure: ../../themes/base/controlgroup.css
  5225. //>>css.theme: ../../themes/base/theme.css
  5226. var controlgroupCornerRegex = /ui-corner-([a-z]){2,6}/g;
  5227. var widgetsControlgroup = $.widget( "ui.controlgroup", {
  5228. version: "1.12.1",
  5229. defaultElement: "<div>",
  5230. options: {
  5231. direction: "horizontal",
  5232. disabled: null,
  5233. onlyVisible: true,
  5234. items: {
  5235. "button": "input[type=button], input[type=submit], input[type=reset], button, a",
  5236. "controlgroupLabel": ".ui-controlgroup-label",
  5237. "checkboxradio": "input[type='checkbox'], input[type='radio']",
  5238. "selectmenu": "select",
  5239. "spinner": ".ui-spinner-input"
  5240. }
  5241. },
  5242. _create: function() {
  5243. this._enhance();
  5244. },
  5245. // To support the enhanced option in jQuery Mobile, we isolate DOM manipulation
  5246. _enhance: function() {
  5247. this.element.attr( "role", "toolbar" );
  5248. this.refresh();
  5249. },
  5250. _destroy: function() {
  5251. this._callChildMethod( "destroy" );
  5252. this.childWidgets.removeData( "ui-controlgroup-data" );
  5253. this.element.removeAttr( "role" );
  5254. if ( this.options.items.controlgroupLabel ) {
  5255. this.element
  5256. .find( this.options.items.controlgroupLabel )
  5257. .find( ".ui-controlgroup-label-contents" )
  5258. .contents().unwrap();
  5259. }
  5260. },
  5261. _initWidgets: function() {
  5262. var that = this,
  5263. childWidgets = [];
  5264. // First we iterate over each of the items options
  5265. $.each( this.options.items, function( widget, selector ) {
  5266. var labels;
  5267. var options = {};
  5268. // Make sure the widget has a selector set
  5269. if ( !selector ) {
  5270. return;
  5271. }
  5272. if ( widget === "controlgroupLabel" ) {
  5273. labels = that.element.find( selector );
  5274. labels.each( function() {
  5275. var element = $( this );
  5276. if ( element.children( ".ui-controlgroup-label-contents" ).length ) {
  5277. return;
  5278. }
  5279. element.contents()
  5280. .wrapAll( "<span class='ui-controlgroup-label-contents'></span>" );
  5281. } );
  5282. that._addClass( labels, null, "ui-widget ui-widget-content ui-state-default" );
  5283. childWidgets = childWidgets.concat( labels.get() );
  5284. return;
  5285. }
  5286. // Make sure the widget actually exists
  5287. if ( !$.fn[ widget ] ) {
  5288. return;
  5289. }
  5290. // We assume everything is in the middle to start because we can't determine
  5291. // first / last elements until all enhancments are done.
  5292. if ( that[ "_" + widget + "Options" ] ) {
  5293. options = that[ "_" + widget + "Options" ]( "middle" );
  5294. } else {
  5295. options = { classes: {} };
  5296. }
  5297. // Find instances of this widget inside controlgroup and init them
  5298. that.element
  5299. .find( selector )
  5300. .each( function() {
  5301. var element = $( this );
  5302. var instance = element[ widget ]( "instance" );
  5303. // We need to clone the default options for this type of widget to avoid
  5304. // polluting the variable options which has a wider scope than a single widget.
  5305. var instanceOptions = $.widget.extend( {}, options );
  5306. // If the button is the child of a spinner ignore it
  5307. // TODO: Find a more generic solution
  5308. if ( widget === "button" && element.parent( ".ui-spinner" ).length ) {
  5309. return;
  5310. }
  5311. // Create the widget if it doesn't exist
  5312. if ( !instance ) {
  5313. instance = element[ widget ]()[ widget ]( "instance" );
  5314. }
  5315. if ( instance ) {
  5316. instanceOptions.classes =
  5317. that._resolveClassesValues( instanceOptions.classes, instance );
  5318. }
  5319. element[ widget ]( instanceOptions );
  5320. // Store an instance of the controlgroup to be able to reference
  5321. // from the outermost element for changing options and refresh
  5322. var widgetElement = element[ widget ]( "widget" );
  5323. $.data( widgetElement[ 0 ], "ui-controlgroup-data",
  5324. instance ? instance : element[ widget ]( "instance" ) );
  5325. childWidgets.push( widgetElement[ 0 ] );
  5326. } );
  5327. } );
  5328. this.childWidgets = $( $.unique( childWidgets ) );
  5329. this._addClass( this.childWidgets, "ui-controlgroup-item" );
  5330. },
  5331. _callChildMethod: function( method ) {
  5332. this.childWidgets.each( function() {
  5333. var element = $( this ),
  5334. data = element.data( "ui-controlgroup-data" );
  5335. if ( data && data[ method ] ) {
  5336. data[ method ]();
  5337. }
  5338. } );
  5339. },
  5340. _updateCornerClass: function( element, position ) {
  5341. var remove = "ui-corner-top ui-corner-bottom ui-corner-left ui-corner-right ui-corner-all";
  5342. var add = this._buildSimpleOptions( position, "label" ).classes.label;
  5343. this._removeClass( element, null, remove );
  5344. this._addClass( element, null, add );
  5345. },
  5346. _buildSimpleOptions: function( position, key ) {
  5347. var direction = this.options.direction === "vertical";
  5348. var result = {
  5349. classes: {}
  5350. };
  5351. result.classes[ key ] = {
  5352. "middle": "",
  5353. "first": "ui-corner-" + ( direction ? "top" : "left" ),
  5354. "last": "ui-corner-" + ( direction ? "bottom" : "right" ),
  5355. "only": "ui-corner-all"
  5356. }[ position ];
  5357. return result;
  5358. },
  5359. _spinnerOptions: function( position ) {
  5360. var options = this._buildSimpleOptions( position, "ui-spinner" );
  5361. options.classes[ "ui-spinner-up" ] = "";
  5362. options.classes[ "ui-spinner-down" ] = "";
  5363. return options;
  5364. },
  5365. _buttonOptions: function( position ) {
  5366. return this._buildSimpleOptions( position, "ui-button" );
  5367. },
  5368. _checkboxradioOptions: function( position ) {
  5369. return this._buildSimpleOptions( position, "ui-checkboxradio-label" );
  5370. },
  5371. _selectmenuOptions: function( position ) {
  5372. var direction = this.options.direction === "vertical";
  5373. return {
  5374. width: direction ? "auto" : false,
  5375. classes: {
  5376. middle: {
  5377. "ui-selectmenu-button-open": "",
  5378. "ui-selectmenu-button-closed": ""
  5379. },
  5380. first: {
  5381. "ui-selectmenu-button-open": "ui-corner-" + ( direction ? "top" : "tl" ),
  5382. "ui-selectmenu-button-closed": "ui-corner-" + ( direction ? "top" : "left" )
  5383. },
  5384. last: {
  5385. "ui-selectmenu-button-open": direction ? "" : "ui-corner-tr",
  5386. "ui-selectmenu-button-closed": "ui-corner-" + ( direction ? "bottom" : "right" )
  5387. },
  5388. only: {
  5389. "ui-selectmenu-button-open": "ui-corner-top",
  5390. "ui-selectmenu-button-closed": "ui-corner-all"
  5391. }
  5392. }[ position ]
  5393. };
  5394. },
  5395. _resolveClassesValues: function( classes, instance ) {
  5396. var result = {};
  5397. $.each( classes, function( key ) {
  5398. var current = instance.options.classes[ key ] || "";
  5399. current = $.trim( current.replace( controlgroupCornerRegex, "" ) );
  5400. result[ key ] = ( current + " " + classes[ key ] ).replace( /\s+/g, " " );
  5401. } );
  5402. return result;
  5403. },
  5404. _setOption: function( key, value ) {
  5405. if ( key === "direction" ) {
  5406. this._removeClass( "ui-controlgroup-" + this.options.direction );
  5407. }
  5408. this._super( key, value );
  5409. if ( key === "disabled" ) {
  5410. this._callChildMethod( value ? "disable" : "enable" );
  5411. return;
  5412. }
  5413. this.refresh();
  5414. },
  5415. refresh: function() {
  5416. var children,
  5417. that = this;
  5418. this._addClass( "ui-controlgroup ui-controlgroup-" + this.options.direction );
  5419. if ( this.options.direction === "horizontal" ) {
  5420. this._addClass( null, "ui-helper-clearfix" );
  5421. }
  5422. this._initWidgets();
  5423. children = this.childWidgets;
  5424. // We filter here because we need to track all childWidgets not just the visible ones
  5425. if ( this.options.onlyVisible ) {
  5426. children = children.filter( ":visible" );
  5427. }
  5428. if ( children.length ) {
  5429. // We do this last because we need to make sure all enhancment is done
  5430. // before determining first and last
  5431. $.each( [ "first", "last" ], function( index, value ) {
  5432. var instance = children[ value ]().data( "ui-controlgroup-data" );
  5433. if ( instance && that[ "_" + instance.widgetName + "Options" ] ) {
  5434. var options = that[ "_" + instance.widgetName + "Options" ](
  5435. children.length === 1 ? "only" : value
  5436. );
  5437. options.classes = that._resolveClassesValues( options.classes, instance );
  5438. instance.element[ instance.widgetName ]( options );
  5439. } else {
  5440. that._updateCornerClass( children[ value ](), value );
  5441. }
  5442. } );
  5443. // Finally call the refresh method on each of the child widgets.
  5444. this._callChildMethod( "refresh" );
  5445. }
  5446. }
  5447. } );
  5448. /*!
  5449. * jQuery UI Checkboxradio 1.12.1
  5450. * http://jqueryui.com
  5451. *
  5452. * Copyright jQuery Foundation and other contributors
  5453. * Released under the MIT license.
  5454. * http://jquery.org/license
  5455. */
  5456. //>>label: Checkboxradio
  5457. //>>group: Widgets
  5458. //>>description: Enhances a form with multiple themeable checkboxes or radio buttons.
  5459. //>>docs: http://api.jqueryui.com/checkboxradio/
  5460. //>>demos: http://jqueryui.com/checkboxradio/
  5461. //>>css.structure: ../../themes/base/core.css
  5462. //>>css.structure: ../../themes/base/button.css
  5463. //>>css.structure: ../../themes/base/checkboxradio.css
  5464. //>>css.theme: ../../themes/base/theme.css
  5465. $.widget( "ui.checkboxradio", [ $.ui.formResetMixin, {
  5466. version: "1.12.1",
  5467. options: {
  5468. disabled: null,
  5469. label: null,
  5470. icon: true,
  5471. classes: {
  5472. "ui-checkboxradio-label": "ui-corner-all",
  5473. "ui-checkboxradio-icon": "ui-corner-all"
  5474. }
  5475. },
  5476. _getCreateOptions: function() {
  5477. var disabled, labels;
  5478. var that = this;
  5479. var options = this._super() || {};
  5480. // We read the type here, because it makes more sense to throw a element type error first,
  5481. // rather then the error for lack of a label. Often if its the wrong type, it
  5482. // won't have a label (e.g. calling on a div, btn, etc)
  5483. this._readType();
  5484. labels = this.element.labels();
  5485. // If there are multiple labels, use the last one
  5486. this.label = $( labels[ labels.length - 1 ] );
  5487. if ( !this.label.length ) {
  5488. $.error( "No label found for checkboxradio widget" );
  5489. }
  5490. this.originalLabel = "";
  5491. // We need to get the label text but this may also need to make sure it does not contain the
  5492. // input itself.
  5493. this.label.contents().not( this.element[ 0 ] ).each( function() {
  5494. // The label contents could be text, html, or a mix. We concat each element to get a
  5495. // string representation of the label, without the input as part of it.
  5496. that.originalLabel += this.nodeType === 3 ? $( this ).text() : this.outerHTML;
  5497. } );
  5498. // Set the label option if we found label text
  5499. if ( this.originalLabel ) {
  5500. options.label = this.originalLabel;
  5501. }
  5502. disabled = this.element[ 0 ].disabled;
  5503. if ( disabled != null ) {
  5504. options.disabled = disabled;
  5505. }
  5506. return options;
  5507. },
  5508. _create: function() {
  5509. var checked = this.element[ 0 ].checked;
  5510. this._bindFormResetHandler();
  5511. if ( this.options.disabled == null ) {
  5512. this.options.disabled = this.element[ 0 ].disabled;
  5513. }
  5514. this._setOption( "disabled", this.options.disabled );
  5515. this._addClass( "ui-checkboxradio", "ui-helper-hidden-accessible" );
  5516. this._addClass( this.label, "ui-checkboxradio-label", "ui-button ui-widget" );
  5517. if ( this.type === "radio" ) {
  5518. this._addClass( this.label, "ui-checkboxradio-radio-label" );
  5519. }
  5520. if ( this.options.label && this.options.label !== this.originalLabel ) {
  5521. this._updateLabel();
  5522. } else if ( this.originalLabel ) {
  5523. this.options.label = this.originalLabel;
  5524. }
  5525. this._enhance();
  5526. if ( checked ) {
  5527. this._addClass( this.label, "ui-checkboxradio-checked", "ui-state-active" );
  5528. if ( this.icon ) {
  5529. this._addClass( this.icon, null, "ui-state-hover" );
  5530. }
  5531. }
  5532. this._on( {
  5533. change: "_toggleClasses",
  5534. focus: function() {
  5535. this._addClass( this.label, null, "ui-state-focus ui-visual-focus" );
  5536. },
  5537. blur: function() {
  5538. this._removeClass( this.label, null, "ui-state-focus ui-visual-focus" );
  5539. }
  5540. } );
  5541. },
  5542. _readType: function() {
  5543. var nodeName = this.element[ 0 ].nodeName.toLowerCase();
  5544. this.type = this.element[ 0 ].type;
  5545. if ( nodeName !== "input" || !/radio|checkbox/.test( this.type ) ) {
  5546. $.error( "Can't create checkboxradio on element.nodeName=" + nodeName +
  5547. " and element.type=" + this.type );
  5548. }
  5549. },
  5550. // Support jQuery Mobile enhanced option
  5551. _enhance: function() {
  5552. this._updateIcon( this.element[ 0 ].checked );
  5553. },
  5554. widget: function() {
  5555. return this.label;
  5556. },
  5557. _getRadioGroup: function() {
  5558. var group;
  5559. var name = this.element[ 0 ].name;
  5560. var nameSelector = "input[name='" + $.ui.escapeSelector( name ) + "']";
  5561. if ( !name ) {
  5562. return $( [] );
  5563. }
  5564. if ( this.form.length ) {
  5565. group = $( this.form[ 0 ].elements ).filter( nameSelector );
  5566. } else {
  5567. // Not inside a form, check all inputs that also are not inside a form
  5568. group = $( nameSelector ).filter( function() {
  5569. return $( this ).form().length === 0;
  5570. } );
  5571. }
  5572. return group.not( this.element );
  5573. },
  5574. _toggleClasses: function() {
  5575. var checked = this.element[ 0 ].checked;
  5576. this._toggleClass( this.label, "ui-checkboxradio-checked", "ui-state-active", checked );
  5577. if ( this.options.icon && this.type === "checkbox" ) {
  5578. this._toggleClass( this.icon, null, "ui-icon-check ui-state-checked", checked )
  5579. ._toggleClass( this.icon, null, "ui-icon-blank", !checked );
  5580. }
  5581. if ( this.type === "radio" ) {
  5582. this._getRadioGroup()
  5583. .each( function() {
  5584. var instance = $( this ).checkboxradio( "instance" );
  5585. if ( instance ) {
  5586. instance._removeClass( instance.label,
  5587. "ui-checkboxradio-checked", "ui-state-active" );
  5588. }
  5589. } );
  5590. }
  5591. },
  5592. _destroy: function() {
  5593. this._unbindFormResetHandler();
  5594. if ( this.icon ) {
  5595. this.icon.remove();
  5596. this.iconSpace.remove();
  5597. }
  5598. },
  5599. _setOption: function( key, value ) {
  5600. // We don't allow the value to be set to nothing
  5601. if ( key === "label" && !value ) {
  5602. return;
  5603. }
  5604. this._super( key, value );
  5605. if ( key === "disabled" ) {
  5606. this._toggleClass( this.label, null, "ui-state-disabled", value );
  5607. this.element[ 0 ].disabled = value;
  5608. // Don't refresh when setting disabled
  5609. return;
  5610. }
  5611. this.refresh();
  5612. },
  5613. _updateIcon: function( checked ) {
  5614. var toAdd = "ui-icon ui-icon-background ";
  5615. if ( this.options.icon ) {
  5616. if ( !this.icon ) {
  5617. this.icon = $( "<span>" );
  5618. this.iconSpace = $( "<span> </span>" );
  5619. this._addClass( this.iconSpace, "ui-checkboxradio-icon-space" );
  5620. }
  5621. if ( this.type === "checkbox" ) {
  5622. toAdd += checked ? "ui-icon-check ui-state-checked" : "ui-icon-blank";
  5623. this._removeClass( this.icon, null, checked ? "ui-icon-blank" : "ui-icon-check" );
  5624. } else {
  5625. toAdd += "ui-icon-blank";
  5626. }
  5627. this._addClass( this.icon, "ui-checkboxradio-icon", toAdd );
  5628. if ( !checked ) {
  5629. this._removeClass( this.icon, null, "ui-icon-check ui-state-checked" );
  5630. }
  5631. this.icon.prependTo( this.label ).after( this.iconSpace );
  5632. } else if ( this.icon !== undefined ) {
  5633. this.icon.remove();
  5634. this.iconSpace.remove();
  5635. delete this.icon;
  5636. }
  5637. },
  5638. _updateLabel: function() {
  5639. // Remove the contents of the label ( minus the icon, icon space, and input )
  5640. var contents = this.label.contents().not( this.element[ 0 ] );
  5641. if ( this.icon ) {
  5642. contents = contents.not( this.icon[ 0 ] );
  5643. }
  5644. if ( this.iconSpace ) {
  5645. contents = contents.not( this.iconSpace[ 0 ] );
  5646. }
  5647. contents.remove();
  5648. this.label.append( this.options.label );
  5649. },
  5650. refresh: function() {
  5651. var checked = this.element[ 0 ].checked,
  5652. isDisabled = this.element[ 0 ].disabled;
  5653. this._updateIcon( checked );
  5654. this._toggleClass( this.label, "ui-checkboxradio-checked", "ui-state-active", checked );
  5655. if ( this.options.label !== null ) {
  5656. this._updateLabel();
  5657. }
  5658. if ( isDisabled !== this.options.disabled ) {
  5659. this._setOptions( { "disabled": isDisabled } );
  5660. }
  5661. }
  5662. } ] );
  5663. var widgetsCheckboxradio = $.ui.checkboxradio;
  5664. /*!
  5665. * jQuery UI Button 1.12.1
  5666. * http://jqueryui.com
  5667. *
  5668. * Copyright jQuery Foundation and other contributors
  5669. * Released under the MIT license.
  5670. * http://jquery.org/license
  5671. */
  5672. //>>label: Button
  5673. //>>group: Widgets
  5674. //>>description: Enhances a form with themeable buttons.
  5675. //>>docs: http://api.jqueryui.com/button/
  5676. //>>demos: http://jqueryui.com/button/
  5677. //>>css.structure: ../../themes/base/core.css
  5678. //>>css.structure: ../../themes/base/button.css
  5679. //>>css.theme: ../../themes/base/theme.css
  5680. $.widget( "ui.button", {
  5681. version: "1.12.1",
  5682. defaultElement: "<button>",
  5683. options: {
  5684. classes: {
  5685. "ui-button": "ui-corner-all"
  5686. },
  5687. disabled: null,
  5688. icon: null,
  5689. iconPosition: "beginning",
  5690. label: null,
  5691. showLabel: true
  5692. },
  5693. _getCreateOptions: function() {
  5694. var disabled,
  5695. // This is to support cases like in jQuery Mobile where the base widget does have
  5696. // an implementation of _getCreateOptions
  5697. options = this._super() || {};
  5698. this.isInput = this.element.is( "input" );
  5699. disabled = this.element[ 0 ].disabled;
  5700. if ( disabled != null ) {
  5701. options.disabled = disabled;
  5702. }
  5703. this.originalLabel = this.isInput ? this.element.val() : this.element.html();
  5704. if ( this.originalLabel ) {
  5705. options.label = this.originalLabel;
  5706. }
  5707. return options;
  5708. },
  5709. _create: function() {
  5710. if ( !this.option.showLabel & !this.options.icon ) {
  5711. this.options.showLabel = true;
  5712. }
  5713. // We have to check the option again here even though we did in _getCreateOptions,
  5714. // because null may have been passed on init which would override what was set in
  5715. // _getCreateOptions
  5716. if ( this.options.disabled == null ) {
  5717. this.options.disabled = this.element[ 0 ].disabled || false;
  5718. }
  5719. this.hasTitle = !!this.element.attr( "title" );
  5720. // Check to see if the label needs to be set or if its already correct
  5721. if ( this.options.label && this.options.label !== this.originalLabel ) {
  5722. if ( this.isInput ) {
  5723. this.element.val( this.options.label );
  5724. } else {
  5725. this.element.html( this.options.label );
  5726. }
  5727. }
  5728. this._addClass( "ui-button", "ui-widget" );
  5729. this._setOption( "disabled", this.options.disabled );
  5730. this._enhance();
  5731. if ( this.element.is( "a" ) ) {
  5732. this._on( {
  5733. "keyup": function( event ) {
  5734. if ( event.keyCode === $.ui.keyCode.SPACE ) {
  5735. event.preventDefault();
  5736. // Support: PhantomJS <= 1.9, IE 8 Only
  5737. // If a native click is available use it so we actually cause navigation
  5738. // otherwise just trigger a click event
  5739. if ( this.element[ 0 ].click ) {
  5740. this.element[ 0 ].click();
  5741. } else {
  5742. this.element.trigger( "click" );
  5743. }
  5744. }
  5745. }
  5746. } );
  5747. }
  5748. },
  5749. _enhance: function() {
  5750. if ( !this.element.is( "button" ) ) {
  5751. this.element.attr( "role", "button" );
  5752. }
  5753. if ( this.options.icon ) {
  5754. this._updateIcon( "icon", this.options.icon );
  5755. this._updateTooltip();
  5756. }
  5757. },
  5758. _updateTooltip: function() {
  5759. this.title = this.element.attr( "title" );
  5760. if ( !this.options.showLabel && !this.title ) {
  5761. this.element.attr( "title", this.options.label );
  5762. }
  5763. },
  5764. _updateIcon: function( option, value ) {
  5765. var icon = option !== "iconPosition",
  5766. position = icon ? this.options.iconPosition : value,
  5767. displayBlock = position === "top" || position === "bottom";
  5768. // Create icon
  5769. if ( !this.icon ) {
  5770. this.icon = $( "<span>" );
  5771. this._addClass( this.icon, "ui-button-icon", "ui-icon" );
  5772. if ( !this.options.showLabel ) {
  5773. this._addClass( "ui-button-icon-only" );
  5774. }
  5775. } else if ( icon ) {
  5776. // If we are updating the icon remove the old icon class
  5777. this._removeClass( this.icon, null, this.options.icon );
  5778. }
  5779. // If we are updating the icon add the new icon class
  5780. if ( icon ) {
  5781. this._addClass( this.icon, null, value );
  5782. }
  5783. this._attachIcon( position );
  5784. // If the icon is on top or bottom we need to add the ui-widget-icon-block class and remove
  5785. // the iconSpace if there is one.
  5786. if ( displayBlock ) {
  5787. this._addClass( this.icon, null, "ui-widget-icon-block" );
  5788. if ( this.iconSpace ) {
  5789. this.iconSpace.remove();
  5790. }
  5791. } else {
  5792. // Position is beginning or end so remove the ui-widget-icon-block class and add the
  5793. // space if it does not exist
  5794. if ( !this.iconSpace ) {
  5795. this.iconSpace = $( "<span> </span>" );
  5796. this._addClass( this.iconSpace, "ui-button-icon-space" );
  5797. }
  5798. this._removeClass( this.icon, null, "ui-wiget-icon-block" );
  5799. this._attachIconSpace( position );
  5800. }
  5801. },
  5802. _destroy: function() {
  5803. this.element.removeAttr( "role" );
  5804. if ( this.icon ) {
  5805. this.icon.remove();
  5806. }
  5807. if ( this.iconSpace ) {
  5808. this.iconSpace.remove();
  5809. }
  5810. if ( !this.hasTitle ) {
  5811. this.element.removeAttr( "title" );
  5812. }
  5813. },
  5814. _attachIconSpace: function( iconPosition ) {
  5815. this.icon[ /^(?:end|bottom)/.test( iconPosition ) ? "before" : "after" ]( this.iconSpace );
  5816. },
  5817. _attachIcon: function( iconPosition ) {
  5818. this.element[ /^(?:end|bottom)/.test( iconPosition ) ? "append" : "prepend" ]( this.icon );
  5819. },
  5820. _setOptions: function( options ) {
  5821. var newShowLabel = options.showLabel === undefined ?
  5822. this.options.showLabel :
  5823. options.showLabel,
  5824. newIcon = options.icon === undefined ? this.options.icon : options.icon;
  5825. if ( !newShowLabel && !newIcon ) {
  5826. options.showLabel = true;
  5827. }
  5828. this._super( options );
  5829. },
  5830. _setOption: function( key, value ) {
  5831. if ( key === "icon" ) {
  5832. if ( value ) {
  5833. this._updateIcon( key, value );
  5834. } else if ( this.icon ) {
  5835. this.icon.remove();
  5836. if ( this.iconSpace ) {
  5837. this.iconSpace.remove();
  5838. }
  5839. }
  5840. }
  5841. if ( key === "iconPosition" ) {
  5842. this._updateIcon( key, value );
  5843. }
  5844. // Make sure we can't end up with a button that has neither text nor icon
  5845. if ( key === "showLabel" ) {
  5846. this._toggleClass( "ui-button-icon-only", null, !value );
  5847. this._updateTooltip();
  5848. }
  5849. if ( key === "label" ) {
  5850. if ( this.isInput ) {
  5851. this.element.val( value );
  5852. } else {
  5853. // If there is an icon, append it, else nothing then append the value
  5854. // this avoids removal of the icon when setting label text
  5855. this.element.html( value );
  5856. if ( this.icon ) {
  5857. this._attachIcon( this.options.iconPosition );
  5858. this._attachIconSpace( this.options.iconPosition );
  5859. }
  5860. }
  5861. }
  5862. this._super( key, value );
  5863. if ( key === "disabled" ) {
  5864. this._toggleClass( null, "ui-state-disabled", value );
  5865. this.element[ 0 ].disabled = value;
  5866. if ( value ) {
  5867. this.element.blur();
  5868. }
  5869. }
  5870. },
  5871. refresh: function() {
  5872. // Make sure to only check disabled if its an element that supports this otherwise
  5873. // check for the disabled class to determine state
  5874. var isDisabled = this.element.is( "input, button" ) ?
  5875. this.element[ 0 ].disabled : this.element.hasClass( "ui-button-disabled" );
  5876. if ( isDisabled !== this.options.disabled ) {
  5877. this._setOptions( { disabled: isDisabled } );
  5878. }
  5879. this._updateTooltip();
  5880. }
  5881. } );
  5882. // DEPRECATED
  5883. if ( $.uiBackCompat !== false ) {
  5884. // Text and Icons options
  5885. $.widget( "ui.button", $.ui.button, {
  5886. options: {
  5887. text: true,
  5888. icons: {
  5889. primary: null,
  5890. secondary: null
  5891. }
  5892. },
  5893. _create: function() {
  5894. if ( this.options.showLabel && !this.options.text ) {
  5895. this.options.showLabel = this.options.text;
  5896. }
  5897. if ( !this.options.showLabel && this.options.text ) {
  5898. this.options.text = this.options.showLabel;
  5899. }
  5900. if ( !this.options.icon && ( this.options.icons.primary ||
  5901. this.options.icons.secondary ) ) {
  5902. if ( this.options.icons.primary ) {
  5903. this.options.icon = this.options.icons.primary;
  5904. } else {
  5905. this.options.icon = this.options.icons.secondary;
  5906. this.options.iconPosition = "end";
  5907. }
  5908. } else if ( this.options.icon ) {
  5909. this.options.icons.primary = this.options.icon;
  5910. }
  5911. this._super();
  5912. },
  5913. _setOption: function( key, value ) {
  5914. if ( key === "text" ) {
  5915. this._super( "showLabel", value );
  5916. return;
  5917. }
  5918. if ( key === "showLabel" ) {
  5919. this.options.text = value;
  5920. }
  5921. if ( key === "icon" ) {
  5922. this.options.icons.primary = value;
  5923. }
  5924. if ( key === "icons" ) {
  5925. if ( value.primary ) {
  5926. this._super( "icon", value.primary );
  5927. this._super( "iconPosition", "beginning" );
  5928. } else if ( value.secondary ) {
  5929. this._super( "icon", value.secondary );
  5930. this._super( "iconPosition", "end" );
  5931. }
  5932. }
  5933. this._superApply( arguments );
  5934. }
  5935. } );
  5936. $.fn.button = ( function( orig ) {
  5937. return function() {
  5938. if ( !this.length || ( this.length && this[ 0 ].tagName !== "INPUT" ) ||
  5939. ( this.length && this[ 0 ].tagName === "INPUT" && (
  5940. this.attr( "type" ) !== "checkbox" && this.attr( "type" ) !== "radio"
  5941. ) ) ) {
  5942. return orig.apply( this, arguments );
  5943. }
  5944. if ( !$.ui.checkboxradio ) {
  5945. $.error( "Checkboxradio widget missing" );
  5946. }
  5947. if ( arguments.length === 0 ) {
  5948. return this.checkboxradio( {
  5949. "icon": false
  5950. } );
  5951. }
  5952. return this.checkboxradio.apply( this, arguments );
  5953. };
  5954. } )( $.fn.button );
  5955. $.fn.buttonset = function() {
  5956. if ( !$.ui.controlgroup ) {
  5957. $.error( "Controlgroup widget missing" );
  5958. }
  5959. if ( arguments[ 0 ] === "option" && arguments[ 1 ] === "items" && arguments[ 2 ] ) {
  5960. return this.controlgroup.apply( this,
  5961. [ arguments[ 0 ], "items.button", arguments[ 2 ] ] );
  5962. }
  5963. if ( arguments[ 0 ] === "option" && arguments[ 1 ] === "items" ) {
  5964. return this.controlgroup.apply( this, [ arguments[ 0 ], "items.button" ] );
  5965. }
  5966. if ( typeof arguments[ 0 ] === "object" && arguments[ 0 ].items ) {
  5967. arguments[ 0 ].items = {
  5968. button: arguments[ 0 ].items
  5969. };
  5970. }
  5971. return this.controlgroup.apply( this, arguments );
  5972. };
  5973. }
  5974. var widgetsButton = $.ui.button;
  5975. // jscs:disable maximumLineLength
  5976. /* jscs:disable requireCamelCaseOrUpperCaseIdentifiers */
  5977. /*!
  5978. * jQuery UI Datepicker 1.12.1
  5979. * http://jqueryui.com
  5980. *
  5981. * Copyright jQuery Foundation and other contributors
  5982. * Released under the MIT license.
  5983. * http://jquery.org/license
  5984. */
  5985. //>>label: Datepicker
  5986. //>>group: Widgets
  5987. //>>description: Displays a calendar from an input or inline for selecting dates.
  5988. //>>docs: http://api.jqueryui.com/datepicker/
  5989. //>>demos: http://jqueryui.com/datepicker/
  5990. //>>css.structure: ../../themes/base/core.css
  5991. //>>css.structure: ../../themes/base/datepicker.css
  5992. //>>css.theme: ../../themes/base/theme.css
  5993. $.extend( $.ui, { datepicker: { version: "1.12.1" } } );
  5994. var datepicker_instActive;
  5995. function datepicker_getZindex( elem ) {
  5996. var position, value;
  5997. while ( elem.length && elem[ 0 ] !== document ) {
  5998. // Ignore z-index if position is set to a value where z-index is ignored by the browser
  5999. // This makes behavior of this function consistent across browsers
  6000. // WebKit always returns auto if the element is positioned
  6001. position = elem.css( "position" );
  6002. if ( position === "absolute" || position === "relative" || position === "fixed" ) {
  6003. // IE returns 0 when zIndex is not specified
  6004. // other browsers return a string
  6005. // we ignore the case of nested elements with an explicit value of 0
  6006. // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
  6007. value = parseInt( elem.css( "zIndex" ), 10 );
  6008. if ( !isNaN( value ) && value !== 0 ) {
  6009. return value;
  6010. }
  6011. }
  6012. elem = elem.parent();
  6013. }
  6014. return 0;
  6015. }
  6016. /* Date picker manager.
  6017. Use the singleton instance of this class, $.datepicker, to interact with the date picker.
  6018. Settings for (groups of) date pickers are maintained in an instance object,
  6019. allowing multiple different settings on the same page. */
  6020. function Datepicker() {
  6021. this._curInst = null; // The current instance in use
  6022. this._keyEvent = false; // If the last event was a key event
  6023. this._disabledInputs = []; // List of date picker inputs that have been disabled
  6024. this._datepickerShowing = false; // True if the popup picker is showing , false if not
  6025. this._inDialog = false; // True if showing within a "dialog", false if not
  6026. this._mainDivId = "ui-datepicker-div"; // The ID of the main datepicker division
  6027. this._inlineClass = "ui-datepicker-inline"; // The name of the inline marker class
  6028. this._appendClass = "ui-datepicker-append"; // The name of the append marker class
  6029. this._triggerClass = "ui-datepicker-trigger"; // The name of the trigger marker class
  6030. this._dialogClass = "ui-datepicker-dialog"; // The name of the dialog marker class
  6031. this._disableClass = "ui-datepicker-disabled"; // The name of the disabled covering marker class
  6032. this._unselectableClass = "ui-datepicker-unselectable"; // The name of the unselectable cell marker class
  6033. this._currentClass = "ui-datepicker-current-day"; // The name of the current day marker class
  6034. this._dayOverClass = "ui-datepicker-days-cell-over"; // The name of the day hover marker class
  6035. this.regional = []; // Available regional settings, indexed by language code
  6036. this.regional[ "" ] = { // Default regional settings
  6037. closeText: "Done", // Display text for close link
  6038. prevText: "Prev", // Display text for previous month link
  6039. nextText: "Next", // Display text for next month link
  6040. currentText: "Today", // Display text for current month link
  6041. monthNames: [ "January","February","March","April","May","June",
  6042. "July","August","September","October","November","December" ], // Names of months for drop-down and formatting
  6043. monthNamesShort: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ], // For formatting
  6044. dayNames: [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ], // For formatting
  6045. dayNamesShort: [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ], // For formatting
  6046. dayNamesMin: [ "Su","Mo","Tu","We","Th","Fr","Sa" ], // Column headings for days starting at Sunday
  6047. weekHeader: "Wk", // Column header for week of the year
  6048. dateFormat: "mm/dd/yy", // See format options on parseDate
  6049. firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
  6050. isRTL: false, // True if right-to-left language, false if left-to-right
  6051. showMonthAfterYear: false, // True if the year select precedes month, false for month then year
  6052. yearSuffix: "" // Additional text to append to the year in the month headers
  6053. };
  6054. this._defaults = { // Global defaults for all the date picker instances
  6055. showOn: "focus", // "focus" for popup on focus,
  6056. // "button" for trigger button, or "both" for either
  6057. showAnim: "fadeIn", // Name of jQuery animation for popup
  6058. showOptions: {}, // Options for enhanced animations
  6059. defaultDate: null, // Used when field is blank: actual date,
  6060. // +/-number for offset from today, null for today
  6061. appendText: "", // Display text following the input box, e.g. showing the format
  6062. buttonText: "...", // Text for trigger button
  6063. buttonImage: "", // URL for trigger button image
  6064. buttonImageOnly: false, // True if the image appears alone, false if it appears on a button
  6065. hideIfNoPrevNext: false, // True to hide next/previous month links
  6066. // if not applicable, false to just disable them
  6067. navigationAsDateFormat: false, // True if date formatting applied to prev/today/next links
  6068. gotoCurrent: false, // True if today link goes back to current selection instead
  6069. changeMonth: false, // True if month can be selected directly, false if only prev/next
  6070. changeYear: false, // True if year can be selected directly, false if only prev/next
  6071. yearRange: "c-10:c+10", // Range of years to display in drop-down,
  6072. // either relative to today's year (-nn:+nn), relative to currently displayed year
  6073. // (c-nn:c+nn), absolute (nnnn:nnnn), or a combination of the above (nnnn:-n)
  6074. showOtherMonths: false, // True to show dates in other months, false to leave blank
  6075. selectOtherMonths: false, // True to allow selection of dates in other months, false for unselectable
  6076. showWeek: false, // True to show week of the year, false to not show it
  6077. calculateWeek: this.iso8601Week, // How to calculate the week of the year,
  6078. // takes a Date and returns the number of the week for it
  6079. shortYearCutoff: "+10", // Short year values < this are in the current century,
  6080. // > this are in the previous century,
  6081. // string value starting with "+" for current year + value
  6082. minDate: null, // The earliest selectable date, or null for no limit
  6083. maxDate: null, // The latest selectable date, or null for no limit
  6084. duration: "fast", // Duration of display/closure
  6085. beforeShowDay: null, // Function that takes a date and returns an array with
  6086. // [0] = true if selectable, false if not, [1] = custom CSS class name(s) or "",
  6087. // [2] = cell title (optional), e.g. $.datepicker.noWeekends
  6088. beforeShow: null, // Function that takes an input field and
  6089. // returns a set of custom settings for the date picker
  6090. onSelect: null, // Define a callback function when a date is selected
  6091. onChangeMonthYear: null, // Define a callback function when the month or year is changed
  6092. onClose: null, // Define a callback function when the datepicker is closed
  6093. numberOfMonths: 1, // Number of months to show at a time
  6094. showCurrentAtPos: 0, // The position in multipe months at which to show the current month (starting at 0)
  6095. stepMonths: 1, // Number of months to step back/forward
  6096. stepBigMonths: 12, // Number of months to step back/forward for the big links
  6097. altField: "", // Selector for an alternate field to store selected dates into
  6098. altFormat: "", // The date format to use for the alternate field
  6099. constrainInput: true, // The input is constrained by the current date format
  6100. showButtonPanel: false, // True to show button panel, false to not show it
  6101. autoSize: false, // True to size the input for the date format, false to leave as is
  6102. disabled: false // The initial disabled state
  6103. };
  6104. $.extend( this._defaults, this.regional[ "" ] );
  6105. this.regional.en = $.extend( true, {}, this.regional[ "" ] );
  6106. this.regional[ "en-US" ] = $.extend( true, {}, this.regional.en );
  6107. this.dpDiv = datepicker_bindHover( $( "<div id='" + this._mainDivId + "' class='ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>" ) );
  6108. }
  6109. $.extend( Datepicker.prototype, {
  6110. /* Class name added to elements to indicate already configured with a date picker. */
  6111. markerClassName: "hasDatepicker",
  6112. //Keep track of the maximum number of rows displayed (see #7043)
  6113. maxRows: 4,
  6114. // TODO rename to "widget" when switching to widget factory
  6115. _widgetDatepicker: function() {
  6116. return this.dpDiv;
  6117. },
  6118. /* Override the default settings for all instances of the date picker.
  6119. * @param settings object - the new settings to use as defaults (anonymous object)
  6120. * @return the manager object
  6121. */
  6122. setDefaults: function( settings ) {
  6123. datepicker_extendRemove( this._defaults, settings || {} );
  6124. return this;
  6125. },
  6126. /* Attach the date picker to a jQuery selection.
  6127. * @param target element - the target input field or division or span
  6128. * @param settings object - the new settings to use for this date picker instance (anonymous)
  6129. */
  6130. _attachDatepicker: function( target, settings ) {
  6131. var nodeName, inline, inst;
  6132. nodeName = target.nodeName.toLowerCase();
  6133. inline = ( nodeName === "div" || nodeName === "span" );
  6134. if ( !target.id ) {
  6135. this.uuid += 1;
  6136. target.id = "dp" + this.uuid;
  6137. }
  6138. inst = this._newInst( $( target ), inline );
  6139. inst.settings = $.extend( {}, settings || {} );
  6140. if ( nodeName === "input" ) {
  6141. this._connectDatepicker( target, inst );
  6142. } else if ( inline ) {
  6143. this._inlineDatepicker( target, inst );
  6144. }
  6145. },
  6146. /* Create a new instance object. */
  6147. _newInst: function( target, inline ) {
  6148. var id = target[ 0 ].id.replace( /([^A-Za-z0-9_\-])/g, "\\\\$1" ); // escape jQuery meta chars
  6149. return { id: id, input: target, // associated target
  6150. selectedDay: 0, selectedMonth: 0, selectedYear: 0, // current selection
  6151. drawMonth: 0, drawYear: 0, // month being drawn
  6152. inline: inline, // is datepicker inline or not
  6153. dpDiv: ( !inline ? this.dpDiv : // presentation div
  6154. datepicker_bindHover( $( "<div class='" + this._inlineClass + " ui-datepicker ui-widget ui-widget-content ui-helper-clearfix ui-corner-all'></div>" ) ) ) };
  6155. },
  6156. /* Attach the date picker to an input field. */
  6157. _connectDatepicker: function( target, inst ) {
  6158. var input = $( target );
  6159. inst.append = $( [] );
  6160. inst.trigger = $( [] );
  6161. if ( input.hasClass( this.markerClassName ) ) {
  6162. return;
  6163. }
  6164. this._attachments( input, inst );
  6165. input.addClass( this.markerClassName ).on( "keydown", this._doKeyDown ).
  6166. on( "keypress", this._doKeyPress ).on( "keyup", this._doKeyUp );
  6167. this._autoSize( inst );
  6168. $.data( target, "datepicker", inst );
  6169. //If disabled option is true, disable the datepicker once it has been attached to the input (see ticket #5665)
  6170. if ( inst.settings.disabled ) {
  6171. this._disableDatepicker( target );
  6172. }
  6173. },
  6174. /* Make attachments based on settings. */
  6175. _attachments: function( input, inst ) {
  6176. var showOn, buttonText, buttonImage,
  6177. appendText = this._get( inst, "appendText" ),
  6178. isRTL = this._get( inst, "isRTL" );
  6179. if ( inst.append ) {
  6180. inst.append.remove();
  6181. }
  6182. if ( appendText ) {
  6183. inst.append = $( "<span class='" + this._appendClass + "'>" + appendText + "</span>" );
  6184. input[ isRTL ? "before" : "after" ]( inst.append );
  6185. }
  6186. input.off( "focus", this._showDatepicker );
  6187. if ( inst.trigger ) {
  6188. inst.trigger.remove();
  6189. }
  6190. showOn = this._get( inst, "showOn" );
  6191. if ( showOn === "focus" || showOn === "both" ) { // pop-up date picker when in the marked field
  6192. input.on( "focus", this._showDatepicker );
  6193. }
  6194. if ( showOn === "button" || showOn === "both" ) { // pop-up date picker when button clicked
  6195. buttonText = this._get( inst, "buttonText" );
  6196. buttonImage = this._get( inst, "buttonImage" );
  6197. inst.trigger = $( this._get( inst, "buttonImageOnly" ) ?
  6198. $( "<img/>" ).addClass( this._triggerClass ).
  6199. attr( { src: buttonImage, alt: buttonText, title: buttonText } ) :
  6200. $( "<button type='button'></button>" ).addClass( this._triggerClass ).
  6201. html( !buttonImage ? buttonText : $( "<img/>" ).attr(
  6202. { src:buttonImage, alt:buttonText, title:buttonText } ) ) );
  6203. input[ isRTL ? "before" : "after" ]( inst.trigger );
  6204. inst.trigger.on( "click", function() {
  6205. if ( $.datepicker._datepickerShowing && $.datepicker._lastInput === input[ 0 ] ) {
  6206. $.datepicker._hideDatepicker();
  6207. } else if ( $.datepicker._datepickerShowing && $.datepicker._lastInput !== input[ 0 ] ) {
  6208. $.datepicker._hideDatepicker();
  6209. $.datepicker._showDatepicker( input[ 0 ] );
  6210. } else {
  6211. $.datepicker._showDatepicker( input[ 0 ] );
  6212. }
  6213. return false;
  6214. } );
  6215. }
  6216. },
  6217. /* Apply the maximum length for the date format. */
  6218. _autoSize: function( inst ) {
  6219. if ( this._get( inst, "autoSize" ) && !inst.inline ) {
  6220. var findMax, max, maxI, i,
  6221. date = new Date( 2009, 12 - 1, 20 ), // Ensure double digits
  6222. dateFormat = this._get( inst, "dateFormat" );
  6223. if ( dateFormat.match( /[DM]/ ) ) {
  6224. findMax = function( names ) {
  6225. max = 0;
  6226. maxI = 0;
  6227. for ( i = 0; i < names.length; i++ ) {
  6228. if ( names[ i ].length > max ) {
  6229. max = names[ i ].length;
  6230. maxI = i;
  6231. }
  6232. }
  6233. return maxI;
  6234. };
  6235. date.setMonth( findMax( this._get( inst, ( dateFormat.match( /MM/ ) ?
  6236. "monthNames" : "monthNamesShort" ) ) ) );
  6237. date.setDate( findMax( this._get( inst, ( dateFormat.match( /DD/ ) ?
  6238. "dayNames" : "dayNamesShort" ) ) ) + 20 - date.getDay() );
  6239. }
  6240. inst.input.attr( "size", this._formatDate( inst, date ).length );
  6241. }
  6242. },
  6243. /* Attach an inline date picker to a div. */
  6244. _inlineDatepicker: function( target, inst ) {
  6245. var divSpan = $( target );
  6246. if ( divSpan.hasClass( this.markerClassName ) ) {
  6247. return;
  6248. }
  6249. divSpan.addClass( this.markerClassName ).append( inst.dpDiv );
  6250. $.data( target, "datepicker", inst );
  6251. this._setDate( inst, this._getDefaultDate( inst ), true );
  6252. this._updateDatepicker( inst );
  6253. this._updateAlternate( inst );
  6254. //If disabled option is true, disable the datepicker before showing it (see ticket #5665)
  6255. if ( inst.settings.disabled ) {
  6256. this._disableDatepicker( target );
  6257. }
  6258. // Set display:block in place of inst.dpDiv.show() which won't work on disconnected elements
  6259. // http://bugs.jqueryui.com/ticket/7552 - A Datepicker created on a detached div has zero height
  6260. inst.dpDiv.css( "display", "block" );
  6261. },
  6262. /* Pop-up the date picker in a "dialog" box.
  6263. * @param input element - ignored
  6264. * @param date string or Date - the initial date to display
  6265. * @param onSelect function - the function to call when a date is selected
  6266. * @param settings object - update the dialog date picker instance's settings (anonymous object)
  6267. * @param pos int[2] - coordinates for the dialog's position within the screen or
  6268. * event - with x/y coordinates or
  6269. * leave empty for default (screen centre)
  6270. * @return the manager object
  6271. */
  6272. _dialogDatepicker: function( input, date, onSelect, settings, pos ) {
  6273. var id, browserWidth, browserHeight, scrollX, scrollY,
  6274. inst = this._dialogInst; // internal instance
  6275. if ( !inst ) {
  6276. this.uuid += 1;
  6277. id = "dp" + this.uuid;
  6278. this._dialogInput = $( "<input type='text' id='" + id +
  6279. "' style='position: absolute; top: -100px; width: 0px;'/>" );
  6280. this._dialogInput.on( "keydown", this._doKeyDown );
  6281. $( "body" ).append( this._dialogInput );
  6282. inst = this._dialogInst = this._newInst( this._dialogInput, false );
  6283. inst.settings = {};
  6284. $.data( this._dialogInput[ 0 ], "datepicker", inst );
  6285. }
  6286. datepicker_extendRemove( inst.settings, settings || {} );
  6287. date = ( date && date.constructor === Date ? this._formatDate( inst, date ) : date );
  6288. this._dialogInput.val( date );
  6289. this._pos = ( pos ? ( pos.length ? pos : [ pos.pageX, pos.pageY ] ) : null );
  6290. if ( !this._pos ) {
  6291. browserWidth = document.documentElement.clientWidth;
  6292. browserHeight = document.documentElement.clientHeight;
  6293. scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
  6294. scrollY = document.documentElement.scrollTop || document.body.scrollTop;
  6295. this._pos = // should use actual width/height below
  6296. [ ( browserWidth / 2 ) - 100 + scrollX, ( browserHeight / 2 ) - 150 + scrollY ];
  6297. }
  6298. // Move input on screen for focus, but hidden behind dialog
  6299. this._dialogInput.css( "left", ( this._pos[ 0 ] + 20 ) + "px" ).css( "top", this._pos[ 1 ] + "px" );
  6300. inst.settings.onSelect = onSelect;
  6301. this._inDialog = true;
  6302. this.dpDiv.addClass( this._dialogClass );
  6303. this._showDatepicker( this._dialogInput[ 0 ] );
  6304. if ( $.blockUI ) {
  6305. $.blockUI( this.dpDiv );
  6306. }
  6307. $.data( this._dialogInput[ 0 ], "datepicker", inst );
  6308. return this;
  6309. },
  6310. /* Detach a datepicker from its control.
  6311. * @param target element - the target input field or division or span
  6312. */
  6313. _destroyDatepicker: function( target ) {
  6314. var nodeName,
  6315. $target = $( target ),
  6316. inst = $.data( target, "datepicker" );
  6317. if ( !$target.hasClass( this.markerClassName ) ) {
  6318. return;
  6319. }
  6320. nodeName = target.nodeName.toLowerCase();
  6321. $.removeData( target, "datepicker" );
  6322. if ( nodeName === "input" ) {
  6323. inst.append.remove();
  6324. inst.trigger.remove();
  6325. $target.removeClass( this.markerClassName ).
  6326. off( "focus", this._showDatepicker ).
  6327. off( "keydown", this._doKeyDown ).
  6328. off( "keypress", this._doKeyPress ).
  6329. off( "keyup", this._doKeyUp );
  6330. } else if ( nodeName === "div" || nodeName === "span" ) {
  6331. $target.removeClass( this.markerClassName ).empty();
  6332. }
  6333. if ( datepicker_instActive === inst ) {
  6334. datepicker_instActive = null;
  6335. }
  6336. },
  6337. /* Enable the date picker to a jQuery selection.
  6338. * @param target element - the target input field or division or span
  6339. */
  6340. _enableDatepicker: function( target ) {
  6341. var nodeName, inline,
  6342. $target = $( target ),
  6343. inst = $.data( target, "datepicker" );
  6344. if ( !$target.hasClass( this.markerClassName ) ) {
  6345. return;
  6346. }
  6347. nodeName = target.nodeName.toLowerCase();
  6348. if ( nodeName === "input" ) {
  6349. target.disabled = false;
  6350. inst.trigger.filter( "button" ).
  6351. each( function() { this.disabled = false; } ).end().
  6352. filter( "img" ).css( { opacity: "1.0", cursor: "" } );
  6353. } else if ( nodeName === "div" || nodeName === "span" ) {
  6354. inline = $target.children( "." + this._inlineClass );
  6355. inline.children().removeClass( "ui-state-disabled" );
  6356. inline.find( "select.ui-datepicker-month, select.ui-datepicker-year" ).
  6357. prop( "disabled", false );
  6358. }
  6359. this._disabledInputs = $.map( this._disabledInputs,
  6360. function( value ) { return ( value === target ? null : value ); } ); // delete entry
  6361. },
  6362. /* Disable the date picker to a jQuery selection.
  6363. * @param target element - the target input field or division or span
  6364. */
  6365. _disableDatepicker: function( target ) {
  6366. var nodeName, inline,
  6367. $target = $( target ),
  6368. inst = $.data( target, "datepicker" );
  6369. if ( !$target.hasClass( this.markerClassName ) ) {
  6370. return;
  6371. }
  6372. nodeName = target.nodeName.toLowerCase();
  6373. if ( nodeName === "input" ) {
  6374. target.disabled = true;
  6375. inst.trigger.filter( "button" ).
  6376. each( function() { this.disabled = true; } ).end().
  6377. filter( "img" ).css( { opacity: "0.5", cursor: "default" } );
  6378. } else if ( nodeName === "div" || nodeName === "span" ) {
  6379. inline = $target.children( "." + this._inlineClass );
  6380. inline.children().addClass( "ui-state-disabled" );
  6381. inline.find( "select.ui-datepicker-month, select.ui-datepicker-year" ).
  6382. prop( "disabled", true );
  6383. }
  6384. this._disabledInputs = $.map( this._disabledInputs,
  6385. function( value ) { return ( value === target ? null : value ); } ); // delete entry
  6386. this._disabledInputs[ this._disabledInputs.length ] = target;
  6387. },
  6388. /* Is the first field in a jQuery collection disabled as a datepicker?
  6389. * @param target element - the target input field or division or span
  6390. * @return boolean - true if disabled, false if enabled
  6391. */
  6392. _isDisabledDatepicker: function( target ) {
  6393. if ( !target ) {
  6394. return false;
  6395. }
  6396. for ( var i = 0; i < this._disabledInputs.length; i++ ) {
  6397. if ( this._disabledInputs[ i ] === target ) {
  6398. return true;
  6399. }
  6400. }
  6401. return false;
  6402. },
  6403. /* Retrieve the instance data for the target control.
  6404. * @param target element - the target input field or division or span
  6405. * @return object - the associated instance data
  6406. * @throws error if a jQuery problem getting data
  6407. */
  6408. _getInst: function( target ) {
  6409. try {
  6410. return $.data( target, "datepicker" );
  6411. }
  6412. catch ( err ) {
  6413. throw "Missing instance data for this datepicker";
  6414. }
  6415. },
  6416. /* Update or retrieve the settings for a date picker attached to an input field or division.
  6417. * @param target element - the target input field or division or span
  6418. * @param name object - the new settings to update or
  6419. * string - the name of the setting to change or retrieve,
  6420. * when retrieving also "all" for all instance settings or
  6421. * "defaults" for all global defaults
  6422. * @param value any - the new value for the setting
  6423. * (omit if above is an object or to retrieve a value)
  6424. */
  6425. _optionDatepicker: function( target, name, value ) {
  6426. var settings, date, minDate, maxDate,
  6427. inst = this._getInst( target );
  6428. if ( arguments.length === 2 && typeof name === "string" ) {
  6429. return ( name === "defaults" ? $.extend( {}, $.datepicker._defaults ) :
  6430. ( inst ? ( name === "all" ? $.extend( {}, inst.settings ) :
  6431. this._get( inst, name ) ) : null ) );
  6432. }
  6433. settings = name || {};
  6434. if ( typeof name === "string" ) {
  6435. settings = {};
  6436. settings[ name ] = value;
  6437. }
  6438. if ( inst ) {
  6439. if ( this._curInst === inst ) {
  6440. this._hideDatepicker();
  6441. }
  6442. date = this._getDateDatepicker( target, true );
  6443. minDate = this._getMinMaxDate( inst, "min" );
  6444. maxDate = this._getMinMaxDate( inst, "max" );
  6445. datepicker_extendRemove( inst.settings, settings );
  6446. // reformat the old minDate/maxDate values if dateFormat changes and a new minDate/maxDate isn't provided
  6447. if ( minDate !== null && settings.dateFormat !== undefined && settings.minDate === undefined ) {
  6448. inst.settings.minDate = this._formatDate( inst, minDate );
  6449. }
  6450. if ( maxDate !== null && settings.dateFormat !== undefined && settings.maxDate === undefined ) {
  6451. inst.settings.maxDate = this._formatDate( inst, maxDate );
  6452. }
  6453. if ( "disabled" in settings ) {
  6454. if ( settings.disabled ) {
  6455. this._disableDatepicker( target );
  6456. } else {
  6457. this._enableDatepicker( target );
  6458. }
  6459. }
  6460. this._attachments( $( target ), inst );
  6461. this._autoSize( inst );
  6462. this._setDate( inst, date );
  6463. this._updateAlternate( inst );
  6464. this._updateDatepicker( inst );
  6465. }
  6466. },
  6467. // Change method deprecated
  6468. _changeDatepicker: function( target, name, value ) {
  6469. this._optionDatepicker( target, name, value );
  6470. },
  6471. /* Redraw the date picker attached to an input field or division.
  6472. * @param target element - the target input field or division or span
  6473. */
  6474. _refreshDatepicker: function( target ) {
  6475. var inst = this._getInst( target );
  6476. if ( inst ) {
  6477. this._updateDatepicker( inst );
  6478. }
  6479. },
  6480. /* Set the dates for a jQuery selection.
  6481. * @param target element - the target input field or division or span
  6482. * @param date Date - the new date
  6483. */
  6484. _setDateDatepicker: function( target, date ) {
  6485. var inst = this._getInst( target );
  6486. if ( inst ) {
  6487. this._setDate( inst, date );
  6488. this._updateDatepicker( inst );
  6489. this._updateAlternate( inst );
  6490. }
  6491. },
  6492. /* Get the date(s) for the first entry in a jQuery selection.
  6493. * @param target element - the target input field or division or span
  6494. * @param noDefault boolean - true if no default date is to be used
  6495. * @return Date - the current date
  6496. */
  6497. _getDateDatepicker: function( target, noDefault ) {
  6498. var inst = this._getInst( target );
  6499. if ( inst && !inst.inline ) {
  6500. this._setDateFromField( inst, noDefault );
  6501. }
  6502. return ( inst ? this._getDate( inst ) : null );
  6503. },
  6504. /* Handle keystrokes. */
  6505. _doKeyDown: function( event ) {
  6506. var onSelect, dateStr, sel,
  6507. inst = $.datepicker._getInst( event.target ),
  6508. handled = true,
  6509. isRTL = inst.dpDiv.is( ".ui-datepicker-rtl" );
  6510. inst._keyEvent = true;
  6511. if ( $.datepicker._datepickerShowing ) {
  6512. switch ( event.keyCode ) {
  6513. case 9: $.datepicker._hideDatepicker();
  6514. handled = false;
  6515. break; // hide on tab out
  6516. case 13: sel = $( "td." + $.datepicker._dayOverClass + ":not(." +
  6517. $.datepicker._currentClass + ")", inst.dpDiv );
  6518. if ( sel[ 0 ] ) {
  6519. $.datepicker._selectDay( event.target, inst.selectedMonth, inst.selectedYear, sel[ 0 ] );
  6520. }
  6521. onSelect = $.datepicker._get( inst, "onSelect" );
  6522. if ( onSelect ) {
  6523. dateStr = $.datepicker._formatDate( inst );
  6524. // Trigger custom callback
  6525. onSelect.apply( ( inst.input ? inst.input[ 0 ] : null ), [ dateStr, inst ] );
  6526. } else {
  6527. $.datepicker._hideDatepicker();
  6528. }
  6529. return false; // don't submit the form
  6530. case 27: $.datepicker._hideDatepicker();
  6531. break; // hide on escape
  6532. case 33: $.datepicker._adjustDate( event.target, ( event.ctrlKey ?
  6533. -$.datepicker._get( inst, "stepBigMonths" ) :
  6534. -$.datepicker._get( inst, "stepMonths" ) ), "M" );
  6535. break; // previous month/year on page up/+ ctrl
  6536. case 34: $.datepicker._adjustDate( event.target, ( event.ctrlKey ?
  6537. +$.datepicker._get( inst, "stepBigMonths" ) :
  6538. +$.datepicker._get( inst, "stepMonths" ) ), "M" );
  6539. break; // next month/year on page down/+ ctrl
  6540. case 35: if ( event.ctrlKey || event.metaKey ) {
  6541. $.datepicker._clearDate( event.target );
  6542. }
  6543. handled = event.ctrlKey || event.metaKey;
  6544. break; // clear on ctrl or command +end
  6545. case 36: if ( event.ctrlKey || event.metaKey ) {
  6546. $.datepicker._gotoToday( event.target );
  6547. }
  6548. handled = event.ctrlKey || event.metaKey;
  6549. break; // current on ctrl or command +home
  6550. case 37: if ( event.ctrlKey || event.metaKey ) {
  6551. $.datepicker._adjustDate( event.target, ( isRTL ? +1 : -1 ), "D" );
  6552. }
  6553. handled = event.ctrlKey || event.metaKey;
  6554. // -1 day on ctrl or command +left
  6555. if ( event.originalEvent.altKey ) {
  6556. $.datepicker._adjustDate( event.target, ( event.ctrlKey ?
  6557. -$.datepicker._get( inst, "stepBigMonths" ) :
  6558. -$.datepicker._get( inst, "stepMonths" ) ), "M" );
  6559. }
  6560. // next month/year on alt +left on Mac
  6561. break;
  6562. case 38: if ( event.ctrlKey || event.metaKey ) {
  6563. $.datepicker._adjustDate( event.target, -7, "D" );
  6564. }
  6565. handled = event.ctrlKey || event.metaKey;
  6566. break; // -1 week on ctrl or command +up
  6567. case 39: if ( event.ctrlKey || event.metaKey ) {
  6568. $.datepicker._adjustDate( event.target, ( isRTL ? -1 : +1 ), "D" );
  6569. }
  6570. handled = event.ctrlKey || event.metaKey;
  6571. // +1 day on ctrl or command +right
  6572. if ( event.originalEvent.altKey ) {
  6573. $.datepicker._adjustDate( event.target, ( event.ctrlKey ?
  6574. +$.datepicker._get( inst, "stepBigMonths" ) :
  6575. +$.datepicker._get( inst, "stepMonths" ) ), "M" );
  6576. }
  6577. // next month/year on alt +right
  6578. break;
  6579. case 40: if ( event.ctrlKey || event.metaKey ) {
  6580. $.datepicker._adjustDate( event.target, +7, "D" );
  6581. }
  6582. handled = event.ctrlKey || event.metaKey;
  6583. break; // +1 week on ctrl or command +down
  6584. default: handled = false;
  6585. }
  6586. } else if ( event.keyCode === 36 && event.ctrlKey ) { // display the date picker on ctrl+home
  6587. $.datepicker._showDatepicker( this );
  6588. } else {
  6589. handled = false;
  6590. }
  6591. if ( handled ) {
  6592. event.preventDefault();
  6593. event.stopPropagation();
  6594. }
  6595. },
  6596. /* Filter entered characters - based on date format. */
  6597. _doKeyPress: function( event ) {
  6598. var chars, chr,
  6599. inst = $.datepicker._getInst( event.target );
  6600. if ( $.datepicker._get( inst, "constrainInput" ) ) {
  6601. chars = $.datepicker._possibleChars( $.datepicker._get( inst, "dateFormat" ) );
  6602. chr = String.fromCharCode( event.charCode == null ? event.keyCode : event.charCode );
  6603. return event.ctrlKey || event.metaKey || ( chr < " " || !chars || chars.indexOf( chr ) > -1 );
  6604. }
  6605. },
  6606. /* Synchronise manual entry and field/alternate field. */
  6607. _doKeyUp: function( event ) {
  6608. var date,
  6609. inst = $.datepicker._getInst( event.target );
  6610. if ( inst.input.val() !== inst.lastVal ) {
  6611. try {
  6612. date = $.datepicker.parseDate( $.datepicker._get( inst, "dateFormat" ),
  6613. ( inst.input ? inst.input.val() : null ),
  6614. $.datepicker._getFormatConfig( inst ) );
  6615. if ( date ) { // only if valid
  6616. $.datepicker._setDateFromField( inst );
  6617. $.datepicker._updateAlternate( inst );
  6618. $.datepicker._updateDatepicker( inst );
  6619. }
  6620. }
  6621. catch ( err ) {
  6622. }
  6623. }
  6624. return true;
  6625. },
  6626. /* Pop-up the date picker for a given input field.
  6627. * If false returned from beforeShow event handler do not show.
  6628. * @param input element - the input field attached to the date picker or
  6629. * event - if triggered by focus
  6630. */
  6631. _showDatepicker: function( input ) {
  6632. input = input.target || input;
  6633. if ( input.nodeName.toLowerCase() !== "input" ) { // find from button/image trigger
  6634. input = $( "input", input.parentNode )[ 0 ];
  6635. }
  6636. if ( $.datepicker._isDisabledDatepicker( input ) || $.datepicker._lastInput === input ) { // already here
  6637. return;
  6638. }
  6639. var inst, beforeShow, beforeShowSettings, isFixed,
  6640. offset, showAnim, duration;
  6641. inst = $.datepicker._getInst( input );
  6642. if ( $.datepicker._curInst && $.datepicker._curInst !== inst ) {
  6643. $.datepicker._curInst.dpDiv.stop( true, true );
  6644. if ( inst && $.datepicker._datepickerShowing ) {
  6645. $.datepicker._hideDatepicker( $.datepicker._curInst.input[ 0 ] );
  6646. }
  6647. }
  6648. beforeShow = $.datepicker._get( inst, "beforeShow" );
  6649. beforeShowSettings = beforeShow ? beforeShow.apply( input, [ input, inst ] ) : {};
  6650. if ( beforeShowSettings === false ) {
  6651. return;
  6652. }
  6653. datepicker_extendRemove( inst.settings, beforeShowSettings );
  6654. inst.lastVal = null;
  6655. $.datepicker._lastInput = input;
  6656. $.datepicker._setDateFromField( inst );
  6657. if ( $.datepicker._inDialog ) { // hide cursor
  6658. input.value = "";
  6659. }
  6660. if ( !$.datepicker._pos ) { // position below input
  6661. $.datepicker._pos = $.datepicker._findPos( input );
  6662. $.datepicker._pos[ 1 ] += input.offsetHeight; // add the height
  6663. }
  6664. isFixed = false;
  6665. $( input ).parents().each( function() {
  6666. isFixed |= $( this ).css( "position" ) === "fixed";
  6667. return !isFixed;
  6668. } );
  6669. offset = { left: $.datepicker._pos[ 0 ], top: $.datepicker._pos[ 1 ] };
  6670. $.datepicker._pos = null;
  6671. //to avoid flashes on Firefox
  6672. inst.dpDiv.empty();
  6673. // determine sizing offscreen
  6674. inst.dpDiv.css( { position: "absolute", display: "block", top: "-1000px" } );
  6675. $.datepicker._updateDatepicker( inst );
  6676. // fix width for dynamic number of date pickers
  6677. // and adjust position before showing
  6678. offset = $.datepicker._checkOffset( inst, offset, isFixed );
  6679. inst.dpDiv.css( { position: ( $.datepicker._inDialog && $.blockUI ?
  6680. "static" : ( isFixed ? "fixed" : "absolute" ) ), display: "none",
  6681. left: offset.left + "px", top: offset.top + "px" } );
  6682. if ( !inst.inline ) {
  6683. showAnim = $.datepicker._get( inst, "showAnim" );
  6684. duration = $.datepicker._get( inst, "duration" );
  6685. inst.dpDiv.css( "z-index", datepicker_getZindex( $( input ) ) + 1 );
  6686. $.datepicker._datepickerShowing = true;
  6687. if ( $.effects && $.effects.effect[ showAnim ] ) {
  6688. inst.dpDiv.show( showAnim, $.datepicker._get( inst, "showOptions" ), duration );
  6689. } else {
  6690. inst.dpDiv[ showAnim || "show" ]( showAnim ? duration : null );
  6691. }
  6692. if ( $.datepicker._shouldFocusInput( inst ) ) {
  6693. inst.input.trigger( "focus" );
  6694. }
  6695. $.datepicker._curInst = inst;
  6696. }
  6697. },
  6698. /* Generate the date picker content. */
  6699. _updateDatepicker: function( inst ) {
  6700. this.maxRows = 4; //Reset the max number of rows being displayed (see #7043)
  6701. datepicker_instActive = inst; // for delegate hover events
  6702. inst.dpDiv.empty().append( this._generateHTML( inst ) );
  6703. this._attachHandlers( inst );
  6704. var origyearshtml,
  6705. numMonths = this._getNumberOfMonths( inst ),
  6706. cols = numMonths[ 1 ],
  6707. width = 17,
  6708. activeCell = inst.dpDiv.find( "." + this._dayOverClass + " a" );
  6709. if ( activeCell.length > 0 ) {
  6710. datepicker_handleMouseover.apply( activeCell.get( 0 ) );
  6711. }
  6712. inst.dpDiv.removeClass( "ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4" ).width( "" );
  6713. if ( cols > 1 ) {
  6714. inst.dpDiv.addClass( "ui-datepicker-multi-" + cols ).css( "width", ( width * cols ) + "em" );
  6715. }
  6716. inst.dpDiv[ ( numMonths[ 0 ] !== 1 || numMonths[ 1 ] !== 1 ? "add" : "remove" ) +
  6717. "Class" ]( "ui-datepicker-multi" );
  6718. inst.dpDiv[ ( this._get( inst, "isRTL" ) ? "add" : "remove" ) +
  6719. "Class" ]( "ui-datepicker-rtl" );
  6720. if ( inst === $.datepicker._curInst && $.datepicker._datepickerShowing && $.datepicker._shouldFocusInput( inst ) ) {
  6721. inst.input.trigger( "focus" );
  6722. }
  6723. // Deffered render of the years select (to avoid flashes on Firefox)
  6724. if ( inst.yearshtml ) {
  6725. origyearshtml = inst.yearshtml;
  6726. setTimeout( function() {
  6727. //assure that inst.yearshtml didn't change.
  6728. if ( origyearshtml === inst.yearshtml && inst.yearshtml ) {
  6729. inst.dpDiv.find( "select.ui-datepicker-year:first" ).replaceWith( inst.yearshtml );
  6730. }
  6731. origyearshtml = inst.yearshtml = null;
  6732. }, 0 );
  6733. }
  6734. },
  6735. // #6694 - don't focus the input if it's already focused
  6736. // this breaks the change event in IE
  6737. // Support: IE and jQuery <1.9
  6738. _shouldFocusInput: function( inst ) {
  6739. return inst.input && inst.input.is( ":visible" ) && !inst.input.is( ":disabled" ) && !inst.input.is( ":focus" );
  6740. },
  6741. /* Check positioning to remain on screen. */
  6742. _checkOffset: function( inst, offset, isFixed ) {
  6743. var dpWidth = inst.dpDiv.outerWidth(),
  6744. dpHeight = inst.dpDiv.outerHeight(),
  6745. inputWidth = inst.input ? inst.input.outerWidth() : 0,
  6746. inputHeight = inst.input ? inst.input.outerHeight() : 0,
  6747. viewWidth = document.documentElement.clientWidth + ( isFixed ? 0 : $( document ).scrollLeft() ),
  6748. viewHeight = document.documentElement.clientHeight + ( isFixed ? 0 : $( document ).scrollTop() );
  6749. offset.left -= ( this._get( inst, "isRTL" ) ? ( dpWidth - inputWidth ) : 0 );
  6750. offset.left -= ( isFixed && offset.left === inst.input.offset().left ) ? $( document ).scrollLeft() : 0;
  6751. offset.top -= ( isFixed && offset.top === ( inst.input.offset().top + inputHeight ) ) ? $( document ).scrollTop() : 0;
  6752. // Now check if datepicker is showing outside window viewport - move to a better place if so.
  6753. offset.left -= Math.min( offset.left, ( offset.left + dpWidth > viewWidth && viewWidth > dpWidth ) ?
  6754. Math.abs( offset.left + dpWidth - viewWidth ) : 0 );
  6755. offset.top -= Math.min( offset.top, ( offset.top + dpHeight > viewHeight && viewHeight > dpHeight ) ?
  6756. Math.abs( dpHeight + inputHeight ) : 0 );
  6757. return offset;
  6758. },
  6759. /* Find an object's position on the screen. */
  6760. _findPos: function( obj ) {
  6761. var position,
  6762. inst = this._getInst( obj ),
  6763. isRTL = this._get( inst, "isRTL" );
  6764. while ( obj && ( obj.type === "hidden" || obj.nodeType !== 1 || $.expr.filters.hidden( obj ) ) ) {
  6765. obj = obj[ isRTL ? "previousSibling" : "nextSibling" ];
  6766. }
  6767. position = $( obj ).offset();
  6768. return [ position.left, position.top ];
  6769. },
  6770. /* Hide the date picker from view.
  6771. * @param input element - the input field attached to the date picker
  6772. */
  6773. _hideDatepicker: function( input ) {
  6774. var showAnim, duration, postProcess, onClose,
  6775. inst = this._curInst;
  6776. if ( !inst || ( input && inst !== $.data( input, "datepicker" ) ) ) {
  6777. return;
  6778. }
  6779. if ( this._datepickerShowing ) {
  6780. showAnim = this._get( inst, "showAnim" );
  6781. duration = this._get( inst, "duration" );
  6782. postProcess = function() {
  6783. $.datepicker._tidyDialog( inst );
  6784. };
  6785. // DEPRECATED: after BC for 1.8.x $.effects[ showAnim ] is not needed
  6786. if ( $.effects && ( $.effects.effect[ showAnim ] || $.effects[ showAnim ] ) ) {
  6787. inst.dpDiv.hide( showAnim, $.datepicker._get( inst, "showOptions" ), duration, postProcess );
  6788. } else {
  6789. inst.dpDiv[ ( showAnim === "slideDown" ? "slideUp" :
  6790. ( showAnim === "fadeIn" ? "fadeOut" : "hide" ) ) ]( ( showAnim ? duration : null ), postProcess );
  6791. }
  6792. if ( !showAnim ) {
  6793. postProcess();
  6794. }
  6795. this._datepickerShowing = false;
  6796. onClose = this._get( inst, "onClose" );
  6797. if ( onClose ) {
  6798. onClose.apply( ( inst.input ? inst.input[ 0 ] : null ), [ ( inst.input ? inst.input.val() : "" ), inst ] );
  6799. }
  6800. this._lastInput = null;
  6801. if ( this._inDialog ) {
  6802. this._dialogInput.css( { position: "absolute", left: "0", top: "-100px" } );
  6803. if ( $.blockUI ) {
  6804. $.unblockUI();
  6805. $( "body" ).append( this.dpDiv );
  6806. }
  6807. }
  6808. this._inDialog = false;
  6809. }
  6810. },
  6811. /* Tidy up after a dialog display. */
  6812. _tidyDialog: function( inst ) {
  6813. inst.dpDiv.removeClass( this._dialogClass ).off( ".ui-datepicker-calendar" );
  6814. },
  6815. /* Close date picker if clicked elsewhere. */
  6816. _checkExternalClick: function( event ) {
  6817. if ( !$.datepicker._curInst ) {
  6818. return;
  6819. }
  6820. var $target = $( event.target ),
  6821. inst = $.datepicker._getInst( $target[ 0 ] );
  6822. if ( ( ( $target[ 0 ].id !== $.datepicker._mainDivId &&
  6823. $target.parents( "#" + $.datepicker._mainDivId ).length === 0 &&
  6824. !$target.hasClass( $.datepicker.markerClassName ) &&
  6825. !$target.closest( "." + $.datepicker._triggerClass ).length &&
  6826. $.datepicker._datepickerShowing && !( $.datepicker._inDialog && $.blockUI ) ) ) ||
  6827. ( $target.hasClass( $.datepicker.markerClassName ) && $.datepicker._curInst !== inst ) ) {
  6828. $.datepicker._hideDatepicker();
  6829. }
  6830. },
  6831. /* Adjust one of the date sub-fields. */
  6832. _adjustDate: function( id, offset, period ) {
  6833. var target = $( id ),
  6834. inst = this._getInst( target[ 0 ] );
  6835. if ( this._isDisabledDatepicker( target[ 0 ] ) ) {
  6836. return;
  6837. }
  6838. this._adjustInstDate( inst, offset +
  6839. ( period === "M" ? this._get( inst, "showCurrentAtPos" ) : 0 ), // undo positioning
  6840. period );
  6841. this._updateDatepicker( inst );
  6842. },
  6843. /* Action for current link. */
  6844. _gotoToday: function( id ) {
  6845. var date,
  6846. target = $( id ),
  6847. inst = this._getInst( target[ 0 ] );
  6848. if ( this._get( inst, "gotoCurrent" ) && inst.currentDay ) {
  6849. inst.selectedDay = inst.currentDay;
  6850. inst.drawMonth = inst.selectedMonth = inst.currentMonth;
  6851. inst.drawYear = inst.selectedYear = inst.currentYear;
  6852. } else {
  6853. date = new Date();
  6854. inst.selectedDay = date.getDate();
  6855. inst.drawMonth = inst.selectedMonth = date.getMonth();
  6856. inst.drawYear = inst.selectedYear = date.getFullYear();
  6857. }
  6858. this._notifyChange( inst );
  6859. this._adjustDate( target );
  6860. },
  6861. /* Action for selecting a new month/year. */
  6862. _selectMonthYear: function( id, select, period ) {
  6863. var target = $( id ),
  6864. inst = this._getInst( target[ 0 ] );
  6865. inst[ "selected" + ( period === "M" ? "Month" : "Year" ) ] =
  6866. inst[ "draw" + ( period === "M" ? "Month" : "Year" ) ] =
  6867. parseInt( select.options[ select.selectedIndex ].value, 10 );
  6868. this._notifyChange( inst );
  6869. this._adjustDate( target );
  6870. },
  6871. /* Action for selecting a day. */
  6872. _selectDay: function( id, month, year, td ) {
  6873. var inst,
  6874. target = $( id );
  6875. if ( $( td ).hasClass( this._unselectableClass ) || this._isDisabledDatepicker( target[ 0 ] ) ) {
  6876. return;
  6877. }
  6878. inst = this._getInst( target[ 0 ] );
  6879. inst.selectedDay = inst.currentDay = $( "a", td ).html();
  6880. inst.selectedMonth = inst.currentMonth = month;
  6881. inst.selectedYear = inst.currentYear = year;
  6882. this._selectDate( id, this._formatDate( inst,
  6883. inst.currentDay, inst.currentMonth, inst.currentYear ) );
  6884. },
  6885. /* Erase the input field and hide the date picker. */
  6886. _clearDate: function( id ) {
  6887. var target = $( id );
  6888. this._selectDate( target, "" );
  6889. },
  6890. /* Update the input field with the selected date. */
  6891. _selectDate: function( id, dateStr ) {
  6892. var onSelect,
  6893. target = $( id ),
  6894. inst = this._getInst( target[ 0 ] );
  6895. dateStr = ( dateStr != null ? dateStr : this._formatDate( inst ) );
  6896. if ( inst.input ) {
  6897. inst.input.val( dateStr );
  6898. }
  6899. this._updateAlternate( inst );
  6900. onSelect = this._get( inst, "onSelect" );
  6901. if ( onSelect ) {
  6902. onSelect.apply( ( inst.input ? inst.input[ 0 ] : null ), [ dateStr, inst ] ); // trigger custom callback
  6903. } else if ( inst.input ) {
  6904. inst.input.trigger( "change" ); // fire the change event
  6905. }
  6906. if ( inst.inline ) {
  6907. this._updateDatepicker( inst );
  6908. } else {
  6909. this._hideDatepicker();
  6910. this._lastInput = inst.input[ 0 ];
  6911. if ( typeof( inst.input[ 0 ] ) !== "object" ) {
  6912. inst.input.trigger( "focus" ); // restore focus
  6913. }
  6914. this._lastInput = null;
  6915. }
  6916. },
  6917. /* Update any alternate field to synchronise with the main field. */
  6918. _updateAlternate: function( inst ) {
  6919. var altFormat, date, dateStr,
  6920. altField = this._get( inst, "altField" );
  6921. if ( altField ) { // update alternate field too
  6922. altFormat = this._get( inst, "altFormat" ) || this._get( inst, "dateFormat" );
  6923. date = this._getDate( inst );
  6924. dateStr = this.formatDate( altFormat, date, this._getFormatConfig( inst ) );
  6925. $( altField ).val( dateStr );
  6926. }
  6927. },
  6928. /* Set as beforeShowDay function to prevent selection of weekends.
  6929. * @param date Date - the date to customise
  6930. * @return [boolean, string] - is this date selectable?, what is its CSS class?
  6931. */
  6932. noWeekends: function( date ) {
  6933. var day = date.getDay();
  6934. return [ ( day > 0 && day < 6 ), "" ];
  6935. },
  6936. /* Set as calculateWeek to determine the week of the year based on the ISO 8601 definition.
  6937. * @param date Date - the date to get the week for
  6938. * @return number - the number of the week within the year that contains this date
  6939. */
  6940. iso8601Week: function( date ) {
  6941. var time,
  6942. checkDate = new Date( date.getTime() );
  6943. // Find Thursday of this week starting on Monday
  6944. checkDate.setDate( checkDate.getDate() + 4 - ( checkDate.getDay() || 7 ) );
  6945. time = checkDate.getTime();
  6946. checkDate.setMonth( 0 ); // Compare with Jan 1
  6947. checkDate.setDate( 1 );
  6948. return Math.floor( Math.round( ( time - checkDate ) / 86400000 ) / 7 ) + 1;
  6949. },
  6950. /* Parse a string value into a date object.
  6951. * See formatDate below for the possible formats.
  6952. *
  6953. * @param format string - the expected format of the date
  6954. * @param value string - the date in the above format
  6955. * @param settings Object - attributes include:
  6956. * shortYearCutoff number - the cutoff year for determining the century (optional)
  6957. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  6958. * dayNames string[7] - names of the days from Sunday (optional)
  6959. * monthNamesShort string[12] - abbreviated names of the months (optional)
  6960. * monthNames string[12] - names of the months (optional)
  6961. * @return Date - the extracted date value or null if value is blank
  6962. */
  6963. parseDate: function( format, value, settings ) {
  6964. if ( format == null || value == null ) {
  6965. throw "Invalid arguments";
  6966. }
  6967. value = ( typeof value === "object" ? value.toString() : value + "" );
  6968. if ( value === "" ) {
  6969. return null;
  6970. }
  6971. var iFormat, dim, extra,
  6972. iValue = 0,
  6973. shortYearCutoffTemp = ( settings ? settings.shortYearCutoff : null ) || this._defaults.shortYearCutoff,
  6974. shortYearCutoff = ( typeof shortYearCutoffTemp !== "string" ? shortYearCutoffTemp :
  6975. new Date().getFullYear() % 100 + parseInt( shortYearCutoffTemp, 10 ) ),
  6976. dayNamesShort = ( settings ? settings.dayNamesShort : null ) || this._defaults.dayNamesShort,
  6977. dayNames = ( settings ? settings.dayNames : null ) || this._defaults.dayNames,
  6978. monthNamesShort = ( settings ? settings.monthNamesShort : null ) || this._defaults.monthNamesShort,
  6979. monthNames = ( settings ? settings.monthNames : null ) || this._defaults.monthNames,
  6980. year = -1,
  6981. month = -1,
  6982. day = -1,
  6983. doy = -1,
  6984. literal = false,
  6985. date,
  6986. // Check whether a format character is doubled
  6987. lookAhead = function( match ) {
  6988. var matches = ( iFormat + 1 < format.length && format.charAt( iFormat + 1 ) === match );
  6989. if ( matches ) {
  6990. iFormat++;
  6991. }
  6992. return matches;
  6993. },
  6994. // Extract a number from the string value
  6995. getNumber = function( match ) {
  6996. var isDoubled = lookAhead( match ),
  6997. size = ( match === "@" ? 14 : ( match === "!" ? 20 :
  6998. ( match === "y" && isDoubled ? 4 : ( match === "o" ? 3 : 2 ) ) ) ),
  6999. minSize = ( match === "y" ? size : 1 ),
  7000. digits = new RegExp( "^\\d{" + minSize + "," + size + "}" ),
  7001. num = value.substring( iValue ).match( digits );
  7002. if ( !num ) {
  7003. throw "Missing number at position " + iValue;
  7004. }
  7005. iValue += num[ 0 ].length;
  7006. return parseInt( num[ 0 ], 10 );
  7007. },
  7008. // Extract a name from the string value and convert to an index
  7009. getName = function( match, shortNames, longNames ) {
  7010. var index = -1,
  7011. names = $.map( lookAhead( match ) ? longNames : shortNames, function( v, k ) {
  7012. return [ [ k, v ] ];
  7013. } ).sort( function( a, b ) {
  7014. return -( a[ 1 ].length - b[ 1 ].length );
  7015. } );
  7016. $.each( names, function( i, pair ) {
  7017. var name = pair[ 1 ];
  7018. if ( value.substr( iValue, name.length ).toLowerCase() === name.toLowerCase() ) {
  7019. index = pair[ 0 ];
  7020. iValue += name.length;
  7021. return false;
  7022. }
  7023. } );
  7024. if ( index !== -1 ) {
  7025. return index + 1;
  7026. } else {
  7027. throw "Unknown name at position " + iValue;
  7028. }
  7029. },
  7030. // Confirm that a literal character matches the string value
  7031. checkLiteral = function() {
  7032. if ( value.charAt( iValue ) !== format.charAt( iFormat ) ) {
  7033. throw "Unexpected literal at position " + iValue;
  7034. }
  7035. iValue++;
  7036. };
  7037. for ( iFormat = 0; iFormat < format.length; iFormat++ ) {
  7038. if ( literal ) {
  7039. if ( format.charAt( iFormat ) === "'" && !lookAhead( "'" ) ) {
  7040. literal = false;
  7041. } else {
  7042. checkLiteral();
  7043. }
  7044. } else {
  7045. switch ( format.charAt( iFormat ) ) {
  7046. case "d":
  7047. day = getNumber( "d" );
  7048. break;
  7049. case "D":
  7050. getName( "D", dayNamesShort, dayNames );
  7051. break;
  7052. case "o":
  7053. doy = getNumber( "o" );
  7054. break;
  7055. case "m":
  7056. month = getNumber( "m" );
  7057. break;
  7058. case "M":
  7059. month = getName( "M", monthNamesShort, monthNames );
  7060. break;
  7061. case "y":
  7062. year = getNumber( "y" );
  7063. break;
  7064. case "@":
  7065. date = new Date( getNumber( "@" ) );
  7066. year = date.getFullYear();
  7067. month = date.getMonth() + 1;
  7068. day = date.getDate();
  7069. break;
  7070. case "!":
  7071. date = new Date( ( getNumber( "!" ) - this._ticksTo1970 ) / 10000 );
  7072. year = date.getFullYear();
  7073. month = date.getMonth() + 1;
  7074. day = date.getDate();
  7075. break;
  7076. case "'":
  7077. if ( lookAhead( "'" ) ) {
  7078. checkLiteral();
  7079. } else {
  7080. literal = true;
  7081. }
  7082. break;
  7083. default:
  7084. checkLiteral();
  7085. }
  7086. }
  7087. }
  7088. if ( iValue < value.length ) {
  7089. extra = value.substr( iValue );
  7090. if ( !/^\s+/.test( extra ) ) {
  7091. throw "Extra/unparsed characters found in date: " + extra;
  7092. }
  7093. }
  7094. if ( year === -1 ) {
  7095. year = new Date().getFullYear();
  7096. } else if ( year < 100 ) {
  7097. year += new Date().getFullYear() - new Date().getFullYear() % 100 +
  7098. ( year <= shortYearCutoff ? 0 : -100 );
  7099. }
  7100. if ( doy > -1 ) {
  7101. month = 1;
  7102. day = doy;
  7103. do {
  7104. dim = this._getDaysInMonth( year, month - 1 );
  7105. if ( day <= dim ) {
  7106. break;
  7107. }
  7108. month++;
  7109. day -= dim;
  7110. } while ( true );
  7111. }
  7112. date = this._daylightSavingAdjust( new Date( year, month - 1, day ) );
  7113. if ( date.getFullYear() !== year || date.getMonth() + 1 !== month || date.getDate() !== day ) {
  7114. throw "Invalid date"; // E.g. 31/02/00
  7115. }
  7116. return date;
  7117. },
  7118. /* Standard date formats. */
  7119. ATOM: "yy-mm-dd", // RFC 3339 (ISO 8601)
  7120. COOKIE: "D, dd M yy",
  7121. ISO_8601: "yy-mm-dd",
  7122. RFC_822: "D, d M y",
  7123. RFC_850: "DD, dd-M-y",
  7124. RFC_1036: "D, d M y",
  7125. RFC_1123: "D, d M yy",
  7126. RFC_2822: "D, d M yy",
  7127. RSS: "D, d M y", // RFC 822
  7128. TICKS: "!",
  7129. TIMESTAMP: "@",
  7130. W3C: "yy-mm-dd", // ISO 8601
  7131. _ticksTo1970: ( ( ( 1970 - 1 ) * 365 + Math.floor( 1970 / 4 ) - Math.floor( 1970 / 100 ) +
  7132. Math.floor( 1970 / 400 ) ) * 24 * 60 * 60 * 10000000 ),
  7133. /* Format a date object into a string value.
  7134. * The format can be combinations of the following:
  7135. * d - day of month (no leading zero)
  7136. * dd - day of month (two digit)
  7137. * o - day of year (no leading zeros)
  7138. * oo - day of year (three digit)
  7139. * D - day name short
  7140. * DD - day name long
  7141. * m - month of year (no leading zero)
  7142. * mm - month of year (two digit)
  7143. * M - month name short
  7144. * MM - month name long
  7145. * y - year (two digit)
  7146. * yy - year (four digit)
  7147. * @ - Unix timestamp (ms since 01/01/1970)
  7148. * ! - Windows ticks (100ns since 01/01/0001)
  7149. * "..." - literal text
  7150. * '' - single quote
  7151. *
  7152. * @param format string - the desired format of the date
  7153. * @param date Date - the date value to format
  7154. * @param settings Object - attributes include:
  7155. * dayNamesShort string[7] - abbreviated names of the days from Sunday (optional)
  7156. * dayNames string[7] - names of the days from Sunday (optional)
  7157. * monthNamesShort string[12] - abbreviated names of the months (optional)
  7158. * monthNames string[12] - names of the months (optional)
  7159. * @return string - the date in the above format
  7160. */
  7161. formatDate: function( format, date, settings ) {
  7162. if ( !date ) {
  7163. return "";
  7164. }
  7165. var iFormat,
  7166. dayNamesShort = ( settings ? settings.dayNamesShort : null ) || this._defaults.dayNamesShort,
  7167. dayNames = ( settings ? settings.dayNames : null ) || this._defaults.dayNames,
  7168. monthNamesShort = ( settings ? settings.monthNamesShort : null ) || this._defaults.monthNamesShort,
  7169. monthNames = ( settings ? settings.monthNames : null ) || this._defaults.monthNames,
  7170. // Check whether a format character is doubled
  7171. lookAhead = function( match ) {
  7172. var matches = ( iFormat + 1 < format.length && format.charAt( iFormat + 1 ) === match );
  7173. if ( matches ) {
  7174. iFormat++;
  7175. }
  7176. return matches;
  7177. },
  7178. // Format a number, with leading zero if necessary
  7179. formatNumber = function( match, value, len ) {
  7180. var num = "" + value;
  7181. if ( lookAhead( match ) ) {
  7182. while ( num.length < len ) {
  7183. num = "0" + num;
  7184. }
  7185. }
  7186. return num;
  7187. },
  7188. // Format a name, short or long as requested
  7189. formatName = function( match, value, shortNames, longNames ) {
  7190. return ( lookAhead( match ) ? longNames[ value ] : shortNames[ value ] );
  7191. },
  7192. output = "",
  7193. literal = false;
  7194. if ( date ) {
  7195. for ( iFormat = 0; iFormat < format.length; iFormat++ ) {
  7196. if ( literal ) {
  7197. if ( format.charAt( iFormat ) === "'" && !lookAhead( "'" ) ) {
  7198. literal = false;
  7199. } else {
  7200. output += format.charAt( iFormat );
  7201. }
  7202. } else {
  7203. switch ( format.charAt( iFormat ) ) {
  7204. case "d":
  7205. output += formatNumber( "d", date.getDate(), 2 );
  7206. break;
  7207. case "D":
  7208. output += formatName( "D", date.getDay(), dayNamesShort, dayNames );
  7209. break;
  7210. case "o":
  7211. output += formatNumber( "o",
  7212. Math.round( ( new Date( date.getFullYear(), date.getMonth(), date.getDate() ).getTime() - new Date( date.getFullYear(), 0, 0 ).getTime() ) / 86400000 ), 3 );
  7213. break;
  7214. case "m":
  7215. output += formatNumber( "m", date.getMonth() + 1, 2 );
  7216. break;
  7217. case "M":
  7218. output += formatName( "M", date.getMonth(), monthNamesShort, monthNames );
  7219. break;
  7220. case "y":
  7221. output += ( lookAhead( "y" ) ? date.getFullYear() :
  7222. ( date.getFullYear() % 100 < 10 ? "0" : "" ) + date.getFullYear() % 100 );
  7223. break;
  7224. case "@":
  7225. output += date.getTime();
  7226. break;
  7227. case "!":
  7228. output += date.getTime() * 10000 + this._ticksTo1970;
  7229. break;
  7230. case "'":
  7231. if ( lookAhead( "'" ) ) {
  7232. output += "'";
  7233. } else {
  7234. literal = true;
  7235. }
  7236. break;
  7237. default:
  7238. output += format.charAt( iFormat );
  7239. }
  7240. }
  7241. }
  7242. }
  7243. return output;
  7244. },
  7245. /* Extract all possible characters from the date format. */
  7246. _possibleChars: function( format ) {
  7247. var iFormat,
  7248. chars = "",
  7249. literal = false,
  7250. // Check whether a format character is doubled
  7251. lookAhead = function( match ) {
  7252. var matches = ( iFormat + 1 < format.length && format.charAt( iFormat + 1 ) === match );
  7253. if ( matches ) {
  7254. iFormat++;
  7255. }
  7256. return matches;
  7257. };
  7258. for ( iFormat = 0; iFormat < format.length; iFormat++ ) {
  7259. if ( literal ) {
  7260. if ( format.charAt( iFormat ) === "'" && !lookAhead( "'" ) ) {
  7261. literal = false;
  7262. } else {
  7263. chars += format.charAt( iFormat );
  7264. }
  7265. } else {
  7266. switch ( format.charAt( iFormat ) ) {
  7267. case "d": case "m": case "y": case "@":
  7268. chars += "0123456789";
  7269. break;
  7270. case "D": case "M":
  7271. return null; // Accept anything
  7272. case "'":
  7273. if ( lookAhead( "'" ) ) {
  7274. chars += "'";
  7275. } else {
  7276. literal = true;
  7277. }
  7278. break;
  7279. default:
  7280. chars += format.charAt( iFormat );
  7281. }
  7282. }
  7283. }
  7284. return chars;
  7285. },
  7286. /* Get a setting value, defaulting if necessary. */
  7287. _get: function( inst, name ) {
  7288. return inst.settings[ name ] !== undefined ?
  7289. inst.settings[ name ] : this._defaults[ name ];
  7290. },
  7291. /* Parse existing date and initialise date picker. */
  7292. _setDateFromField: function( inst, noDefault ) {
  7293. if ( inst.input.val() === inst.lastVal ) {
  7294. return;
  7295. }
  7296. var dateFormat = this._get( inst, "dateFormat" ),
  7297. dates = inst.lastVal = inst.input ? inst.input.val() : null,
  7298. defaultDate = this._getDefaultDate( inst ),
  7299. date = defaultDate,
  7300. settings = this._getFormatConfig( inst );
  7301. try {
  7302. date = this.parseDate( dateFormat, dates, settings ) || defaultDate;
  7303. } catch ( event ) {
  7304. dates = ( noDefault ? "" : dates );
  7305. }
  7306. inst.selectedDay = date.getDate();
  7307. inst.drawMonth = inst.selectedMonth = date.getMonth();
  7308. inst.drawYear = inst.selectedYear = date.getFullYear();
  7309. inst.currentDay = ( dates ? date.getDate() : 0 );
  7310. inst.currentMonth = ( dates ? date.getMonth() : 0 );
  7311. inst.currentYear = ( dates ? date.getFullYear() : 0 );
  7312. this._adjustInstDate( inst );
  7313. },
  7314. /* Retrieve the default date shown on opening. */
  7315. _getDefaultDate: function( inst ) {
  7316. return this._restrictMinMax( inst,
  7317. this._determineDate( inst, this._get( inst, "defaultDate" ), new Date() ) );
  7318. },
  7319. /* A date may be specified as an exact value or a relative one. */
  7320. _determineDate: function( inst, date, defaultDate ) {
  7321. var offsetNumeric = function( offset ) {
  7322. var date = new Date();
  7323. date.setDate( date.getDate() + offset );
  7324. return date;
  7325. },
  7326. offsetString = function( offset ) {
  7327. try {
  7328. return $.datepicker.parseDate( $.datepicker._get( inst, "dateFormat" ),
  7329. offset, $.datepicker._getFormatConfig( inst ) );
  7330. }
  7331. catch ( e ) {
  7332. // Ignore
  7333. }
  7334. var date = ( offset.toLowerCase().match( /^c/ ) ?
  7335. $.datepicker._getDate( inst ) : null ) || new Date(),
  7336. year = date.getFullYear(),
  7337. month = date.getMonth(),
  7338. day = date.getDate(),
  7339. pattern = /([+\-]?[0-9]+)\s*(d|D|w|W|m|M|y|Y)?/g,
  7340. matches = pattern.exec( offset );
  7341. while ( matches ) {
  7342. switch ( matches[ 2 ] || "d" ) {
  7343. case "d" : case "D" :
  7344. day += parseInt( matches[ 1 ], 10 ); break;
  7345. case "w" : case "W" :
  7346. day += parseInt( matches[ 1 ], 10 ) * 7; break;
  7347. case "m" : case "M" :
  7348. month += parseInt( matches[ 1 ], 10 );
  7349. day = Math.min( day, $.datepicker._getDaysInMonth( year, month ) );
  7350. break;
  7351. case "y": case "Y" :
  7352. year += parseInt( matches[ 1 ], 10 );
  7353. day = Math.min( day, $.datepicker._getDaysInMonth( year, month ) );
  7354. break;
  7355. }
  7356. matches = pattern.exec( offset );
  7357. }
  7358. return new Date( year, month, day );
  7359. },
  7360. newDate = ( date == null || date === "" ? defaultDate : ( typeof date === "string" ? offsetString( date ) :
  7361. ( typeof date === "number" ? ( isNaN( date ) ? defaultDate : offsetNumeric( date ) ) : new Date( date.getTime() ) ) ) );
  7362. newDate = ( newDate && newDate.toString() === "Invalid Date" ? defaultDate : newDate );
  7363. if ( newDate ) {
  7364. newDate.setHours( 0 );
  7365. newDate.setMinutes( 0 );
  7366. newDate.setSeconds( 0 );
  7367. newDate.setMilliseconds( 0 );
  7368. }
  7369. return this._daylightSavingAdjust( newDate );
  7370. },
  7371. /* Handle switch to/from daylight saving.
  7372. * Hours may be non-zero on daylight saving cut-over:
  7373. * > 12 when midnight changeover, but then cannot generate
  7374. * midnight datetime, so jump to 1AM, otherwise reset.
  7375. * @param date (Date) the date to check
  7376. * @return (Date) the corrected date
  7377. */
  7378. _daylightSavingAdjust: function( date ) {
  7379. if ( !date ) {
  7380. return null;
  7381. }
  7382. date.setHours( date.getHours() > 12 ? date.getHours() + 2 : 0 );
  7383. return date;
  7384. },
  7385. /* Set the date(s) directly. */
  7386. _setDate: function( inst, date, noChange ) {
  7387. var clear = !date,
  7388. origMonth = inst.selectedMonth,
  7389. origYear = inst.selectedYear,
  7390. newDate = this._restrictMinMax( inst, this._determineDate( inst, date, new Date() ) );
  7391. inst.selectedDay = inst.currentDay = newDate.getDate();
  7392. inst.drawMonth = inst.selectedMonth = inst.currentMonth = newDate.getMonth();
  7393. inst.drawYear = inst.selectedYear = inst.currentYear = newDate.getFullYear();
  7394. if ( ( origMonth !== inst.selectedMonth || origYear !== inst.selectedYear ) && !noChange ) {
  7395. this._notifyChange( inst );
  7396. }
  7397. this._adjustInstDate( inst );
  7398. if ( inst.input ) {
  7399. inst.input.val( clear ? "" : this._formatDate( inst ) );
  7400. }
  7401. },
  7402. /* Retrieve the date(s) directly. */
  7403. _getDate: function( inst ) {
  7404. var startDate = ( !inst.currentYear || ( inst.input && inst.input.val() === "" ) ? null :
  7405. this._daylightSavingAdjust( new Date(
  7406. inst.currentYear, inst.currentMonth, inst.currentDay ) ) );
  7407. return startDate;
  7408. },
  7409. /* Attach the onxxx handlers. These are declared statically so
  7410. * they work with static code transformers like Caja.
  7411. */
  7412. _attachHandlers: function( inst ) {
  7413. var stepMonths = this._get( inst, "stepMonths" ),
  7414. id = "#" + inst.id.replace( /\\\\/g, "\\" );
  7415. inst.dpDiv.find( "[data-handler]" ).map( function() {
  7416. var handler = {
  7417. prev: function() {
  7418. $.datepicker._adjustDate( id, -stepMonths, "M" );
  7419. },
  7420. next: function() {
  7421. $.datepicker._adjustDate( id, +stepMonths, "M" );
  7422. },
  7423. hide: function() {
  7424. $.datepicker._hideDatepicker();
  7425. },
  7426. today: function() {
  7427. $.datepicker._gotoToday( id );
  7428. },
  7429. selectDay: function() {
  7430. $.datepicker._selectDay( id, +this.getAttribute( "data-month" ), +this.getAttribute( "data-year" ), this );
  7431. return false;
  7432. },
  7433. selectMonth: function() {
  7434. $.datepicker._selectMonthYear( id, this, "M" );
  7435. return false;
  7436. },
  7437. selectYear: function() {
  7438. $.datepicker._selectMonthYear( id, this, "Y" );
  7439. return false;
  7440. }
  7441. };
  7442. $( this ).on( this.getAttribute( "data-event" ), handler[ this.getAttribute( "data-handler" ) ] );
  7443. } );
  7444. },
  7445. /* Generate the HTML for the current state of the date picker. */
  7446. _generateHTML: function( inst ) {
  7447. var maxDraw, prevText, prev, nextText, next, currentText, gotoDate,
  7448. controls, buttonPanel, firstDay, showWeek, dayNames, dayNamesMin,
  7449. monthNames, monthNamesShort, beforeShowDay, showOtherMonths,
  7450. selectOtherMonths, defaultDate, html, dow, row, group, col, selectedDate,
  7451. cornerClass, calender, thead, day, daysInMonth, leadDays, curRows, numRows,
  7452. printDate, dRow, tbody, daySettings, otherMonth, unselectable,
  7453. tempDate = new Date(),
  7454. today = this._daylightSavingAdjust(
  7455. new Date( tempDate.getFullYear(), tempDate.getMonth(), tempDate.getDate() ) ), // clear time
  7456. isRTL = this._get( inst, "isRTL" ),
  7457. showButtonPanel = this._get( inst, "showButtonPanel" ),
  7458. hideIfNoPrevNext = this._get( inst, "hideIfNoPrevNext" ),
  7459. navigationAsDateFormat = this._get( inst, "navigationAsDateFormat" ),
  7460. numMonths = this._getNumberOfMonths( inst ),
  7461. showCurrentAtPos = this._get( inst, "showCurrentAtPos" ),
  7462. stepMonths = this._get( inst, "stepMonths" ),
  7463. isMultiMonth = ( numMonths[ 0 ] !== 1 || numMonths[ 1 ] !== 1 ),
  7464. currentDate = this._daylightSavingAdjust( ( !inst.currentDay ? new Date( 9999, 9, 9 ) :
  7465. new Date( inst.currentYear, inst.currentMonth, inst.currentDay ) ) ),
  7466. minDate = this._getMinMaxDate( inst, "min" ),
  7467. maxDate = this._getMinMaxDate( inst, "max" ),
  7468. drawMonth = inst.drawMonth - showCurrentAtPos,
  7469. drawYear = inst.drawYear;
  7470. if ( drawMonth < 0 ) {
  7471. drawMonth += 12;
  7472. drawYear--;
  7473. }
  7474. if ( maxDate ) {
  7475. maxDraw = this._daylightSavingAdjust( new Date( maxDate.getFullYear(),
  7476. maxDate.getMonth() - ( numMonths[ 0 ] * numMonths[ 1 ] ) + 1, maxDate.getDate() ) );
  7477. maxDraw = ( minDate && maxDraw < minDate ? minDate : maxDraw );
  7478. while ( this._daylightSavingAdjust( new Date( drawYear, drawMonth, 1 ) ) > maxDraw ) {
  7479. drawMonth--;
  7480. if ( drawMonth < 0 ) {
  7481. drawMonth = 11;
  7482. drawYear--;
  7483. }
  7484. }
  7485. }
  7486. inst.drawMonth = drawMonth;
  7487. inst.drawYear = drawYear;
  7488. prevText = this._get( inst, "prevText" );
  7489. prevText = ( !navigationAsDateFormat ? prevText : this.formatDate( prevText,
  7490. this._daylightSavingAdjust( new Date( drawYear, drawMonth - stepMonths, 1 ) ),
  7491. this._getFormatConfig( inst ) ) );
  7492. prev = ( this._canAdjustMonth( inst, -1, drawYear, drawMonth ) ?
  7493. "<a class='ui-datepicker-prev ui-corner-all' data-handler='prev' data-event='click'" +
  7494. " title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w" ) + "'>" + prevText + "</span></a>" :
  7495. ( hideIfNoPrevNext ? "" : "<a class='ui-datepicker-prev ui-corner-all ui-state-disabled' title='" + prevText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "e" : "w" ) + "'>" + prevText + "</span></a>" ) );
  7496. nextText = this._get( inst, "nextText" );
  7497. nextText = ( !navigationAsDateFormat ? nextText : this.formatDate( nextText,
  7498. this._daylightSavingAdjust( new Date( drawYear, drawMonth + stepMonths, 1 ) ),
  7499. this._getFormatConfig( inst ) ) );
  7500. next = ( this._canAdjustMonth( inst, +1, drawYear, drawMonth ) ?
  7501. "<a class='ui-datepicker-next ui-corner-all' data-handler='next' data-event='click'" +
  7502. " title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e" ) + "'>" + nextText + "</span></a>" :
  7503. ( hideIfNoPrevNext ? "" : "<a class='ui-datepicker-next ui-corner-all ui-state-disabled' title='" + nextText + "'><span class='ui-icon ui-icon-circle-triangle-" + ( isRTL ? "w" : "e" ) + "'>" + nextText + "</span></a>" ) );
  7504. currentText = this._get( inst, "currentText" );
  7505. gotoDate = ( this._get( inst, "gotoCurrent" ) && inst.currentDay ? currentDate : today );
  7506. currentText = ( !navigationAsDateFormat ? currentText :
  7507. this.formatDate( currentText, gotoDate, this._getFormatConfig( inst ) ) );
  7508. controls = ( !inst.inline ? "<button type='button' class='ui-datepicker-close ui-state-default ui-priority-primary ui-corner-all' data-handler='hide' data-event='click'>" +
  7509. this._get( inst, "closeText" ) + "</button>" : "" );
  7510. buttonPanel = ( showButtonPanel ) ? "<div class='ui-datepicker-buttonpane ui-widget-content'>" + ( isRTL ? controls : "" ) +
  7511. ( this._isInRange( inst, gotoDate ) ? "<button type='button' class='ui-datepicker-current ui-state-default ui-priority-secondary ui-corner-all' data-handler='today' data-event='click'" +
  7512. ">" + currentText + "</button>" : "" ) + ( isRTL ? "" : controls ) + "</div>" : "";
  7513. firstDay = parseInt( this._get( inst, "firstDay" ), 10 );
  7514. firstDay = ( isNaN( firstDay ) ? 0 : firstDay );
  7515. showWeek = this._get( inst, "showWeek" );
  7516. dayNames = this._get( inst, "dayNames" );
  7517. dayNamesMin = this._get( inst, "dayNamesMin" );
  7518. monthNames = this._get( inst, "monthNames" );
  7519. monthNamesShort = this._get( inst, "monthNamesShort" );
  7520. beforeShowDay = this._get( inst, "beforeShowDay" );
  7521. showOtherMonths = this._get( inst, "showOtherMonths" );
  7522. selectOtherMonths = this._get( inst, "selectOtherMonths" );
  7523. defaultDate = this._getDefaultDate( inst );
  7524. html = "";
  7525. for ( row = 0; row < numMonths[ 0 ]; row++ ) {
  7526. group = "";
  7527. this.maxRows = 4;
  7528. for ( col = 0; col < numMonths[ 1 ]; col++ ) {
  7529. selectedDate = this._daylightSavingAdjust( new Date( drawYear, drawMonth, inst.selectedDay ) );
  7530. cornerClass = " ui-corner-all";
  7531. calender = "";
  7532. if ( isMultiMonth ) {
  7533. calender += "<div class='ui-datepicker-group";
  7534. if ( numMonths[ 1 ] > 1 ) {
  7535. switch ( col ) {
  7536. case 0: calender += " ui-datepicker-group-first";
  7537. cornerClass = " ui-corner-" + ( isRTL ? "right" : "left" ); break;
  7538. case numMonths[ 1 ] - 1: calender += " ui-datepicker-group-last";
  7539. cornerClass = " ui-corner-" + ( isRTL ? "left" : "right" ); break;
  7540. default: calender += " ui-datepicker-group-middle"; cornerClass = ""; break;
  7541. }
  7542. }
  7543. calender += "'>";
  7544. }
  7545. calender += "<div class='ui-datepicker-header ui-widget-header ui-helper-clearfix" + cornerClass + "'>" +
  7546. ( /all|left/.test( cornerClass ) && row === 0 ? ( isRTL ? next : prev ) : "" ) +
  7547. ( /all|right/.test( cornerClass ) && row === 0 ? ( isRTL ? prev : next ) : "" ) +
  7548. this._generateMonthYearHeader( inst, drawMonth, drawYear, minDate, maxDate,
  7549. row > 0 || col > 0, monthNames, monthNamesShort ) + // draw month headers
  7550. "</div><table class='ui-datepicker-calendar'><thead>" +
  7551. "<tr>";
  7552. thead = ( showWeek ? "<th class='ui-datepicker-week-col'>" + this._get( inst, "weekHeader" ) + "</th>" : "" );
  7553. for ( dow = 0; dow < 7; dow++ ) { // days of the week
  7554. day = ( dow + firstDay ) % 7;
  7555. thead += "<th scope='col'" + ( ( dow + firstDay + 6 ) % 7 >= 5 ? " class='ui-datepicker-week-end'" : "" ) + ">" +
  7556. "<span title='" + dayNames[ day ] + "'>" + dayNamesMin[ day ] + "</span></th>";
  7557. }
  7558. calender += thead + "</tr></thead><tbody>";
  7559. daysInMonth = this._getDaysInMonth( drawYear, drawMonth );
  7560. if ( drawYear === inst.selectedYear && drawMonth === inst.selectedMonth ) {
  7561. inst.selectedDay = Math.min( inst.selectedDay, daysInMonth );
  7562. }
  7563. leadDays = ( this._getFirstDayOfMonth( drawYear, drawMonth ) - firstDay + 7 ) % 7;
  7564. curRows = Math.ceil( ( leadDays + daysInMonth ) / 7 ); // calculate the number of rows to generate
  7565. numRows = ( isMultiMonth ? this.maxRows > curRows ? this.maxRows : curRows : curRows ); //If multiple months, use the higher number of rows (see #7043)
  7566. this.maxRows = numRows;
  7567. printDate = this._daylightSavingAdjust( new Date( drawYear, drawMonth, 1 - leadDays ) );
  7568. for ( dRow = 0; dRow < numRows; dRow++ ) { // create date picker rows
  7569. calender += "<tr>";
  7570. tbody = ( !showWeek ? "" : "<td class='ui-datepicker-week-col'>" +
  7571. this._get( inst, "calculateWeek" )( printDate ) + "</td>" );
  7572. for ( dow = 0; dow < 7; dow++ ) { // create date picker days
  7573. daySettings = ( beforeShowDay ?
  7574. beforeShowDay.apply( ( inst.input ? inst.input[ 0 ] : null ), [ printDate ] ) : [ true, "" ] );
  7575. otherMonth = ( printDate.getMonth() !== drawMonth );
  7576. unselectable = ( otherMonth && !selectOtherMonths ) || !daySettings[ 0 ] ||
  7577. ( minDate && printDate < minDate ) || ( maxDate && printDate > maxDate );
  7578. tbody += "<td class='" +
  7579. ( ( dow + firstDay + 6 ) % 7 >= 5 ? " ui-datepicker-week-end" : "" ) + // highlight weekends
  7580. ( otherMonth ? " ui-datepicker-other-month" : "" ) + // highlight days from other months
  7581. ( ( printDate.getTime() === selectedDate.getTime() && drawMonth === inst.selectedMonth && inst._keyEvent ) || // user pressed key
  7582. ( defaultDate.getTime() === printDate.getTime() && defaultDate.getTime() === selectedDate.getTime() ) ?
  7583. // or defaultDate is current printedDate and defaultDate is selectedDate
  7584. " " + this._dayOverClass : "" ) + // highlight selected day
  7585. ( unselectable ? " " + this._unselectableClass + " ui-state-disabled" : "" ) + // highlight unselectable days
  7586. ( otherMonth && !showOtherMonths ? "" : " " + daySettings[ 1 ] + // highlight custom dates
  7587. ( printDate.getTime() === currentDate.getTime() ? " " + this._currentClass : "" ) + // highlight selected day
  7588. ( printDate.getTime() === today.getTime() ? " ui-datepicker-today" : "" ) ) + "'" + // highlight today (if different)
  7589. ( ( !otherMonth || showOtherMonths ) && daySettings[ 2 ] ? " title='" + daySettings[ 2 ].replace( /'/g, "&#39;" ) + "'" : "" ) + // cell title
  7590. ( unselectable ? "" : " data-handler='selectDay' data-event='click' data-month='" + printDate.getMonth() + "' data-year='" + printDate.getFullYear() + "'" ) + ">" + // actions
  7591. ( otherMonth && !showOtherMonths ? "&#xa0;" : // display for other months
  7592. ( unselectable ? "<span class='ui-state-default'>" + printDate.getDate() + "</span>" : "<a class='ui-state-default" +
  7593. ( printDate.getTime() === today.getTime() ? " ui-state-highlight" : "" ) +
  7594. ( printDate.getTime() === currentDate.getTime() ? " ui-state-active" : "" ) + // highlight selected day
  7595. ( otherMonth ? " ui-priority-secondary" : "" ) + // distinguish dates from other months
  7596. "' href='#'>" + printDate.getDate() + "</a>" ) ) + "</td>"; // display selectable date
  7597. printDate.setDate( printDate.getDate() + 1 );
  7598. printDate = this._daylightSavingAdjust( printDate );
  7599. }
  7600. calender += tbody + "</tr>";
  7601. }
  7602. drawMonth++;
  7603. if ( drawMonth > 11 ) {
  7604. drawMonth = 0;
  7605. drawYear++;
  7606. }
  7607. calender += "</tbody></table>" + ( isMultiMonth ? "</div>" +
  7608. ( ( numMonths[ 0 ] > 0 && col === numMonths[ 1 ] - 1 ) ? "<div class='ui-datepicker-row-break'></div>" : "" ) : "" );
  7609. group += calender;
  7610. }
  7611. html += group;
  7612. }
  7613. html += buttonPanel;
  7614. inst._keyEvent = false;
  7615. return html;
  7616. },
  7617. /* Generate the month and year header. */
  7618. _generateMonthYearHeader: function( inst, drawMonth, drawYear, minDate, maxDate,
  7619. secondary, monthNames, monthNamesShort ) {
  7620. var inMinYear, inMaxYear, month, years, thisYear, determineYear, year, endYear,
  7621. changeMonth = this._get( inst, "changeMonth" ),
  7622. changeYear = this._get( inst, "changeYear" ),
  7623. showMonthAfterYear = this._get( inst, "showMonthAfterYear" ),
  7624. html = "<div class='ui-datepicker-title'>",
  7625. monthHtml = "";
  7626. // Month selection
  7627. if ( secondary || !changeMonth ) {
  7628. monthHtml += "<span class='ui-datepicker-month'>" + monthNames[ drawMonth ] + "</span>";
  7629. } else {
  7630. inMinYear = ( minDate && minDate.getFullYear() === drawYear );
  7631. inMaxYear = ( maxDate && maxDate.getFullYear() === drawYear );
  7632. monthHtml += "<select class='ui-datepicker-month' data-handler='selectMonth' data-event='change'>";
  7633. for ( month = 0; month < 12; month++ ) {
  7634. if ( ( !inMinYear || month >= minDate.getMonth() ) && ( !inMaxYear || month <= maxDate.getMonth() ) ) {
  7635. monthHtml += "<option value='" + month + "'" +
  7636. ( month === drawMonth ? " selected='selected'" : "" ) +
  7637. ">" + monthNamesShort[ month ] + "</option>";
  7638. }
  7639. }
  7640. monthHtml += "</select>";
  7641. }
  7642. if ( !showMonthAfterYear ) {
  7643. html += monthHtml + ( secondary || !( changeMonth && changeYear ) ? "&#xa0;" : "" );
  7644. }
  7645. // Year selection
  7646. if ( !inst.yearshtml ) {
  7647. inst.yearshtml = "";
  7648. if ( secondary || !changeYear ) {
  7649. html += "<span class='ui-datepicker-year'>" + drawYear + "</span>";
  7650. } else {
  7651. // determine range of years to display
  7652. years = this._get( inst, "yearRange" ).split( ":" );
  7653. thisYear = new Date().getFullYear();
  7654. determineYear = function( value ) {
  7655. var year = ( value.match( /c[+\-].*/ ) ? drawYear + parseInt( value.substring( 1 ), 10 ) :
  7656. ( value.match( /[+\-].*/ ) ? thisYear + parseInt( value, 10 ) :
  7657. parseInt( value, 10 ) ) );
  7658. return ( isNaN( year ) ? thisYear : year );
  7659. };
  7660. year = determineYear( years[ 0 ] );
  7661. endYear = Math.max( year, determineYear( years[ 1 ] || "" ) );
  7662. year = ( minDate ? Math.max( year, minDate.getFullYear() ) : year );
  7663. endYear = ( maxDate ? Math.min( endYear, maxDate.getFullYear() ) : endYear );
  7664. inst.yearshtml += "<select class='ui-datepicker-year' data-handler='selectYear' data-event='change'>";
  7665. for ( ; year <= endYear; year++ ) {
  7666. inst.yearshtml += "<option value='" + year + "'" +
  7667. ( year === drawYear ? " selected='selected'" : "" ) +
  7668. ">" + year + "</option>";
  7669. }
  7670. inst.yearshtml += "</select>";
  7671. html += inst.yearshtml;
  7672. inst.yearshtml = null;
  7673. }
  7674. }
  7675. html += this._get( inst, "yearSuffix" );
  7676. if ( showMonthAfterYear ) {
  7677. html += ( secondary || !( changeMonth && changeYear ) ? "&#xa0;" : "" ) + monthHtml;
  7678. }
  7679. html += "</div>"; // Close datepicker_header
  7680. return html;
  7681. },
  7682. /* Adjust one of the date sub-fields. */
  7683. _adjustInstDate: function( inst, offset, period ) {
  7684. var year = inst.selectedYear + ( period === "Y" ? offset : 0 ),
  7685. month = inst.selectedMonth + ( period === "M" ? offset : 0 ),
  7686. day = Math.min( inst.selectedDay, this._getDaysInMonth( year, month ) ) + ( period === "D" ? offset : 0 ),
  7687. date = this._restrictMinMax( inst, this._daylightSavingAdjust( new Date( year, month, day ) ) );
  7688. inst.selectedDay = date.getDate();
  7689. inst.drawMonth = inst.selectedMonth = date.getMonth();
  7690. inst.drawYear = inst.selectedYear = date.getFullYear();
  7691. if ( period === "M" || period === "Y" ) {
  7692. this._notifyChange( inst );
  7693. }
  7694. },
  7695. /* Ensure a date is within any min/max bounds. */
  7696. _restrictMinMax: function( inst, date ) {
  7697. var minDate = this._getMinMaxDate( inst, "min" ),
  7698. maxDate = this._getMinMaxDate( inst, "max" ),
  7699. newDate = ( minDate && date < minDate ? minDate : date );
  7700. return ( maxDate && newDate > maxDate ? maxDate : newDate );
  7701. },
  7702. /* Notify change of month/year. */
  7703. _notifyChange: function( inst ) {
  7704. var onChange = this._get( inst, "onChangeMonthYear" );
  7705. if ( onChange ) {
  7706. onChange.apply( ( inst.input ? inst.input[ 0 ] : null ),
  7707. [ inst.selectedYear, inst.selectedMonth + 1, inst ] );
  7708. }
  7709. },
  7710. /* Determine the number of months to show. */
  7711. _getNumberOfMonths: function( inst ) {
  7712. var numMonths = this._get( inst, "numberOfMonths" );
  7713. return ( numMonths == null ? [ 1, 1 ] : ( typeof numMonths === "number" ? [ 1, numMonths ] : numMonths ) );
  7714. },
  7715. /* Determine the current maximum date - ensure no time components are set. */
  7716. _getMinMaxDate: function( inst, minMax ) {
  7717. return this._determineDate( inst, this._get( inst, minMax + "Date" ), null );
  7718. },
  7719. /* Find the number of days in a given month. */
  7720. _getDaysInMonth: function( year, month ) {
  7721. return 32 - this._daylightSavingAdjust( new Date( year, month, 32 ) ).getDate();
  7722. },
  7723. /* Find the day of the week of the first of a month. */
  7724. _getFirstDayOfMonth: function( year, month ) {
  7725. return new Date( year, month, 1 ).getDay();
  7726. },
  7727. /* Determines if we should allow a "next/prev" month display change. */
  7728. _canAdjustMonth: function( inst, offset, curYear, curMonth ) {
  7729. var numMonths = this._getNumberOfMonths( inst ),
  7730. date = this._daylightSavingAdjust( new Date( curYear,
  7731. curMonth + ( offset < 0 ? offset : numMonths[ 0 ] * numMonths[ 1 ] ), 1 ) );
  7732. if ( offset < 0 ) {
  7733. date.setDate( this._getDaysInMonth( date.getFullYear(), date.getMonth() ) );
  7734. }
  7735. return this._isInRange( inst, date );
  7736. },
  7737. /* Is the given date in the accepted range? */
  7738. _isInRange: function( inst, date ) {
  7739. var yearSplit, currentYear,
  7740. minDate = this._getMinMaxDate( inst, "min" ),
  7741. maxDate = this._getMinMaxDate( inst, "max" ),
  7742. minYear = null,
  7743. maxYear = null,
  7744. years = this._get( inst, "yearRange" );
  7745. if ( years ) {
  7746. yearSplit = years.split( ":" );
  7747. currentYear = new Date().getFullYear();
  7748. minYear = parseInt( yearSplit[ 0 ], 10 );
  7749. maxYear = parseInt( yearSplit[ 1 ], 10 );
  7750. if ( yearSplit[ 0 ].match( /[+\-].*/ ) ) {
  7751. minYear += currentYear;
  7752. }
  7753. if ( yearSplit[ 1 ].match( /[+\-].*/ ) ) {
  7754. maxYear += currentYear;
  7755. }
  7756. }
  7757. return ( ( !minDate || date.getTime() >= minDate.getTime() ) &&
  7758. ( !maxDate || date.getTime() <= maxDate.getTime() ) &&
  7759. ( !minYear || date.getFullYear() >= minYear ) &&
  7760. ( !maxYear || date.getFullYear() <= maxYear ) );
  7761. },
  7762. /* Provide the configuration settings for formatting/parsing. */
  7763. _getFormatConfig: function( inst ) {
  7764. var shortYearCutoff = this._get( inst, "shortYearCutoff" );
  7765. shortYearCutoff = ( typeof shortYearCutoff !== "string" ? shortYearCutoff :
  7766. new Date().getFullYear() % 100 + parseInt( shortYearCutoff, 10 ) );
  7767. return { shortYearCutoff: shortYearCutoff,
  7768. dayNamesShort: this._get( inst, "dayNamesShort" ), dayNames: this._get( inst, "dayNames" ),
  7769. monthNamesShort: this._get( inst, "monthNamesShort" ), monthNames: this._get( inst, "monthNames" ) };
  7770. },
  7771. /* Format the given date for display. */
  7772. _formatDate: function( inst, day, month, year ) {
  7773. if ( !day ) {
  7774. inst.currentDay = inst.selectedDay;
  7775. inst.currentMonth = inst.selectedMonth;
  7776. inst.currentYear = inst.selectedYear;
  7777. }
  7778. var date = ( day ? ( typeof day === "object" ? day :
  7779. this._daylightSavingAdjust( new Date( year, month, day ) ) ) :
  7780. this._daylightSavingAdjust( new Date( inst.currentYear, inst.currentMonth, inst.currentDay ) ) );
  7781. return this.formatDate( this._get( inst, "dateFormat" ), date, this._getFormatConfig( inst ) );
  7782. }
  7783. } );
  7784. /*
  7785. * Bind hover events for datepicker elements.
  7786. * Done via delegate so the binding only occurs once in the lifetime of the parent div.
  7787. * Global datepicker_instActive, set by _updateDatepicker allows the handlers to find their way back to the active picker.
  7788. */
  7789. function datepicker_bindHover( dpDiv ) {
  7790. var selector = "button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a";
  7791. return dpDiv.on( "mouseout", selector, function() {
  7792. $( this ).removeClass( "ui-state-hover" );
  7793. if ( this.className.indexOf( "ui-datepicker-prev" ) !== -1 ) {
  7794. $( this ).removeClass( "ui-datepicker-prev-hover" );
  7795. }
  7796. if ( this.className.indexOf( "ui-datepicker-next" ) !== -1 ) {
  7797. $( this ).removeClass( "ui-datepicker-next-hover" );
  7798. }
  7799. } )
  7800. .on( "mouseover", selector, datepicker_handleMouseover );
  7801. }
  7802. function datepicker_handleMouseover() {
  7803. if ( !$.datepicker._isDisabledDatepicker( datepicker_instActive.inline ? datepicker_instActive.dpDiv.parent()[ 0 ] : datepicker_instActive.input[ 0 ] ) ) {
  7804. $( this ).parents( ".ui-datepicker-calendar" ).find( "a" ).removeClass( "ui-state-hover" );
  7805. $( this ).addClass( "ui-state-hover" );
  7806. if ( this.className.indexOf( "ui-datepicker-prev" ) !== -1 ) {
  7807. $( this ).addClass( "ui-datepicker-prev-hover" );
  7808. }
  7809. if ( this.className.indexOf( "ui-datepicker-next" ) !== -1 ) {
  7810. $( this ).addClass( "ui-datepicker-next-hover" );
  7811. }
  7812. }
  7813. }
  7814. /* jQuery extend now ignores nulls! */
  7815. function datepicker_extendRemove( target, props ) {
  7816. $.extend( target, props );
  7817. for ( var name in props ) {
  7818. if ( props[ name ] == null ) {
  7819. target[ name ] = props[ name ];
  7820. }
  7821. }
  7822. return target;
  7823. }
  7824. /* Invoke the datepicker functionality.
  7825. @param options string - a command, optionally followed by additional parameters or
  7826. Object - settings for attaching new datepicker functionality
  7827. @return jQuery object */
  7828. $.fn.datepicker = function( options ) {
  7829. /* Verify an empty collection wasn't passed - Fixes #6976 */
  7830. if ( !this.length ) {
  7831. return this;
  7832. }
  7833. /* Initialise the date picker. */
  7834. if ( !$.datepicker.initialized ) {
  7835. $( document ).on( "mousedown", $.datepicker._checkExternalClick );
  7836. $.datepicker.initialized = true;
  7837. }
  7838. /* Append datepicker main container to body if not exist. */
  7839. if ( $( "#" + $.datepicker._mainDivId ).length === 0 ) {
  7840. $( "body" ).append( $.datepicker.dpDiv );
  7841. }
  7842. var otherArgs = Array.prototype.slice.call( arguments, 1 );
  7843. if ( typeof options === "string" && ( options === "isDisabled" || options === "getDate" || options === "widget" ) ) {
  7844. return $.datepicker[ "_" + options + "Datepicker" ].
  7845. apply( $.datepicker, [ this[ 0 ] ].concat( otherArgs ) );
  7846. }
  7847. if ( options === "option" && arguments.length === 2 && typeof arguments[ 1 ] === "string" ) {
  7848. return $.datepicker[ "_" + options + "Datepicker" ].
  7849. apply( $.datepicker, [ this[ 0 ] ].concat( otherArgs ) );
  7850. }
  7851. return this.each( function() {
  7852. typeof options === "string" ?
  7853. $.datepicker[ "_" + options + "Datepicker" ].
  7854. apply( $.datepicker, [ this ].concat( otherArgs ) ) :
  7855. $.datepicker._attachDatepicker( this, options );
  7856. } );
  7857. };
  7858. $.datepicker = new Datepicker(); // singleton instance
  7859. $.datepicker.initialized = false;
  7860. $.datepicker.uuid = new Date().getTime();
  7861. $.datepicker.version = "1.12.1";
  7862. var widgetsDatepicker = $.datepicker;
  7863. // This file is deprecated
  7864. var ie = $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
  7865. /*!
  7866. * jQuery UI Mouse 1.12.1
  7867. * http://jqueryui.com
  7868. *
  7869. * Copyright jQuery Foundation and other contributors
  7870. * Released under the MIT license.
  7871. * http://jquery.org/license
  7872. */
  7873. //>>label: Mouse
  7874. //>>group: Widgets
  7875. //>>description: Abstracts mouse-based interactions to assist in creating certain widgets.
  7876. //>>docs: http://api.jqueryui.com/mouse/
  7877. var mouseHandled = false;
  7878. $( document ).on( "mouseup", function() {
  7879. mouseHandled = false;
  7880. } );
  7881. var widgetsMouse = $.widget( "ui.mouse", {
  7882. version: "1.12.1",
  7883. options: {
  7884. cancel: "input, textarea, button, select, option",
  7885. distance: 1,
  7886. delay: 0
  7887. },
  7888. _mouseInit: function() {
  7889. var that = this;
  7890. this.element
  7891. .on( "mousedown." + this.widgetName, function( event ) {
  7892. return that._mouseDown( event );
  7893. } )
  7894. .on( "click." + this.widgetName, function( event ) {
  7895. if ( true === $.data( event.target, that.widgetName + ".preventClickEvent" ) ) {
  7896. $.removeData( event.target, that.widgetName + ".preventClickEvent" );
  7897. event.stopImmediatePropagation();
  7898. return false;
  7899. }
  7900. } );
  7901. this.started = false;
  7902. },
  7903. // TODO: make sure destroying one instance of mouse doesn't mess with
  7904. // other instances of mouse
  7905. _mouseDestroy: function() {
  7906. this.element.off( "." + this.widgetName );
  7907. if ( this._mouseMoveDelegate ) {
  7908. this.document
  7909. .off( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  7910. .off( "mouseup." + this.widgetName, this._mouseUpDelegate );
  7911. }
  7912. },
  7913. _mouseDown: function( event ) {
  7914. // don't let more than one widget handle mouseStart
  7915. if ( mouseHandled ) {
  7916. return;
  7917. }
  7918. this._mouseMoved = false;
  7919. // We may have missed mouseup (out of window)
  7920. ( this._mouseStarted && this._mouseUp( event ) );
  7921. this._mouseDownEvent = event;
  7922. var that = this,
  7923. btnIsLeft = ( event.which === 1 ),
  7924. // event.target.nodeName works around a bug in IE 8 with
  7925. // disabled inputs (#7620)
  7926. elIsCancel = ( typeof this.options.cancel === "string" && event.target.nodeName ?
  7927. $( event.target ).closest( this.options.cancel ).length : false );
  7928. if ( !btnIsLeft || elIsCancel || !this._mouseCapture( event ) ) {
  7929. return true;
  7930. }
  7931. this.mouseDelayMet = !this.options.delay;
  7932. if ( !this.mouseDelayMet ) {
  7933. this._mouseDelayTimer = setTimeout( function() {
  7934. that.mouseDelayMet = true;
  7935. }, this.options.delay );
  7936. }
  7937. if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) {
  7938. this._mouseStarted = ( this._mouseStart( event ) !== false );
  7939. if ( !this._mouseStarted ) {
  7940. event.preventDefault();
  7941. return true;
  7942. }
  7943. }
  7944. // Click event may never have fired (Gecko & Opera)
  7945. if ( true === $.data( event.target, this.widgetName + ".preventClickEvent" ) ) {
  7946. $.removeData( event.target, this.widgetName + ".preventClickEvent" );
  7947. }
  7948. // These delegates are required to keep context
  7949. this._mouseMoveDelegate = function( event ) {
  7950. return that._mouseMove( event );
  7951. };
  7952. this._mouseUpDelegate = function( event ) {
  7953. return that._mouseUp( event );
  7954. };
  7955. this.document
  7956. .on( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  7957. .on( "mouseup." + this.widgetName, this._mouseUpDelegate );
  7958. event.preventDefault();
  7959. mouseHandled = true;
  7960. return true;
  7961. },
  7962. _mouseMove: function( event ) {
  7963. // Only check for mouseups outside the document if you've moved inside the document
  7964. // at least once. This prevents the firing of mouseup in the case of IE<9, which will
  7965. // fire a mousemove event if content is placed under the cursor. See #7778
  7966. // Support: IE <9
  7967. if ( this._mouseMoved ) {
  7968. // IE mouseup check - mouseup happened when mouse was out of window
  7969. if ( $.ui.ie && ( !document.documentMode || document.documentMode < 9 ) &&
  7970. !event.button ) {
  7971. return this._mouseUp( event );
  7972. // Iframe mouseup check - mouseup occurred in another document
  7973. } else if ( !event.which ) {
  7974. // Support: Safari <=8 - 9
  7975. // Safari sets which to 0 if you press any of the following keys
  7976. // during a drag (#14461)
  7977. if ( event.originalEvent.altKey || event.originalEvent.ctrlKey ||
  7978. event.originalEvent.metaKey || event.originalEvent.shiftKey ) {
  7979. this.ignoreMissingWhich = true;
  7980. } else if ( !this.ignoreMissingWhich ) {
  7981. return this._mouseUp( event );
  7982. }
  7983. }
  7984. }
  7985. if ( event.which || event.button ) {
  7986. this._mouseMoved = true;
  7987. }
  7988. if ( this._mouseStarted ) {
  7989. this._mouseDrag( event );
  7990. return event.preventDefault();
  7991. }
  7992. if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) {
  7993. this._mouseStarted =
  7994. ( this._mouseStart( this._mouseDownEvent, event ) !== false );
  7995. ( this._mouseStarted ? this._mouseDrag( event ) : this._mouseUp( event ) );
  7996. }
  7997. return !this._mouseStarted;
  7998. },
  7999. _mouseUp: function( event ) {
  8000. this.document
  8001. .off( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  8002. .off( "mouseup." + this.widgetName, this._mouseUpDelegate );
  8003. if ( this._mouseStarted ) {
  8004. this._mouseStarted = false;
  8005. if ( event.target === this._mouseDownEvent.target ) {
  8006. $.data( event.target, this.widgetName + ".preventClickEvent", true );
  8007. }
  8008. this._mouseStop( event );
  8009. }
  8010. if ( this._mouseDelayTimer ) {
  8011. clearTimeout( this._mouseDelayTimer );
  8012. delete this._mouseDelayTimer;
  8013. }
  8014. this.ignoreMissingWhich = false;
  8015. mouseHandled = false;
  8016. event.preventDefault();
  8017. },
  8018. _mouseDistanceMet: function( event ) {
  8019. return ( Math.max(
  8020. Math.abs( this._mouseDownEvent.pageX - event.pageX ),
  8021. Math.abs( this._mouseDownEvent.pageY - event.pageY )
  8022. ) >= this.options.distance
  8023. );
  8024. },
  8025. _mouseDelayMet: function( /* event */ ) {
  8026. return this.mouseDelayMet;
  8027. },
  8028. // These are placeholder methods, to be overriden by extending plugin
  8029. _mouseStart: function( /* event */ ) {},
  8030. _mouseDrag: function( /* event */ ) {},
  8031. _mouseStop: function( /* event */ ) {},
  8032. _mouseCapture: function( /* event */ ) { return true; }
  8033. } );
  8034. // $.ui.plugin is deprecated. Use $.widget() extensions instead.
  8035. var plugin = $.ui.plugin = {
  8036. add: function( module, option, set ) {
  8037. var i,
  8038. proto = $.ui[ module ].prototype;
  8039. for ( i in set ) {
  8040. proto.plugins[ i ] = proto.plugins[ i ] || [];
  8041. proto.plugins[ i ].push( [ option, set[ i ] ] );
  8042. }
  8043. },
  8044. call: function( instance, name, args, allowDisconnected ) {
  8045. var i,
  8046. set = instance.plugins[ name ];
  8047. if ( !set ) {
  8048. return;
  8049. }
  8050. if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode ||
  8051. instance.element[ 0 ].parentNode.nodeType === 11 ) ) {
  8052. return;
  8053. }
  8054. for ( i = 0; i < set.length; i++ ) {
  8055. if ( instance.options[ set[ i ][ 0 ] ] ) {
  8056. set[ i ][ 1 ].apply( instance.element, args );
  8057. }
  8058. }
  8059. }
  8060. };
  8061. var safeBlur = $.ui.safeBlur = function( element ) {
  8062. // Support: IE9 - 10 only
  8063. // If the <body> is blurred, IE will switch windows, see #9420
  8064. if ( element && element.nodeName.toLowerCase() !== "body" ) {
  8065. $( element ).trigger( "blur" );
  8066. }
  8067. };
  8068. /*!
  8069. * jQuery UI Draggable 1.12.1
  8070. * http://jqueryui.com
  8071. *
  8072. * Copyright jQuery Foundation and other contributors
  8073. * Released under the MIT license.
  8074. * http://jquery.org/license
  8075. */
  8076. //>>label: Draggable
  8077. //>>group: Interactions
  8078. //>>description: Enables dragging functionality for any element.
  8079. //>>docs: http://api.jqueryui.com/draggable/
  8080. //>>demos: http://jqueryui.com/draggable/
  8081. //>>css.structure: ../../themes/base/draggable.css
  8082. $.widget( "ui.draggable", $.ui.mouse, {
  8083. version: "1.12.1",
  8084. widgetEventPrefix: "drag",
  8085. options: {
  8086. addClasses: true,
  8087. appendTo: "parent",
  8088. axis: false,
  8089. connectToSortable: false,
  8090. containment: false,
  8091. cursor: "auto",
  8092. cursorAt: false,
  8093. grid: false,
  8094. handle: false,
  8095. helper: "original",
  8096. iframeFix: false,
  8097. opacity: false,
  8098. refreshPositions: false,
  8099. revert: false,
  8100. revertDuration: 500,
  8101. scope: "default",
  8102. scroll: true,
  8103. scrollSensitivity: 20,
  8104. scrollSpeed: 20,
  8105. snap: false,
  8106. snapMode: "both",
  8107. snapTolerance: 20,
  8108. stack: false,
  8109. zIndex: false,
  8110. // Callbacks
  8111. drag: null,
  8112. start: null,
  8113. stop: null
  8114. },
  8115. _create: function() {
  8116. if ( this.options.helper === "original" ) {
  8117. this._setPositionRelative();
  8118. }
  8119. if ( this.options.addClasses ) {
  8120. this._addClass( "ui-draggable" );
  8121. }
  8122. this._setHandleClassName();
  8123. this._mouseInit();
  8124. },
  8125. _setOption: function( key, value ) {
  8126. this._super( key, value );
  8127. if ( key === "handle" ) {
  8128. this._removeHandleClassName();
  8129. this._setHandleClassName();
  8130. }
  8131. },
  8132. _destroy: function() {
  8133. if ( ( this.helper || this.element ).is( ".ui-draggable-dragging" ) ) {
  8134. this.destroyOnClear = true;
  8135. return;
  8136. }
  8137. this._removeHandleClassName();
  8138. this._mouseDestroy();
  8139. },
  8140. _mouseCapture: function( event ) {
  8141. var o = this.options;
  8142. // Among others, prevent a drag on a resizable-handle
  8143. if ( this.helper || o.disabled ||
  8144. $( event.target ).closest( ".ui-resizable-handle" ).length > 0 ) {
  8145. return false;
  8146. }
  8147. //Quit if we're not on a valid handle
  8148. this.handle = this._getHandle( event );
  8149. if ( !this.handle ) {
  8150. return false;
  8151. }
  8152. this._blurActiveElement( event );
  8153. this._blockFrames( o.iframeFix === true ? "iframe" : o.iframeFix );
  8154. return true;
  8155. },
  8156. _blockFrames: function( selector ) {
  8157. this.iframeBlocks = this.document.find( selector ).map( function() {
  8158. var iframe = $( this );
  8159. return $( "<div>" )
  8160. .css( "position", "absolute" )
  8161. .appendTo( iframe.parent() )
  8162. .outerWidth( iframe.outerWidth() )
  8163. .outerHeight( iframe.outerHeight() )
  8164. .offset( iframe.offset() )[ 0 ];
  8165. } );
  8166. },
  8167. _unblockFrames: function() {
  8168. if ( this.iframeBlocks ) {
  8169. this.iframeBlocks.remove();
  8170. delete this.iframeBlocks;
  8171. }
  8172. },
  8173. _blurActiveElement: function( event ) {
  8174. var activeElement = $.ui.safeActiveElement( this.document[ 0 ] ),
  8175. target = $( event.target );
  8176. // Don't blur if the event occurred on an element that is within
  8177. // the currently focused element
  8178. // See #10527, #12472
  8179. if ( target.closest( activeElement ).length ) {
  8180. return;
  8181. }
  8182. // Blur any element that currently has focus, see #4261
  8183. $.ui.safeBlur( activeElement );
  8184. },
  8185. _mouseStart: function( event ) {
  8186. var o = this.options;
  8187. //Create and append the visible helper
  8188. this.helper = this._createHelper( event );
  8189. this._addClass( this.helper, "ui-draggable-dragging" );
  8190. //Cache the helper size
  8191. this._cacheHelperProportions();
  8192. //If ddmanager is used for droppables, set the global draggable
  8193. if ( $.ui.ddmanager ) {
  8194. $.ui.ddmanager.current = this;
  8195. }
  8196. /*
  8197. * - Position generation -
  8198. * This block generates everything position related - it's the core of draggables.
  8199. */
  8200. //Cache the margins of the original element
  8201. this._cacheMargins();
  8202. //Store the helper's css position
  8203. this.cssPosition = this.helper.css( "position" );
  8204. this.scrollParent = this.helper.scrollParent( true );
  8205. this.offsetParent = this.helper.offsetParent();
  8206. this.hasFixedAncestor = this.helper.parents().filter( function() {
  8207. return $( this ).css( "position" ) === "fixed";
  8208. } ).length > 0;
  8209. //The element's absolute position on the page minus margins
  8210. this.positionAbs = this.element.offset();
  8211. this._refreshOffsets( event );
  8212. //Generate the original position
  8213. this.originalPosition = this.position = this._generatePosition( event, false );
  8214. this.originalPageX = event.pageX;
  8215. this.originalPageY = event.pageY;
  8216. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  8217. ( o.cursorAt && this._adjustOffsetFromHelper( o.cursorAt ) );
  8218. //Set a containment if given in the options
  8219. this._setContainment();
  8220. //Trigger event + callbacks
  8221. if ( this._trigger( "start", event ) === false ) {
  8222. this._clear();
  8223. return false;
  8224. }
  8225. //Recache the helper size
  8226. this._cacheHelperProportions();
  8227. //Prepare the droppable offsets
  8228. if ( $.ui.ddmanager && !o.dropBehaviour ) {
  8229. $.ui.ddmanager.prepareOffsets( this, event );
  8230. }
  8231. // Execute the drag once - this causes the helper not to be visible before getting its
  8232. // correct position
  8233. this._mouseDrag( event, true );
  8234. // If the ddmanager is used for droppables, inform the manager that dragging has started
  8235. // (see #5003)
  8236. if ( $.ui.ddmanager ) {
  8237. $.ui.ddmanager.dragStart( this, event );
  8238. }
  8239. return true;
  8240. },
  8241. _refreshOffsets: function( event ) {
  8242. this.offset = {
  8243. top: this.positionAbs.top - this.margins.top,
  8244. left: this.positionAbs.left - this.margins.left,
  8245. scroll: false,
  8246. parent: this._getParentOffset(),
  8247. relative: this._getRelativeOffset()
  8248. };
  8249. this.offset.click = {
  8250. left: event.pageX - this.offset.left,
  8251. top: event.pageY - this.offset.top
  8252. };
  8253. },
  8254. _mouseDrag: function( event, noPropagation ) {
  8255. // reset any necessary cached properties (see #5009)
  8256. if ( this.hasFixedAncestor ) {
  8257. this.offset.parent = this._getParentOffset();
  8258. }
  8259. //Compute the helpers position
  8260. this.position = this._generatePosition( event, true );
  8261. this.positionAbs = this._convertPositionTo( "absolute" );
  8262. //Call plugins and callbacks and use the resulting position if something is returned
  8263. if ( !noPropagation ) {
  8264. var ui = this._uiHash();
  8265. if ( this._trigger( "drag", event, ui ) === false ) {
  8266. this._mouseUp( new $.Event( "mouseup", event ) );
  8267. return false;
  8268. }
  8269. this.position = ui.position;
  8270. }
  8271. this.helper[ 0 ].style.left = this.position.left + "px";
  8272. this.helper[ 0 ].style.top = this.position.top + "px";
  8273. if ( $.ui.ddmanager ) {
  8274. $.ui.ddmanager.drag( this, event );
  8275. }
  8276. return false;
  8277. },
  8278. _mouseStop: function( event ) {
  8279. //If we are using droppables, inform the manager about the drop
  8280. var that = this,
  8281. dropped = false;
  8282. if ( $.ui.ddmanager && !this.options.dropBehaviour ) {
  8283. dropped = $.ui.ddmanager.drop( this, event );
  8284. }
  8285. //if a drop comes from outside (a sortable)
  8286. if ( this.dropped ) {
  8287. dropped = this.dropped;
  8288. this.dropped = false;
  8289. }
  8290. if ( ( this.options.revert === "invalid" && !dropped ) ||
  8291. ( this.options.revert === "valid" && dropped ) ||
  8292. this.options.revert === true || ( $.isFunction( this.options.revert ) &&
  8293. this.options.revert.call( this.element, dropped ) )
  8294. ) {
  8295. $( this.helper ).animate(
  8296. this.originalPosition,
  8297. parseInt( this.options.revertDuration, 10 ),
  8298. function() {
  8299. if ( that._trigger( "stop", event ) !== false ) {
  8300. that._clear();
  8301. }
  8302. }
  8303. );
  8304. } else {
  8305. if ( this._trigger( "stop", event ) !== false ) {
  8306. this._clear();
  8307. }
  8308. }
  8309. return false;
  8310. },
  8311. _mouseUp: function( event ) {
  8312. this._unblockFrames();
  8313. // If the ddmanager is used for droppables, inform the manager that dragging has stopped
  8314. // (see #5003)
  8315. if ( $.ui.ddmanager ) {
  8316. $.ui.ddmanager.dragStop( this, event );
  8317. }
  8318. // Only need to focus if the event occurred on the draggable itself, see #10527
  8319. if ( this.handleElement.is( event.target ) ) {
  8320. // The interaction is over; whether or not the click resulted in a drag,
  8321. // focus the element
  8322. this.element.trigger( "focus" );
  8323. }
  8324. return $.ui.mouse.prototype._mouseUp.call( this, event );
  8325. },
  8326. cancel: function() {
  8327. if ( this.helper.is( ".ui-draggable-dragging" ) ) {
  8328. this._mouseUp( new $.Event( "mouseup", { target: this.element[ 0 ] } ) );
  8329. } else {
  8330. this._clear();
  8331. }
  8332. return this;
  8333. },
  8334. _getHandle: function( event ) {
  8335. return this.options.handle ?
  8336. !!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
  8337. true;
  8338. },
  8339. _setHandleClassName: function() {
  8340. this.handleElement = this.options.handle ?
  8341. this.element.find( this.options.handle ) : this.element;
  8342. this._addClass( this.handleElement, "ui-draggable-handle" );
  8343. },
  8344. _removeHandleClassName: function() {
  8345. this._removeClass( this.handleElement, "ui-draggable-handle" );
  8346. },
  8347. _createHelper: function( event ) {
  8348. var o = this.options,
  8349. helperIsFunction = $.isFunction( o.helper ),
  8350. helper = helperIsFunction ?
  8351. $( o.helper.apply( this.element[ 0 ], [ event ] ) ) :
  8352. ( o.helper === "clone" ?
  8353. this.element.clone().removeAttr( "id" ) :
  8354. this.element );
  8355. if ( !helper.parents( "body" ).length ) {
  8356. helper.appendTo( ( o.appendTo === "parent" ?
  8357. this.element[ 0 ].parentNode :
  8358. o.appendTo ) );
  8359. }
  8360. // Http://bugs.jqueryui.com/ticket/9446
  8361. // a helper function can return the original element
  8362. // which wouldn't have been set to relative in _create
  8363. if ( helperIsFunction && helper[ 0 ] === this.element[ 0 ] ) {
  8364. this._setPositionRelative();
  8365. }
  8366. if ( helper[ 0 ] !== this.element[ 0 ] &&
  8367. !( /(fixed|absolute)/ ).test( helper.css( "position" ) ) ) {
  8368. helper.css( "position", "absolute" );
  8369. }
  8370. return helper;
  8371. },
  8372. _setPositionRelative: function() {
  8373. if ( !( /^(?:r|a|f)/ ).test( this.element.css( "position" ) ) ) {
  8374. this.element[ 0 ].style.position = "relative";
  8375. }
  8376. },
  8377. _adjustOffsetFromHelper: function( obj ) {
  8378. if ( typeof obj === "string" ) {
  8379. obj = obj.split( " " );
  8380. }
  8381. if ( $.isArray( obj ) ) {
  8382. obj = { left: +obj[ 0 ], top: +obj[ 1 ] || 0 };
  8383. }
  8384. if ( "left" in obj ) {
  8385. this.offset.click.left = obj.left + this.margins.left;
  8386. }
  8387. if ( "right" in obj ) {
  8388. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  8389. }
  8390. if ( "top" in obj ) {
  8391. this.offset.click.top = obj.top + this.margins.top;
  8392. }
  8393. if ( "bottom" in obj ) {
  8394. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  8395. }
  8396. },
  8397. _isRootNode: function( element ) {
  8398. return ( /(html|body)/i ).test( element.tagName ) || element === this.document[ 0 ];
  8399. },
  8400. _getParentOffset: function() {
  8401. //Get the offsetParent and cache its position
  8402. var po = this.offsetParent.offset(),
  8403. document = this.document[ 0 ];
  8404. // This is a special case where we need to modify a offset calculated on start, since the
  8405. // following happened:
  8406. // 1. The position of the helper is absolute, so it's position is calculated based on the
  8407. // next positioned parent
  8408. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't
  8409. // the document, which means that the scroll is included in the initial calculation of the
  8410. // offset of the parent, and never recalculated upon drag
  8411. if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== document &&
  8412. $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) {
  8413. po.left += this.scrollParent.scrollLeft();
  8414. po.top += this.scrollParent.scrollTop();
  8415. }
  8416. if ( this._isRootNode( this.offsetParent[ 0 ] ) ) {
  8417. po = { top: 0, left: 0 };
  8418. }
  8419. return {
  8420. top: po.top + ( parseInt( this.offsetParent.css( "borderTopWidth" ), 10 ) || 0 ),
  8421. left: po.left + ( parseInt( this.offsetParent.css( "borderLeftWidth" ), 10 ) || 0 )
  8422. };
  8423. },
  8424. _getRelativeOffset: function() {
  8425. if ( this.cssPosition !== "relative" ) {
  8426. return { top: 0, left: 0 };
  8427. }
  8428. var p = this.element.position(),
  8429. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
  8430. return {
  8431. top: p.top - ( parseInt( this.helper.css( "top" ), 10 ) || 0 ) +
  8432. ( !scrollIsRootNode ? this.scrollParent.scrollTop() : 0 ),
  8433. left: p.left - ( parseInt( this.helper.css( "left" ), 10 ) || 0 ) +
  8434. ( !scrollIsRootNode ? this.scrollParent.scrollLeft() : 0 )
  8435. };
  8436. },
  8437. _cacheMargins: function() {
  8438. this.margins = {
  8439. left: ( parseInt( this.element.css( "marginLeft" ), 10 ) || 0 ),
  8440. top: ( parseInt( this.element.css( "marginTop" ), 10 ) || 0 ),
  8441. right: ( parseInt( this.element.css( "marginRight" ), 10 ) || 0 ),
  8442. bottom: ( parseInt( this.element.css( "marginBottom" ), 10 ) || 0 )
  8443. };
  8444. },
  8445. _cacheHelperProportions: function() {
  8446. this.helperProportions = {
  8447. width: this.helper.outerWidth(),
  8448. height: this.helper.outerHeight()
  8449. };
  8450. },
  8451. _setContainment: function() {
  8452. var isUserScrollable, c, ce,
  8453. o = this.options,
  8454. document = this.document[ 0 ];
  8455. this.relativeContainer = null;
  8456. if ( !o.containment ) {
  8457. this.containment = null;
  8458. return;
  8459. }
  8460. if ( o.containment === "window" ) {
  8461. this.containment = [
  8462. $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
  8463. $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top,
  8464. $( window ).scrollLeft() + $( window ).width() -
  8465. this.helperProportions.width - this.margins.left,
  8466. $( window ).scrollTop() +
  8467. ( $( window ).height() || document.body.parentNode.scrollHeight ) -
  8468. this.helperProportions.height - this.margins.top
  8469. ];
  8470. return;
  8471. }
  8472. if ( o.containment === "document" ) {
  8473. this.containment = [
  8474. 0,
  8475. 0,
  8476. $( document ).width() - this.helperProportions.width - this.margins.left,
  8477. ( $( document ).height() || document.body.parentNode.scrollHeight ) -
  8478. this.helperProportions.height - this.margins.top
  8479. ];
  8480. return;
  8481. }
  8482. if ( o.containment.constructor === Array ) {
  8483. this.containment = o.containment;
  8484. return;
  8485. }
  8486. if ( o.containment === "parent" ) {
  8487. o.containment = this.helper[ 0 ].parentNode;
  8488. }
  8489. c = $( o.containment );
  8490. ce = c[ 0 ];
  8491. if ( !ce ) {
  8492. return;
  8493. }
  8494. isUserScrollable = /(scroll|auto)/.test( c.css( "overflow" ) );
  8495. this.containment = [
  8496. ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) +
  8497. ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ),
  8498. ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) +
  8499. ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ),
  8500. ( isUserScrollable ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) -
  8501. ( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) -
  8502. ( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) -
  8503. this.helperProportions.width -
  8504. this.margins.left -
  8505. this.margins.right,
  8506. ( isUserScrollable ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) -
  8507. ( parseInt( c.css( "borderBottomWidth" ), 10 ) || 0 ) -
  8508. ( parseInt( c.css( "paddingBottom" ), 10 ) || 0 ) -
  8509. this.helperProportions.height -
  8510. this.margins.top -
  8511. this.margins.bottom
  8512. ];
  8513. this.relativeContainer = c;
  8514. },
  8515. _convertPositionTo: function( d, pos ) {
  8516. if ( !pos ) {
  8517. pos = this.position;
  8518. }
  8519. var mod = d === "absolute" ? 1 : -1,
  8520. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
  8521. return {
  8522. top: (
  8523. // The absolute mouse position
  8524. pos.top +
  8525. // Only for relative positioned nodes: Relative offset from element to offset parent
  8526. this.offset.relative.top * mod +
  8527. // The offsetParent's offset without borders (offset + border)
  8528. this.offset.parent.top * mod -
  8529. ( ( this.cssPosition === "fixed" ?
  8530. -this.offset.scroll.top :
  8531. ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) * mod )
  8532. ),
  8533. left: (
  8534. // The absolute mouse position
  8535. pos.left +
  8536. // Only for relative positioned nodes: Relative offset from element to offset parent
  8537. this.offset.relative.left * mod +
  8538. // The offsetParent's offset without borders (offset + border)
  8539. this.offset.parent.left * mod -
  8540. ( ( this.cssPosition === "fixed" ?
  8541. -this.offset.scroll.left :
  8542. ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) * mod )
  8543. )
  8544. };
  8545. },
  8546. _generatePosition: function( event, constrainPosition ) {
  8547. var containment, co, top, left,
  8548. o = this.options,
  8549. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] ),
  8550. pageX = event.pageX,
  8551. pageY = event.pageY;
  8552. // Cache the scroll
  8553. if ( !scrollIsRootNode || !this.offset.scroll ) {
  8554. this.offset.scroll = {
  8555. top: this.scrollParent.scrollTop(),
  8556. left: this.scrollParent.scrollLeft()
  8557. };
  8558. }
  8559. /*
  8560. * - Position constraining -
  8561. * Constrain the position to a mix of grid, containment.
  8562. */
  8563. // If we are not dragging yet, we won't check for options
  8564. if ( constrainPosition ) {
  8565. if ( this.containment ) {
  8566. if ( this.relativeContainer ) {
  8567. co = this.relativeContainer.offset();
  8568. containment = [
  8569. this.containment[ 0 ] + co.left,
  8570. this.containment[ 1 ] + co.top,
  8571. this.containment[ 2 ] + co.left,
  8572. this.containment[ 3 ] + co.top
  8573. ];
  8574. } else {
  8575. containment = this.containment;
  8576. }
  8577. if ( event.pageX - this.offset.click.left < containment[ 0 ] ) {
  8578. pageX = containment[ 0 ] + this.offset.click.left;
  8579. }
  8580. if ( event.pageY - this.offset.click.top < containment[ 1 ] ) {
  8581. pageY = containment[ 1 ] + this.offset.click.top;
  8582. }
  8583. if ( event.pageX - this.offset.click.left > containment[ 2 ] ) {
  8584. pageX = containment[ 2 ] + this.offset.click.left;
  8585. }
  8586. if ( event.pageY - this.offset.click.top > containment[ 3 ] ) {
  8587. pageY = containment[ 3 ] + this.offset.click.top;
  8588. }
  8589. }
  8590. if ( o.grid ) {
  8591. //Check for grid elements set to 0 to prevent divide by 0 error causing invalid
  8592. // argument errors in IE (see ticket #6950)
  8593. top = o.grid[ 1 ] ? this.originalPageY + Math.round( ( pageY -
  8594. this.originalPageY ) / o.grid[ 1 ] ) * o.grid[ 1 ] : this.originalPageY;
  8595. pageY = containment ? ( ( top - this.offset.click.top >= containment[ 1 ] ||
  8596. top - this.offset.click.top > containment[ 3 ] ) ?
  8597. top :
  8598. ( ( top - this.offset.click.top >= containment[ 1 ] ) ?
  8599. top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) : top;
  8600. left = o.grid[ 0 ] ? this.originalPageX +
  8601. Math.round( ( pageX - this.originalPageX ) / o.grid[ 0 ] ) * o.grid[ 0 ] :
  8602. this.originalPageX;
  8603. pageX = containment ? ( ( left - this.offset.click.left >= containment[ 0 ] ||
  8604. left - this.offset.click.left > containment[ 2 ] ) ?
  8605. left :
  8606. ( ( left - this.offset.click.left >= containment[ 0 ] ) ?
  8607. left - o.grid[ 0 ] : left + o.grid[ 0 ] ) ) : left;
  8608. }
  8609. if ( o.axis === "y" ) {
  8610. pageX = this.originalPageX;
  8611. }
  8612. if ( o.axis === "x" ) {
  8613. pageY = this.originalPageY;
  8614. }
  8615. }
  8616. return {
  8617. top: (
  8618. // The absolute mouse position
  8619. pageY -
  8620. // Click offset (relative to the element)
  8621. this.offset.click.top -
  8622. // Only for relative positioned nodes: Relative offset from element to offset parent
  8623. this.offset.relative.top -
  8624. // The offsetParent's offset without borders (offset + border)
  8625. this.offset.parent.top +
  8626. ( this.cssPosition === "fixed" ?
  8627. -this.offset.scroll.top :
  8628. ( scrollIsRootNode ? 0 : this.offset.scroll.top ) )
  8629. ),
  8630. left: (
  8631. // The absolute mouse position
  8632. pageX -
  8633. // Click offset (relative to the element)
  8634. this.offset.click.left -
  8635. // Only for relative positioned nodes: Relative offset from element to offset parent
  8636. this.offset.relative.left -
  8637. // The offsetParent's offset without borders (offset + border)
  8638. this.offset.parent.left +
  8639. ( this.cssPosition === "fixed" ?
  8640. -this.offset.scroll.left :
  8641. ( scrollIsRootNode ? 0 : this.offset.scroll.left ) )
  8642. )
  8643. };
  8644. },
  8645. _clear: function() {
  8646. this._removeClass( this.helper, "ui-draggable-dragging" );
  8647. if ( this.helper[ 0 ] !== this.element[ 0 ] && !this.cancelHelperRemoval ) {
  8648. this.helper.remove();
  8649. }
  8650. this.helper = null;
  8651. this.cancelHelperRemoval = false;
  8652. if ( this.destroyOnClear ) {
  8653. this.destroy();
  8654. }
  8655. },
  8656. // From now on bulk stuff - mainly helpers
  8657. _trigger: function( type, event, ui ) {
  8658. ui = ui || this._uiHash();
  8659. $.ui.plugin.call( this, type, [ event, ui, this ], true );
  8660. // Absolute position and offset (see #6884 ) have to be recalculated after plugins
  8661. if ( /^(drag|start|stop)/.test( type ) ) {
  8662. this.positionAbs = this._convertPositionTo( "absolute" );
  8663. ui.offset = this.positionAbs;
  8664. }
  8665. return $.Widget.prototype._trigger.call( this, type, event, ui );
  8666. },
  8667. plugins: {},
  8668. _uiHash: function() {
  8669. return {
  8670. helper: this.helper,
  8671. position: this.position,
  8672. originalPosition: this.originalPosition,
  8673. offset: this.positionAbs
  8674. };
  8675. }
  8676. } );
  8677. $.ui.plugin.add( "draggable", "connectToSortable", {
  8678. start: function( event, ui, draggable ) {
  8679. var uiSortable = $.extend( {}, ui, {
  8680. item: draggable.element
  8681. } );
  8682. draggable.sortables = [];
  8683. $( draggable.options.connectToSortable ).each( function() {
  8684. var sortable = $( this ).sortable( "instance" );
  8685. if ( sortable && !sortable.options.disabled ) {
  8686. draggable.sortables.push( sortable );
  8687. // RefreshPositions is called at drag start to refresh the containerCache
  8688. // which is used in drag. This ensures it's initialized and synchronized
  8689. // with any changes that might have happened on the page since initialization.
  8690. sortable.refreshPositions();
  8691. sortable._trigger( "activate", event, uiSortable );
  8692. }
  8693. } );
  8694. },
  8695. stop: function( event, ui, draggable ) {
  8696. var uiSortable = $.extend( {}, ui, {
  8697. item: draggable.element
  8698. } );
  8699. draggable.cancelHelperRemoval = false;
  8700. $.each( draggable.sortables, function() {
  8701. var sortable = this;
  8702. if ( sortable.isOver ) {
  8703. sortable.isOver = 0;
  8704. // Allow this sortable to handle removing the helper
  8705. draggable.cancelHelperRemoval = true;
  8706. sortable.cancelHelperRemoval = false;
  8707. // Use _storedCSS To restore properties in the sortable,
  8708. // as this also handles revert (#9675) since the draggable
  8709. // may have modified them in unexpected ways (#8809)
  8710. sortable._storedCSS = {
  8711. position: sortable.placeholder.css( "position" ),
  8712. top: sortable.placeholder.css( "top" ),
  8713. left: sortable.placeholder.css( "left" )
  8714. };
  8715. sortable._mouseStop( event );
  8716. // Once drag has ended, the sortable should return to using
  8717. // its original helper, not the shared helper from draggable
  8718. sortable.options.helper = sortable.options._helper;
  8719. } else {
  8720. // Prevent this Sortable from removing the helper.
  8721. // However, don't set the draggable to remove the helper
  8722. // either as another connected Sortable may yet handle the removal.
  8723. sortable.cancelHelperRemoval = true;
  8724. sortable._trigger( "deactivate", event, uiSortable );
  8725. }
  8726. } );
  8727. },
  8728. drag: function( event, ui, draggable ) {
  8729. $.each( draggable.sortables, function() {
  8730. var innermostIntersecting = false,
  8731. sortable = this;
  8732. // Copy over variables that sortable's _intersectsWith uses
  8733. sortable.positionAbs = draggable.positionAbs;
  8734. sortable.helperProportions = draggable.helperProportions;
  8735. sortable.offset.click = draggable.offset.click;
  8736. if ( sortable._intersectsWith( sortable.containerCache ) ) {
  8737. innermostIntersecting = true;
  8738. $.each( draggable.sortables, function() {
  8739. // Copy over variables that sortable's _intersectsWith uses
  8740. this.positionAbs = draggable.positionAbs;
  8741. this.helperProportions = draggable.helperProportions;
  8742. this.offset.click = draggable.offset.click;
  8743. if ( this !== sortable &&
  8744. this._intersectsWith( this.containerCache ) &&
  8745. $.contains( sortable.element[ 0 ], this.element[ 0 ] ) ) {
  8746. innermostIntersecting = false;
  8747. }
  8748. return innermostIntersecting;
  8749. } );
  8750. }
  8751. if ( innermostIntersecting ) {
  8752. // If it intersects, we use a little isOver variable and set it once,
  8753. // so that the move-in stuff gets fired only once.
  8754. if ( !sortable.isOver ) {
  8755. sortable.isOver = 1;
  8756. // Store draggable's parent in case we need to reappend to it later.
  8757. draggable._parent = ui.helper.parent();
  8758. sortable.currentItem = ui.helper
  8759. .appendTo( sortable.element )
  8760. .data( "ui-sortable-item", true );
  8761. // Store helper option to later restore it
  8762. sortable.options._helper = sortable.options.helper;
  8763. sortable.options.helper = function() {
  8764. return ui.helper[ 0 ];
  8765. };
  8766. // Fire the start events of the sortable with our passed browser event,
  8767. // and our own helper (so it doesn't create a new one)
  8768. event.target = sortable.currentItem[ 0 ];
  8769. sortable._mouseCapture( event, true );
  8770. sortable._mouseStart( event, true, true );
  8771. // Because the browser event is way off the new appended portlet,
  8772. // modify necessary variables to reflect the changes
  8773. sortable.offset.click.top = draggable.offset.click.top;
  8774. sortable.offset.click.left = draggable.offset.click.left;
  8775. sortable.offset.parent.left -= draggable.offset.parent.left -
  8776. sortable.offset.parent.left;
  8777. sortable.offset.parent.top -= draggable.offset.parent.top -
  8778. sortable.offset.parent.top;
  8779. draggable._trigger( "toSortable", event );
  8780. // Inform draggable that the helper is in a valid drop zone,
  8781. // used solely in the revert option to handle "valid/invalid".
  8782. draggable.dropped = sortable.element;
  8783. // Need to refreshPositions of all sortables in the case that
  8784. // adding to one sortable changes the location of the other sortables (#9675)
  8785. $.each( draggable.sortables, function() {
  8786. this.refreshPositions();
  8787. } );
  8788. // Hack so receive/update callbacks work (mostly)
  8789. draggable.currentItem = draggable.element;
  8790. sortable.fromOutside = draggable;
  8791. }
  8792. if ( sortable.currentItem ) {
  8793. sortable._mouseDrag( event );
  8794. // Copy the sortable's position because the draggable's can potentially reflect
  8795. // a relative position, while sortable is always absolute, which the dragged
  8796. // element has now become. (#8809)
  8797. ui.position = sortable.position;
  8798. }
  8799. } else {
  8800. // If it doesn't intersect with the sortable, and it intersected before,
  8801. // we fake the drag stop of the sortable, but make sure it doesn't remove
  8802. // the helper by using cancelHelperRemoval.
  8803. if ( sortable.isOver ) {
  8804. sortable.isOver = 0;
  8805. sortable.cancelHelperRemoval = true;
  8806. // Calling sortable's mouseStop would trigger a revert,
  8807. // so revert must be temporarily false until after mouseStop is called.
  8808. sortable.options._revert = sortable.options.revert;
  8809. sortable.options.revert = false;
  8810. sortable._trigger( "out", event, sortable._uiHash( sortable ) );
  8811. sortable._mouseStop( event, true );
  8812. // Restore sortable behaviors that were modfied
  8813. // when the draggable entered the sortable area (#9481)
  8814. sortable.options.revert = sortable.options._revert;
  8815. sortable.options.helper = sortable.options._helper;
  8816. if ( sortable.placeholder ) {
  8817. sortable.placeholder.remove();
  8818. }
  8819. // Restore and recalculate the draggable's offset considering the sortable
  8820. // may have modified them in unexpected ways. (#8809, #10669)
  8821. ui.helper.appendTo( draggable._parent );
  8822. draggable._refreshOffsets( event );
  8823. ui.position = draggable._generatePosition( event, true );
  8824. draggable._trigger( "fromSortable", event );
  8825. // Inform draggable that the helper is no longer in a valid drop zone
  8826. draggable.dropped = false;
  8827. // Need to refreshPositions of all sortables just in case removing
  8828. // from one sortable changes the location of other sortables (#9675)
  8829. $.each( draggable.sortables, function() {
  8830. this.refreshPositions();
  8831. } );
  8832. }
  8833. }
  8834. } );
  8835. }
  8836. } );
  8837. $.ui.plugin.add( "draggable", "cursor", {
  8838. start: function( event, ui, instance ) {
  8839. var t = $( "body" ),
  8840. o = instance.options;
  8841. if ( t.css( "cursor" ) ) {
  8842. o._cursor = t.css( "cursor" );
  8843. }
  8844. t.css( "cursor", o.cursor );
  8845. },
  8846. stop: function( event, ui, instance ) {
  8847. var o = instance.options;
  8848. if ( o._cursor ) {
  8849. $( "body" ).css( "cursor", o._cursor );
  8850. }
  8851. }
  8852. } );
  8853. $.ui.plugin.add( "draggable", "opacity", {
  8854. start: function( event, ui, instance ) {
  8855. var t = $( ui.helper ),
  8856. o = instance.options;
  8857. if ( t.css( "opacity" ) ) {
  8858. o._opacity = t.css( "opacity" );
  8859. }
  8860. t.css( "opacity", o.opacity );
  8861. },
  8862. stop: function( event, ui, instance ) {
  8863. var o = instance.options;
  8864. if ( o._opacity ) {
  8865. $( ui.helper ).css( "opacity", o._opacity );
  8866. }
  8867. }
  8868. } );
  8869. $.ui.plugin.add( "draggable", "scroll", {
  8870. start: function( event, ui, i ) {
  8871. if ( !i.scrollParentNotHidden ) {
  8872. i.scrollParentNotHidden = i.helper.scrollParent( false );
  8873. }
  8874. if ( i.scrollParentNotHidden[ 0 ] !== i.document[ 0 ] &&
  8875. i.scrollParentNotHidden[ 0 ].tagName !== "HTML" ) {
  8876. i.overflowOffset = i.scrollParentNotHidden.offset();
  8877. }
  8878. },
  8879. drag: function( event, ui, i ) {
  8880. var o = i.options,
  8881. scrolled = false,
  8882. scrollParent = i.scrollParentNotHidden[ 0 ],
  8883. document = i.document[ 0 ];
  8884. if ( scrollParent !== document && scrollParent.tagName !== "HTML" ) {
  8885. if ( !o.axis || o.axis !== "x" ) {
  8886. if ( ( i.overflowOffset.top + scrollParent.offsetHeight ) - event.pageY <
  8887. o.scrollSensitivity ) {
  8888. scrollParent.scrollTop = scrolled = scrollParent.scrollTop + o.scrollSpeed;
  8889. } else if ( event.pageY - i.overflowOffset.top < o.scrollSensitivity ) {
  8890. scrollParent.scrollTop = scrolled = scrollParent.scrollTop - o.scrollSpeed;
  8891. }
  8892. }
  8893. if ( !o.axis || o.axis !== "y" ) {
  8894. if ( ( i.overflowOffset.left + scrollParent.offsetWidth ) - event.pageX <
  8895. o.scrollSensitivity ) {
  8896. scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft + o.scrollSpeed;
  8897. } else if ( event.pageX - i.overflowOffset.left < o.scrollSensitivity ) {
  8898. scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft - o.scrollSpeed;
  8899. }
  8900. }
  8901. } else {
  8902. if ( !o.axis || o.axis !== "x" ) {
  8903. if ( event.pageY - $( document ).scrollTop() < o.scrollSensitivity ) {
  8904. scrolled = $( document ).scrollTop( $( document ).scrollTop() - o.scrollSpeed );
  8905. } else if ( $( window ).height() - ( event.pageY - $( document ).scrollTop() ) <
  8906. o.scrollSensitivity ) {
  8907. scrolled = $( document ).scrollTop( $( document ).scrollTop() + o.scrollSpeed );
  8908. }
  8909. }
  8910. if ( !o.axis || o.axis !== "y" ) {
  8911. if ( event.pageX - $( document ).scrollLeft() < o.scrollSensitivity ) {
  8912. scrolled = $( document ).scrollLeft(
  8913. $( document ).scrollLeft() - o.scrollSpeed
  8914. );
  8915. } else if ( $( window ).width() - ( event.pageX - $( document ).scrollLeft() ) <
  8916. o.scrollSensitivity ) {
  8917. scrolled = $( document ).scrollLeft(
  8918. $( document ).scrollLeft() + o.scrollSpeed
  8919. );
  8920. }
  8921. }
  8922. }
  8923. if ( scrolled !== false && $.ui.ddmanager && !o.dropBehaviour ) {
  8924. $.ui.ddmanager.prepareOffsets( i, event );
  8925. }
  8926. }
  8927. } );
  8928. $.ui.plugin.add( "draggable", "snap", {
  8929. start: function( event, ui, i ) {
  8930. var o = i.options;
  8931. i.snapElements = [];
  8932. $( o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap )
  8933. .each( function() {
  8934. var $t = $( this ),
  8935. $o = $t.offset();
  8936. if ( this !== i.element[ 0 ] ) {
  8937. i.snapElements.push( {
  8938. item: this,
  8939. width: $t.outerWidth(), height: $t.outerHeight(),
  8940. top: $o.top, left: $o.left
  8941. } );
  8942. }
  8943. } );
  8944. },
  8945. drag: function( event, ui, inst ) {
  8946. var ts, bs, ls, rs, l, r, t, b, i, first,
  8947. o = inst.options,
  8948. d = o.snapTolerance,
  8949. x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
  8950. y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
  8951. for ( i = inst.snapElements.length - 1; i >= 0; i-- ) {
  8952. l = inst.snapElements[ i ].left - inst.margins.left;
  8953. r = l + inst.snapElements[ i ].width;
  8954. t = inst.snapElements[ i ].top - inst.margins.top;
  8955. b = t + inst.snapElements[ i ].height;
  8956. if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d ||
  8957. !$.contains( inst.snapElements[ i ].item.ownerDocument,
  8958. inst.snapElements[ i ].item ) ) {
  8959. if ( inst.snapElements[ i ].snapping ) {
  8960. ( inst.options.snap.release &&
  8961. inst.options.snap.release.call(
  8962. inst.element,
  8963. event,
  8964. $.extend( inst._uiHash(), { snapItem: inst.snapElements[ i ].item } )
  8965. ) );
  8966. }
  8967. inst.snapElements[ i ].snapping = false;
  8968. continue;
  8969. }
  8970. if ( o.snapMode !== "inner" ) {
  8971. ts = Math.abs( t - y2 ) <= d;
  8972. bs = Math.abs( b - y1 ) <= d;
  8973. ls = Math.abs( l - x2 ) <= d;
  8974. rs = Math.abs( r - x1 ) <= d;
  8975. if ( ts ) {
  8976. ui.position.top = inst._convertPositionTo( "relative", {
  8977. top: t - inst.helperProportions.height,
  8978. left: 0
  8979. } ).top;
  8980. }
  8981. if ( bs ) {
  8982. ui.position.top = inst._convertPositionTo( "relative", {
  8983. top: b,
  8984. left: 0
  8985. } ).top;
  8986. }
  8987. if ( ls ) {
  8988. ui.position.left = inst._convertPositionTo( "relative", {
  8989. top: 0,
  8990. left: l - inst.helperProportions.width
  8991. } ).left;
  8992. }
  8993. if ( rs ) {
  8994. ui.position.left = inst._convertPositionTo( "relative", {
  8995. top: 0,
  8996. left: r
  8997. } ).left;
  8998. }
  8999. }
  9000. first = ( ts || bs || ls || rs );
  9001. if ( o.snapMode !== "outer" ) {
  9002. ts = Math.abs( t - y1 ) <= d;
  9003. bs = Math.abs( b - y2 ) <= d;
  9004. ls = Math.abs( l - x1 ) <= d;
  9005. rs = Math.abs( r - x2 ) <= d;
  9006. if ( ts ) {
  9007. ui.position.top = inst._convertPositionTo( "relative", {
  9008. top: t,
  9009. left: 0
  9010. } ).top;
  9011. }
  9012. if ( bs ) {
  9013. ui.position.top = inst._convertPositionTo( "relative", {
  9014. top: b - inst.helperProportions.height,
  9015. left: 0
  9016. } ).top;
  9017. }
  9018. if ( ls ) {
  9019. ui.position.left = inst._convertPositionTo( "relative", {
  9020. top: 0,
  9021. left: l
  9022. } ).left;
  9023. }
  9024. if ( rs ) {
  9025. ui.position.left = inst._convertPositionTo( "relative", {
  9026. top: 0,
  9027. left: r - inst.helperProportions.width
  9028. } ).left;
  9029. }
  9030. }
  9031. if ( !inst.snapElements[ i ].snapping && ( ts || bs || ls || rs || first ) ) {
  9032. ( inst.options.snap.snap &&
  9033. inst.options.snap.snap.call(
  9034. inst.element,
  9035. event,
  9036. $.extend( inst._uiHash(), {
  9037. snapItem: inst.snapElements[ i ].item
  9038. } ) ) );
  9039. }
  9040. inst.snapElements[ i ].snapping = ( ts || bs || ls || rs || first );
  9041. }
  9042. }
  9043. } );
  9044. $.ui.plugin.add( "draggable", "stack", {
  9045. start: function( event, ui, instance ) {
  9046. var min,
  9047. o = instance.options,
  9048. group = $.makeArray( $( o.stack ) ).sort( function( a, b ) {
  9049. return ( parseInt( $( a ).css( "zIndex" ), 10 ) || 0 ) -
  9050. ( parseInt( $( b ).css( "zIndex" ), 10 ) || 0 );
  9051. } );
  9052. if ( !group.length ) { return; }
  9053. min = parseInt( $( group[ 0 ] ).css( "zIndex" ), 10 ) || 0;
  9054. $( group ).each( function( i ) {
  9055. $( this ).css( "zIndex", min + i );
  9056. } );
  9057. this.css( "zIndex", ( min + group.length ) );
  9058. }
  9059. } );
  9060. $.ui.plugin.add( "draggable", "zIndex", {
  9061. start: function( event, ui, instance ) {
  9062. var t = $( ui.helper ),
  9063. o = instance.options;
  9064. if ( t.css( "zIndex" ) ) {
  9065. o._zIndex = t.css( "zIndex" );
  9066. }
  9067. t.css( "zIndex", o.zIndex );
  9068. },
  9069. stop: function( event, ui, instance ) {
  9070. var o = instance.options;
  9071. if ( o._zIndex ) {
  9072. $( ui.helper ).css( "zIndex", o._zIndex );
  9073. }
  9074. }
  9075. } );
  9076. var widgetsDraggable = $.ui.draggable;
  9077. /*!
  9078. * jQuery UI Resizable 1.12.1
  9079. * http://jqueryui.com
  9080. *
  9081. * Copyright jQuery Foundation and other contributors
  9082. * Released under the MIT license.
  9083. * http://jquery.org/license
  9084. */
  9085. //>>label: Resizable
  9086. //>>group: Interactions
  9087. //>>description: Enables resize functionality for any element.
  9088. //>>docs: http://api.jqueryui.com/resizable/
  9089. //>>demos: http://jqueryui.com/resizable/
  9090. //>>css.structure: ../../themes/base/core.css
  9091. //>>css.structure: ../../themes/base/resizable.css
  9092. //>>css.theme: ../../themes/base/theme.css
  9093. $.widget( "ui.resizable", $.ui.mouse, {
  9094. version: "1.12.1",
  9095. widgetEventPrefix: "resize",
  9096. options: {
  9097. alsoResize: false,
  9098. animate: false,
  9099. animateDuration: "slow",
  9100. animateEasing: "swing",
  9101. aspectRatio: false,
  9102. autoHide: false,
  9103. classes: {
  9104. "ui-resizable-se": "ui-icon ui-icon-gripsmall-diagonal-se"
  9105. },
  9106. containment: false,
  9107. ghost: false,
  9108. grid: false,
  9109. handles: "e,s,se",
  9110. helper: false,
  9111. maxHeight: null,
  9112. maxWidth: null,
  9113. minHeight: 10,
  9114. minWidth: 10,
  9115. // See #7960
  9116. zIndex: 90,
  9117. // Callbacks
  9118. resize: null,
  9119. start: null,
  9120. stop: null
  9121. },
  9122. _num: function( value ) {
  9123. return parseFloat( value ) || 0;
  9124. },
  9125. _isNumber: function( value ) {
  9126. return !isNaN( parseFloat( value ) );
  9127. },
  9128. _hasScroll: function( el, a ) {
  9129. if ( $( el ).css( "overflow" ) === "hidden" ) {
  9130. return false;
  9131. }
  9132. var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
  9133. has = false;
  9134. if ( el[ scroll ] > 0 ) {
  9135. return true;
  9136. }
  9137. // TODO: determine which cases actually cause this to happen
  9138. // if the element doesn't have the scroll set, see if it's possible to
  9139. // set the scroll
  9140. el[ scroll ] = 1;
  9141. has = ( el[ scroll ] > 0 );
  9142. el[ scroll ] = 0;
  9143. return has;
  9144. },
  9145. _create: function() {
  9146. var margins,
  9147. o = this.options,
  9148. that = this;
  9149. this._addClass( "ui-resizable" );
  9150. $.extend( this, {
  9151. _aspectRatio: !!( o.aspectRatio ),
  9152. aspectRatio: o.aspectRatio,
  9153. originalElement: this.element,
  9154. _proportionallyResizeElements: [],
  9155. _helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
  9156. } );
  9157. // Wrap the element if it cannot hold child nodes
  9158. if ( this.element[ 0 ].nodeName.match( /^(canvas|textarea|input|select|button|img)$/i ) ) {
  9159. this.element.wrap(
  9160. $( "<div class='ui-wrapper' style='overflow: hidden;'></div>" ).css( {
  9161. position: this.element.css( "position" ),
  9162. width: this.element.outerWidth(),
  9163. height: this.element.outerHeight(),
  9164. top: this.element.css( "top" ),
  9165. left: this.element.css( "left" )
  9166. } )
  9167. );
  9168. this.element = this.element.parent().data(
  9169. "ui-resizable", this.element.resizable( "instance" )
  9170. );
  9171. this.elementIsWrapper = true;
  9172. margins = {
  9173. marginTop: this.originalElement.css( "marginTop" ),
  9174. marginRight: this.originalElement.css( "marginRight" ),
  9175. marginBottom: this.originalElement.css( "marginBottom" ),
  9176. marginLeft: this.originalElement.css( "marginLeft" )
  9177. };
  9178. this.element.css( margins );
  9179. this.originalElement.css( "margin", 0 );
  9180. // support: Safari
  9181. // Prevent Safari textarea resize
  9182. this.originalResizeStyle = this.originalElement.css( "resize" );
  9183. this.originalElement.css( "resize", "none" );
  9184. this._proportionallyResizeElements.push( this.originalElement.css( {
  9185. position: "static",
  9186. zoom: 1,
  9187. display: "block"
  9188. } ) );
  9189. // Support: IE9
  9190. // avoid IE jump (hard set the margin)
  9191. this.originalElement.css( margins );
  9192. this._proportionallyResize();
  9193. }
  9194. this._setupHandles();
  9195. if ( o.autoHide ) {
  9196. $( this.element )
  9197. .on( "mouseenter", function() {
  9198. if ( o.disabled ) {
  9199. return;
  9200. }
  9201. that._removeClass( "ui-resizable-autohide" );
  9202. that._handles.show();
  9203. } )
  9204. .on( "mouseleave", function() {
  9205. if ( o.disabled ) {
  9206. return;
  9207. }
  9208. if ( !that.resizing ) {
  9209. that._addClass( "ui-resizable-autohide" );
  9210. that._handles.hide();
  9211. }
  9212. } );
  9213. }
  9214. this._mouseInit();
  9215. },
  9216. _destroy: function() {
  9217. this._mouseDestroy();
  9218. var wrapper,
  9219. _destroy = function( exp ) {
  9220. $( exp )
  9221. .removeData( "resizable" )
  9222. .removeData( "ui-resizable" )
  9223. .off( ".resizable" )
  9224. .find( ".ui-resizable-handle" )
  9225. .remove();
  9226. };
  9227. // TODO: Unwrap at same DOM position
  9228. if ( this.elementIsWrapper ) {
  9229. _destroy( this.element );
  9230. wrapper = this.element;
  9231. this.originalElement.css( {
  9232. position: wrapper.css( "position" ),
  9233. width: wrapper.outerWidth(),
  9234. height: wrapper.outerHeight(),
  9235. top: wrapper.css( "top" ),
  9236. left: wrapper.css( "left" )
  9237. } ).insertAfter( wrapper );
  9238. wrapper.remove();
  9239. }
  9240. this.originalElement.css( "resize", this.originalResizeStyle );
  9241. _destroy( this.originalElement );
  9242. return this;
  9243. },
  9244. _setOption: function( key, value ) {
  9245. this._super( key, value );
  9246. switch ( key ) {
  9247. case "handles":
  9248. this._removeHandles();
  9249. this._setupHandles();
  9250. break;
  9251. default:
  9252. break;
  9253. }
  9254. },
  9255. _setupHandles: function() {
  9256. var o = this.options, handle, i, n, hname, axis, that = this;
  9257. this.handles = o.handles ||
  9258. ( !$( ".ui-resizable-handle", this.element ).length ?
  9259. "e,s,se" : {
  9260. n: ".ui-resizable-n",
  9261. e: ".ui-resizable-e",
  9262. s: ".ui-resizable-s",
  9263. w: ".ui-resizable-w",
  9264. se: ".ui-resizable-se",
  9265. sw: ".ui-resizable-sw",
  9266. ne: ".ui-resizable-ne",
  9267. nw: ".ui-resizable-nw"
  9268. } );
  9269. this._handles = $();
  9270. if ( this.handles.constructor === String ) {
  9271. if ( this.handles === "all" ) {
  9272. this.handles = "n,e,s,w,se,sw,ne,nw";
  9273. }
  9274. n = this.handles.split( "," );
  9275. this.handles = {};
  9276. for ( i = 0; i < n.length; i++ ) {
  9277. handle = $.trim( n[ i ] );
  9278. hname = "ui-resizable-" + handle;
  9279. axis = $( "<div>" );
  9280. this._addClass( axis, "ui-resizable-handle " + hname );
  9281. axis.css( { zIndex: o.zIndex } );
  9282. this.handles[ handle ] = ".ui-resizable-" + handle;
  9283. this.element.append( axis );
  9284. }
  9285. }
  9286. this._renderAxis = function( target ) {
  9287. var i, axis, padPos, padWrapper;
  9288. target = target || this.element;
  9289. for ( i in this.handles ) {
  9290. if ( this.handles[ i ].constructor === String ) {
  9291. this.handles[ i ] = this.element.children( this.handles[ i ] ).first().show();
  9292. } else if ( this.handles[ i ].jquery || this.handles[ i ].nodeType ) {
  9293. this.handles[ i ] = $( this.handles[ i ] );
  9294. this._on( this.handles[ i ], { "mousedown": that._mouseDown } );
  9295. }
  9296. if ( this.elementIsWrapper &&
  9297. this.originalElement[ 0 ]
  9298. .nodeName
  9299. .match( /^(textarea|input|select|button)$/i ) ) {
  9300. axis = $( this.handles[ i ], this.element );
  9301. padWrapper = /sw|ne|nw|se|n|s/.test( i ) ?
  9302. axis.outerHeight() :
  9303. axis.outerWidth();
  9304. padPos = [ "padding",
  9305. /ne|nw|n/.test( i ) ? "Top" :
  9306. /se|sw|s/.test( i ) ? "Bottom" :
  9307. /^e$/.test( i ) ? "Right" : "Left" ].join( "" );
  9308. target.css( padPos, padWrapper );
  9309. this._proportionallyResize();
  9310. }
  9311. this._handles = this._handles.add( this.handles[ i ] );
  9312. }
  9313. };
  9314. // TODO: make renderAxis a prototype function
  9315. this._renderAxis( this.element );
  9316. this._handles = this._handles.add( this.element.find( ".ui-resizable-handle" ) );
  9317. this._handles.disableSelection();
  9318. this._handles.on( "mouseover", function() {
  9319. if ( !that.resizing ) {
  9320. if ( this.className ) {
  9321. axis = this.className.match( /ui-resizable-(se|sw|ne|nw|n|e|s|w)/i );
  9322. }
  9323. that.axis = axis && axis[ 1 ] ? axis[ 1 ] : "se";
  9324. }
  9325. } );
  9326. if ( o.autoHide ) {
  9327. this._handles.hide();
  9328. this._addClass( "ui-resizable-autohide" );
  9329. }
  9330. },
  9331. _removeHandles: function() {
  9332. this._handles.remove();
  9333. },
  9334. _mouseCapture: function( event ) {
  9335. var i, handle,
  9336. capture = false;
  9337. for ( i in this.handles ) {
  9338. handle = $( this.handles[ i ] )[ 0 ];
  9339. if ( handle === event.target || $.contains( handle, event.target ) ) {
  9340. capture = true;
  9341. }
  9342. }
  9343. return !this.options.disabled && capture;
  9344. },
  9345. _mouseStart: function( event ) {
  9346. var curleft, curtop, cursor,
  9347. o = this.options,
  9348. el = this.element;
  9349. this.resizing = true;
  9350. this._renderProxy();
  9351. curleft = this._num( this.helper.css( "left" ) );
  9352. curtop = this._num( this.helper.css( "top" ) );
  9353. if ( o.containment ) {
  9354. curleft += $( o.containment ).scrollLeft() || 0;
  9355. curtop += $( o.containment ).scrollTop() || 0;
  9356. }
  9357. this.offset = this.helper.offset();
  9358. this.position = { left: curleft, top: curtop };
  9359. this.size = this._helper ? {
  9360. width: this.helper.width(),
  9361. height: this.helper.height()
  9362. } : {
  9363. width: el.width(),
  9364. height: el.height()
  9365. };
  9366. this.originalSize = this._helper ? {
  9367. width: el.outerWidth(),
  9368. height: el.outerHeight()
  9369. } : {
  9370. width: el.width(),
  9371. height: el.height()
  9372. };
  9373. this.sizeDiff = {
  9374. width: el.outerWidth() - el.width(),
  9375. height: el.outerHeight() - el.height()
  9376. };
  9377. this.originalPosition = { left: curleft, top: curtop };
  9378. this.originalMousePosition = { left: event.pageX, top: event.pageY };
  9379. this.aspectRatio = ( typeof o.aspectRatio === "number" ) ?
  9380. o.aspectRatio :
  9381. ( ( this.originalSize.width / this.originalSize.height ) || 1 );
  9382. cursor = $( ".ui-resizable-" + this.axis ).css( "cursor" );
  9383. $( "body" ).css( "cursor", cursor === "auto" ? this.axis + "-resize" : cursor );
  9384. this._addClass( "ui-resizable-resizing" );
  9385. this._propagate( "start", event );
  9386. return true;
  9387. },
  9388. _mouseDrag: function( event ) {
  9389. var data, props,
  9390. smp = this.originalMousePosition,
  9391. a = this.axis,
  9392. dx = ( event.pageX - smp.left ) || 0,
  9393. dy = ( event.pageY - smp.top ) || 0,
  9394. trigger = this._change[ a ];
  9395. this._updatePrevProperties();
  9396. if ( !trigger ) {
  9397. return false;
  9398. }
  9399. data = trigger.apply( this, [ event, dx, dy ] );
  9400. this._updateVirtualBoundaries( event.shiftKey );
  9401. if ( this._aspectRatio || event.shiftKey ) {
  9402. data = this._updateRatio( data, event );
  9403. }
  9404. data = this._respectSize( data, event );
  9405. this._updateCache( data );
  9406. this._propagate( "resize", event );
  9407. props = this._applyChanges();
  9408. if ( !this._helper && this._proportionallyResizeElements.length ) {
  9409. this._proportionallyResize();
  9410. }
  9411. if ( !$.isEmptyObject( props ) ) {
  9412. this._updatePrevProperties();
  9413. this._trigger( "resize", event, this.ui() );
  9414. this._applyChanges();
  9415. }
  9416. return false;
  9417. },
  9418. _mouseStop: function( event ) {
  9419. this.resizing = false;
  9420. var pr, ista, soffseth, soffsetw, s, left, top,
  9421. o = this.options, that = this;
  9422. if ( this._helper ) {
  9423. pr = this._proportionallyResizeElements;
  9424. ista = pr.length && ( /textarea/i ).test( pr[ 0 ].nodeName );
  9425. soffseth = ista && this._hasScroll( pr[ 0 ], "left" ) ? 0 : that.sizeDiff.height;
  9426. soffsetw = ista ? 0 : that.sizeDiff.width;
  9427. s = {
  9428. width: ( that.helper.width() - soffsetw ),
  9429. height: ( that.helper.height() - soffseth )
  9430. };
  9431. left = ( parseFloat( that.element.css( "left" ) ) +
  9432. ( that.position.left - that.originalPosition.left ) ) || null;
  9433. top = ( parseFloat( that.element.css( "top" ) ) +
  9434. ( that.position.top - that.originalPosition.top ) ) || null;
  9435. if ( !o.animate ) {
  9436. this.element.css( $.extend( s, { top: top, left: left } ) );
  9437. }
  9438. that.helper.height( that.size.height );
  9439. that.helper.width( that.size.width );
  9440. if ( this._helper && !o.animate ) {
  9441. this._proportionallyResize();
  9442. }
  9443. }
  9444. $( "body" ).css( "cursor", "auto" );
  9445. this._removeClass( "ui-resizable-resizing" );
  9446. this._propagate( "stop", event );
  9447. if ( this._helper ) {
  9448. this.helper.remove();
  9449. }
  9450. return false;
  9451. },
  9452. _updatePrevProperties: function() {
  9453. this.prevPosition = {
  9454. top: this.position.top,
  9455. left: this.position.left
  9456. };
  9457. this.prevSize = {
  9458. width: this.size.width,
  9459. height: this.size.height
  9460. };
  9461. },
  9462. _applyChanges: function() {
  9463. var props = {};
  9464. if ( this.position.top !== this.prevPosition.top ) {
  9465. props.top = this.position.top + "px";
  9466. }
  9467. if ( this.position.left !== this.prevPosition.left ) {
  9468. props.left = this.position.left + "px";
  9469. }
  9470. if ( this.size.width !== this.prevSize.width ) {
  9471. props.width = this.size.width + "px";
  9472. }
  9473. if ( this.size.height !== this.prevSize.height ) {
  9474. props.height = this.size.height + "px";
  9475. }
  9476. this.helper.css( props );
  9477. return props;
  9478. },
  9479. _updateVirtualBoundaries: function( forceAspectRatio ) {
  9480. var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b,
  9481. o = this.options;
  9482. b = {
  9483. minWidth: this._isNumber( o.minWidth ) ? o.minWidth : 0,
  9484. maxWidth: this._isNumber( o.maxWidth ) ? o.maxWidth : Infinity,
  9485. minHeight: this._isNumber( o.minHeight ) ? o.minHeight : 0,
  9486. maxHeight: this._isNumber( o.maxHeight ) ? o.maxHeight : Infinity
  9487. };
  9488. if ( this._aspectRatio || forceAspectRatio ) {
  9489. pMinWidth = b.minHeight * this.aspectRatio;
  9490. pMinHeight = b.minWidth / this.aspectRatio;
  9491. pMaxWidth = b.maxHeight * this.aspectRatio;
  9492. pMaxHeight = b.maxWidth / this.aspectRatio;
  9493. if ( pMinWidth > b.minWidth ) {
  9494. b.minWidth = pMinWidth;
  9495. }
  9496. if ( pMinHeight > b.minHeight ) {
  9497. b.minHeight = pMinHeight;
  9498. }
  9499. if ( pMaxWidth < b.maxWidth ) {
  9500. b.maxWidth = pMaxWidth;
  9501. }
  9502. if ( pMaxHeight < b.maxHeight ) {
  9503. b.maxHeight = pMaxHeight;
  9504. }
  9505. }
  9506. this._vBoundaries = b;
  9507. },
  9508. _updateCache: function( data ) {
  9509. this.offset = this.helper.offset();
  9510. if ( this._isNumber( data.left ) ) {
  9511. this.position.left = data.left;
  9512. }
  9513. if ( this._isNumber( data.top ) ) {
  9514. this.position.top = data.top;
  9515. }
  9516. if ( this._isNumber( data.height ) ) {
  9517. this.size.height = data.height;
  9518. }
  9519. if ( this._isNumber( data.width ) ) {
  9520. this.size.width = data.width;
  9521. }
  9522. },
  9523. _updateRatio: function( data ) {
  9524. var cpos = this.position,
  9525. csize = this.size,
  9526. a = this.axis;
  9527. if ( this._isNumber( data.height ) ) {
  9528. data.width = ( data.height * this.aspectRatio );
  9529. } else if ( this._isNumber( data.width ) ) {
  9530. data.height = ( data.width / this.aspectRatio );
  9531. }
  9532. if ( a === "sw" ) {
  9533. data.left = cpos.left + ( csize.width - data.width );
  9534. data.top = null;
  9535. }
  9536. if ( a === "nw" ) {
  9537. data.top = cpos.top + ( csize.height - data.height );
  9538. data.left = cpos.left + ( csize.width - data.width );
  9539. }
  9540. return data;
  9541. },
  9542. _respectSize: function( data ) {
  9543. var o = this._vBoundaries,
  9544. a = this.axis,
  9545. ismaxw = this._isNumber( data.width ) && o.maxWidth && ( o.maxWidth < data.width ),
  9546. ismaxh = this._isNumber( data.height ) && o.maxHeight && ( o.maxHeight < data.height ),
  9547. isminw = this._isNumber( data.width ) && o.minWidth && ( o.minWidth > data.width ),
  9548. isminh = this._isNumber( data.height ) && o.minHeight && ( o.minHeight > data.height ),
  9549. dw = this.originalPosition.left + this.originalSize.width,
  9550. dh = this.originalPosition.top + this.originalSize.height,
  9551. cw = /sw|nw|w/.test( a ), ch = /nw|ne|n/.test( a );
  9552. if ( isminw ) {
  9553. data.width = o.minWidth;
  9554. }
  9555. if ( isminh ) {
  9556. data.height = o.minHeight;
  9557. }
  9558. if ( ismaxw ) {
  9559. data.width = o.maxWidth;
  9560. }
  9561. if ( ismaxh ) {
  9562. data.height = o.maxHeight;
  9563. }
  9564. if ( isminw && cw ) {
  9565. data.left = dw - o.minWidth;
  9566. }
  9567. if ( ismaxw && cw ) {
  9568. data.left = dw - o.maxWidth;
  9569. }
  9570. if ( isminh && ch ) {
  9571. data.top = dh - o.minHeight;
  9572. }
  9573. if ( ismaxh && ch ) {
  9574. data.top = dh - o.maxHeight;
  9575. }
  9576. // Fixing jump error on top/left - bug #2330
  9577. if ( !data.width && !data.height && !data.left && data.top ) {
  9578. data.top = null;
  9579. } else if ( !data.width && !data.height && !data.top && data.left ) {
  9580. data.left = null;
  9581. }
  9582. return data;
  9583. },
  9584. _getPaddingPlusBorderDimensions: function( element ) {
  9585. var i = 0,
  9586. widths = [],
  9587. borders = [
  9588. element.css( "borderTopWidth" ),
  9589. element.css( "borderRightWidth" ),
  9590. element.css( "borderBottomWidth" ),
  9591. element.css( "borderLeftWidth" )
  9592. ],
  9593. paddings = [
  9594. element.css( "paddingTop" ),
  9595. element.css( "paddingRight" ),
  9596. element.css( "paddingBottom" ),
  9597. element.css( "paddingLeft" )
  9598. ];
  9599. for ( ; i < 4; i++ ) {
  9600. widths[ i ] = ( parseFloat( borders[ i ] ) || 0 );
  9601. widths[ i ] += ( parseFloat( paddings[ i ] ) || 0 );
  9602. }
  9603. return {
  9604. height: widths[ 0 ] + widths[ 2 ],
  9605. width: widths[ 1 ] + widths[ 3 ]
  9606. };
  9607. },
  9608. _proportionallyResize: function() {
  9609. if ( !this._proportionallyResizeElements.length ) {
  9610. return;
  9611. }
  9612. var prel,
  9613. i = 0,
  9614. element = this.helper || this.element;
  9615. for ( ; i < this._proportionallyResizeElements.length; i++ ) {
  9616. prel = this._proportionallyResizeElements[ i ];
  9617. // TODO: Seems like a bug to cache this.outerDimensions
  9618. // considering that we are in a loop.
  9619. if ( !this.outerDimensions ) {
  9620. this.outerDimensions = this._getPaddingPlusBorderDimensions( prel );
  9621. }
  9622. prel.css( {
  9623. height: ( element.height() - this.outerDimensions.height ) || 0,
  9624. width: ( element.width() - this.outerDimensions.width ) || 0
  9625. } );
  9626. }
  9627. },
  9628. _renderProxy: function() {
  9629. var el = this.element, o = this.options;
  9630. this.elementOffset = el.offset();
  9631. if ( this._helper ) {
  9632. this.helper = this.helper || $( "<div style='overflow:hidden;'></div>" );
  9633. this._addClass( this.helper, this._helper );
  9634. this.helper.css( {
  9635. width: this.element.outerWidth(),
  9636. height: this.element.outerHeight(),
  9637. position: "absolute",
  9638. left: this.elementOffset.left + "px",
  9639. top: this.elementOffset.top + "px",
  9640. zIndex: ++o.zIndex //TODO: Don't modify option
  9641. } );
  9642. this.helper
  9643. .appendTo( "body" )
  9644. .disableSelection();
  9645. } else {
  9646. this.helper = this.element;
  9647. }
  9648. },
  9649. _change: {
  9650. e: function( event, dx ) {
  9651. return { width: this.originalSize.width + dx };
  9652. },
  9653. w: function( event, dx ) {
  9654. var cs = this.originalSize, sp = this.originalPosition;
  9655. return { left: sp.left + dx, width: cs.width - dx };
  9656. },
  9657. n: function( event, dx, dy ) {
  9658. var cs = this.originalSize, sp = this.originalPosition;
  9659. return { top: sp.top + dy, height: cs.height - dy };
  9660. },
  9661. s: function( event, dx, dy ) {
  9662. return { height: this.originalSize.height + dy };
  9663. },
  9664. se: function( event, dx, dy ) {
  9665. return $.extend( this._change.s.apply( this, arguments ),
  9666. this._change.e.apply( this, [ event, dx, dy ] ) );
  9667. },
  9668. sw: function( event, dx, dy ) {
  9669. return $.extend( this._change.s.apply( this, arguments ),
  9670. this._change.w.apply( this, [ event, dx, dy ] ) );
  9671. },
  9672. ne: function( event, dx, dy ) {
  9673. return $.extend( this._change.n.apply( this, arguments ),
  9674. this._change.e.apply( this, [ event, dx, dy ] ) );
  9675. },
  9676. nw: function( event, dx, dy ) {
  9677. return $.extend( this._change.n.apply( this, arguments ),
  9678. this._change.w.apply( this, [ event, dx, dy ] ) );
  9679. }
  9680. },
  9681. _propagate: function( n, event ) {
  9682. $.ui.plugin.call( this, n, [ event, this.ui() ] );
  9683. ( n !== "resize" && this._trigger( n, event, this.ui() ) );
  9684. },
  9685. plugins: {},
  9686. ui: function() {
  9687. return {
  9688. originalElement: this.originalElement,
  9689. element: this.element,
  9690. helper: this.helper,
  9691. position: this.position,
  9692. size: this.size,
  9693. originalSize: this.originalSize,
  9694. originalPosition: this.originalPosition
  9695. };
  9696. }
  9697. } );
  9698. /*
  9699. * Resizable Extensions
  9700. */
  9701. $.ui.plugin.add( "resizable", "animate", {
  9702. stop: function( event ) {
  9703. var that = $( this ).resizable( "instance" ),
  9704. o = that.options,
  9705. pr = that._proportionallyResizeElements,
  9706. ista = pr.length && ( /textarea/i ).test( pr[ 0 ].nodeName ),
  9707. soffseth = ista && that._hasScroll( pr[ 0 ], "left" ) ? 0 : that.sizeDiff.height,
  9708. soffsetw = ista ? 0 : that.sizeDiff.width,
  9709. style = {
  9710. width: ( that.size.width - soffsetw ),
  9711. height: ( that.size.height - soffseth )
  9712. },
  9713. left = ( parseFloat( that.element.css( "left" ) ) +
  9714. ( that.position.left - that.originalPosition.left ) ) || null,
  9715. top = ( parseFloat( that.element.css( "top" ) ) +
  9716. ( that.position.top - that.originalPosition.top ) ) || null;
  9717. that.element.animate(
  9718. $.extend( style, top && left ? { top: top, left: left } : {} ), {
  9719. duration: o.animateDuration,
  9720. easing: o.animateEasing,
  9721. step: function() {
  9722. var data = {
  9723. width: parseFloat( that.element.css( "width" ) ),
  9724. height: parseFloat( that.element.css( "height" ) ),
  9725. top: parseFloat( that.element.css( "top" ) ),
  9726. left: parseFloat( that.element.css( "left" ) )
  9727. };
  9728. if ( pr && pr.length ) {
  9729. $( pr[ 0 ] ).css( { width: data.width, height: data.height } );
  9730. }
  9731. // Propagating resize, and updating values for each animation step
  9732. that._updateCache( data );
  9733. that._propagate( "resize", event );
  9734. }
  9735. }
  9736. );
  9737. }
  9738. } );
  9739. $.ui.plugin.add( "resizable", "containment", {
  9740. start: function() {
  9741. var element, p, co, ch, cw, width, height,
  9742. that = $( this ).resizable( "instance" ),
  9743. o = that.options,
  9744. el = that.element,
  9745. oc = o.containment,
  9746. ce = ( oc instanceof $ ) ?
  9747. oc.get( 0 ) :
  9748. ( /parent/.test( oc ) ) ? el.parent().get( 0 ) : oc;
  9749. if ( !ce ) {
  9750. return;
  9751. }
  9752. that.containerElement = $( ce );
  9753. if ( /document/.test( oc ) || oc === document ) {
  9754. that.containerOffset = {
  9755. left: 0,
  9756. top: 0
  9757. };
  9758. that.containerPosition = {
  9759. left: 0,
  9760. top: 0
  9761. };
  9762. that.parentData = {
  9763. element: $( document ),
  9764. left: 0,
  9765. top: 0,
  9766. width: $( document ).width(),
  9767. height: $( document ).height() || document.body.parentNode.scrollHeight
  9768. };
  9769. } else {
  9770. element = $( ce );
  9771. p = [];
  9772. $( [ "Top", "Right", "Left", "Bottom" ] ).each( function( i, name ) {
  9773. p[ i ] = that._num( element.css( "padding" + name ) );
  9774. } );
  9775. that.containerOffset = element.offset();
  9776. that.containerPosition = element.position();
  9777. that.containerSize = {
  9778. height: ( element.innerHeight() - p[ 3 ] ),
  9779. width: ( element.innerWidth() - p[ 1 ] )
  9780. };
  9781. co = that.containerOffset;
  9782. ch = that.containerSize.height;
  9783. cw = that.containerSize.width;
  9784. width = ( that._hasScroll ( ce, "left" ) ? ce.scrollWidth : cw );
  9785. height = ( that._hasScroll ( ce ) ? ce.scrollHeight : ch ) ;
  9786. that.parentData = {
  9787. element: ce,
  9788. left: co.left,
  9789. top: co.top,
  9790. width: width,
  9791. height: height
  9792. };
  9793. }
  9794. },
  9795. resize: function( event ) {
  9796. var woset, hoset, isParent, isOffsetRelative,
  9797. that = $( this ).resizable( "instance" ),
  9798. o = that.options,
  9799. co = that.containerOffset,
  9800. cp = that.position,
  9801. pRatio = that._aspectRatio || event.shiftKey,
  9802. cop = {
  9803. top: 0,
  9804. left: 0
  9805. },
  9806. ce = that.containerElement,
  9807. continueResize = true;
  9808. if ( ce[ 0 ] !== document && ( /static/ ).test( ce.css( "position" ) ) ) {
  9809. cop = co;
  9810. }
  9811. if ( cp.left < ( that._helper ? co.left : 0 ) ) {
  9812. that.size.width = that.size.width +
  9813. ( that._helper ?
  9814. ( that.position.left - co.left ) :
  9815. ( that.position.left - cop.left ) );
  9816. if ( pRatio ) {
  9817. that.size.height = that.size.width / that.aspectRatio;
  9818. continueResize = false;
  9819. }
  9820. that.position.left = o.helper ? co.left : 0;
  9821. }
  9822. if ( cp.top < ( that._helper ? co.top : 0 ) ) {
  9823. that.size.height = that.size.height +
  9824. ( that._helper ?
  9825. ( that.position.top - co.top ) :
  9826. that.position.top );
  9827. if ( pRatio ) {
  9828. that.size.width = that.size.height * that.aspectRatio;
  9829. continueResize = false;
  9830. }
  9831. that.position.top = that._helper ? co.top : 0;
  9832. }
  9833. isParent = that.containerElement.get( 0 ) === that.element.parent().get( 0 );
  9834. isOffsetRelative = /relative|absolute/.test( that.containerElement.css( "position" ) );
  9835. if ( isParent && isOffsetRelative ) {
  9836. that.offset.left = that.parentData.left + that.position.left;
  9837. that.offset.top = that.parentData.top + that.position.top;
  9838. } else {
  9839. that.offset.left = that.element.offset().left;
  9840. that.offset.top = that.element.offset().top;
  9841. }
  9842. woset = Math.abs( that.sizeDiff.width +
  9843. ( that._helper ?
  9844. that.offset.left - cop.left :
  9845. ( that.offset.left - co.left ) ) );
  9846. hoset = Math.abs( that.sizeDiff.height +
  9847. ( that._helper ?
  9848. that.offset.top - cop.top :
  9849. ( that.offset.top - co.top ) ) );
  9850. if ( woset + that.size.width >= that.parentData.width ) {
  9851. that.size.width = that.parentData.width - woset;
  9852. if ( pRatio ) {
  9853. that.size.height = that.size.width / that.aspectRatio;
  9854. continueResize = false;
  9855. }
  9856. }
  9857. if ( hoset + that.size.height >= that.parentData.height ) {
  9858. that.size.height = that.parentData.height - hoset;
  9859. if ( pRatio ) {
  9860. that.size.width = that.size.height * that.aspectRatio;
  9861. continueResize = false;
  9862. }
  9863. }
  9864. if ( !continueResize ) {
  9865. that.position.left = that.prevPosition.left;
  9866. that.position.top = that.prevPosition.top;
  9867. that.size.width = that.prevSize.width;
  9868. that.size.height = that.prevSize.height;
  9869. }
  9870. },
  9871. stop: function() {
  9872. var that = $( this ).resizable( "instance" ),
  9873. o = that.options,
  9874. co = that.containerOffset,
  9875. cop = that.containerPosition,
  9876. ce = that.containerElement,
  9877. helper = $( that.helper ),
  9878. ho = helper.offset(),
  9879. w = helper.outerWidth() - that.sizeDiff.width,
  9880. h = helper.outerHeight() - that.sizeDiff.height;
  9881. if ( that._helper && !o.animate && ( /relative/ ).test( ce.css( "position" ) ) ) {
  9882. $( this ).css( {
  9883. left: ho.left - cop.left - co.left,
  9884. width: w,
  9885. height: h
  9886. } );
  9887. }
  9888. if ( that._helper && !o.animate && ( /static/ ).test( ce.css( "position" ) ) ) {
  9889. $( this ).css( {
  9890. left: ho.left - cop.left - co.left,
  9891. width: w,
  9892. height: h
  9893. } );
  9894. }
  9895. }
  9896. } );
  9897. $.ui.plugin.add( "resizable", "alsoResize", {
  9898. start: function() {
  9899. var that = $( this ).resizable( "instance" ),
  9900. o = that.options;
  9901. $( o.alsoResize ).each( function() {
  9902. var el = $( this );
  9903. el.data( "ui-resizable-alsoresize", {
  9904. width: parseFloat( el.width() ), height: parseFloat( el.height() ),
  9905. left: parseFloat( el.css( "left" ) ), top: parseFloat( el.css( "top" ) )
  9906. } );
  9907. } );
  9908. },
  9909. resize: function( event, ui ) {
  9910. var that = $( this ).resizable( "instance" ),
  9911. o = that.options,
  9912. os = that.originalSize,
  9913. op = that.originalPosition,
  9914. delta = {
  9915. height: ( that.size.height - os.height ) || 0,
  9916. width: ( that.size.width - os.width ) || 0,
  9917. top: ( that.position.top - op.top ) || 0,
  9918. left: ( that.position.left - op.left ) || 0
  9919. };
  9920. $( o.alsoResize ).each( function() {
  9921. var el = $( this ), start = $( this ).data( "ui-resizable-alsoresize" ), style = {},
  9922. css = el.parents( ui.originalElement[ 0 ] ).length ?
  9923. [ "width", "height" ] :
  9924. [ "width", "height", "top", "left" ];
  9925. $.each( css, function( i, prop ) {
  9926. var sum = ( start[ prop ] || 0 ) + ( delta[ prop ] || 0 );
  9927. if ( sum && sum >= 0 ) {
  9928. style[ prop ] = sum || null;
  9929. }
  9930. } );
  9931. el.css( style );
  9932. } );
  9933. },
  9934. stop: function() {
  9935. $( this ).removeData( "ui-resizable-alsoresize" );
  9936. }
  9937. } );
  9938. $.ui.plugin.add( "resizable", "ghost", {
  9939. start: function() {
  9940. var that = $( this ).resizable( "instance" ), cs = that.size;
  9941. that.ghost = that.originalElement.clone();
  9942. that.ghost.css( {
  9943. opacity: 0.25,
  9944. display: "block",
  9945. position: "relative",
  9946. height: cs.height,
  9947. width: cs.width,
  9948. margin: 0,
  9949. left: 0,
  9950. top: 0
  9951. } );
  9952. that._addClass( that.ghost, "ui-resizable-ghost" );
  9953. // DEPRECATED
  9954. // TODO: remove after 1.12
  9955. if ( $.uiBackCompat !== false && typeof that.options.ghost === "string" ) {
  9956. // Ghost option
  9957. that.ghost.addClass( this.options.ghost );
  9958. }
  9959. that.ghost.appendTo( that.helper );
  9960. },
  9961. resize: function() {
  9962. var that = $( this ).resizable( "instance" );
  9963. if ( that.ghost ) {
  9964. that.ghost.css( {
  9965. position: "relative",
  9966. height: that.size.height,
  9967. width: that.size.width
  9968. } );
  9969. }
  9970. },
  9971. stop: function() {
  9972. var that = $( this ).resizable( "instance" );
  9973. if ( that.ghost && that.helper ) {
  9974. that.helper.get( 0 ).removeChild( that.ghost.get( 0 ) );
  9975. }
  9976. }
  9977. } );
  9978. $.ui.plugin.add( "resizable", "grid", {
  9979. resize: function() {
  9980. var outerDimensions,
  9981. that = $( this ).resizable( "instance" ),
  9982. o = that.options,
  9983. cs = that.size,
  9984. os = that.originalSize,
  9985. op = that.originalPosition,
  9986. a = that.axis,
  9987. grid = typeof o.grid === "number" ? [ o.grid, o.grid ] : o.grid,
  9988. gridX = ( grid[ 0 ] || 1 ),
  9989. gridY = ( grid[ 1 ] || 1 ),
  9990. ox = Math.round( ( cs.width - os.width ) / gridX ) * gridX,
  9991. oy = Math.round( ( cs.height - os.height ) / gridY ) * gridY,
  9992. newWidth = os.width + ox,
  9993. newHeight = os.height + oy,
  9994. isMaxWidth = o.maxWidth && ( o.maxWidth < newWidth ),
  9995. isMaxHeight = o.maxHeight && ( o.maxHeight < newHeight ),
  9996. isMinWidth = o.minWidth && ( o.minWidth > newWidth ),
  9997. isMinHeight = o.minHeight && ( o.minHeight > newHeight );
  9998. o.grid = grid;
  9999. if ( isMinWidth ) {
  10000. newWidth += gridX;
  10001. }
  10002. if ( isMinHeight ) {
  10003. newHeight += gridY;
  10004. }
  10005. if ( isMaxWidth ) {
  10006. newWidth -= gridX;
  10007. }
  10008. if ( isMaxHeight ) {
  10009. newHeight -= gridY;
  10010. }
  10011. if ( /^(se|s|e)$/.test( a ) ) {
  10012. that.size.width = newWidth;
  10013. that.size.height = newHeight;
  10014. } else if ( /^(ne)$/.test( a ) ) {
  10015. that.size.width = newWidth;
  10016. that.size.height = newHeight;
  10017. that.position.top = op.top - oy;
  10018. } else if ( /^(sw)$/.test( a ) ) {
  10019. that.size.width = newWidth;
  10020. that.size.height = newHeight;
  10021. that.position.left = op.left - ox;
  10022. } else {
  10023. if ( newHeight - gridY <= 0 || newWidth - gridX <= 0 ) {
  10024. outerDimensions = that._getPaddingPlusBorderDimensions( this );
  10025. }
  10026. if ( newHeight - gridY > 0 ) {
  10027. that.size.height = newHeight;
  10028. that.position.top = op.top - oy;
  10029. } else {
  10030. newHeight = gridY - outerDimensions.height;
  10031. that.size.height = newHeight;
  10032. that.position.top = op.top + os.height - newHeight;
  10033. }
  10034. if ( newWidth - gridX > 0 ) {
  10035. that.size.width = newWidth;
  10036. that.position.left = op.left - ox;
  10037. } else {
  10038. newWidth = gridX - outerDimensions.width;
  10039. that.size.width = newWidth;
  10040. that.position.left = op.left + os.width - newWidth;
  10041. }
  10042. }
  10043. }
  10044. } );
  10045. var widgetsResizable = $.ui.resizable;
  10046. /*!
  10047. * jQuery UI Dialog 1.12.1
  10048. * http://jqueryui.com
  10049. *
  10050. * Copyright jQuery Foundation and other contributors
  10051. * Released under the MIT license.
  10052. * http://jquery.org/license
  10053. */
  10054. //>>label: Dialog
  10055. //>>group: Widgets
  10056. //>>description: Displays customizable dialog windows.
  10057. //>>docs: http://api.jqueryui.com/dialog/
  10058. //>>demos: http://jqueryui.com/dialog/
  10059. //>>css.structure: ../../themes/base/core.css
  10060. //>>css.structure: ../../themes/base/dialog.css
  10061. //>>css.theme: ../../themes/base/theme.css
  10062. $.widget( "ui.dialog", {
  10063. version: "1.12.1",
  10064. options: {
  10065. appendTo: "body",
  10066. autoOpen: true,
  10067. buttons: [],
  10068. classes: {
  10069. "ui-dialog": "ui-corner-all",
  10070. "ui-dialog-titlebar": "ui-corner-all"
  10071. },
  10072. closeOnEscape: true,
  10073. closeText: "Close",
  10074. draggable: true,
  10075. hide: null,
  10076. height: "auto",
  10077. maxHeight: null,
  10078. maxWidth: null,
  10079. minHeight: 150,
  10080. minWidth: 150,
  10081. modal: false,
  10082. position: {
  10083. my: "center",
  10084. at: "center",
  10085. of: window,
  10086. collision: "fit",
  10087. // Ensure the titlebar is always visible
  10088. using: function( pos ) {
  10089. var topOffset = $( this ).css( pos ).offset().top;
  10090. if ( topOffset < 0 ) {
  10091. $( this ).css( "top", pos.top - topOffset );
  10092. }
  10093. }
  10094. },
  10095. resizable: true,
  10096. show: null,
  10097. title: null,
  10098. width: 300,
  10099. // Callbacks
  10100. beforeClose: null,
  10101. close: null,
  10102. drag: null,
  10103. dragStart: null,
  10104. dragStop: null,
  10105. focus: null,
  10106. open: null,
  10107. resize: null,
  10108. resizeStart: null,
  10109. resizeStop: null
  10110. },
  10111. sizeRelatedOptions: {
  10112. buttons: true,
  10113. height: true,
  10114. maxHeight: true,
  10115. maxWidth: true,
  10116. minHeight: true,
  10117. minWidth: true,
  10118. width: true
  10119. },
  10120. resizableRelatedOptions: {
  10121. maxHeight: true,
  10122. maxWidth: true,
  10123. minHeight: true,
  10124. minWidth: true
  10125. },
  10126. _create: function() {
  10127. this.originalCss = {
  10128. display: this.element[ 0 ].style.display,
  10129. width: this.element[ 0 ].style.width,
  10130. minHeight: this.element[ 0 ].style.minHeight,
  10131. maxHeight: this.element[ 0 ].style.maxHeight,
  10132. height: this.element[ 0 ].style.height
  10133. };
  10134. this.originalPosition = {
  10135. parent: this.element.parent(),
  10136. index: this.element.parent().children().index( this.element )
  10137. };
  10138. this.originalTitle = this.element.attr( "title" );
  10139. if ( this.options.title == null && this.originalTitle != null ) {
  10140. this.options.title = this.originalTitle;
  10141. }
  10142. // Dialogs can't be disabled
  10143. if ( this.options.disabled ) {
  10144. this.options.disabled = false;
  10145. }
  10146. this._createWrapper();
  10147. this.element
  10148. .show()
  10149. .removeAttr( "title" )
  10150. .appendTo( this.uiDialog );
  10151. this._addClass( "ui-dialog-content", "ui-widget-content" );
  10152. this._createTitlebar();
  10153. this._createButtonPane();
  10154. if ( this.options.draggable && $.fn.draggable ) {
  10155. this._makeDraggable();
  10156. }
  10157. if ( this.options.resizable && $.fn.resizable ) {
  10158. this._makeResizable();
  10159. }
  10160. this._isOpen = false;
  10161. this._trackFocus();
  10162. },
  10163. _init: function() {
  10164. if ( this.options.autoOpen ) {
  10165. this.open();
  10166. }
  10167. },
  10168. _appendTo: function() {
  10169. var element = this.options.appendTo;
  10170. if ( element && ( element.jquery || element.nodeType ) ) {
  10171. return $( element );
  10172. }
  10173. return this.document.find( element || "body" ).eq( 0 );
  10174. },
  10175. _destroy: function() {
  10176. var next,
  10177. originalPosition = this.originalPosition;
  10178. this._untrackInstance();
  10179. this._destroyOverlay();
  10180. this.element
  10181. .removeUniqueId()
  10182. .css( this.originalCss )
  10183. // Without detaching first, the following becomes really slow
  10184. .detach();
  10185. this.uiDialog.remove();
  10186. if ( this.originalTitle ) {
  10187. this.element.attr( "title", this.originalTitle );
  10188. }
  10189. next = originalPosition.parent.children().eq( originalPosition.index );
  10190. // Don't try to place the dialog next to itself (#8613)
  10191. if ( next.length && next[ 0 ] !== this.element[ 0 ] ) {
  10192. next.before( this.element );
  10193. } else {
  10194. originalPosition.parent.append( this.element );
  10195. }
  10196. },
  10197. widget: function() {
  10198. return this.uiDialog;
  10199. },
  10200. disable: $.noop,
  10201. enable: $.noop,
  10202. close: function( event ) {
  10203. var that = this;
  10204. if ( !this._isOpen || this._trigger( "beforeClose", event ) === false ) {
  10205. return;
  10206. }
  10207. this._isOpen = false;
  10208. this._focusedElement = null;
  10209. this._destroyOverlay();
  10210. this._untrackInstance();
  10211. if ( !this.opener.filter( ":focusable" ).trigger( "focus" ).length ) {
  10212. // Hiding a focused element doesn't trigger blur in WebKit
  10213. // so in case we have nothing to focus on, explicitly blur the active element
  10214. // https://bugs.webkit.org/show_bug.cgi?id=47182
  10215. $.ui.safeBlur( $.ui.safeActiveElement( this.document[ 0 ] ) );
  10216. }
  10217. this._hide( this.uiDialog, this.options.hide, function() {
  10218. that._trigger( "close", event );
  10219. } );
  10220. },
  10221. isOpen: function() {
  10222. return this._isOpen;
  10223. },
  10224. moveToTop: function() {
  10225. this._moveToTop();
  10226. },
  10227. _moveToTop: function( event, silent ) {
  10228. var moved = false,
  10229. zIndices = this.uiDialog.siblings( ".ui-front:visible" ).map( function() {
  10230. return +$( this ).css( "z-index" );
  10231. } ).get(),
  10232. zIndexMax = Math.max.apply( null, zIndices );
  10233. if ( zIndexMax >= +this.uiDialog.css( "z-index" ) ) {
  10234. this.uiDialog.css( "z-index", zIndexMax + 1 );
  10235. moved = true;
  10236. }
  10237. if ( moved && !silent ) {
  10238. this._trigger( "focus", event );
  10239. }
  10240. return moved;
  10241. },
  10242. open: function() {
  10243. var that = this;
  10244. if ( this._isOpen ) {
  10245. if ( this._moveToTop() ) {
  10246. this._focusTabbable();
  10247. }
  10248. return;
  10249. }
  10250. this._isOpen = true;
  10251. this.opener = $( $.ui.safeActiveElement( this.document[ 0 ] ) );
  10252. this._size();
  10253. this._position();
  10254. this._createOverlay();
  10255. this._moveToTop( null, true );
  10256. // Ensure the overlay is moved to the top with the dialog, but only when
  10257. // opening. The overlay shouldn't move after the dialog is open so that
  10258. // modeless dialogs opened after the modal dialog stack properly.
  10259. if ( this.overlay ) {
  10260. this.overlay.css( "z-index", this.uiDialog.css( "z-index" ) - 1 );
  10261. }
  10262. this._show( this.uiDialog, this.options.show, function() {
  10263. that._focusTabbable();
  10264. that._trigger( "focus" );
  10265. } );
  10266. // Track the dialog immediately upon openening in case a focus event
  10267. // somehow occurs outside of the dialog before an element inside the
  10268. // dialog is focused (#10152)
  10269. this._makeFocusTarget();
  10270. this._trigger( "open" );
  10271. },
  10272. _focusTabbable: function() {
  10273. // Set focus to the first match:
  10274. // 1. An element that was focused previously
  10275. // 2. First element inside the dialog matching [autofocus]
  10276. // 3. Tabbable element inside the content element
  10277. // 4. Tabbable element inside the buttonpane
  10278. // 5. The close button
  10279. // 6. The dialog itself
  10280. var hasFocus = this._focusedElement;
  10281. if ( !hasFocus ) {
  10282. hasFocus = this.element.find( "[autofocus]" );
  10283. }
  10284. if ( !hasFocus.length ) {
  10285. hasFocus = this.element.find( ":tabbable" );
  10286. }
  10287. if ( !hasFocus.length ) {
  10288. hasFocus = this.uiDialogButtonPane.find( ":tabbable" );
  10289. }
  10290. if ( !hasFocus.length ) {
  10291. hasFocus = this.uiDialogTitlebarClose.filter( ":tabbable" );
  10292. }
  10293. if ( !hasFocus.length ) {
  10294. hasFocus = this.uiDialog;
  10295. }
  10296. hasFocus.eq( 0 ).trigger( "focus" );
  10297. },
  10298. _keepFocus: function( event ) {
  10299. function checkFocus() {
  10300. var activeElement = $.ui.safeActiveElement( this.document[ 0 ] ),
  10301. isActive = this.uiDialog[ 0 ] === activeElement ||
  10302. $.contains( this.uiDialog[ 0 ], activeElement );
  10303. if ( !isActive ) {
  10304. this._focusTabbable();
  10305. }
  10306. }
  10307. event.preventDefault();
  10308. checkFocus.call( this );
  10309. // support: IE
  10310. // IE <= 8 doesn't prevent moving focus even with event.preventDefault()
  10311. // so we check again later
  10312. this._delay( checkFocus );
  10313. },
  10314. _createWrapper: function() {
  10315. this.uiDialog = $( "<div>" )
  10316. .hide()
  10317. .attr( {
  10318. // Setting tabIndex makes the div focusable
  10319. tabIndex: -1,
  10320. role: "dialog"
  10321. } )
  10322. .appendTo( this._appendTo() );
  10323. this._addClass( this.uiDialog, "ui-dialog", "ui-widget ui-widget-content ui-front" );
  10324. this._on( this.uiDialog, {
  10325. keydown: function( event ) {
  10326. if ( this.options.closeOnEscape && !event.isDefaultPrevented() && event.keyCode &&
  10327. event.keyCode === $.ui.keyCode.ESCAPE ) {
  10328. event.preventDefault();
  10329. this.close( event );
  10330. return;
  10331. }
  10332. // Prevent tabbing out of dialogs
  10333. if ( event.keyCode !== $.ui.keyCode.TAB || event.isDefaultPrevented() ) {
  10334. return;
  10335. }
  10336. var tabbables = this.uiDialog.find( ":tabbable" ),
  10337. first = tabbables.filter( ":first" ),
  10338. last = tabbables.filter( ":last" );
  10339. if ( ( event.target === last[ 0 ] || event.target === this.uiDialog[ 0 ] ) &&
  10340. !event.shiftKey ) {
  10341. this._delay( function() {
  10342. first.trigger( "focus" );
  10343. } );
  10344. event.preventDefault();
  10345. } else if ( ( event.target === first[ 0 ] ||
  10346. event.target === this.uiDialog[ 0 ] ) && event.shiftKey ) {
  10347. this._delay( function() {
  10348. last.trigger( "focus" );
  10349. } );
  10350. event.preventDefault();
  10351. }
  10352. },
  10353. mousedown: function( event ) {
  10354. if ( this._moveToTop( event ) ) {
  10355. this._focusTabbable();
  10356. }
  10357. }
  10358. } );
  10359. // We assume that any existing aria-describedby attribute means
  10360. // that the dialog content is marked up properly
  10361. // otherwise we brute force the content as the description
  10362. if ( !this.element.find( "[aria-describedby]" ).length ) {
  10363. this.uiDialog.attr( {
  10364. "aria-describedby": this.element.uniqueId().attr( "id" )
  10365. } );
  10366. }
  10367. },
  10368. _createTitlebar: function() {
  10369. var uiDialogTitle;
  10370. this.uiDialogTitlebar = $( "<div>" );
  10371. this._addClass( this.uiDialogTitlebar,
  10372. "ui-dialog-titlebar", "ui-widget-header ui-helper-clearfix" );
  10373. this._on( this.uiDialogTitlebar, {
  10374. mousedown: function( event ) {
  10375. // Don't prevent click on close button (#8838)
  10376. // Focusing a dialog that is partially scrolled out of view
  10377. // causes the browser to scroll it into view, preventing the click event
  10378. if ( !$( event.target ).closest( ".ui-dialog-titlebar-close" ) ) {
  10379. // Dialog isn't getting focus when dragging (#8063)
  10380. this.uiDialog.trigger( "focus" );
  10381. }
  10382. }
  10383. } );
  10384. // Support: IE
  10385. // Use type="button" to prevent enter keypresses in textboxes from closing the
  10386. // dialog in IE (#9312)
  10387. this.uiDialogTitlebarClose = $( "<button type='button'></button>" )
  10388. .button( {
  10389. label: $( "<a>" ).text( this.options.closeText ).html(),
  10390. icon: "ui-icon-closethick",
  10391. showLabel: false
  10392. } )
  10393. .appendTo( this.uiDialogTitlebar );
  10394. this._addClass( this.uiDialogTitlebarClose, "ui-dialog-titlebar-close" );
  10395. this._on( this.uiDialogTitlebarClose, {
  10396. click: function( event ) {
  10397. event.preventDefault();
  10398. this.close( event );
  10399. }
  10400. } );
  10401. uiDialogTitle = $( "<span>" ).uniqueId().prependTo( this.uiDialogTitlebar );
  10402. this._addClass( uiDialogTitle, "ui-dialog-title" );
  10403. this._title( uiDialogTitle );
  10404. this.uiDialogTitlebar.prependTo( this.uiDialog );
  10405. this.uiDialog.attr( {
  10406. "aria-labelledby": uiDialogTitle.attr( "id" )
  10407. } );
  10408. },
  10409. _title: function( title ) {
  10410. if ( this.options.title ) {
  10411. title.text( this.options.title );
  10412. } else {
  10413. title.html( "&#160;" );
  10414. }
  10415. },
  10416. _createButtonPane: function() {
  10417. this.uiDialogButtonPane = $( "<div>" );
  10418. this._addClass( this.uiDialogButtonPane, "ui-dialog-buttonpane",
  10419. "ui-widget-content ui-helper-clearfix" );
  10420. this.uiButtonSet = $( "<div>" )
  10421. .appendTo( this.uiDialogButtonPane );
  10422. this._addClass( this.uiButtonSet, "ui-dialog-buttonset" );
  10423. this._createButtons();
  10424. },
  10425. _createButtons: function() {
  10426. var that = this,
  10427. buttons = this.options.buttons;
  10428. // If we already have a button pane, remove it
  10429. this.uiDialogButtonPane.remove();
  10430. this.uiButtonSet.empty();
  10431. if ( $.isEmptyObject( buttons ) || ( $.isArray( buttons ) && !buttons.length ) ) {
  10432. this._removeClass( this.uiDialog, "ui-dialog-buttons" );
  10433. return;
  10434. }
  10435. $.each( buttons, function( name, props ) {
  10436. var click, buttonOptions;
  10437. props = $.isFunction( props ) ?
  10438. { click: props, text: name } :
  10439. props;
  10440. // Default to a non-submitting button
  10441. props = $.extend( { type: "button" }, props );
  10442. // Change the context for the click callback to be the main element
  10443. click = props.click;
  10444. buttonOptions = {
  10445. icon: props.icon,
  10446. iconPosition: props.iconPosition,
  10447. showLabel: props.showLabel,
  10448. // Deprecated options
  10449. icons: props.icons,
  10450. text: props.text
  10451. };
  10452. delete props.click;
  10453. delete props.icon;
  10454. delete props.iconPosition;
  10455. delete props.showLabel;
  10456. // Deprecated options
  10457. delete props.icons;
  10458. if ( typeof props.text === "boolean" ) {
  10459. delete props.text;
  10460. }
  10461. $( "<button></button>", props )
  10462. .button( buttonOptions )
  10463. .appendTo( that.uiButtonSet )
  10464. .on( "click", function() {
  10465. click.apply( that.element[ 0 ], arguments );
  10466. } );
  10467. } );
  10468. this._addClass( this.uiDialog, "ui-dialog-buttons" );
  10469. this.uiDialogButtonPane.appendTo( this.uiDialog );
  10470. },
  10471. _makeDraggable: function() {
  10472. var that = this,
  10473. options = this.options;
  10474. function filteredUi( ui ) {
  10475. return {
  10476. position: ui.position,
  10477. offset: ui.offset
  10478. };
  10479. }
  10480. this.uiDialog.draggable( {
  10481. cancel: ".ui-dialog-content, .ui-dialog-titlebar-close",
  10482. handle: ".ui-dialog-titlebar",
  10483. containment: "document",
  10484. start: function( event, ui ) {
  10485. that._addClass( $( this ), "ui-dialog-dragging" );
  10486. that._blockFrames();
  10487. that._trigger( "dragStart", event, filteredUi( ui ) );
  10488. },
  10489. drag: function( event, ui ) {
  10490. that._trigger( "drag", event, filteredUi( ui ) );
  10491. },
  10492. stop: function( event, ui ) {
  10493. var left = ui.offset.left - that.document.scrollLeft(),
  10494. top = ui.offset.top - that.document.scrollTop();
  10495. options.position = {
  10496. my: "left top",
  10497. at: "left" + ( left >= 0 ? "+" : "" ) + left + " " +
  10498. "top" + ( top >= 0 ? "+" : "" ) + top,
  10499. of: that.window
  10500. };
  10501. that._removeClass( $( this ), "ui-dialog-dragging" );
  10502. that._unblockFrames();
  10503. that._trigger( "dragStop", event, filteredUi( ui ) );
  10504. }
  10505. } );
  10506. },
  10507. _makeResizable: function() {
  10508. var that = this,
  10509. options = this.options,
  10510. handles = options.resizable,
  10511. // .ui-resizable has position: relative defined in the stylesheet
  10512. // but dialogs have to use absolute or fixed positioning
  10513. position = this.uiDialog.css( "position" ),
  10514. resizeHandles = typeof handles === "string" ?
  10515. handles :
  10516. "n,e,s,w,se,sw,ne,nw";
  10517. function filteredUi( ui ) {
  10518. return {
  10519. originalPosition: ui.originalPosition,
  10520. originalSize: ui.originalSize,
  10521. position: ui.position,
  10522. size: ui.size
  10523. };
  10524. }
  10525. this.uiDialog.resizable( {
  10526. cancel: ".ui-dialog-content",
  10527. containment: "document",
  10528. alsoResize: this.element,
  10529. maxWidth: options.maxWidth,
  10530. maxHeight: options.maxHeight,
  10531. minWidth: options.minWidth,
  10532. minHeight: this._minHeight(),
  10533. handles: resizeHandles,
  10534. start: function( event, ui ) {
  10535. that._addClass( $( this ), "ui-dialog-resizing" );
  10536. that._blockFrames();
  10537. that._trigger( "resizeStart", event, filteredUi( ui ) );
  10538. },
  10539. resize: function( event, ui ) {
  10540. that._trigger( "resize", event, filteredUi( ui ) );
  10541. },
  10542. stop: function( event, ui ) {
  10543. var offset = that.uiDialog.offset(),
  10544. left = offset.left - that.document.scrollLeft(),
  10545. top = offset.top - that.document.scrollTop();
  10546. options.height = that.uiDialog.height();
  10547. options.width = that.uiDialog.width();
  10548. options.position = {
  10549. my: "left top",
  10550. at: "left" + ( left >= 0 ? "+" : "" ) + left + " " +
  10551. "top" + ( top >= 0 ? "+" : "" ) + top,
  10552. of: that.window
  10553. };
  10554. that._removeClass( $( this ), "ui-dialog-resizing" );
  10555. that._unblockFrames();
  10556. that._trigger( "resizeStop", event, filteredUi( ui ) );
  10557. }
  10558. } )
  10559. .css( "position", position );
  10560. },
  10561. _trackFocus: function() {
  10562. this._on( this.widget(), {
  10563. focusin: function( event ) {
  10564. this._makeFocusTarget();
  10565. this._focusedElement = $( event.target );
  10566. }
  10567. } );
  10568. },
  10569. _makeFocusTarget: function() {
  10570. this._untrackInstance();
  10571. this._trackingInstances().unshift( this );
  10572. },
  10573. _untrackInstance: function() {
  10574. var instances = this._trackingInstances(),
  10575. exists = $.inArray( this, instances );
  10576. if ( exists !== -1 ) {
  10577. instances.splice( exists, 1 );
  10578. }
  10579. },
  10580. _trackingInstances: function() {
  10581. var instances = this.document.data( "ui-dialog-instances" );
  10582. if ( !instances ) {
  10583. instances = [];
  10584. this.document.data( "ui-dialog-instances", instances );
  10585. }
  10586. return instances;
  10587. },
  10588. _minHeight: function() {
  10589. var options = this.options;
  10590. return options.height === "auto" ?
  10591. options.minHeight :
  10592. Math.min( options.minHeight, options.height );
  10593. },
  10594. _position: function() {
  10595. // Need to show the dialog to get the actual offset in the position plugin
  10596. var isVisible = this.uiDialog.is( ":visible" );
  10597. if ( !isVisible ) {
  10598. this.uiDialog.show();
  10599. }
  10600. this.uiDialog.position( this.options.position );
  10601. if ( !isVisible ) {
  10602. this.uiDialog.hide();
  10603. }
  10604. },
  10605. _setOptions: function( options ) {
  10606. var that = this,
  10607. resize = false,
  10608. resizableOptions = {};
  10609. $.each( options, function( key, value ) {
  10610. that._setOption( key, value );
  10611. if ( key in that.sizeRelatedOptions ) {
  10612. resize = true;
  10613. }
  10614. if ( key in that.resizableRelatedOptions ) {
  10615. resizableOptions[ key ] = value;
  10616. }
  10617. } );
  10618. if ( resize ) {
  10619. this._size();
  10620. this._position();
  10621. }
  10622. if ( this.uiDialog.is( ":data(ui-resizable)" ) ) {
  10623. this.uiDialog.resizable( "option", resizableOptions );
  10624. }
  10625. },
  10626. _setOption: function( key, value ) {
  10627. var isDraggable, isResizable,
  10628. uiDialog = this.uiDialog;
  10629. if ( key === "disabled" ) {
  10630. return;
  10631. }
  10632. this._super( key, value );
  10633. if ( key === "appendTo" ) {
  10634. this.uiDialog.appendTo( this._appendTo() );
  10635. }
  10636. if ( key === "buttons" ) {
  10637. this._createButtons();
  10638. }
  10639. if ( key === "closeText" ) {
  10640. this.uiDialogTitlebarClose.button( {
  10641. // Ensure that we always pass a string
  10642. label: $( "<a>" ).text( "" + this.options.closeText ).html()
  10643. } );
  10644. }
  10645. if ( key === "draggable" ) {
  10646. isDraggable = uiDialog.is( ":data(ui-draggable)" );
  10647. if ( isDraggable && !value ) {
  10648. uiDialog.draggable( "destroy" );
  10649. }
  10650. if ( !isDraggable && value ) {
  10651. this._makeDraggable();
  10652. }
  10653. }
  10654. if ( key === "position" ) {
  10655. this._position();
  10656. }
  10657. if ( key === "resizable" ) {
  10658. // currently resizable, becoming non-resizable
  10659. isResizable = uiDialog.is( ":data(ui-resizable)" );
  10660. if ( isResizable && !value ) {
  10661. uiDialog.resizable( "destroy" );
  10662. }
  10663. // Currently resizable, changing handles
  10664. if ( isResizable && typeof value === "string" ) {
  10665. uiDialog.resizable( "option", "handles", value );
  10666. }
  10667. // Currently non-resizable, becoming resizable
  10668. if ( !isResizable && value !== false ) {
  10669. this._makeResizable();
  10670. }
  10671. }
  10672. if ( key === "title" ) {
  10673. this._title( this.uiDialogTitlebar.find( ".ui-dialog-title" ) );
  10674. }
  10675. },
  10676. _size: function() {
  10677. // If the user has resized the dialog, the .ui-dialog and .ui-dialog-content
  10678. // divs will both have width and height set, so we need to reset them
  10679. var nonContentHeight, minContentHeight, maxContentHeight,
  10680. options = this.options;
  10681. // Reset content sizing
  10682. this.element.show().css( {
  10683. width: "auto",
  10684. minHeight: 0,
  10685. maxHeight: "none",
  10686. height: 0
  10687. } );
  10688. if ( options.minWidth > options.width ) {
  10689. options.width = options.minWidth;
  10690. }
  10691. // Reset wrapper sizing
  10692. // determine the height of all the non-content elements
  10693. nonContentHeight = this.uiDialog.css( {
  10694. height: "auto",
  10695. width: options.width
  10696. } )
  10697. .outerHeight();
  10698. minContentHeight = Math.max( 0, options.minHeight - nonContentHeight );
  10699. maxContentHeight = typeof options.maxHeight === "number" ?
  10700. Math.max( 0, options.maxHeight - nonContentHeight ) :
  10701. "none";
  10702. if ( options.height === "auto" ) {
  10703. this.element.css( {
  10704. minHeight: minContentHeight,
  10705. maxHeight: maxContentHeight,
  10706. height: "auto"
  10707. } );
  10708. } else {
  10709. this.element.height( Math.max( 0, options.height - nonContentHeight ) );
  10710. }
  10711. if ( this.uiDialog.is( ":data(ui-resizable)" ) ) {
  10712. this.uiDialog.resizable( "option", "minHeight", this._minHeight() );
  10713. }
  10714. },
  10715. _blockFrames: function() {
  10716. this.iframeBlocks = this.document.find( "iframe" ).map( function() {
  10717. var iframe = $( this );
  10718. return $( "<div>" )
  10719. .css( {
  10720. position: "absolute",
  10721. width: iframe.outerWidth(),
  10722. height: iframe.outerHeight()
  10723. } )
  10724. .appendTo( iframe.parent() )
  10725. .offset( iframe.offset() )[ 0 ];
  10726. } );
  10727. },
  10728. _unblockFrames: function() {
  10729. if ( this.iframeBlocks ) {
  10730. this.iframeBlocks.remove();
  10731. delete this.iframeBlocks;
  10732. }
  10733. },
  10734. _allowInteraction: function( event ) {
  10735. if ( $( event.target ).closest( ".ui-dialog" ).length ) {
  10736. return true;
  10737. }
  10738. // TODO: Remove hack when datepicker implements
  10739. // the .ui-front logic (#8989)
  10740. return !!$( event.target ).closest( ".ui-datepicker" ).length;
  10741. },
  10742. _createOverlay: function() {
  10743. if ( !this.options.modal ) {
  10744. return;
  10745. }
  10746. // We use a delay in case the overlay is created from an
  10747. // event that we're going to be cancelling (#2804)
  10748. var isOpening = true;
  10749. this._delay( function() {
  10750. isOpening = false;
  10751. } );
  10752. if ( !this.document.data( "ui-dialog-overlays" ) ) {
  10753. // Prevent use of anchors and inputs
  10754. // Using _on() for an event handler shared across many instances is
  10755. // safe because the dialogs stack and must be closed in reverse order
  10756. this._on( this.document, {
  10757. focusin: function( event ) {
  10758. if ( isOpening ) {
  10759. return;
  10760. }
  10761. if ( !this._allowInteraction( event ) ) {
  10762. event.preventDefault();
  10763. this._trackingInstances()[ 0 ]._focusTabbable();
  10764. }
  10765. }
  10766. } );
  10767. }
  10768. this.overlay = $( "<div>" )
  10769. .appendTo( this._appendTo() );
  10770. this._addClass( this.overlay, null, "ui-widget-overlay ui-front" );
  10771. this._on( this.overlay, {
  10772. mousedown: "_keepFocus"
  10773. } );
  10774. this.document.data( "ui-dialog-overlays",
  10775. ( this.document.data( "ui-dialog-overlays" ) || 0 ) + 1 );
  10776. },
  10777. _destroyOverlay: function() {
  10778. if ( !this.options.modal ) {
  10779. return;
  10780. }
  10781. if ( this.overlay ) {
  10782. var overlays = this.document.data( "ui-dialog-overlays" ) - 1;
  10783. if ( !overlays ) {
  10784. this._off( this.document, "focusin" );
  10785. this.document.removeData( "ui-dialog-overlays" );
  10786. } else {
  10787. this.document.data( "ui-dialog-overlays", overlays );
  10788. }
  10789. this.overlay.remove();
  10790. this.overlay = null;
  10791. }
  10792. }
  10793. } );
  10794. // DEPRECATED
  10795. // TODO: switch return back to widget declaration at top of file when this is removed
  10796. if ( $.uiBackCompat !== false ) {
  10797. // Backcompat for dialogClass option
  10798. $.widget( "ui.dialog", $.ui.dialog, {
  10799. options: {
  10800. dialogClass: ""
  10801. },
  10802. _createWrapper: function() {
  10803. this._super();
  10804. this.uiDialog.addClass( this.options.dialogClass );
  10805. },
  10806. _setOption: function( key, value ) {
  10807. if ( key === "dialogClass" ) {
  10808. this.uiDialog
  10809. .removeClass( this.options.dialogClass )
  10810. .addClass( value );
  10811. }
  10812. this._superApply( arguments );
  10813. }
  10814. } );
  10815. }
  10816. var widgetsDialog = $.ui.dialog;
  10817. /*!
  10818. * jQuery UI Droppable 1.12.1
  10819. * http://jqueryui.com
  10820. *
  10821. * Copyright jQuery Foundation and other contributors
  10822. * Released under the MIT license.
  10823. * http://jquery.org/license
  10824. */
  10825. //>>label: Droppable
  10826. //>>group: Interactions
  10827. //>>description: Enables drop targets for draggable elements.
  10828. //>>docs: http://api.jqueryui.com/droppable/
  10829. //>>demos: http://jqueryui.com/droppable/
  10830. $.widget( "ui.droppable", {
  10831. version: "1.12.1",
  10832. widgetEventPrefix: "drop",
  10833. options: {
  10834. accept: "*",
  10835. addClasses: true,
  10836. greedy: false,
  10837. scope: "default",
  10838. tolerance: "intersect",
  10839. // Callbacks
  10840. activate: null,
  10841. deactivate: null,
  10842. drop: null,
  10843. out: null,
  10844. over: null
  10845. },
  10846. _create: function() {
  10847. var proportions,
  10848. o = this.options,
  10849. accept = o.accept;
  10850. this.isover = false;
  10851. this.isout = true;
  10852. this.accept = $.isFunction( accept ) ? accept : function( d ) {
  10853. return d.is( accept );
  10854. };
  10855. this.proportions = function( /* valueToWrite */ ) {
  10856. if ( arguments.length ) {
  10857. // Store the droppable's proportions
  10858. proportions = arguments[ 0 ];
  10859. } else {
  10860. // Retrieve or derive the droppable's proportions
  10861. return proportions ?
  10862. proportions :
  10863. proportions = {
  10864. width: this.element[ 0 ].offsetWidth,
  10865. height: this.element[ 0 ].offsetHeight
  10866. };
  10867. }
  10868. };
  10869. this._addToManager( o.scope );
  10870. o.addClasses && this._addClass( "ui-droppable" );
  10871. },
  10872. _addToManager: function( scope ) {
  10873. // Add the reference and positions to the manager
  10874. $.ui.ddmanager.droppables[ scope ] = $.ui.ddmanager.droppables[ scope ] || [];
  10875. $.ui.ddmanager.droppables[ scope ].push( this );
  10876. },
  10877. _splice: function( drop ) {
  10878. var i = 0;
  10879. for ( ; i < drop.length; i++ ) {
  10880. if ( drop[ i ] === this ) {
  10881. drop.splice( i, 1 );
  10882. }
  10883. }
  10884. },
  10885. _destroy: function() {
  10886. var drop = $.ui.ddmanager.droppables[ this.options.scope ];
  10887. this._splice( drop );
  10888. },
  10889. _setOption: function( key, value ) {
  10890. if ( key === "accept" ) {
  10891. this.accept = $.isFunction( value ) ? value : function( d ) {
  10892. return d.is( value );
  10893. };
  10894. } else if ( key === "scope" ) {
  10895. var drop = $.ui.ddmanager.droppables[ this.options.scope ];
  10896. this._splice( drop );
  10897. this._addToManager( value );
  10898. }
  10899. this._super( key, value );
  10900. },
  10901. _activate: function( event ) {
  10902. var draggable = $.ui.ddmanager.current;
  10903. this._addActiveClass();
  10904. if ( draggable ) {
  10905. this._trigger( "activate", event, this.ui( draggable ) );
  10906. }
  10907. },
  10908. _deactivate: function( event ) {
  10909. var draggable = $.ui.ddmanager.current;
  10910. this._removeActiveClass();
  10911. if ( draggable ) {
  10912. this._trigger( "deactivate", event, this.ui( draggable ) );
  10913. }
  10914. },
  10915. _over: function( event ) {
  10916. var draggable = $.ui.ddmanager.current;
  10917. // Bail if draggable and droppable are same element
  10918. if ( !draggable || ( draggable.currentItem ||
  10919. draggable.element )[ 0 ] === this.element[ 0 ] ) {
  10920. return;
  10921. }
  10922. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem ||
  10923. draggable.element ) ) ) {
  10924. this._addHoverClass();
  10925. this._trigger( "over", event, this.ui( draggable ) );
  10926. }
  10927. },
  10928. _out: function( event ) {
  10929. var draggable = $.ui.ddmanager.current;
  10930. // Bail if draggable and droppable are same element
  10931. if ( !draggable || ( draggable.currentItem ||
  10932. draggable.element )[ 0 ] === this.element[ 0 ] ) {
  10933. return;
  10934. }
  10935. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem ||
  10936. draggable.element ) ) ) {
  10937. this._removeHoverClass();
  10938. this._trigger( "out", event, this.ui( draggable ) );
  10939. }
  10940. },
  10941. _drop: function( event, custom ) {
  10942. var draggable = custom || $.ui.ddmanager.current,
  10943. childrenIntersection = false;
  10944. // Bail if draggable and droppable are same element
  10945. if ( !draggable || ( draggable.currentItem ||
  10946. draggable.element )[ 0 ] === this.element[ 0 ] ) {
  10947. return false;
  10948. }
  10949. this.element
  10950. .find( ":data(ui-droppable)" )
  10951. .not( ".ui-draggable-dragging" )
  10952. .each( function() {
  10953. var inst = $( this ).droppable( "instance" );
  10954. if (
  10955. inst.options.greedy &&
  10956. !inst.options.disabled &&
  10957. inst.options.scope === draggable.options.scope &&
  10958. inst.accept.call(
  10959. inst.element[ 0 ], ( draggable.currentItem || draggable.element )
  10960. ) &&
  10961. intersect(
  10962. draggable,
  10963. $.extend( inst, { offset: inst.element.offset() } ),
  10964. inst.options.tolerance, event
  10965. )
  10966. ) {
  10967. childrenIntersection = true;
  10968. return false; }
  10969. } );
  10970. if ( childrenIntersection ) {
  10971. return false;
  10972. }
  10973. if ( this.accept.call( this.element[ 0 ],
  10974. ( draggable.currentItem || draggable.element ) ) ) {
  10975. this._removeActiveClass();
  10976. this._removeHoverClass();
  10977. this._trigger( "drop", event, this.ui( draggable ) );
  10978. return this.element;
  10979. }
  10980. return false;
  10981. },
  10982. ui: function( c ) {
  10983. return {
  10984. draggable: ( c.currentItem || c.element ),
  10985. helper: c.helper,
  10986. position: c.position,
  10987. offset: c.positionAbs
  10988. };
  10989. },
  10990. // Extension points just to make backcompat sane and avoid duplicating logic
  10991. // TODO: Remove in 1.13 along with call to it below
  10992. _addHoverClass: function() {
  10993. this._addClass( "ui-droppable-hover" );
  10994. },
  10995. _removeHoverClass: function() {
  10996. this._removeClass( "ui-droppable-hover" );
  10997. },
  10998. _addActiveClass: function() {
  10999. this._addClass( "ui-droppable-active" );
  11000. },
  11001. _removeActiveClass: function() {
  11002. this._removeClass( "ui-droppable-active" );
  11003. }
  11004. } );
  11005. var intersect = $.ui.intersect = ( function() {
  11006. function isOverAxis( x, reference, size ) {
  11007. return ( x >= reference ) && ( x < ( reference + size ) );
  11008. }
  11009. return function( draggable, droppable, toleranceMode, event ) {
  11010. if ( !droppable.offset ) {
  11011. return false;
  11012. }
  11013. var x1 = ( draggable.positionAbs ||
  11014. draggable.position.absolute ).left + draggable.margins.left,
  11015. y1 = ( draggable.positionAbs ||
  11016. draggable.position.absolute ).top + draggable.margins.top,
  11017. x2 = x1 + draggable.helperProportions.width,
  11018. y2 = y1 + draggable.helperProportions.height,
  11019. l = droppable.offset.left,
  11020. t = droppable.offset.top,
  11021. r = l + droppable.proportions().width,
  11022. b = t + droppable.proportions().height;
  11023. switch ( toleranceMode ) {
  11024. case "fit":
  11025. return ( l <= x1 && x2 <= r && t <= y1 && y2 <= b );
  11026. case "intersect":
  11027. return ( l < x1 + ( draggable.helperProportions.width / 2 ) && // Right Half
  11028. x2 - ( draggable.helperProportions.width / 2 ) < r && // Left Half
  11029. t < y1 + ( draggable.helperProportions.height / 2 ) && // Bottom Half
  11030. y2 - ( draggable.helperProportions.height / 2 ) < b ); // Top Half
  11031. case "pointer":
  11032. return isOverAxis( event.pageY, t, droppable.proportions().height ) &&
  11033. isOverAxis( event.pageX, l, droppable.proportions().width );
  11034. case "touch":
  11035. return (
  11036. ( y1 >= t && y1 <= b ) || // Top edge touching
  11037. ( y2 >= t && y2 <= b ) || // Bottom edge touching
  11038. ( y1 < t && y2 > b ) // Surrounded vertically
  11039. ) && (
  11040. ( x1 >= l && x1 <= r ) || // Left edge touching
  11041. ( x2 >= l && x2 <= r ) || // Right edge touching
  11042. ( x1 < l && x2 > r ) // Surrounded horizontally
  11043. );
  11044. default:
  11045. return false;
  11046. }
  11047. };
  11048. } )();
  11049. /*
  11050. This manager tracks offsets of draggables and droppables
  11051. */
  11052. $.ui.ddmanager = {
  11053. current: null,
  11054. droppables: { "default": [] },
  11055. prepareOffsets: function( t, event ) {
  11056. var i, j,
  11057. m = $.ui.ddmanager.droppables[ t.options.scope ] || [],
  11058. type = event ? event.type : null, // workaround for #2317
  11059. list = ( t.currentItem || t.element ).find( ":data(ui-droppable)" ).addBack();
  11060. droppablesLoop: for ( i = 0; i < m.length; i++ ) {
  11061. // No disabled and non-accepted
  11062. if ( m[ i ].options.disabled || ( t && !m[ i ].accept.call( m[ i ].element[ 0 ],
  11063. ( t.currentItem || t.element ) ) ) ) {
  11064. continue;
  11065. }
  11066. // Filter out elements in the current dragged item
  11067. for ( j = 0; j < list.length; j++ ) {
  11068. if ( list[ j ] === m[ i ].element[ 0 ] ) {
  11069. m[ i ].proportions().height = 0;
  11070. continue droppablesLoop;
  11071. }
  11072. }
  11073. m[ i ].visible = m[ i ].element.css( "display" ) !== "none";
  11074. if ( !m[ i ].visible ) {
  11075. continue;
  11076. }
  11077. // Activate the droppable if used directly from draggables
  11078. if ( type === "mousedown" ) {
  11079. m[ i ]._activate.call( m[ i ], event );
  11080. }
  11081. m[ i ].offset = m[ i ].element.offset();
  11082. m[ i ].proportions( {
  11083. width: m[ i ].element[ 0 ].offsetWidth,
  11084. height: m[ i ].element[ 0 ].offsetHeight
  11085. } );
  11086. }
  11087. },
  11088. drop: function( draggable, event ) {
  11089. var dropped = false;
  11090. // Create a copy of the droppables in case the list changes during the drop (#9116)
  11091. $.each( ( $.ui.ddmanager.droppables[ draggable.options.scope ] || [] ).slice(), function() {
  11092. if ( !this.options ) {
  11093. return;
  11094. }
  11095. if ( !this.options.disabled && this.visible &&
  11096. intersect( draggable, this, this.options.tolerance, event ) ) {
  11097. dropped = this._drop.call( this, event ) || dropped;
  11098. }
  11099. if ( !this.options.disabled && this.visible && this.accept.call( this.element[ 0 ],
  11100. ( draggable.currentItem || draggable.element ) ) ) {
  11101. this.isout = true;
  11102. this.isover = false;
  11103. this._deactivate.call( this, event );
  11104. }
  11105. } );
  11106. return dropped;
  11107. },
  11108. dragStart: function( draggable, event ) {
  11109. // Listen for scrolling so that if the dragging causes scrolling the position of the
  11110. // droppables can be recalculated (see #5003)
  11111. draggable.element.parentsUntil( "body" ).on( "scroll.droppable", function() {
  11112. if ( !draggable.options.refreshPositions ) {
  11113. $.ui.ddmanager.prepareOffsets( draggable, event );
  11114. }
  11115. } );
  11116. },
  11117. drag: function( draggable, event ) {
  11118. // If you have a highly dynamic page, you might try this option. It renders positions
  11119. // every time you move the mouse.
  11120. if ( draggable.options.refreshPositions ) {
  11121. $.ui.ddmanager.prepareOffsets( draggable, event );
  11122. }
  11123. // Run through all droppables and check their positions based on specific tolerance options
  11124. $.each( $.ui.ddmanager.droppables[ draggable.options.scope ] || [], function() {
  11125. if ( this.options.disabled || this.greedyChild || !this.visible ) {
  11126. return;
  11127. }
  11128. var parentInstance, scope, parent,
  11129. intersects = intersect( draggable, this, this.options.tolerance, event ),
  11130. c = !intersects && this.isover ?
  11131. "isout" :
  11132. ( intersects && !this.isover ? "isover" : null );
  11133. if ( !c ) {
  11134. return;
  11135. }
  11136. if ( this.options.greedy ) {
  11137. // find droppable parents with same scope
  11138. scope = this.options.scope;
  11139. parent = this.element.parents( ":data(ui-droppable)" ).filter( function() {
  11140. return $( this ).droppable( "instance" ).options.scope === scope;
  11141. } );
  11142. if ( parent.length ) {
  11143. parentInstance = $( parent[ 0 ] ).droppable( "instance" );
  11144. parentInstance.greedyChild = ( c === "isover" );
  11145. }
  11146. }
  11147. // We just moved into a greedy child
  11148. if ( parentInstance && c === "isover" ) {
  11149. parentInstance.isover = false;
  11150. parentInstance.isout = true;
  11151. parentInstance._out.call( parentInstance, event );
  11152. }
  11153. this[ c ] = true;
  11154. this[ c === "isout" ? "isover" : "isout" ] = false;
  11155. this[ c === "isover" ? "_over" : "_out" ].call( this, event );
  11156. // We just moved out of a greedy child
  11157. if ( parentInstance && c === "isout" ) {
  11158. parentInstance.isout = false;
  11159. parentInstance.isover = true;
  11160. parentInstance._over.call( parentInstance, event );
  11161. }
  11162. } );
  11163. },
  11164. dragStop: function( draggable, event ) {
  11165. draggable.element.parentsUntil( "body" ).off( "scroll.droppable" );
  11166. // Call prepareOffsets one final time since IE does not fire return scroll events when
  11167. // overflow was caused by drag (see #5003)
  11168. if ( !draggable.options.refreshPositions ) {
  11169. $.ui.ddmanager.prepareOffsets( draggable, event );
  11170. }
  11171. }
  11172. };
  11173. // DEPRECATED
  11174. // TODO: switch return back to widget declaration at top of file when this is removed
  11175. if ( $.uiBackCompat !== false ) {
  11176. // Backcompat for activeClass and hoverClass options
  11177. $.widget( "ui.droppable", $.ui.droppable, {
  11178. options: {
  11179. hoverClass: false,
  11180. activeClass: false
  11181. },
  11182. _addActiveClass: function() {
  11183. this._super();
  11184. if ( this.options.activeClass ) {
  11185. this.element.addClass( this.options.activeClass );
  11186. }
  11187. },
  11188. _removeActiveClass: function() {
  11189. this._super();
  11190. if ( this.options.activeClass ) {
  11191. this.element.removeClass( this.options.activeClass );
  11192. }
  11193. },
  11194. _addHoverClass: function() {
  11195. this._super();
  11196. if ( this.options.hoverClass ) {
  11197. this.element.addClass( this.options.hoverClass );
  11198. }
  11199. },
  11200. _removeHoverClass: function() {
  11201. this._super();
  11202. if ( this.options.hoverClass ) {
  11203. this.element.removeClass( this.options.hoverClass );
  11204. }
  11205. }
  11206. } );
  11207. }
  11208. var widgetsDroppable = $.ui.droppable;
  11209. /*!
  11210. * jQuery UI Progressbar 1.12.1
  11211. * http://jqueryui.com
  11212. *
  11213. * Copyright jQuery Foundation and other contributors
  11214. * Released under the MIT license.
  11215. * http://jquery.org/license
  11216. */
  11217. //>>label: Progressbar
  11218. //>>group: Widgets
  11219. // jscs:disable maximumLineLength
  11220. //>>description: Displays a status indicator for loading state, standard percentage, and other progress indicators.
  11221. // jscs:enable maximumLineLength
  11222. //>>docs: http://api.jqueryui.com/progressbar/
  11223. //>>demos: http://jqueryui.com/progressbar/
  11224. //>>css.structure: ../../themes/base/core.css
  11225. //>>css.structure: ../../themes/base/progressbar.css
  11226. //>>css.theme: ../../themes/base/theme.css
  11227. var widgetsProgressbar = $.widget( "ui.progressbar", {
  11228. version: "1.12.1",
  11229. options: {
  11230. classes: {
  11231. "ui-progressbar": "ui-corner-all",
  11232. "ui-progressbar-value": "ui-corner-left",
  11233. "ui-progressbar-complete": "ui-corner-right"
  11234. },
  11235. max: 100,
  11236. value: 0,
  11237. change: null,
  11238. complete: null
  11239. },
  11240. min: 0,
  11241. _create: function() {
  11242. // Constrain initial value
  11243. this.oldValue = this.options.value = this._constrainedValue();
  11244. this.element.attr( {
  11245. // Only set static values; aria-valuenow and aria-valuemax are
  11246. // set inside _refreshValue()
  11247. role: "progressbar",
  11248. "aria-valuemin": this.min
  11249. } );
  11250. this._addClass( "ui-progressbar", "ui-widget ui-widget-content" );
  11251. this.valueDiv = $( "<div>" ).appendTo( this.element );
  11252. this._addClass( this.valueDiv, "ui-progressbar-value", "ui-widget-header" );
  11253. this._refreshValue();
  11254. },
  11255. _destroy: function() {
  11256. this.element.removeAttr( "role aria-valuemin aria-valuemax aria-valuenow" );
  11257. this.valueDiv.remove();
  11258. },
  11259. value: function( newValue ) {
  11260. if ( newValue === undefined ) {
  11261. return this.options.value;
  11262. }
  11263. this.options.value = this._constrainedValue( newValue );
  11264. this._refreshValue();
  11265. },
  11266. _constrainedValue: function( newValue ) {
  11267. if ( newValue === undefined ) {
  11268. newValue = this.options.value;
  11269. }
  11270. this.indeterminate = newValue === false;
  11271. // Sanitize value
  11272. if ( typeof newValue !== "number" ) {
  11273. newValue = 0;
  11274. }
  11275. return this.indeterminate ? false :
  11276. Math.min( this.options.max, Math.max( this.min, newValue ) );
  11277. },
  11278. _setOptions: function( options ) {
  11279. // Ensure "value" option is set after other values (like max)
  11280. var value = options.value;
  11281. delete options.value;
  11282. this._super( options );
  11283. this.options.value = this._constrainedValue( value );
  11284. this._refreshValue();
  11285. },
  11286. _setOption: function( key, value ) {
  11287. if ( key === "max" ) {
  11288. // Don't allow a max less than min
  11289. value = Math.max( this.min, value );
  11290. }
  11291. this._super( key, value );
  11292. },
  11293. _setOptionDisabled: function( value ) {
  11294. this._super( value );
  11295. this.element.attr( "aria-disabled", value );
  11296. this._toggleClass( null, "ui-state-disabled", !!value );
  11297. },
  11298. _percentage: function() {
  11299. return this.indeterminate ?
  11300. 100 :
  11301. 100 * ( this.options.value - this.min ) / ( this.options.max - this.min );
  11302. },
  11303. _refreshValue: function() {
  11304. var value = this.options.value,
  11305. percentage = this._percentage();
  11306. this.valueDiv
  11307. .toggle( this.indeterminate || value > this.min )
  11308. .width( percentage.toFixed( 0 ) + "%" );
  11309. this
  11310. ._toggleClass( this.valueDiv, "ui-progressbar-complete", null,
  11311. value === this.options.max )
  11312. ._toggleClass( "ui-progressbar-indeterminate", null, this.indeterminate );
  11313. if ( this.indeterminate ) {
  11314. this.element.removeAttr( "aria-valuenow" );
  11315. if ( !this.overlayDiv ) {
  11316. this.overlayDiv = $( "<div>" ).appendTo( this.valueDiv );
  11317. this._addClass( this.overlayDiv, "ui-progressbar-overlay" );
  11318. }
  11319. } else {
  11320. this.element.attr( {
  11321. "aria-valuemax": this.options.max,
  11322. "aria-valuenow": value
  11323. } );
  11324. if ( this.overlayDiv ) {
  11325. this.overlayDiv.remove();
  11326. this.overlayDiv = null;
  11327. }
  11328. }
  11329. if ( this.oldValue !== value ) {
  11330. this.oldValue = value;
  11331. this._trigger( "change" );
  11332. }
  11333. if ( value === this.options.max ) {
  11334. this._trigger( "complete" );
  11335. }
  11336. }
  11337. } );
  11338. /*!
  11339. * jQuery UI Selectable 1.12.1
  11340. * http://jqueryui.com
  11341. *
  11342. * Copyright jQuery Foundation and other contributors
  11343. * Released under the MIT license.
  11344. * http://jquery.org/license
  11345. */
  11346. //>>label: Selectable
  11347. //>>group: Interactions
  11348. //>>description: Allows groups of elements to be selected with the mouse.
  11349. //>>docs: http://api.jqueryui.com/selectable/
  11350. //>>demos: http://jqueryui.com/selectable/
  11351. //>>css.structure: ../../themes/base/selectable.css
  11352. var widgetsSelectable = $.widget( "ui.selectable", $.ui.mouse, {
  11353. version: "1.12.1",
  11354. options: {
  11355. appendTo: "body",
  11356. autoRefresh: true,
  11357. distance: 0,
  11358. filter: "*",
  11359. tolerance: "touch",
  11360. // Callbacks
  11361. selected: null,
  11362. selecting: null,
  11363. start: null,
  11364. stop: null,
  11365. unselected: null,
  11366. unselecting: null
  11367. },
  11368. _create: function() {
  11369. var that = this;
  11370. this._addClass( "ui-selectable" );
  11371. this.dragged = false;
  11372. // Cache selectee children based on filter
  11373. this.refresh = function() {
  11374. that.elementPos = $( that.element[ 0 ] ).offset();
  11375. that.selectees = $( that.options.filter, that.element[ 0 ] );
  11376. that._addClass( that.selectees, "ui-selectee" );
  11377. that.selectees.each( function() {
  11378. var $this = $( this ),
  11379. selecteeOffset = $this.offset(),
  11380. pos = {
  11381. left: selecteeOffset.left - that.elementPos.left,
  11382. top: selecteeOffset.top - that.elementPos.top
  11383. };
  11384. $.data( this, "selectable-item", {
  11385. element: this,
  11386. $element: $this,
  11387. left: pos.left,
  11388. top: pos.top,
  11389. right: pos.left + $this.outerWidth(),
  11390. bottom: pos.top + $this.outerHeight(),
  11391. startselected: false,
  11392. selected: $this.hasClass( "ui-selected" ),
  11393. selecting: $this.hasClass( "ui-selecting" ),
  11394. unselecting: $this.hasClass( "ui-unselecting" )
  11395. } );
  11396. } );
  11397. };
  11398. this.refresh();
  11399. this._mouseInit();
  11400. this.helper = $( "<div>" );
  11401. this._addClass( this.helper, "ui-selectable-helper" );
  11402. },
  11403. _destroy: function() {
  11404. this.selectees.removeData( "selectable-item" );
  11405. this._mouseDestroy();
  11406. },
  11407. _mouseStart: function( event ) {
  11408. var that = this,
  11409. options = this.options;
  11410. this.opos = [ event.pageX, event.pageY ];
  11411. this.elementPos = $( this.element[ 0 ] ).offset();
  11412. if ( this.options.disabled ) {
  11413. return;
  11414. }
  11415. this.selectees = $( options.filter, this.element[ 0 ] );
  11416. this._trigger( "start", event );
  11417. $( options.appendTo ).append( this.helper );
  11418. // position helper (lasso)
  11419. this.helper.css( {
  11420. "left": event.pageX,
  11421. "top": event.pageY,
  11422. "width": 0,
  11423. "height": 0
  11424. } );
  11425. if ( options.autoRefresh ) {
  11426. this.refresh();
  11427. }
  11428. this.selectees.filter( ".ui-selected" ).each( function() {
  11429. var selectee = $.data( this, "selectable-item" );
  11430. selectee.startselected = true;
  11431. if ( !event.metaKey && !event.ctrlKey ) {
  11432. that._removeClass( selectee.$element, "ui-selected" );
  11433. selectee.selected = false;
  11434. that._addClass( selectee.$element, "ui-unselecting" );
  11435. selectee.unselecting = true;
  11436. // selectable UNSELECTING callback
  11437. that._trigger( "unselecting", event, {
  11438. unselecting: selectee.element
  11439. } );
  11440. }
  11441. } );
  11442. $( event.target ).parents().addBack().each( function() {
  11443. var doSelect,
  11444. selectee = $.data( this, "selectable-item" );
  11445. if ( selectee ) {
  11446. doSelect = ( !event.metaKey && !event.ctrlKey ) ||
  11447. !selectee.$element.hasClass( "ui-selected" );
  11448. that._removeClass( selectee.$element, doSelect ? "ui-unselecting" : "ui-selected" )
  11449. ._addClass( selectee.$element, doSelect ? "ui-selecting" : "ui-unselecting" );
  11450. selectee.unselecting = !doSelect;
  11451. selectee.selecting = doSelect;
  11452. selectee.selected = doSelect;
  11453. // selectable (UN)SELECTING callback
  11454. if ( doSelect ) {
  11455. that._trigger( "selecting", event, {
  11456. selecting: selectee.element
  11457. } );
  11458. } else {
  11459. that._trigger( "unselecting", event, {
  11460. unselecting: selectee.element
  11461. } );
  11462. }
  11463. return false;
  11464. }
  11465. } );
  11466. },
  11467. _mouseDrag: function( event ) {
  11468. this.dragged = true;
  11469. if ( this.options.disabled ) {
  11470. return;
  11471. }
  11472. var tmp,
  11473. that = this,
  11474. options = this.options,
  11475. x1 = this.opos[ 0 ],
  11476. y1 = this.opos[ 1 ],
  11477. x2 = event.pageX,
  11478. y2 = event.pageY;
  11479. if ( x1 > x2 ) { tmp = x2; x2 = x1; x1 = tmp; }
  11480. if ( y1 > y2 ) { tmp = y2; y2 = y1; y1 = tmp; }
  11481. this.helper.css( { left: x1, top: y1, width: x2 - x1, height: y2 - y1 } );
  11482. this.selectees.each( function() {
  11483. var selectee = $.data( this, "selectable-item" ),
  11484. hit = false,
  11485. offset = {};
  11486. //prevent helper from being selected if appendTo: selectable
  11487. if ( !selectee || selectee.element === that.element[ 0 ] ) {
  11488. return;
  11489. }
  11490. offset.left = selectee.left + that.elementPos.left;
  11491. offset.right = selectee.right + that.elementPos.left;
  11492. offset.top = selectee.top + that.elementPos.top;
  11493. offset.bottom = selectee.bottom + that.elementPos.top;
  11494. if ( options.tolerance === "touch" ) {
  11495. hit = ( !( offset.left > x2 || offset.right < x1 || offset.top > y2 ||
  11496. offset.bottom < y1 ) );
  11497. } else if ( options.tolerance === "fit" ) {
  11498. hit = ( offset.left > x1 && offset.right < x2 && offset.top > y1 &&
  11499. offset.bottom < y2 );
  11500. }
  11501. if ( hit ) {
  11502. // SELECT
  11503. if ( selectee.selected ) {
  11504. that._removeClass( selectee.$element, "ui-selected" );
  11505. selectee.selected = false;
  11506. }
  11507. if ( selectee.unselecting ) {
  11508. that._removeClass( selectee.$element, "ui-unselecting" );
  11509. selectee.unselecting = false;
  11510. }
  11511. if ( !selectee.selecting ) {
  11512. that._addClass( selectee.$element, "ui-selecting" );
  11513. selectee.selecting = true;
  11514. // selectable SELECTING callback
  11515. that._trigger( "selecting", event, {
  11516. selecting: selectee.element
  11517. } );
  11518. }
  11519. } else {
  11520. // UNSELECT
  11521. if ( selectee.selecting ) {
  11522. if ( ( event.metaKey || event.ctrlKey ) && selectee.startselected ) {
  11523. that._removeClass( selectee.$element, "ui-selecting" );
  11524. selectee.selecting = false;
  11525. that._addClass( selectee.$element, "ui-selected" );
  11526. selectee.selected = true;
  11527. } else {
  11528. that._removeClass( selectee.$element, "ui-selecting" );
  11529. selectee.selecting = false;
  11530. if ( selectee.startselected ) {
  11531. that._addClass( selectee.$element, "ui-unselecting" );
  11532. selectee.unselecting = true;
  11533. }
  11534. // selectable UNSELECTING callback
  11535. that._trigger( "unselecting", event, {
  11536. unselecting: selectee.element
  11537. } );
  11538. }
  11539. }
  11540. if ( selectee.selected ) {
  11541. if ( !event.metaKey && !event.ctrlKey && !selectee.startselected ) {
  11542. that._removeClass( selectee.$element, "ui-selected" );
  11543. selectee.selected = false;
  11544. that._addClass( selectee.$element, "ui-unselecting" );
  11545. selectee.unselecting = true;
  11546. // selectable UNSELECTING callback
  11547. that._trigger( "unselecting", event, {
  11548. unselecting: selectee.element
  11549. } );
  11550. }
  11551. }
  11552. }
  11553. } );
  11554. return false;
  11555. },
  11556. _mouseStop: function( event ) {
  11557. var that = this;
  11558. this.dragged = false;
  11559. $( ".ui-unselecting", this.element[ 0 ] ).each( function() {
  11560. var selectee = $.data( this, "selectable-item" );
  11561. that._removeClass( selectee.$element, "ui-unselecting" );
  11562. selectee.unselecting = false;
  11563. selectee.startselected = false;
  11564. that._trigger( "unselected", event, {
  11565. unselected: selectee.element
  11566. } );
  11567. } );
  11568. $( ".ui-selecting", this.element[ 0 ] ).each( function() {
  11569. var selectee = $.data( this, "selectable-item" );
  11570. that._removeClass( selectee.$element, "ui-selecting" )
  11571. ._addClass( selectee.$element, "ui-selected" );
  11572. selectee.selecting = false;
  11573. selectee.selected = true;
  11574. selectee.startselected = true;
  11575. that._trigger( "selected", event, {
  11576. selected: selectee.element
  11577. } );
  11578. } );
  11579. this._trigger( "stop", event );
  11580. this.helper.remove();
  11581. return false;
  11582. }
  11583. } );
  11584. /*!
  11585. * jQuery UI Selectmenu 1.12.1
  11586. * http://jqueryui.com
  11587. *
  11588. * Copyright jQuery Foundation and other contributors
  11589. * Released under the MIT license.
  11590. * http://jquery.org/license
  11591. */
  11592. //>>label: Selectmenu
  11593. //>>group: Widgets
  11594. // jscs:disable maximumLineLength
  11595. //>>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.
  11596. // jscs:enable maximumLineLength
  11597. //>>docs: http://api.jqueryui.com/selectmenu/
  11598. //>>demos: http://jqueryui.com/selectmenu/
  11599. //>>css.structure: ../../themes/base/core.css
  11600. //>>css.structure: ../../themes/base/selectmenu.css, ../../themes/base/button.css
  11601. //>>css.theme: ../../themes/base/theme.css
  11602. var widgetsSelectmenu = $.widget( "ui.selectmenu", [ $.ui.formResetMixin, {
  11603. version: "1.12.1",
  11604. defaultElement: "<select>",
  11605. options: {
  11606. appendTo: null,
  11607. classes: {
  11608. "ui-selectmenu-button-open": "ui-corner-top",
  11609. "ui-selectmenu-button-closed": "ui-corner-all"
  11610. },
  11611. disabled: null,
  11612. icons: {
  11613. button: "ui-icon-triangle-1-s"
  11614. },
  11615. position: {
  11616. my: "left top",
  11617. at: "left bottom",
  11618. collision: "none"
  11619. },
  11620. width: false,
  11621. // Callbacks
  11622. change: null,
  11623. close: null,
  11624. focus: null,
  11625. open: null,
  11626. select: null
  11627. },
  11628. _create: function() {
  11629. var selectmenuId = this.element.uniqueId().attr( "id" );
  11630. this.ids = {
  11631. element: selectmenuId,
  11632. button: selectmenuId + "-button",
  11633. menu: selectmenuId + "-menu"
  11634. };
  11635. this._drawButton();
  11636. this._drawMenu();
  11637. this._bindFormResetHandler();
  11638. this._rendered = false;
  11639. this.menuItems = $();
  11640. },
  11641. _drawButton: function() {
  11642. var icon,
  11643. that = this,
  11644. item = this._parseOption(
  11645. this.element.find( "option:selected" ),
  11646. this.element[ 0 ].selectedIndex
  11647. );
  11648. // Associate existing label with the new button
  11649. this.labels = this.element.labels().attr( "for", this.ids.button );
  11650. this._on( this.labels, {
  11651. click: function( event ) {
  11652. this.button.focus();
  11653. event.preventDefault();
  11654. }
  11655. } );
  11656. // Hide original select element
  11657. this.element.hide();
  11658. // Create button
  11659. this.button = $( "<span>", {
  11660. tabindex: this.options.disabled ? -1 : 0,
  11661. id: this.ids.button,
  11662. role: "combobox",
  11663. "aria-expanded": "false",
  11664. "aria-autocomplete": "list",
  11665. "aria-owns": this.ids.menu,
  11666. "aria-haspopup": "true",
  11667. title: this.element.attr( "title" )
  11668. } )
  11669. .insertAfter( this.element );
  11670. this._addClass( this.button, "ui-selectmenu-button ui-selectmenu-button-closed",
  11671. "ui-button ui-widget" );
  11672. icon = $( "<span>" ).appendTo( this.button );
  11673. this._addClass( icon, "ui-selectmenu-icon", "ui-icon " + this.options.icons.button );
  11674. this.buttonItem = this._renderButtonItem( item )
  11675. .appendTo( this.button );
  11676. if ( this.options.width !== false ) {
  11677. this._resizeButton();
  11678. }
  11679. this._on( this.button, this._buttonEvents );
  11680. this.button.one( "focusin", function() {
  11681. // Delay rendering the menu items until the button receives focus.
  11682. // The menu may have already been rendered via a programmatic open.
  11683. if ( !that._rendered ) {
  11684. that._refreshMenu();
  11685. }
  11686. } );
  11687. },
  11688. _drawMenu: function() {
  11689. var that = this;
  11690. // Create menu
  11691. this.menu = $( "<ul>", {
  11692. "aria-hidden": "true",
  11693. "aria-labelledby": this.ids.button,
  11694. id: this.ids.menu
  11695. } );
  11696. // Wrap menu
  11697. this.menuWrap = $( "<div>" ).append( this.menu );
  11698. this._addClass( this.menuWrap, "ui-selectmenu-menu", "ui-front" );
  11699. this.menuWrap.appendTo( this._appendTo() );
  11700. // Initialize menu widget
  11701. this.menuInstance = this.menu
  11702. .menu( {
  11703. classes: {
  11704. "ui-menu": "ui-corner-bottom"
  11705. },
  11706. role: "listbox",
  11707. select: function( event, ui ) {
  11708. event.preventDefault();
  11709. // Support: IE8
  11710. // If the item was selected via a click, the text selection
  11711. // will be destroyed in IE
  11712. that._setSelection();
  11713. that._select( ui.item.data( "ui-selectmenu-item" ), event );
  11714. },
  11715. focus: function( event, ui ) {
  11716. var item = ui.item.data( "ui-selectmenu-item" );
  11717. // Prevent inital focus from firing and check if its a newly focused item
  11718. if ( that.focusIndex != null && item.index !== that.focusIndex ) {
  11719. that._trigger( "focus", event, { item: item } );
  11720. if ( !that.isOpen ) {
  11721. that._select( item, event );
  11722. }
  11723. }
  11724. that.focusIndex = item.index;
  11725. that.button.attr( "aria-activedescendant",
  11726. that.menuItems.eq( item.index ).attr( "id" ) );
  11727. }
  11728. } )
  11729. .menu( "instance" );
  11730. // Don't close the menu on mouseleave
  11731. this.menuInstance._off( this.menu, "mouseleave" );
  11732. // Cancel the menu's collapseAll on document click
  11733. this.menuInstance._closeOnDocumentClick = function() {
  11734. return false;
  11735. };
  11736. // Selects often contain empty items, but never contain dividers
  11737. this.menuInstance._isDivider = function() {
  11738. return false;
  11739. };
  11740. },
  11741. refresh: function() {
  11742. this._refreshMenu();
  11743. this.buttonItem.replaceWith(
  11744. this.buttonItem = this._renderButtonItem(
  11745. // Fall back to an empty object in case there are no options
  11746. this._getSelectedItem().data( "ui-selectmenu-item" ) || {}
  11747. )
  11748. );
  11749. if ( this.options.width === null ) {
  11750. this._resizeButton();
  11751. }
  11752. },
  11753. _refreshMenu: function() {
  11754. var item,
  11755. options = this.element.find( "option" );
  11756. this.menu.empty();
  11757. this._parseOptions( options );
  11758. this._renderMenu( this.menu, this.items );
  11759. this.menuInstance.refresh();
  11760. this.menuItems = this.menu.find( "li" )
  11761. .not( ".ui-selectmenu-optgroup" )
  11762. .find( ".ui-menu-item-wrapper" );
  11763. this._rendered = true;
  11764. if ( !options.length ) {
  11765. return;
  11766. }
  11767. item = this._getSelectedItem();
  11768. // Update the menu to have the correct item focused
  11769. this.menuInstance.focus( null, item );
  11770. this._setAria( item.data( "ui-selectmenu-item" ) );
  11771. // Set disabled state
  11772. this._setOption( "disabled", this.element.prop( "disabled" ) );
  11773. },
  11774. open: function( event ) {
  11775. if ( this.options.disabled ) {
  11776. return;
  11777. }
  11778. // If this is the first time the menu is being opened, render the items
  11779. if ( !this._rendered ) {
  11780. this._refreshMenu();
  11781. } else {
  11782. // Menu clears focus on close, reset focus to selected item
  11783. this._removeClass( this.menu.find( ".ui-state-active" ), null, "ui-state-active" );
  11784. this.menuInstance.focus( null, this._getSelectedItem() );
  11785. }
  11786. // If there are no options, don't open the menu
  11787. if ( !this.menuItems.length ) {
  11788. return;
  11789. }
  11790. this.isOpen = true;
  11791. this._toggleAttr();
  11792. this._resizeMenu();
  11793. this._position();
  11794. this._on( this.document, this._documentClick );
  11795. this._trigger( "open", event );
  11796. },
  11797. _position: function() {
  11798. this.menuWrap.position( $.extend( { of: this.button }, this.options.position ) );
  11799. },
  11800. close: function( event ) {
  11801. if ( !this.isOpen ) {
  11802. return;
  11803. }
  11804. this.isOpen = false;
  11805. this._toggleAttr();
  11806. this.range = null;
  11807. this._off( this.document );
  11808. this._trigger( "close", event );
  11809. },
  11810. widget: function() {
  11811. return this.button;
  11812. },
  11813. menuWidget: function() {
  11814. return this.menu;
  11815. },
  11816. _renderButtonItem: function( item ) {
  11817. var buttonItem = $( "<span>" );
  11818. this._setText( buttonItem, item.label );
  11819. this._addClass( buttonItem, "ui-selectmenu-text" );
  11820. return buttonItem;
  11821. },
  11822. _renderMenu: function( ul, items ) {
  11823. var that = this,
  11824. currentOptgroup = "";
  11825. $.each( items, function( index, item ) {
  11826. var li;
  11827. if ( item.optgroup !== currentOptgroup ) {
  11828. li = $( "<li>", {
  11829. text: item.optgroup
  11830. } );
  11831. that._addClass( li, "ui-selectmenu-optgroup", "ui-menu-divider" +
  11832. ( item.element.parent( "optgroup" ).prop( "disabled" ) ?
  11833. " ui-state-disabled" :
  11834. "" ) );
  11835. li.appendTo( ul );
  11836. currentOptgroup = item.optgroup;
  11837. }
  11838. that._renderItemData( ul, item );
  11839. } );
  11840. },
  11841. _renderItemData: function( ul, item ) {
  11842. return this._renderItem( ul, item ).data( "ui-selectmenu-item", item );
  11843. },
  11844. _renderItem: function( ul, item ) {
  11845. var li = $( "<li>" ),
  11846. wrapper = $( "<div>", {
  11847. title: item.element.attr( "title" )
  11848. } );
  11849. if ( item.disabled ) {
  11850. this._addClass( li, null, "ui-state-disabled" );
  11851. }
  11852. this._setText( wrapper, item.label );
  11853. return li.append( wrapper ).appendTo( ul );
  11854. },
  11855. _setText: function( element, value ) {
  11856. if ( value ) {
  11857. element.text( value );
  11858. } else {
  11859. element.html( "&#160;" );
  11860. }
  11861. },
  11862. _move: function( direction, event ) {
  11863. var item, next,
  11864. filter = ".ui-menu-item";
  11865. if ( this.isOpen ) {
  11866. item = this.menuItems.eq( this.focusIndex ).parent( "li" );
  11867. } else {
  11868. item = this.menuItems.eq( this.element[ 0 ].selectedIndex ).parent( "li" );
  11869. filter += ":not(.ui-state-disabled)";
  11870. }
  11871. if ( direction === "first" || direction === "last" ) {
  11872. next = item[ direction === "first" ? "prevAll" : "nextAll" ]( filter ).eq( -1 );
  11873. } else {
  11874. next = item[ direction + "All" ]( filter ).eq( 0 );
  11875. }
  11876. if ( next.length ) {
  11877. this.menuInstance.focus( event, next );
  11878. }
  11879. },
  11880. _getSelectedItem: function() {
  11881. return this.menuItems.eq( this.element[ 0 ].selectedIndex ).parent( "li" );
  11882. },
  11883. _toggle: function( event ) {
  11884. this[ this.isOpen ? "close" : "open" ]( event );
  11885. },
  11886. _setSelection: function() {
  11887. var selection;
  11888. if ( !this.range ) {
  11889. return;
  11890. }
  11891. if ( window.getSelection ) {
  11892. selection = window.getSelection();
  11893. selection.removeAllRanges();
  11894. selection.addRange( this.range );
  11895. // Support: IE8
  11896. } else {
  11897. this.range.select();
  11898. }
  11899. // Support: IE
  11900. // Setting the text selection kills the button focus in IE, but
  11901. // restoring the focus doesn't kill the selection.
  11902. this.button.focus();
  11903. },
  11904. _documentClick: {
  11905. mousedown: function( event ) {
  11906. if ( !this.isOpen ) {
  11907. return;
  11908. }
  11909. if ( !$( event.target ).closest( ".ui-selectmenu-menu, #" +
  11910. $.ui.escapeSelector( this.ids.button ) ).length ) {
  11911. this.close( event );
  11912. }
  11913. }
  11914. },
  11915. _buttonEvents: {
  11916. // Prevent text selection from being reset when interacting with the selectmenu (#10144)
  11917. mousedown: function() {
  11918. var selection;
  11919. if ( window.getSelection ) {
  11920. selection = window.getSelection();
  11921. if ( selection.rangeCount ) {
  11922. this.range = selection.getRangeAt( 0 );
  11923. }
  11924. // Support: IE8
  11925. } else {
  11926. this.range = document.selection.createRange();
  11927. }
  11928. },
  11929. click: function( event ) {
  11930. this._setSelection();
  11931. this._toggle( event );
  11932. },
  11933. keydown: function( event ) {
  11934. var preventDefault = true;
  11935. switch ( event.keyCode ) {
  11936. case $.ui.keyCode.TAB:
  11937. case $.ui.keyCode.ESCAPE:
  11938. this.close( event );
  11939. preventDefault = false;
  11940. break;
  11941. case $.ui.keyCode.ENTER:
  11942. if ( this.isOpen ) {
  11943. this._selectFocusedItem( event );
  11944. }
  11945. break;
  11946. case $.ui.keyCode.UP:
  11947. if ( event.altKey ) {
  11948. this._toggle( event );
  11949. } else {
  11950. this._move( "prev", event );
  11951. }
  11952. break;
  11953. case $.ui.keyCode.DOWN:
  11954. if ( event.altKey ) {
  11955. this._toggle( event );
  11956. } else {
  11957. this._move( "next", event );
  11958. }
  11959. break;
  11960. case $.ui.keyCode.SPACE:
  11961. if ( this.isOpen ) {
  11962. this._selectFocusedItem( event );
  11963. } else {
  11964. this._toggle( event );
  11965. }
  11966. break;
  11967. case $.ui.keyCode.LEFT:
  11968. this._move( "prev", event );
  11969. break;
  11970. case $.ui.keyCode.RIGHT:
  11971. this._move( "next", event );
  11972. break;
  11973. case $.ui.keyCode.HOME:
  11974. case $.ui.keyCode.PAGE_UP:
  11975. this._move( "first", event );
  11976. break;
  11977. case $.ui.keyCode.END:
  11978. case $.ui.keyCode.PAGE_DOWN:
  11979. this._move( "last", event );
  11980. break;
  11981. default:
  11982. this.menu.trigger( event );
  11983. preventDefault = false;
  11984. }
  11985. if ( preventDefault ) {
  11986. event.preventDefault();
  11987. }
  11988. }
  11989. },
  11990. _selectFocusedItem: function( event ) {
  11991. var item = this.menuItems.eq( this.focusIndex ).parent( "li" );
  11992. if ( !item.hasClass( "ui-state-disabled" ) ) {
  11993. this._select( item.data( "ui-selectmenu-item" ), event );
  11994. }
  11995. },
  11996. _select: function( item, event ) {
  11997. var oldIndex = this.element[ 0 ].selectedIndex;
  11998. // Change native select element
  11999. this.element[ 0 ].selectedIndex = item.index;
  12000. this.buttonItem.replaceWith( this.buttonItem = this._renderButtonItem( item ) );
  12001. this._setAria( item );
  12002. this._trigger( "select", event, { item: item } );
  12003. if ( item.index !== oldIndex ) {
  12004. this._trigger( "change", event, { item: item } );
  12005. }
  12006. this.close( event );
  12007. },
  12008. _setAria: function( item ) {
  12009. var id = this.menuItems.eq( item.index ).attr( "id" );
  12010. this.button.attr( {
  12011. "aria-labelledby": id,
  12012. "aria-activedescendant": id
  12013. } );
  12014. this.menu.attr( "aria-activedescendant", id );
  12015. },
  12016. _setOption: function( key, value ) {
  12017. if ( key === "icons" ) {
  12018. var icon = this.button.find( "span.ui-icon" );
  12019. this._removeClass( icon, null, this.options.icons.button )
  12020. ._addClass( icon, null, value.button );
  12021. }
  12022. this._super( key, value );
  12023. if ( key === "appendTo" ) {
  12024. this.menuWrap.appendTo( this._appendTo() );
  12025. }
  12026. if ( key === "width" ) {
  12027. this._resizeButton();
  12028. }
  12029. },
  12030. _setOptionDisabled: function( value ) {
  12031. this._super( value );
  12032. this.menuInstance.option( "disabled", value );
  12033. this.button.attr( "aria-disabled", value );
  12034. this._toggleClass( this.button, null, "ui-state-disabled", value );
  12035. this.element.prop( "disabled", value );
  12036. if ( value ) {
  12037. this.button.attr( "tabindex", -1 );
  12038. this.close();
  12039. } else {
  12040. this.button.attr( "tabindex", 0 );
  12041. }
  12042. },
  12043. _appendTo: function() {
  12044. var element = this.options.appendTo;
  12045. if ( element ) {
  12046. element = element.jquery || element.nodeType ?
  12047. $( element ) :
  12048. this.document.find( element ).eq( 0 );
  12049. }
  12050. if ( !element || !element[ 0 ] ) {
  12051. element = this.element.closest( ".ui-front, dialog" );
  12052. }
  12053. if ( !element.length ) {
  12054. element = this.document[ 0 ].body;
  12055. }
  12056. return element;
  12057. },
  12058. _toggleAttr: function() {
  12059. this.button.attr( "aria-expanded", this.isOpen );
  12060. // We can't use two _toggleClass() calls here, because we need to make sure
  12061. // we always remove classes first and add them second, otherwise if both classes have the
  12062. // same theme class, it will be removed after we add it.
  12063. this._removeClass( this.button, "ui-selectmenu-button-" +
  12064. ( this.isOpen ? "closed" : "open" ) )
  12065. ._addClass( this.button, "ui-selectmenu-button-" +
  12066. ( this.isOpen ? "open" : "closed" ) )
  12067. ._toggleClass( this.menuWrap, "ui-selectmenu-open", null, this.isOpen );
  12068. this.menu.attr( "aria-hidden", !this.isOpen );
  12069. },
  12070. _resizeButton: function() {
  12071. var width = this.options.width;
  12072. // For `width: false`, just remove inline style and stop
  12073. if ( width === false ) {
  12074. this.button.css( "width", "" );
  12075. return;
  12076. }
  12077. // For `width: null`, match the width of the original element
  12078. if ( width === null ) {
  12079. width = this.element.show().outerWidth();
  12080. this.element.hide();
  12081. }
  12082. this.button.outerWidth( width );
  12083. },
  12084. _resizeMenu: function() {
  12085. this.menu.outerWidth( Math.max(
  12086. this.button.outerWidth(),
  12087. // Support: IE10
  12088. // IE10 wraps long text (possibly a rounding bug)
  12089. // so we add 1px to avoid the wrapping
  12090. this.menu.width( "" ).outerWidth() + 1
  12091. ) );
  12092. },
  12093. _getCreateOptions: function() {
  12094. var options = this._super();
  12095. options.disabled = this.element.prop( "disabled" );
  12096. return options;
  12097. },
  12098. _parseOptions: function( options ) {
  12099. var that = this,
  12100. data = [];
  12101. options.each( function( index, item ) {
  12102. data.push( that._parseOption( $( item ), index ) );
  12103. } );
  12104. this.items = data;
  12105. },
  12106. _parseOption: function( option, index ) {
  12107. var optgroup = option.parent( "optgroup" );
  12108. return {
  12109. element: option,
  12110. index: index,
  12111. value: option.val(),
  12112. label: option.text(),
  12113. optgroup: optgroup.attr( "label" ) || "",
  12114. disabled: optgroup.prop( "disabled" ) || option.prop( "disabled" )
  12115. };
  12116. },
  12117. _destroy: function() {
  12118. this._unbindFormResetHandler();
  12119. this.menuWrap.remove();
  12120. this.button.remove();
  12121. this.element.show();
  12122. this.element.removeUniqueId();
  12123. this.labels.attr( "for", this.ids.element );
  12124. }
  12125. } ] );
  12126. /*!
  12127. * jQuery UI Slider 1.12.1
  12128. * http://jqueryui.com
  12129. *
  12130. * Copyright jQuery Foundation and other contributors
  12131. * Released under the MIT license.
  12132. * http://jquery.org/license
  12133. */
  12134. //>>label: Slider
  12135. //>>group: Widgets
  12136. //>>description: Displays a flexible slider with ranges and accessibility via keyboard.
  12137. //>>docs: http://api.jqueryui.com/slider/
  12138. //>>demos: http://jqueryui.com/slider/
  12139. //>>css.structure: ../../themes/base/core.css
  12140. //>>css.structure: ../../themes/base/slider.css
  12141. //>>css.theme: ../../themes/base/theme.css
  12142. var widgetsSlider = $.widget( "ui.slider", $.ui.mouse, {
  12143. version: "1.12.1",
  12144. widgetEventPrefix: "slide",
  12145. options: {
  12146. animate: false,
  12147. classes: {
  12148. "ui-slider": "ui-corner-all",
  12149. "ui-slider-handle": "ui-corner-all",
  12150. // Note: ui-widget-header isn't the most fittingly semantic framework class for this
  12151. // element, but worked best visually with a variety of themes
  12152. "ui-slider-range": "ui-corner-all ui-widget-header"
  12153. },
  12154. distance: 0,
  12155. max: 100,
  12156. min: 0,
  12157. orientation: "horizontal",
  12158. range: false,
  12159. step: 1,
  12160. value: 0,
  12161. values: null,
  12162. // Callbacks
  12163. change: null,
  12164. slide: null,
  12165. start: null,
  12166. stop: null
  12167. },
  12168. // Number of pages in a slider
  12169. // (how many times can you page up/down to go through the whole range)
  12170. numPages: 5,
  12171. _create: function() {
  12172. this._keySliding = false;
  12173. this._mouseSliding = false;
  12174. this._animateOff = true;
  12175. this._handleIndex = null;
  12176. this._detectOrientation();
  12177. this._mouseInit();
  12178. this._calculateNewMax();
  12179. this._addClass( "ui-slider ui-slider-" + this.orientation,
  12180. "ui-widget ui-widget-content" );
  12181. this._refresh();
  12182. this._animateOff = false;
  12183. },
  12184. _refresh: function() {
  12185. this._createRange();
  12186. this._createHandles();
  12187. this._setupEvents();
  12188. this._refreshValue();
  12189. },
  12190. _createHandles: function() {
  12191. var i, handleCount,
  12192. options = this.options,
  12193. existingHandles = this.element.find( ".ui-slider-handle" ),
  12194. handle = "<span tabindex='0'></span>",
  12195. handles = [];
  12196. handleCount = ( options.values && options.values.length ) || 1;
  12197. if ( existingHandles.length > handleCount ) {
  12198. existingHandles.slice( handleCount ).remove();
  12199. existingHandles = existingHandles.slice( 0, handleCount );
  12200. }
  12201. for ( i = existingHandles.length; i < handleCount; i++ ) {
  12202. handles.push( handle );
  12203. }
  12204. this.handles = existingHandles.add( $( handles.join( "" ) ).appendTo( this.element ) );
  12205. this._addClass( this.handles, "ui-slider-handle", "ui-state-default" );
  12206. this.handle = this.handles.eq( 0 );
  12207. this.handles.each( function( i ) {
  12208. $( this )
  12209. .data( "ui-slider-handle-index", i )
  12210. .attr( "tabIndex", 0 );
  12211. } );
  12212. },
  12213. _createRange: function() {
  12214. var options = this.options;
  12215. if ( options.range ) {
  12216. if ( options.range === true ) {
  12217. if ( !options.values ) {
  12218. options.values = [ this._valueMin(), this._valueMin() ];
  12219. } else if ( options.values.length && options.values.length !== 2 ) {
  12220. options.values = [ options.values[ 0 ], options.values[ 0 ] ];
  12221. } else if ( $.isArray( options.values ) ) {
  12222. options.values = options.values.slice( 0 );
  12223. }
  12224. }
  12225. if ( !this.range || !this.range.length ) {
  12226. this.range = $( "<div>" )
  12227. .appendTo( this.element );
  12228. this._addClass( this.range, "ui-slider-range" );
  12229. } else {
  12230. this._removeClass( this.range, "ui-slider-range-min ui-slider-range-max" );
  12231. // Handle range switching from true to min/max
  12232. this.range.css( {
  12233. "left": "",
  12234. "bottom": ""
  12235. } );
  12236. }
  12237. if ( options.range === "min" || options.range === "max" ) {
  12238. this._addClass( this.range, "ui-slider-range-" + options.range );
  12239. }
  12240. } else {
  12241. if ( this.range ) {
  12242. this.range.remove();
  12243. }
  12244. this.range = null;
  12245. }
  12246. },
  12247. _setupEvents: function() {
  12248. this._off( this.handles );
  12249. this._on( this.handles, this._handleEvents );
  12250. this._hoverable( this.handles );
  12251. this._focusable( this.handles );
  12252. },
  12253. _destroy: function() {
  12254. this.handles.remove();
  12255. if ( this.range ) {
  12256. this.range.remove();
  12257. }
  12258. this._mouseDestroy();
  12259. },
  12260. _mouseCapture: function( event ) {
  12261. var position, normValue, distance, closestHandle, index, allowed, offset, mouseOverHandle,
  12262. that = this,
  12263. o = this.options;
  12264. if ( o.disabled ) {
  12265. return false;
  12266. }
  12267. this.elementSize = {
  12268. width: this.element.outerWidth(),
  12269. height: this.element.outerHeight()
  12270. };
  12271. this.elementOffset = this.element.offset();
  12272. position = { x: event.pageX, y: event.pageY };
  12273. normValue = this._normValueFromMouse( position );
  12274. distance = this._valueMax() - this._valueMin() + 1;
  12275. this.handles.each( function( i ) {
  12276. var thisDistance = Math.abs( normValue - that.values( i ) );
  12277. if ( ( distance > thisDistance ) ||
  12278. ( distance === thisDistance &&
  12279. ( i === that._lastChangedValue || that.values( i ) === o.min ) ) ) {
  12280. distance = thisDistance;
  12281. closestHandle = $( this );
  12282. index = i;
  12283. }
  12284. } );
  12285. allowed = this._start( event, index );
  12286. if ( allowed === false ) {
  12287. return false;
  12288. }
  12289. this._mouseSliding = true;
  12290. this._handleIndex = index;
  12291. this._addClass( closestHandle, null, "ui-state-active" );
  12292. closestHandle.trigger( "focus" );
  12293. offset = closestHandle.offset();
  12294. mouseOverHandle = !$( event.target ).parents().addBack().is( ".ui-slider-handle" );
  12295. this._clickOffset = mouseOverHandle ? { left: 0, top: 0 } : {
  12296. left: event.pageX - offset.left - ( closestHandle.width() / 2 ),
  12297. top: event.pageY - offset.top -
  12298. ( closestHandle.height() / 2 ) -
  12299. ( parseInt( closestHandle.css( "borderTopWidth" ), 10 ) || 0 ) -
  12300. ( parseInt( closestHandle.css( "borderBottomWidth" ), 10 ) || 0 ) +
  12301. ( parseInt( closestHandle.css( "marginTop" ), 10 ) || 0 )
  12302. };
  12303. if ( !this.handles.hasClass( "ui-state-hover" ) ) {
  12304. this._slide( event, index, normValue );
  12305. }
  12306. this._animateOff = true;
  12307. return true;
  12308. },
  12309. _mouseStart: function() {
  12310. return true;
  12311. },
  12312. _mouseDrag: function( event ) {
  12313. var position = { x: event.pageX, y: event.pageY },
  12314. normValue = this._normValueFromMouse( position );
  12315. this._slide( event, this._handleIndex, normValue );
  12316. return false;
  12317. },
  12318. _mouseStop: function( event ) {
  12319. this._removeClass( this.handles, null, "ui-state-active" );
  12320. this._mouseSliding = false;
  12321. this._stop( event, this._handleIndex );
  12322. this._change( event, this._handleIndex );
  12323. this._handleIndex = null;
  12324. this._clickOffset = null;
  12325. this._animateOff = false;
  12326. return false;
  12327. },
  12328. _detectOrientation: function() {
  12329. this.orientation = ( this.options.orientation === "vertical" ) ? "vertical" : "horizontal";
  12330. },
  12331. _normValueFromMouse: function( position ) {
  12332. var pixelTotal,
  12333. pixelMouse,
  12334. percentMouse,
  12335. valueTotal,
  12336. valueMouse;
  12337. if ( this.orientation === "horizontal" ) {
  12338. pixelTotal = this.elementSize.width;
  12339. pixelMouse = position.x - this.elementOffset.left -
  12340. ( this._clickOffset ? this._clickOffset.left : 0 );
  12341. } else {
  12342. pixelTotal = this.elementSize.height;
  12343. pixelMouse = position.y - this.elementOffset.top -
  12344. ( this._clickOffset ? this._clickOffset.top : 0 );
  12345. }
  12346. percentMouse = ( pixelMouse / pixelTotal );
  12347. if ( percentMouse > 1 ) {
  12348. percentMouse = 1;
  12349. }
  12350. if ( percentMouse < 0 ) {
  12351. percentMouse = 0;
  12352. }
  12353. if ( this.orientation === "vertical" ) {
  12354. percentMouse = 1 - percentMouse;
  12355. }
  12356. valueTotal = this._valueMax() - this._valueMin();
  12357. valueMouse = this._valueMin() + percentMouse * valueTotal;
  12358. return this._trimAlignValue( valueMouse );
  12359. },
  12360. _uiHash: function( index, value, values ) {
  12361. var uiHash = {
  12362. handle: this.handles[ index ],
  12363. handleIndex: index,
  12364. value: value !== undefined ? value : this.value()
  12365. };
  12366. if ( this._hasMultipleValues() ) {
  12367. uiHash.value = value !== undefined ? value : this.values( index );
  12368. uiHash.values = values || this.values();
  12369. }
  12370. return uiHash;
  12371. },
  12372. _hasMultipleValues: function() {
  12373. return this.options.values && this.options.values.length;
  12374. },
  12375. _start: function( event, index ) {
  12376. return this._trigger( "start", event, this._uiHash( index ) );
  12377. },
  12378. _slide: function( event, index, newVal ) {
  12379. var allowed, otherVal,
  12380. currentValue = this.value(),
  12381. newValues = this.values();
  12382. if ( this._hasMultipleValues() ) {
  12383. otherVal = this.values( index ? 0 : 1 );
  12384. currentValue = this.values( index );
  12385. if ( this.options.values.length === 2 && this.options.range === true ) {
  12386. newVal = index === 0 ? Math.min( otherVal, newVal ) : Math.max( otherVal, newVal );
  12387. }
  12388. newValues[ index ] = newVal;
  12389. }
  12390. if ( newVal === currentValue ) {
  12391. return;
  12392. }
  12393. allowed = this._trigger( "slide", event, this._uiHash( index, newVal, newValues ) );
  12394. // A slide can be canceled by returning false from the slide callback
  12395. if ( allowed === false ) {
  12396. return;
  12397. }
  12398. if ( this._hasMultipleValues() ) {
  12399. this.values( index, newVal );
  12400. } else {
  12401. this.value( newVal );
  12402. }
  12403. },
  12404. _stop: function( event, index ) {
  12405. this._trigger( "stop", event, this._uiHash( index ) );
  12406. },
  12407. _change: function( event, index ) {
  12408. if ( !this._keySliding && !this._mouseSliding ) {
  12409. //store the last changed value index for reference when handles overlap
  12410. this._lastChangedValue = index;
  12411. this._trigger( "change", event, this._uiHash( index ) );
  12412. }
  12413. },
  12414. value: function( newValue ) {
  12415. if ( arguments.length ) {
  12416. this.options.value = this._trimAlignValue( newValue );
  12417. this._refreshValue();
  12418. this._change( null, 0 );
  12419. return;
  12420. }
  12421. return this._value();
  12422. },
  12423. values: function( index, newValue ) {
  12424. var vals,
  12425. newValues,
  12426. i;
  12427. if ( arguments.length > 1 ) {
  12428. this.options.values[ index ] = this._trimAlignValue( newValue );
  12429. this._refreshValue();
  12430. this._change( null, index );
  12431. return;
  12432. }
  12433. if ( arguments.length ) {
  12434. if ( $.isArray( arguments[ 0 ] ) ) {
  12435. vals = this.options.values;
  12436. newValues = arguments[ 0 ];
  12437. for ( i = 0; i < vals.length; i += 1 ) {
  12438. vals[ i ] = this._trimAlignValue( newValues[ i ] );
  12439. this._change( null, i );
  12440. }
  12441. this._refreshValue();
  12442. } else {
  12443. if ( this._hasMultipleValues() ) {
  12444. return this._values( index );
  12445. } else {
  12446. return this.value();
  12447. }
  12448. }
  12449. } else {
  12450. return this._values();
  12451. }
  12452. },
  12453. _setOption: function( key, value ) {
  12454. var i,
  12455. valsLength = 0;
  12456. if ( key === "range" && this.options.range === true ) {
  12457. if ( value === "min" ) {
  12458. this.options.value = this._values( 0 );
  12459. this.options.values = null;
  12460. } else if ( value === "max" ) {
  12461. this.options.value = this._values( this.options.values.length - 1 );
  12462. this.options.values = null;
  12463. }
  12464. }
  12465. if ( $.isArray( this.options.values ) ) {
  12466. valsLength = this.options.values.length;
  12467. }
  12468. this._super( key, value );
  12469. switch ( key ) {
  12470. case "orientation":
  12471. this._detectOrientation();
  12472. this._removeClass( "ui-slider-horizontal ui-slider-vertical" )
  12473. ._addClass( "ui-slider-" + this.orientation );
  12474. this._refreshValue();
  12475. if ( this.options.range ) {
  12476. this._refreshRange( value );
  12477. }
  12478. // Reset positioning from previous orientation
  12479. this.handles.css( value === "horizontal" ? "bottom" : "left", "" );
  12480. break;
  12481. case "value":
  12482. this._animateOff = true;
  12483. this._refreshValue();
  12484. this._change( null, 0 );
  12485. this._animateOff = false;
  12486. break;
  12487. case "values":
  12488. this._animateOff = true;
  12489. this._refreshValue();
  12490. // Start from the last handle to prevent unreachable handles (#9046)
  12491. for ( i = valsLength - 1; i >= 0; i-- ) {
  12492. this._change( null, i );
  12493. }
  12494. this._animateOff = false;
  12495. break;
  12496. case "step":
  12497. case "min":
  12498. case "max":
  12499. this._animateOff = true;
  12500. this._calculateNewMax();
  12501. this._refreshValue();
  12502. this._animateOff = false;
  12503. break;
  12504. case "range":
  12505. this._animateOff = true;
  12506. this._refresh();
  12507. this._animateOff = false;
  12508. break;
  12509. }
  12510. },
  12511. _setOptionDisabled: function( value ) {
  12512. this._super( value );
  12513. this._toggleClass( null, "ui-state-disabled", !!value );
  12514. },
  12515. //internal value getter
  12516. // _value() returns value trimmed by min and max, aligned by step
  12517. _value: function() {
  12518. var val = this.options.value;
  12519. val = this._trimAlignValue( val );
  12520. return val;
  12521. },
  12522. //internal values getter
  12523. // _values() returns array of values trimmed by min and max, aligned by step
  12524. // _values( index ) returns single value trimmed by min and max, aligned by step
  12525. _values: function( index ) {
  12526. var val,
  12527. vals,
  12528. i;
  12529. if ( arguments.length ) {
  12530. val = this.options.values[ index ];
  12531. val = this._trimAlignValue( val );
  12532. return val;
  12533. } else if ( this._hasMultipleValues() ) {
  12534. // .slice() creates a copy of the array
  12535. // this copy gets trimmed by min and max and then returned
  12536. vals = this.options.values.slice();
  12537. for ( i = 0; i < vals.length; i += 1 ) {
  12538. vals[ i ] = this._trimAlignValue( vals[ i ] );
  12539. }
  12540. return vals;
  12541. } else {
  12542. return [];
  12543. }
  12544. },
  12545. // Returns the step-aligned value that val is closest to, between (inclusive) min and max
  12546. _trimAlignValue: function( val ) {
  12547. if ( val <= this._valueMin() ) {
  12548. return this._valueMin();
  12549. }
  12550. if ( val >= this._valueMax() ) {
  12551. return this._valueMax();
  12552. }
  12553. var step = ( this.options.step > 0 ) ? this.options.step : 1,
  12554. valModStep = ( val - this._valueMin() ) % step,
  12555. alignValue = val - valModStep;
  12556. if ( Math.abs( valModStep ) * 2 >= step ) {
  12557. alignValue += ( valModStep > 0 ) ? step : ( -step );
  12558. }
  12559. // Since JavaScript has problems with large floats, round
  12560. // the final value to 5 digits after the decimal point (see #4124)
  12561. return parseFloat( alignValue.toFixed( 5 ) );
  12562. },
  12563. _calculateNewMax: function() {
  12564. var max = this.options.max,
  12565. min = this._valueMin(),
  12566. step = this.options.step,
  12567. aboveMin = Math.round( ( max - min ) / step ) * step;
  12568. max = aboveMin + min;
  12569. if ( max > this.options.max ) {
  12570. //If max is not divisible by step, rounding off may increase its value
  12571. max -= step;
  12572. }
  12573. this.max = parseFloat( max.toFixed( this._precision() ) );
  12574. },
  12575. _precision: function() {
  12576. var precision = this._precisionOf( this.options.step );
  12577. if ( this.options.min !== null ) {
  12578. precision = Math.max( precision, this._precisionOf( this.options.min ) );
  12579. }
  12580. return precision;
  12581. },
  12582. _precisionOf: function( num ) {
  12583. var str = num.toString(),
  12584. decimal = str.indexOf( "." );
  12585. return decimal === -1 ? 0 : str.length - decimal - 1;
  12586. },
  12587. _valueMin: function() {
  12588. return this.options.min;
  12589. },
  12590. _valueMax: function() {
  12591. return this.max;
  12592. },
  12593. _refreshRange: function( orientation ) {
  12594. if ( orientation === "vertical" ) {
  12595. this.range.css( { "width": "", "left": "" } );
  12596. }
  12597. if ( orientation === "horizontal" ) {
  12598. this.range.css( { "height": "", "bottom": "" } );
  12599. }
  12600. },
  12601. _refreshValue: function() {
  12602. var lastValPercent, valPercent, value, valueMin, valueMax,
  12603. oRange = this.options.range,
  12604. o = this.options,
  12605. that = this,
  12606. animate = ( !this._animateOff ) ? o.animate : false,
  12607. _set = {};
  12608. if ( this._hasMultipleValues() ) {
  12609. this.handles.each( function( i ) {
  12610. valPercent = ( that.values( i ) - that._valueMin() ) / ( that._valueMax() -
  12611. that._valueMin() ) * 100;
  12612. _set[ that.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  12613. $( this ).stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  12614. if ( that.options.range === true ) {
  12615. if ( that.orientation === "horizontal" ) {
  12616. if ( i === 0 ) {
  12617. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
  12618. left: valPercent + "%"
  12619. }, o.animate );
  12620. }
  12621. if ( i === 1 ) {
  12622. that.range[ animate ? "animate" : "css" ]( {
  12623. width: ( valPercent - lastValPercent ) + "%"
  12624. }, {
  12625. queue: false,
  12626. duration: o.animate
  12627. } );
  12628. }
  12629. } else {
  12630. if ( i === 0 ) {
  12631. that.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
  12632. bottom: ( valPercent ) + "%"
  12633. }, o.animate );
  12634. }
  12635. if ( i === 1 ) {
  12636. that.range[ animate ? "animate" : "css" ]( {
  12637. height: ( valPercent - lastValPercent ) + "%"
  12638. }, {
  12639. queue: false,
  12640. duration: o.animate
  12641. } );
  12642. }
  12643. }
  12644. }
  12645. lastValPercent = valPercent;
  12646. } );
  12647. } else {
  12648. value = this.value();
  12649. valueMin = this._valueMin();
  12650. valueMax = this._valueMax();
  12651. valPercent = ( valueMax !== valueMin ) ?
  12652. ( value - valueMin ) / ( valueMax - valueMin ) * 100 :
  12653. 0;
  12654. _set[ this.orientation === "horizontal" ? "left" : "bottom" ] = valPercent + "%";
  12655. this.handle.stop( 1, 1 )[ animate ? "animate" : "css" ]( _set, o.animate );
  12656. if ( oRange === "min" && this.orientation === "horizontal" ) {
  12657. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
  12658. width: valPercent + "%"
  12659. }, o.animate );
  12660. }
  12661. if ( oRange === "max" && this.orientation === "horizontal" ) {
  12662. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
  12663. width: ( 100 - valPercent ) + "%"
  12664. }, o.animate );
  12665. }
  12666. if ( oRange === "min" && this.orientation === "vertical" ) {
  12667. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
  12668. height: valPercent + "%"
  12669. }, o.animate );
  12670. }
  12671. if ( oRange === "max" && this.orientation === "vertical" ) {
  12672. this.range.stop( 1, 1 )[ animate ? "animate" : "css" ]( {
  12673. height: ( 100 - valPercent ) + "%"
  12674. }, o.animate );
  12675. }
  12676. }
  12677. },
  12678. _handleEvents: {
  12679. keydown: function( event ) {
  12680. var allowed, curVal, newVal, step,
  12681. index = $( event.target ).data( "ui-slider-handle-index" );
  12682. switch ( event.keyCode ) {
  12683. case $.ui.keyCode.HOME:
  12684. case $.ui.keyCode.END:
  12685. case $.ui.keyCode.PAGE_UP:
  12686. case $.ui.keyCode.PAGE_DOWN:
  12687. case $.ui.keyCode.UP:
  12688. case $.ui.keyCode.RIGHT:
  12689. case $.ui.keyCode.DOWN:
  12690. case $.ui.keyCode.LEFT:
  12691. event.preventDefault();
  12692. if ( !this._keySliding ) {
  12693. this._keySliding = true;
  12694. this._addClass( $( event.target ), null, "ui-state-active" );
  12695. allowed = this._start( event, index );
  12696. if ( allowed === false ) {
  12697. return;
  12698. }
  12699. }
  12700. break;
  12701. }
  12702. step = this.options.step;
  12703. if ( this._hasMultipleValues() ) {
  12704. curVal = newVal = this.values( index );
  12705. } else {
  12706. curVal = newVal = this.value();
  12707. }
  12708. switch ( event.keyCode ) {
  12709. case $.ui.keyCode.HOME:
  12710. newVal = this._valueMin();
  12711. break;
  12712. case $.ui.keyCode.END:
  12713. newVal = this._valueMax();
  12714. break;
  12715. case $.ui.keyCode.PAGE_UP:
  12716. newVal = this._trimAlignValue(
  12717. curVal + ( ( this._valueMax() - this._valueMin() ) / this.numPages )
  12718. );
  12719. break;
  12720. case $.ui.keyCode.PAGE_DOWN:
  12721. newVal = this._trimAlignValue(
  12722. curVal - ( ( this._valueMax() - this._valueMin() ) / this.numPages ) );
  12723. break;
  12724. case $.ui.keyCode.UP:
  12725. case $.ui.keyCode.RIGHT:
  12726. if ( curVal === this._valueMax() ) {
  12727. return;
  12728. }
  12729. newVal = this._trimAlignValue( curVal + step );
  12730. break;
  12731. case $.ui.keyCode.DOWN:
  12732. case $.ui.keyCode.LEFT:
  12733. if ( curVal === this._valueMin() ) {
  12734. return;
  12735. }
  12736. newVal = this._trimAlignValue( curVal - step );
  12737. break;
  12738. }
  12739. this._slide( event, index, newVal );
  12740. },
  12741. keyup: function( event ) {
  12742. var index = $( event.target ).data( "ui-slider-handle-index" );
  12743. if ( this._keySliding ) {
  12744. this._keySliding = false;
  12745. this._stop( event, index );
  12746. this._change( event, index );
  12747. this._removeClass( $( event.target ), null, "ui-state-active" );
  12748. }
  12749. }
  12750. }
  12751. } );
  12752. /*!
  12753. * jQuery UI Sortable 1.12.1
  12754. * http://jqueryui.com
  12755. *
  12756. * Copyright jQuery Foundation and other contributors
  12757. * Released under the MIT license.
  12758. * http://jquery.org/license
  12759. */
  12760. //>>label: Sortable
  12761. //>>group: Interactions
  12762. //>>description: Enables items in a list to be sorted using the mouse.
  12763. //>>docs: http://api.jqueryui.com/sortable/
  12764. //>>demos: http://jqueryui.com/sortable/
  12765. //>>css.structure: ../../themes/base/sortable.css
  12766. var widgetsSortable = $.widget( "ui.sortable", $.ui.mouse, {
  12767. version: "1.12.1",
  12768. widgetEventPrefix: "sort",
  12769. ready: false,
  12770. options: {
  12771. appendTo: "parent",
  12772. axis: false,
  12773. connectWith: false,
  12774. containment: false,
  12775. cursor: "auto",
  12776. cursorAt: false,
  12777. dropOnEmpty: true,
  12778. forcePlaceholderSize: false,
  12779. forceHelperSize: false,
  12780. grid: false,
  12781. handle: false,
  12782. helper: "original",
  12783. items: "> *",
  12784. opacity: false,
  12785. placeholder: false,
  12786. revert: false,
  12787. scroll: true,
  12788. scrollSensitivity: 20,
  12789. scrollSpeed: 20,
  12790. scope: "default",
  12791. tolerance: "intersect",
  12792. zIndex: 1000,
  12793. // Callbacks
  12794. activate: null,
  12795. beforeStop: null,
  12796. change: null,
  12797. deactivate: null,
  12798. out: null,
  12799. over: null,
  12800. receive: null,
  12801. remove: null,
  12802. sort: null,
  12803. start: null,
  12804. stop: null,
  12805. update: null
  12806. },
  12807. _isOverAxis: function( x, reference, size ) {
  12808. return ( x >= reference ) && ( x < ( reference + size ) );
  12809. },
  12810. _isFloating: function( item ) {
  12811. return ( /left|right/ ).test( item.css( "float" ) ) ||
  12812. ( /inline|table-cell/ ).test( item.css( "display" ) );
  12813. },
  12814. _create: function() {
  12815. this.containerCache = {};
  12816. this._addClass( "ui-sortable" );
  12817. //Get the items
  12818. this.refresh();
  12819. //Let's determine the parent's offset
  12820. this.offset = this.element.offset();
  12821. //Initialize mouse events for interaction
  12822. this._mouseInit();
  12823. this._setHandleClassName();
  12824. //We're ready to go
  12825. this.ready = true;
  12826. },
  12827. _setOption: function( key, value ) {
  12828. this._super( key, value );
  12829. if ( key === "handle" ) {
  12830. this._setHandleClassName();
  12831. }
  12832. },
  12833. _setHandleClassName: function() {
  12834. var that = this;
  12835. this._removeClass( this.element.find( ".ui-sortable-handle" ), "ui-sortable-handle" );
  12836. $.each( this.items, function() {
  12837. that._addClass(
  12838. this.instance.options.handle ?
  12839. this.item.find( this.instance.options.handle ) :
  12840. this.item,
  12841. "ui-sortable-handle"
  12842. );
  12843. } );
  12844. },
  12845. _destroy: function() {
  12846. this._mouseDestroy();
  12847. for ( var i = this.items.length - 1; i >= 0; i-- ) {
  12848. this.items[ i ].item.removeData( this.widgetName + "-item" );
  12849. }
  12850. return this;
  12851. },
  12852. _mouseCapture: function( event, overrideHandle ) {
  12853. var currentItem = null,
  12854. validHandle = false,
  12855. that = this;
  12856. if ( this.reverting ) {
  12857. return false;
  12858. }
  12859. if ( this.options.disabled || this.options.type === "static" ) {
  12860. return false;
  12861. }
  12862. //We have to refresh the items data once first
  12863. this._refreshItems( event );
  12864. //Find out if the clicked node (or one of its parents) is a actual item in this.items
  12865. $( event.target ).parents().each( function() {
  12866. if ( $.data( this, that.widgetName + "-item" ) === that ) {
  12867. currentItem = $( this );
  12868. return false;
  12869. }
  12870. } );
  12871. if ( $.data( event.target, that.widgetName + "-item" ) === that ) {
  12872. currentItem = $( event.target );
  12873. }
  12874. if ( !currentItem ) {
  12875. return false;
  12876. }
  12877. if ( this.options.handle && !overrideHandle ) {
  12878. $( this.options.handle, currentItem ).find( "*" ).addBack().each( function() {
  12879. if ( this === event.target ) {
  12880. validHandle = true;
  12881. }
  12882. } );
  12883. if ( !validHandle ) {
  12884. return false;
  12885. }
  12886. }
  12887. this.currentItem = currentItem;
  12888. this._removeCurrentsFromItems();
  12889. return true;
  12890. },
  12891. _mouseStart: function( event, overrideHandle, noActivation ) {
  12892. var i, body,
  12893. o = this.options;
  12894. this.currentContainer = this;
  12895. //We only need to call refreshPositions, because the refreshItems call has been moved to
  12896. // mouseCapture
  12897. this.refreshPositions();
  12898. //Create and append the visible helper
  12899. this.helper = this._createHelper( event );
  12900. //Cache the helper size
  12901. this._cacheHelperProportions();
  12902. /*
  12903. * - Position generation -
  12904. * This block generates everything position related - it's the core of draggables.
  12905. */
  12906. //Cache the margins of the original element
  12907. this._cacheMargins();
  12908. //Get the next scrolling parent
  12909. this.scrollParent = this.helper.scrollParent();
  12910. //The element's absolute position on the page minus margins
  12911. this.offset = this.currentItem.offset();
  12912. this.offset = {
  12913. top: this.offset.top - this.margins.top,
  12914. left: this.offset.left - this.margins.left
  12915. };
  12916. $.extend( this.offset, {
  12917. click: { //Where the click happened, relative to the element
  12918. left: event.pageX - this.offset.left,
  12919. top: event.pageY - this.offset.top
  12920. },
  12921. parent: this._getParentOffset(),
  12922. // This is a relative to absolute position minus the actual position calculation -
  12923. // only used for relative positioned helper
  12924. relative: this._getRelativeOffset()
  12925. } );
  12926. // Only after we got the offset, we can change the helper's position to absolute
  12927. // TODO: Still need to figure out a way to make relative sorting possible
  12928. this.helper.css( "position", "absolute" );
  12929. this.cssPosition = this.helper.css( "position" );
  12930. //Generate the original position
  12931. this.originalPosition = this._generatePosition( event );
  12932. this.originalPageX = event.pageX;
  12933. this.originalPageY = event.pageY;
  12934. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  12935. ( o.cursorAt && this._adjustOffsetFromHelper( o.cursorAt ) );
  12936. //Cache the former DOM position
  12937. this.domPosition = {
  12938. prev: this.currentItem.prev()[ 0 ],
  12939. parent: this.currentItem.parent()[ 0 ]
  12940. };
  12941. // If the helper is not the original, hide the original so it's not playing any role during
  12942. // the drag, won't cause anything bad this way
  12943. if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) {
  12944. this.currentItem.hide();
  12945. }
  12946. //Create the placeholder
  12947. this._createPlaceholder();
  12948. //Set a containment if given in the options
  12949. if ( o.containment ) {
  12950. this._setContainment();
  12951. }
  12952. if ( o.cursor && o.cursor !== "auto" ) { // cursor option
  12953. body = this.document.find( "body" );
  12954. // Support: IE
  12955. this.storedCursor = body.css( "cursor" );
  12956. body.css( "cursor", o.cursor );
  12957. this.storedStylesheet =
  12958. $( "<style>*{ cursor: " + o.cursor + " !important; }</style>" ).appendTo( body );
  12959. }
  12960. if ( o.opacity ) { // opacity option
  12961. if ( this.helper.css( "opacity" ) ) {
  12962. this._storedOpacity = this.helper.css( "opacity" );
  12963. }
  12964. this.helper.css( "opacity", o.opacity );
  12965. }
  12966. if ( o.zIndex ) { // zIndex option
  12967. if ( this.helper.css( "zIndex" ) ) {
  12968. this._storedZIndex = this.helper.css( "zIndex" );
  12969. }
  12970. this.helper.css( "zIndex", o.zIndex );
  12971. }
  12972. //Prepare scrolling
  12973. if ( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  12974. this.scrollParent[ 0 ].tagName !== "HTML" ) {
  12975. this.overflowOffset = this.scrollParent.offset();
  12976. }
  12977. //Call callbacks
  12978. this._trigger( "start", event, this._uiHash() );
  12979. //Recache the helper size
  12980. if ( !this._preserveHelperProportions ) {
  12981. this._cacheHelperProportions();
  12982. }
  12983. //Post "activate" events to possible containers
  12984. if ( !noActivation ) {
  12985. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  12986. this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
  12987. }
  12988. }
  12989. //Prepare possible droppables
  12990. if ( $.ui.ddmanager ) {
  12991. $.ui.ddmanager.current = this;
  12992. }
  12993. if ( $.ui.ddmanager && !o.dropBehaviour ) {
  12994. $.ui.ddmanager.prepareOffsets( this, event );
  12995. }
  12996. this.dragging = true;
  12997. this._addClass( this.helper, "ui-sortable-helper" );
  12998. // Execute the drag once - this causes the helper not to be visiblebefore getting its
  12999. // correct position
  13000. this._mouseDrag( event );
  13001. return true;
  13002. },
  13003. _mouseDrag: function( event ) {
  13004. var i, item, itemElement, intersection,
  13005. o = this.options,
  13006. scrolled = false;
  13007. //Compute the helpers position
  13008. this.position = this._generatePosition( event );
  13009. this.positionAbs = this._convertPositionTo( "absolute" );
  13010. if ( !this.lastPositionAbs ) {
  13011. this.lastPositionAbs = this.positionAbs;
  13012. }
  13013. //Do scrolling
  13014. if ( this.options.scroll ) {
  13015. if ( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  13016. this.scrollParent[ 0 ].tagName !== "HTML" ) {
  13017. if ( ( this.overflowOffset.top + this.scrollParent[ 0 ].offsetHeight ) -
  13018. event.pageY < o.scrollSensitivity ) {
  13019. this.scrollParent[ 0 ].scrollTop =
  13020. scrolled = this.scrollParent[ 0 ].scrollTop + o.scrollSpeed;
  13021. } else if ( event.pageY - this.overflowOffset.top < o.scrollSensitivity ) {
  13022. this.scrollParent[ 0 ].scrollTop =
  13023. scrolled = this.scrollParent[ 0 ].scrollTop - o.scrollSpeed;
  13024. }
  13025. if ( ( this.overflowOffset.left + this.scrollParent[ 0 ].offsetWidth ) -
  13026. event.pageX < o.scrollSensitivity ) {
  13027. this.scrollParent[ 0 ].scrollLeft = scrolled =
  13028. this.scrollParent[ 0 ].scrollLeft + o.scrollSpeed;
  13029. } else if ( event.pageX - this.overflowOffset.left < o.scrollSensitivity ) {
  13030. this.scrollParent[ 0 ].scrollLeft = scrolled =
  13031. this.scrollParent[ 0 ].scrollLeft - o.scrollSpeed;
  13032. }
  13033. } else {
  13034. if ( event.pageY - this.document.scrollTop() < o.scrollSensitivity ) {
  13035. scrolled = this.document.scrollTop( this.document.scrollTop() - o.scrollSpeed );
  13036. } else if ( this.window.height() - ( event.pageY - this.document.scrollTop() ) <
  13037. o.scrollSensitivity ) {
  13038. scrolled = this.document.scrollTop( this.document.scrollTop() + o.scrollSpeed );
  13039. }
  13040. if ( event.pageX - this.document.scrollLeft() < o.scrollSensitivity ) {
  13041. scrolled = this.document.scrollLeft(
  13042. this.document.scrollLeft() - o.scrollSpeed
  13043. );
  13044. } else if ( this.window.width() - ( event.pageX - this.document.scrollLeft() ) <
  13045. o.scrollSensitivity ) {
  13046. scrolled = this.document.scrollLeft(
  13047. this.document.scrollLeft() + o.scrollSpeed
  13048. );
  13049. }
  13050. }
  13051. if ( scrolled !== false && $.ui.ddmanager && !o.dropBehaviour ) {
  13052. $.ui.ddmanager.prepareOffsets( this, event );
  13053. }
  13054. }
  13055. //Regenerate the absolute position used for position checks
  13056. this.positionAbs = this._convertPositionTo( "absolute" );
  13057. //Set the helper position
  13058. if ( !this.options.axis || this.options.axis !== "y" ) {
  13059. this.helper[ 0 ].style.left = this.position.left + "px";
  13060. }
  13061. if ( !this.options.axis || this.options.axis !== "x" ) {
  13062. this.helper[ 0 ].style.top = this.position.top + "px";
  13063. }
  13064. //Rearrange
  13065. for ( i = this.items.length - 1; i >= 0; i-- ) {
  13066. //Cache variables and intersection, continue if no intersection
  13067. item = this.items[ i ];
  13068. itemElement = item.item[ 0 ];
  13069. intersection = this._intersectsWithPointer( item );
  13070. if ( !intersection ) {
  13071. continue;
  13072. }
  13073. // Only put the placeholder inside the current Container, skip all
  13074. // items from other containers. This works because when moving
  13075. // an item from one container to another the
  13076. // currentContainer is switched before the placeholder is moved.
  13077. //
  13078. // Without this, moving items in "sub-sortables" can cause
  13079. // the placeholder to jitter between the outer and inner container.
  13080. if ( item.instance !== this.currentContainer ) {
  13081. continue;
  13082. }
  13083. // Cannot intersect with itself
  13084. // no useless actions that have been done before
  13085. // no action if the item moved is the parent of the item checked
  13086. if ( itemElement !== this.currentItem[ 0 ] &&
  13087. this.placeholder[ intersection === 1 ? "next" : "prev" ]()[ 0 ] !== itemElement &&
  13088. !$.contains( this.placeholder[ 0 ], itemElement ) &&
  13089. ( this.options.type === "semi-dynamic" ?
  13090. !$.contains( this.element[ 0 ], itemElement ) :
  13091. true
  13092. )
  13093. ) {
  13094. this.direction = intersection === 1 ? "down" : "up";
  13095. if ( this.options.tolerance === "pointer" || this._intersectsWithSides( item ) ) {
  13096. this._rearrange( event, item );
  13097. } else {
  13098. break;
  13099. }
  13100. this._trigger( "change", event, this._uiHash() );
  13101. break;
  13102. }
  13103. }
  13104. //Post events to containers
  13105. this._contactContainers( event );
  13106. //Interconnect with droppables
  13107. if ( $.ui.ddmanager ) {
  13108. $.ui.ddmanager.drag( this, event );
  13109. }
  13110. //Call callbacks
  13111. this._trigger( "sort", event, this._uiHash() );
  13112. this.lastPositionAbs = this.positionAbs;
  13113. return false;
  13114. },
  13115. _mouseStop: function( event, noPropagation ) {
  13116. if ( !event ) {
  13117. return;
  13118. }
  13119. //If we are using droppables, inform the manager about the drop
  13120. if ( $.ui.ddmanager && !this.options.dropBehaviour ) {
  13121. $.ui.ddmanager.drop( this, event );
  13122. }
  13123. if ( this.options.revert ) {
  13124. var that = this,
  13125. cur = this.placeholder.offset(),
  13126. axis = this.options.axis,
  13127. animation = {};
  13128. if ( !axis || axis === "x" ) {
  13129. animation.left = cur.left - this.offset.parent.left - this.margins.left +
  13130. ( this.offsetParent[ 0 ] === this.document[ 0 ].body ?
  13131. 0 :
  13132. this.offsetParent[ 0 ].scrollLeft
  13133. );
  13134. }
  13135. if ( !axis || axis === "y" ) {
  13136. animation.top = cur.top - this.offset.parent.top - this.margins.top +
  13137. ( this.offsetParent[ 0 ] === this.document[ 0 ].body ?
  13138. 0 :
  13139. this.offsetParent[ 0 ].scrollTop
  13140. );
  13141. }
  13142. this.reverting = true;
  13143. $( this.helper ).animate(
  13144. animation,
  13145. parseInt( this.options.revert, 10 ) || 500,
  13146. function() {
  13147. that._clear( event );
  13148. }
  13149. );
  13150. } else {
  13151. this._clear( event, noPropagation );
  13152. }
  13153. return false;
  13154. },
  13155. cancel: function() {
  13156. if ( this.dragging ) {
  13157. this._mouseUp( new $.Event( "mouseup", { target: null } ) );
  13158. if ( this.options.helper === "original" ) {
  13159. this.currentItem.css( this._storedCSS );
  13160. this._removeClass( this.currentItem, "ui-sortable-helper" );
  13161. } else {
  13162. this.currentItem.show();
  13163. }
  13164. //Post deactivating events to containers
  13165. for ( var i = this.containers.length - 1; i >= 0; i-- ) {
  13166. this.containers[ i ]._trigger( "deactivate", null, this._uiHash( this ) );
  13167. if ( this.containers[ i ].containerCache.over ) {
  13168. this.containers[ i ]._trigger( "out", null, this._uiHash( this ) );
  13169. this.containers[ i ].containerCache.over = 0;
  13170. }
  13171. }
  13172. }
  13173. if ( this.placeholder ) {
  13174. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately,
  13175. // it unbinds ALL events from the original node!
  13176. if ( this.placeholder[ 0 ].parentNode ) {
  13177. this.placeholder[ 0 ].parentNode.removeChild( this.placeholder[ 0 ] );
  13178. }
  13179. if ( this.options.helper !== "original" && this.helper &&
  13180. this.helper[ 0 ].parentNode ) {
  13181. this.helper.remove();
  13182. }
  13183. $.extend( this, {
  13184. helper: null,
  13185. dragging: false,
  13186. reverting: false,
  13187. _noFinalSort: null
  13188. } );
  13189. if ( this.domPosition.prev ) {
  13190. $( this.domPosition.prev ).after( this.currentItem );
  13191. } else {
  13192. $( this.domPosition.parent ).prepend( this.currentItem );
  13193. }
  13194. }
  13195. return this;
  13196. },
  13197. serialize: function( o ) {
  13198. var items = this._getItemsAsjQuery( o && o.connected ),
  13199. str = [];
  13200. o = o || {};
  13201. $( items ).each( function() {
  13202. var res = ( $( o.item || this ).attr( o.attribute || "id" ) || "" )
  13203. .match( o.expression || ( /(.+)[\-=_](.+)/ ) );
  13204. if ( res ) {
  13205. str.push(
  13206. ( o.key || res[ 1 ] + "[]" ) +
  13207. "=" + ( o.key && o.expression ? res[ 1 ] : res[ 2 ] ) );
  13208. }
  13209. } );
  13210. if ( !str.length && o.key ) {
  13211. str.push( o.key + "=" );
  13212. }
  13213. return str.join( "&" );
  13214. },
  13215. toArray: function( o ) {
  13216. var items = this._getItemsAsjQuery( o && o.connected ),
  13217. ret = [];
  13218. o = o || {};
  13219. items.each( function() {
  13220. ret.push( $( o.item || this ).attr( o.attribute || "id" ) || "" );
  13221. } );
  13222. return ret;
  13223. },
  13224. /* Be careful with the following core functions */
  13225. _intersectsWith: function( item ) {
  13226. var x1 = this.positionAbs.left,
  13227. x2 = x1 + this.helperProportions.width,
  13228. y1 = this.positionAbs.top,
  13229. y2 = y1 + this.helperProportions.height,
  13230. l = item.left,
  13231. r = l + item.width,
  13232. t = item.top,
  13233. b = t + item.height,
  13234. dyClick = this.offset.click.top,
  13235. dxClick = this.offset.click.left,
  13236. isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t &&
  13237. ( y1 + dyClick ) < b ),
  13238. isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l &&
  13239. ( x1 + dxClick ) < r ),
  13240. isOverElement = isOverElementHeight && isOverElementWidth;
  13241. if ( this.options.tolerance === "pointer" ||
  13242. this.options.forcePointerForContainers ||
  13243. ( this.options.tolerance !== "pointer" &&
  13244. this.helperProportions[ this.floating ? "width" : "height" ] >
  13245. item[ this.floating ? "width" : "height" ] )
  13246. ) {
  13247. return isOverElement;
  13248. } else {
  13249. return ( l < x1 + ( this.helperProportions.width / 2 ) && // Right Half
  13250. x2 - ( this.helperProportions.width / 2 ) < r && // Left Half
  13251. t < y1 + ( this.helperProportions.height / 2 ) && // Bottom Half
  13252. y2 - ( this.helperProportions.height / 2 ) < b ); // Top Half
  13253. }
  13254. },
  13255. _intersectsWithPointer: function( item ) {
  13256. var verticalDirection, horizontalDirection,
  13257. isOverElementHeight = ( this.options.axis === "x" ) ||
  13258. this._isOverAxis(
  13259. this.positionAbs.top + this.offset.click.top, item.top, item.height ),
  13260. isOverElementWidth = ( this.options.axis === "y" ) ||
  13261. this._isOverAxis(
  13262. this.positionAbs.left + this.offset.click.left, item.left, item.width ),
  13263. isOverElement = isOverElementHeight && isOverElementWidth;
  13264. if ( !isOverElement ) {
  13265. return false;
  13266. }
  13267. verticalDirection = this._getDragVerticalDirection();
  13268. horizontalDirection = this._getDragHorizontalDirection();
  13269. return this.floating ?
  13270. ( ( horizontalDirection === "right" || verticalDirection === "down" ) ? 2 : 1 )
  13271. : ( verticalDirection && ( verticalDirection === "down" ? 2 : 1 ) );
  13272. },
  13273. _intersectsWithSides: function( item ) {
  13274. var isOverBottomHalf = this._isOverAxis( this.positionAbs.top +
  13275. this.offset.click.top, item.top + ( item.height / 2 ), item.height ),
  13276. isOverRightHalf = this._isOverAxis( this.positionAbs.left +
  13277. this.offset.click.left, item.left + ( item.width / 2 ), item.width ),
  13278. verticalDirection = this._getDragVerticalDirection(),
  13279. horizontalDirection = this._getDragHorizontalDirection();
  13280. if ( this.floating && horizontalDirection ) {
  13281. return ( ( horizontalDirection === "right" && isOverRightHalf ) ||
  13282. ( horizontalDirection === "left" && !isOverRightHalf ) );
  13283. } else {
  13284. return verticalDirection && ( ( verticalDirection === "down" && isOverBottomHalf ) ||
  13285. ( verticalDirection === "up" && !isOverBottomHalf ) );
  13286. }
  13287. },
  13288. _getDragVerticalDirection: function() {
  13289. var delta = this.positionAbs.top - this.lastPositionAbs.top;
  13290. return delta !== 0 && ( delta > 0 ? "down" : "up" );
  13291. },
  13292. _getDragHorizontalDirection: function() {
  13293. var delta = this.positionAbs.left - this.lastPositionAbs.left;
  13294. return delta !== 0 && ( delta > 0 ? "right" : "left" );
  13295. },
  13296. refresh: function( event ) {
  13297. this._refreshItems( event );
  13298. this._setHandleClassName();
  13299. this.refreshPositions();
  13300. return this;
  13301. },
  13302. _connectWith: function() {
  13303. var options = this.options;
  13304. return options.connectWith.constructor === String ?
  13305. [ options.connectWith ] :
  13306. options.connectWith;
  13307. },
  13308. _getItemsAsjQuery: function( connected ) {
  13309. var i, j, cur, inst,
  13310. items = [],
  13311. queries = [],
  13312. connectWith = this._connectWith();
  13313. if ( connectWith && connected ) {
  13314. for ( i = connectWith.length - 1; i >= 0; i-- ) {
  13315. cur = $( connectWith[ i ], this.document[ 0 ] );
  13316. for ( j = cur.length - 1; j >= 0; j-- ) {
  13317. inst = $.data( cur[ j ], this.widgetFullName );
  13318. if ( inst && inst !== this && !inst.options.disabled ) {
  13319. queries.push( [ $.isFunction( inst.options.items ) ?
  13320. inst.options.items.call( inst.element ) :
  13321. $( inst.options.items, inst.element )
  13322. .not( ".ui-sortable-helper" )
  13323. .not( ".ui-sortable-placeholder" ), inst ] );
  13324. }
  13325. }
  13326. }
  13327. }
  13328. queries.push( [ $.isFunction( this.options.items ) ?
  13329. this.options.items
  13330. .call( this.element, null, { options: this.options, item: this.currentItem } ) :
  13331. $( this.options.items, this.element )
  13332. .not( ".ui-sortable-helper" )
  13333. .not( ".ui-sortable-placeholder" ), this ] );
  13334. function addItems() {
  13335. items.push( this );
  13336. }
  13337. for ( i = queries.length - 1; i >= 0; i-- ) {
  13338. queries[ i ][ 0 ].each( addItems );
  13339. }
  13340. return $( items );
  13341. },
  13342. _removeCurrentsFromItems: function() {
  13343. var list = this.currentItem.find( ":data(" + this.widgetName + "-item)" );
  13344. this.items = $.grep( this.items, function( item ) {
  13345. for ( var j = 0; j < list.length; j++ ) {
  13346. if ( list[ j ] === item.item[ 0 ] ) {
  13347. return false;
  13348. }
  13349. }
  13350. return true;
  13351. } );
  13352. },
  13353. _refreshItems: function( event ) {
  13354. this.items = [];
  13355. this.containers = [ this ];
  13356. var i, j, cur, inst, targetData, _queries, item, queriesLength,
  13357. items = this.items,
  13358. queries = [ [ $.isFunction( this.options.items ) ?
  13359. this.options.items.call( this.element[ 0 ], event, { item: this.currentItem } ) :
  13360. $( this.options.items, this.element ), this ] ],
  13361. connectWith = this._connectWith();
  13362. //Shouldn't be run the first time through due to massive slow-down
  13363. if ( connectWith && this.ready ) {
  13364. for ( i = connectWith.length - 1; i >= 0; i-- ) {
  13365. cur = $( connectWith[ i ], this.document[ 0 ] );
  13366. for ( j = cur.length - 1; j >= 0; j-- ) {
  13367. inst = $.data( cur[ j ], this.widgetFullName );
  13368. if ( inst && inst !== this && !inst.options.disabled ) {
  13369. queries.push( [ $.isFunction( inst.options.items ) ?
  13370. inst.options.items
  13371. .call( inst.element[ 0 ], event, { item: this.currentItem } ) :
  13372. $( inst.options.items, inst.element ), inst ] );
  13373. this.containers.push( inst );
  13374. }
  13375. }
  13376. }
  13377. }
  13378. for ( i = queries.length - 1; i >= 0; i-- ) {
  13379. targetData = queries[ i ][ 1 ];
  13380. _queries = queries[ i ][ 0 ];
  13381. for ( j = 0, queriesLength = _queries.length; j < queriesLength; j++ ) {
  13382. item = $( _queries[ j ] );
  13383. // Data for target checking (mouse manager)
  13384. item.data( this.widgetName + "-item", targetData );
  13385. items.push( {
  13386. item: item,
  13387. instance: targetData,
  13388. width: 0, height: 0,
  13389. left: 0, top: 0
  13390. } );
  13391. }
  13392. }
  13393. },
  13394. refreshPositions: function( fast ) {
  13395. // Determine whether items are being displayed horizontally
  13396. this.floating = this.items.length ?
  13397. this.options.axis === "x" || this._isFloating( this.items[ 0 ].item ) :
  13398. false;
  13399. //This has to be redone because due to the item being moved out/into the offsetParent,
  13400. // the offsetParent's position will change
  13401. if ( this.offsetParent && this.helper ) {
  13402. this.offset.parent = this._getParentOffset();
  13403. }
  13404. var i, item, t, p;
  13405. for ( i = this.items.length - 1; i >= 0; i-- ) {
  13406. item = this.items[ i ];
  13407. //We ignore calculating positions of all connected containers when we're not over them
  13408. if ( item.instance !== this.currentContainer && this.currentContainer &&
  13409. item.item[ 0 ] !== this.currentItem[ 0 ] ) {
  13410. continue;
  13411. }
  13412. t = this.options.toleranceElement ?
  13413. $( this.options.toleranceElement, item.item ) :
  13414. item.item;
  13415. if ( !fast ) {
  13416. item.width = t.outerWidth();
  13417. item.height = t.outerHeight();
  13418. }
  13419. p = t.offset();
  13420. item.left = p.left;
  13421. item.top = p.top;
  13422. }
  13423. if ( this.options.custom && this.options.custom.refreshContainers ) {
  13424. this.options.custom.refreshContainers.call( this );
  13425. } else {
  13426. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  13427. p = this.containers[ i ].element.offset();
  13428. this.containers[ i ].containerCache.left = p.left;
  13429. this.containers[ i ].containerCache.top = p.top;
  13430. this.containers[ i ].containerCache.width =
  13431. this.containers[ i ].element.outerWidth();
  13432. this.containers[ i ].containerCache.height =
  13433. this.containers[ i ].element.outerHeight();
  13434. }
  13435. }
  13436. return this;
  13437. },
  13438. _createPlaceholder: function( that ) {
  13439. that = that || this;
  13440. var className,
  13441. o = that.options;
  13442. if ( !o.placeholder || o.placeholder.constructor === String ) {
  13443. className = o.placeholder;
  13444. o.placeholder = {
  13445. element: function() {
  13446. var nodeName = that.currentItem[ 0 ].nodeName.toLowerCase(),
  13447. element = $( "<" + nodeName + ">", that.document[ 0 ] );
  13448. that._addClass( element, "ui-sortable-placeholder",
  13449. className || that.currentItem[ 0 ].className )
  13450. ._removeClass( element, "ui-sortable-helper" );
  13451. if ( nodeName === "tbody" ) {
  13452. that._createTrPlaceholder(
  13453. that.currentItem.find( "tr" ).eq( 0 ),
  13454. $( "<tr>", that.document[ 0 ] ).appendTo( element )
  13455. );
  13456. } else if ( nodeName === "tr" ) {
  13457. that._createTrPlaceholder( that.currentItem, element );
  13458. } else if ( nodeName === "img" ) {
  13459. element.attr( "src", that.currentItem.attr( "src" ) );
  13460. }
  13461. if ( !className ) {
  13462. element.css( "visibility", "hidden" );
  13463. }
  13464. return element;
  13465. },
  13466. update: function( container, p ) {
  13467. // 1. If a className is set as 'placeholder option, we don't force sizes -
  13468. // the class is responsible for that
  13469. // 2. The option 'forcePlaceholderSize can be enabled to force it even if a
  13470. // class name is specified
  13471. if ( className && !o.forcePlaceholderSize ) {
  13472. return;
  13473. }
  13474. //If the element doesn't have a actual height by itself (without styles coming
  13475. // from a stylesheet), it receives the inline height from the dragged item
  13476. if ( !p.height() ) {
  13477. p.height(
  13478. that.currentItem.innerHeight() -
  13479. parseInt( that.currentItem.css( "paddingTop" ) || 0, 10 ) -
  13480. parseInt( that.currentItem.css( "paddingBottom" ) || 0, 10 ) );
  13481. }
  13482. if ( !p.width() ) {
  13483. p.width(
  13484. that.currentItem.innerWidth() -
  13485. parseInt( that.currentItem.css( "paddingLeft" ) || 0, 10 ) -
  13486. parseInt( that.currentItem.css( "paddingRight" ) || 0, 10 ) );
  13487. }
  13488. }
  13489. };
  13490. }
  13491. //Create the placeholder
  13492. that.placeholder = $( o.placeholder.element.call( that.element, that.currentItem ) );
  13493. //Append it after the actual current item
  13494. that.currentItem.after( that.placeholder );
  13495. //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
  13496. o.placeholder.update( that, that.placeholder );
  13497. },
  13498. _createTrPlaceholder: function( sourceTr, targetTr ) {
  13499. var that = this;
  13500. sourceTr.children().each( function() {
  13501. $( "<td>&#160;</td>", that.document[ 0 ] )
  13502. .attr( "colspan", $( this ).attr( "colspan" ) || 1 )
  13503. .appendTo( targetTr );
  13504. } );
  13505. },
  13506. _contactContainers: function( event ) {
  13507. var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, cur, nearBottom,
  13508. floating, axis,
  13509. innermostContainer = null,
  13510. innermostIndex = null;
  13511. // Get innermost container that intersects with item
  13512. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  13513. // Never consider a container that's located within the item itself
  13514. if ( $.contains( this.currentItem[ 0 ], this.containers[ i ].element[ 0 ] ) ) {
  13515. continue;
  13516. }
  13517. if ( this._intersectsWith( this.containers[ i ].containerCache ) ) {
  13518. // If we've already found a container and it's more "inner" than this, then continue
  13519. if ( innermostContainer &&
  13520. $.contains(
  13521. this.containers[ i ].element[ 0 ],
  13522. innermostContainer.element[ 0 ] ) ) {
  13523. continue;
  13524. }
  13525. innermostContainer = this.containers[ i ];
  13526. innermostIndex = i;
  13527. } else {
  13528. // container doesn't intersect. trigger "out" event if necessary
  13529. if ( this.containers[ i ].containerCache.over ) {
  13530. this.containers[ i ]._trigger( "out", event, this._uiHash( this ) );
  13531. this.containers[ i ].containerCache.over = 0;
  13532. }
  13533. }
  13534. }
  13535. // If no intersecting containers found, return
  13536. if ( !innermostContainer ) {
  13537. return;
  13538. }
  13539. // Move the item into the container if it's not there already
  13540. if ( this.containers.length === 1 ) {
  13541. if ( !this.containers[ innermostIndex ].containerCache.over ) {
  13542. this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash( this ) );
  13543. this.containers[ innermostIndex ].containerCache.over = 1;
  13544. }
  13545. } else {
  13546. // When entering a new container, we will find the item with the least distance and
  13547. // append our item near it
  13548. dist = 10000;
  13549. itemWithLeastDistance = null;
  13550. floating = innermostContainer.floating || this._isFloating( this.currentItem );
  13551. posProperty = floating ? "left" : "top";
  13552. sizeProperty = floating ? "width" : "height";
  13553. axis = floating ? "pageX" : "pageY";
  13554. for ( j = this.items.length - 1; j >= 0; j-- ) {
  13555. if ( !$.contains(
  13556. this.containers[ innermostIndex ].element[ 0 ], this.items[ j ].item[ 0 ] )
  13557. ) {
  13558. continue;
  13559. }
  13560. if ( this.items[ j ].item[ 0 ] === this.currentItem[ 0 ] ) {
  13561. continue;
  13562. }
  13563. cur = this.items[ j ].item.offset()[ posProperty ];
  13564. nearBottom = false;
  13565. if ( event[ axis ] - cur > this.items[ j ][ sizeProperty ] / 2 ) {
  13566. nearBottom = true;
  13567. }
  13568. if ( Math.abs( event[ axis ] - cur ) < dist ) {
  13569. dist = Math.abs( event[ axis ] - cur );
  13570. itemWithLeastDistance = this.items[ j ];
  13571. this.direction = nearBottom ? "up" : "down";
  13572. }
  13573. }
  13574. //Check if dropOnEmpty is enabled
  13575. if ( !itemWithLeastDistance && !this.options.dropOnEmpty ) {
  13576. return;
  13577. }
  13578. if ( this.currentContainer === this.containers[ innermostIndex ] ) {
  13579. if ( !this.currentContainer.containerCache.over ) {
  13580. this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash() );
  13581. this.currentContainer.containerCache.over = 1;
  13582. }
  13583. return;
  13584. }
  13585. itemWithLeastDistance ?
  13586. this._rearrange( event, itemWithLeastDistance, null, true ) :
  13587. this._rearrange( event, null, this.containers[ innermostIndex ].element, true );
  13588. this._trigger( "change", event, this._uiHash() );
  13589. this.containers[ innermostIndex ]._trigger( "change", event, this._uiHash( this ) );
  13590. this.currentContainer = this.containers[ innermostIndex ];
  13591. //Update the placeholder
  13592. this.options.placeholder.update( this.currentContainer, this.placeholder );
  13593. this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash( this ) );
  13594. this.containers[ innermostIndex ].containerCache.over = 1;
  13595. }
  13596. },
  13597. _createHelper: function( event ) {
  13598. var o = this.options,
  13599. helper = $.isFunction( o.helper ) ?
  13600. $( o.helper.apply( this.element[ 0 ], [ event, this.currentItem ] ) ) :
  13601. ( o.helper === "clone" ? this.currentItem.clone() : this.currentItem );
  13602. //Add the helper to the DOM if that didn't happen already
  13603. if ( !helper.parents( "body" ).length ) {
  13604. $( o.appendTo !== "parent" ?
  13605. o.appendTo :
  13606. this.currentItem[ 0 ].parentNode )[ 0 ].appendChild( helper[ 0 ] );
  13607. }
  13608. if ( helper[ 0 ] === this.currentItem[ 0 ] ) {
  13609. this._storedCSS = {
  13610. width: this.currentItem[ 0 ].style.width,
  13611. height: this.currentItem[ 0 ].style.height,
  13612. position: this.currentItem.css( "position" ),
  13613. top: this.currentItem.css( "top" ),
  13614. left: this.currentItem.css( "left" )
  13615. };
  13616. }
  13617. if ( !helper[ 0 ].style.width || o.forceHelperSize ) {
  13618. helper.width( this.currentItem.width() );
  13619. }
  13620. if ( !helper[ 0 ].style.height || o.forceHelperSize ) {
  13621. helper.height( this.currentItem.height() );
  13622. }
  13623. return helper;
  13624. },
  13625. _adjustOffsetFromHelper: function( obj ) {
  13626. if ( typeof obj === "string" ) {
  13627. obj = obj.split( " " );
  13628. }
  13629. if ( $.isArray( obj ) ) {
  13630. obj = { left: +obj[ 0 ], top: +obj[ 1 ] || 0 };
  13631. }
  13632. if ( "left" in obj ) {
  13633. this.offset.click.left = obj.left + this.margins.left;
  13634. }
  13635. if ( "right" in obj ) {
  13636. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  13637. }
  13638. if ( "top" in obj ) {
  13639. this.offset.click.top = obj.top + this.margins.top;
  13640. }
  13641. if ( "bottom" in obj ) {
  13642. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  13643. }
  13644. },
  13645. _getParentOffset: function() {
  13646. //Get the offsetParent and cache its position
  13647. this.offsetParent = this.helper.offsetParent();
  13648. var po = this.offsetParent.offset();
  13649. // This is a special case where we need to modify a offset calculated on start, since the
  13650. // following happened:
  13651. // 1. The position of the helper is absolute, so it's position is calculated based on the
  13652. // next positioned parent
  13653. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't
  13654. // the document, which means that the scroll is included in the initial calculation of the
  13655. // offset of the parent, and never recalculated upon drag
  13656. if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  13657. $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) {
  13658. po.left += this.scrollParent.scrollLeft();
  13659. po.top += this.scrollParent.scrollTop();
  13660. }
  13661. // This needs to be actually done for all browsers, since pageX/pageY includes this
  13662. // information with an ugly IE fix
  13663. if ( this.offsetParent[ 0 ] === this.document[ 0 ].body ||
  13664. ( this.offsetParent[ 0 ].tagName &&
  13665. this.offsetParent[ 0 ].tagName.toLowerCase() === "html" && $.ui.ie ) ) {
  13666. po = { top: 0, left: 0 };
  13667. }
  13668. return {
  13669. top: po.top + ( parseInt( this.offsetParent.css( "borderTopWidth" ), 10 ) || 0 ),
  13670. left: po.left + ( parseInt( this.offsetParent.css( "borderLeftWidth" ), 10 ) || 0 )
  13671. };
  13672. },
  13673. _getRelativeOffset: function() {
  13674. if ( this.cssPosition === "relative" ) {
  13675. var p = this.currentItem.position();
  13676. return {
  13677. top: p.top - ( parseInt( this.helper.css( "top" ), 10 ) || 0 ) +
  13678. this.scrollParent.scrollTop(),
  13679. left: p.left - ( parseInt( this.helper.css( "left" ), 10 ) || 0 ) +
  13680. this.scrollParent.scrollLeft()
  13681. };
  13682. } else {
  13683. return { top: 0, left: 0 };
  13684. }
  13685. },
  13686. _cacheMargins: function() {
  13687. this.margins = {
  13688. left: ( parseInt( this.currentItem.css( "marginLeft" ), 10 ) || 0 ),
  13689. top: ( parseInt( this.currentItem.css( "marginTop" ), 10 ) || 0 )
  13690. };
  13691. },
  13692. _cacheHelperProportions: function() {
  13693. this.helperProportions = {
  13694. width: this.helper.outerWidth(),
  13695. height: this.helper.outerHeight()
  13696. };
  13697. },
  13698. _setContainment: function() {
  13699. var ce, co, over,
  13700. o = this.options;
  13701. if ( o.containment === "parent" ) {
  13702. o.containment = this.helper[ 0 ].parentNode;
  13703. }
  13704. if ( o.containment === "document" || o.containment === "window" ) {
  13705. this.containment = [
  13706. 0 - this.offset.relative.left - this.offset.parent.left,
  13707. 0 - this.offset.relative.top - this.offset.parent.top,
  13708. o.containment === "document" ?
  13709. this.document.width() :
  13710. this.window.width() - this.helperProportions.width - this.margins.left,
  13711. ( o.containment === "document" ?
  13712. ( this.document.height() || document.body.parentNode.scrollHeight ) :
  13713. this.window.height() || this.document[ 0 ].body.parentNode.scrollHeight
  13714. ) - this.helperProportions.height - this.margins.top
  13715. ];
  13716. }
  13717. if ( !( /^(document|window|parent)$/ ).test( o.containment ) ) {
  13718. ce = $( o.containment )[ 0 ];
  13719. co = $( o.containment ).offset();
  13720. over = ( $( ce ).css( "overflow" ) !== "hidden" );
  13721. this.containment = [
  13722. co.left + ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) +
  13723. ( parseInt( $( ce ).css( "paddingLeft" ), 10 ) || 0 ) - this.margins.left,
  13724. co.top + ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) +
  13725. ( parseInt( $( ce ).css( "paddingTop" ), 10 ) || 0 ) - this.margins.top,
  13726. co.left + ( over ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) -
  13727. ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) -
  13728. ( parseInt( $( ce ).css( "paddingRight" ), 10 ) || 0 ) -
  13729. this.helperProportions.width - this.margins.left,
  13730. co.top + ( over ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) -
  13731. ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) -
  13732. ( parseInt( $( ce ).css( "paddingBottom" ), 10 ) || 0 ) -
  13733. this.helperProportions.height - this.margins.top
  13734. ];
  13735. }
  13736. },
  13737. _convertPositionTo: function( d, pos ) {
  13738. if ( !pos ) {
  13739. pos = this.position;
  13740. }
  13741. var mod = d === "absolute" ? 1 : -1,
  13742. scroll = this.cssPosition === "absolute" &&
  13743. !( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  13744. $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ?
  13745. this.offsetParent :
  13746. this.scrollParent,
  13747. scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName );
  13748. return {
  13749. top: (
  13750. // The absolute mouse position
  13751. pos.top +
  13752. // Only for relative positioned nodes: Relative offset from element to offset parent
  13753. this.offset.relative.top * mod +
  13754. // The offsetParent's offset without borders (offset + border)
  13755. this.offset.parent.top * mod -
  13756. ( ( this.cssPosition === "fixed" ?
  13757. -this.scrollParent.scrollTop() :
  13758. ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod )
  13759. ),
  13760. left: (
  13761. // The absolute mouse position
  13762. pos.left +
  13763. // Only for relative positioned nodes: Relative offset from element to offset parent
  13764. this.offset.relative.left * mod +
  13765. // The offsetParent's offset without borders (offset + border)
  13766. this.offset.parent.left * mod -
  13767. ( ( this.cssPosition === "fixed" ?
  13768. -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 :
  13769. scroll.scrollLeft() ) * mod )
  13770. )
  13771. };
  13772. },
  13773. _generatePosition: function( event ) {
  13774. var top, left,
  13775. o = this.options,
  13776. pageX = event.pageX,
  13777. pageY = event.pageY,
  13778. scroll = this.cssPosition === "absolute" &&
  13779. !( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  13780. $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ?
  13781. this.offsetParent :
  13782. this.scrollParent,
  13783. scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName );
  13784. // This is another very weird special case that only happens for relative elements:
  13785. // 1. If the css position is relative
  13786. // 2. and the scroll parent is the document or similar to the offset parent
  13787. // we have to refresh the relative offset during the scroll so there are no jumps
  13788. if ( this.cssPosition === "relative" && !( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  13789. this.scrollParent[ 0 ] !== this.offsetParent[ 0 ] ) ) {
  13790. this.offset.relative = this._getRelativeOffset();
  13791. }
  13792. /*
  13793. * - Position constraining -
  13794. * Constrain the position to a mix of grid, containment.
  13795. */
  13796. if ( this.originalPosition ) { //If we are not dragging yet, we won't check for options
  13797. if ( this.containment ) {
  13798. if ( event.pageX - this.offset.click.left < this.containment[ 0 ] ) {
  13799. pageX = this.containment[ 0 ] + this.offset.click.left;
  13800. }
  13801. if ( event.pageY - this.offset.click.top < this.containment[ 1 ] ) {
  13802. pageY = this.containment[ 1 ] + this.offset.click.top;
  13803. }
  13804. if ( event.pageX - this.offset.click.left > this.containment[ 2 ] ) {
  13805. pageX = this.containment[ 2 ] + this.offset.click.left;
  13806. }
  13807. if ( event.pageY - this.offset.click.top > this.containment[ 3 ] ) {
  13808. pageY = this.containment[ 3 ] + this.offset.click.top;
  13809. }
  13810. }
  13811. if ( o.grid ) {
  13812. top = this.originalPageY + Math.round( ( pageY - this.originalPageY ) /
  13813. o.grid[ 1 ] ) * o.grid[ 1 ];
  13814. pageY = this.containment ?
  13815. ( ( top - this.offset.click.top >= this.containment[ 1 ] &&
  13816. top - this.offset.click.top <= this.containment[ 3 ] ) ?
  13817. top :
  13818. ( ( top - this.offset.click.top >= this.containment[ 1 ] ) ?
  13819. top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) :
  13820. top;
  13821. left = this.originalPageX + Math.round( ( pageX - this.originalPageX ) /
  13822. o.grid[ 0 ] ) * o.grid[ 0 ];
  13823. pageX = this.containment ?
  13824. ( ( left - this.offset.click.left >= this.containment[ 0 ] &&
  13825. left - this.offset.click.left <= this.containment[ 2 ] ) ?
  13826. left :
  13827. ( ( left - this.offset.click.left >= this.containment[ 0 ] ) ?
  13828. left - o.grid[ 0 ] : left + o.grid[ 0 ] ) ) :
  13829. left;
  13830. }
  13831. }
  13832. return {
  13833. top: (
  13834. // The absolute mouse position
  13835. pageY -
  13836. // Click offset (relative to the element)
  13837. this.offset.click.top -
  13838. // Only for relative positioned nodes: Relative offset from element to offset parent
  13839. this.offset.relative.top -
  13840. // The offsetParent's offset without borders (offset + border)
  13841. this.offset.parent.top +
  13842. ( ( this.cssPosition === "fixed" ?
  13843. -this.scrollParent.scrollTop() :
  13844. ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) )
  13845. ),
  13846. left: (
  13847. // The absolute mouse position
  13848. pageX -
  13849. // Click offset (relative to the element)
  13850. this.offset.click.left -
  13851. // Only for relative positioned nodes: Relative offset from element to offset parent
  13852. this.offset.relative.left -
  13853. // The offsetParent's offset without borders (offset + border)
  13854. this.offset.parent.left +
  13855. ( ( this.cssPosition === "fixed" ?
  13856. -this.scrollParent.scrollLeft() :
  13857. scrollIsRootNode ? 0 : scroll.scrollLeft() ) )
  13858. )
  13859. };
  13860. },
  13861. _rearrange: function( event, i, a, hardRefresh ) {
  13862. a ? a[ 0 ].appendChild( this.placeholder[ 0 ] ) :
  13863. i.item[ 0 ].parentNode.insertBefore( this.placeholder[ 0 ],
  13864. ( this.direction === "down" ? i.item[ 0 ] : i.item[ 0 ].nextSibling ) );
  13865. //Various things done here to improve the performance:
  13866. // 1. we create a setTimeout, that calls refreshPositions
  13867. // 2. on the instance, we have a counter variable, that get's higher after every append
  13868. // 3. on the local scope, we copy the counter variable, and check in the timeout,
  13869. // if it's still the same
  13870. // 4. this lets only the last addition to the timeout stack through
  13871. this.counter = this.counter ? ++this.counter : 1;
  13872. var counter = this.counter;
  13873. this._delay( function() {
  13874. if ( counter === this.counter ) {
  13875. //Precompute after each DOM insertion, NOT on mousemove
  13876. this.refreshPositions( !hardRefresh );
  13877. }
  13878. } );
  13879. },
  13880. _clear: function( event, noPropagation ) {
  13881. this.reverting = false;
  13882. // We delay all events that have to be triggered to after the point where the placeholder
  13883. // has been removed and everything else normalized again
  13884. var i,
  13885. delayedTriggers = [];
  13886. // We first have to update the dom position of the actual currentItem
  13887. // Note: don't do it if the current item is already removed (by a user), or it gets
  13888. // reappended (see #4088)
  13889. if ( !this._noFinalSort && this.currentItem.parent().length ) {
  13890. this.placeholder.before( this.currentItem );
  13891. }
  13892. this._noFinalSort = null;
  13893. if ( this.helper[ 0 ] === this.currentItem[ 0 ] ) {
  13894. for ( i in this._storedCSS ) {
  13895. if ( this._storedCSS[ i ] === "auto" || this._storedCSS[ i ] === "static" ) {
  13896. this._storedCSS[ i ] = "";
  13897. }
  13898. }
  13899. this.currentItem.css( this._storedCSS );
  13900. this._removeClass( this.currentItem, "ui-sortable-helper" );
  13901. } else {
  13902. this.currentItem.show();
  13903. }
  13904. if ( this.fromOutside && !noPropagation ) {
  13905. delayedTriggers.push( function( event ) {
  13906. this._trigger( "receive", event, this._uiHash( this.fromOutside ) );
  13907. } );
  13908. }
  13909. if ( ( this.fromOutside ||
  13910. this.domPosition.prev !==
  13911. this.currentItem.prev().not( ".ui-sortable-helper" )[ 0 ] ||
  13912. this.domPosition.parent !== this.currentItem.parent()[ 0 ] ) && !noPropagation ) {
  13913. // Trigger update callback if the DOM position has changed
  13914. delayedTriggers.push( function( event ) {
  13915. this._trigger( "update", event, this._uiHash() );
  13916. } );
  13917. }
  13918. // Check if the items Container has Changed and trigger appropriate
  13919. // events.
  13920. if ( this !== this.currentContainer ) {
  13921. if ( !noPropagation ) {
  13922. delayedTriggers.push( function( event ) {
  13923. this._trigger( "remove", event, this._uiHash() );
  13924. } );
  13925. delayedTriggers.push( ( function( c ) {
  13926. return function( event ) {
  13927. c._trigger( "receive", event, this._uiHash( this ) );
  13928. };
  13929. } ).call( this, this.currentContainer ) );
  13930. delayedTriggers.push( ( function( c ) {
  13931. return function( event ) {
  13932. c._trigger( "update", event, this._uiHash( this ) );
  13933. };
  13934. } ).call( this, this.currentContainer ) );
  13935. }
  13936. }
  13937. //Post events to containers
  13938. function delayEvent( type, instance, container ) {
  13939. return function( event ) {
  13940. container._trigger( type, event, instance._uiHash( instance ) );
  13941. };
  13942. }
  13943. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  13944. if ( !noPropagation ) {
  13945. delayedTriggers.push( delayEvent( "deactivate", this, this.containers[ i ] ) );
  13946. }
  13947. if ( this.containers[ i ].containerCache.over ) {
  13948. delayedTriggers.push( delayEvent( "out", this, this.containers[ i ] ) );
  13949. this.containers[ i ].containerCache.over = 0;
  13950. }
  13951. }
  13952. //Do what was originally in plugins
  13953. if ( this.storedCursor ) {
  13954. this.document.find( "body" ).css( "cursor", this.storedCursor );
  13955. this.storedStylesheet.remove();
  13956. }
  13957. if ( this._storedOpacity ) {
  13958. this.helper.css( "opacity", this._storedOpacity );
  13959. }
  13960. if ( this._storedZIndex ) {
  13961. this.helper.css( "zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex );
  13962. }
  13963. this.dragging = false;
  13964. if ( !noPropagation ) {
  13965. this._trigger( "beforeStop", event, this._uiHash() );
  13966. }
  13967. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately,
  13968. // it unbinds ALL events from the original node!
  13969. this.placeholder[ 0 ].parentNode.removeChild( this.placeholder[ 0 ] );
  13970. if ( !this.cancelHelperRemoval ) {
  13971. if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) {
  13972. this.helper.remove();
  13973. }
  13974. this.helper = null;
  13975. }
  13976. if ( !noPropagation ) {
  13977. for ( i = 0; i < delayedTriggers.length; i++ ) {
  13978. // Trigger all delayed events
  13979. delayedTriggers[ i ].call( this, event );
  13980. }
  13981. this._trigger( "stop", event, this._uiHash() );
  13982. }
  13983. this.fromOutside = false;
  13984. return !this.cancelHelperRemoval;
  13985. },
  13986. _trigger: function() {
  13987. if ( $.Widget.prototype._trigger.apply( this, arguments ) === false ) {
  13988. this.cancel();
  13989. }
  13990. },
  13991. _uiHash: function( _inst ) {
  13992. var inst = _inst || this;
  13993. return {
  13994. helper: inst.helper,
  13995. placeholder: inst.placeholder || $( [] ),
  13996. position: inst.position,
  13997. originalPosition: inst.originalPosition,
  13998. offset: inst.positionAbs,
  13999. item: inst.currentItem,
  14000. sender: _inst ? _inst.element : null
  14001. };
  14002. }
  14003. } );
  14004. /*!
  14005. * jQuery UI Spinner 1.12.1
  14006. * http://jqueryui.com
  14007. *
  14008. * Copyright jQuery Foundation and other contributors
  14009. * Released under the MIT license.
  14010. * http://jquery.org/license
  14011. */
  14012. //>>label: Spinner
  14013. //>>group: Widgets
  14014. //>>description: Displays buttons to easily input numbers via the keyboard or mouse.
  14015. //>>docs: http://api.jqueryui.com/spinner/
  14016. //>>demos: http://jqueryui.com/spinner/
  14017. //>>css.structure: ../../themes/base/core.css
  14018. //>>css.structure: ../../themes/base/spinner.css
  14019. //>>css.theme: ../../themes/base/theme.css
  14020. function spinnerModifer( fn ) {
  14021. return function() {
  14022. var previous = this.element.val();
  14023. fn.apply( this, arguments );
  14024. this._refresh();
  14025. if ( previous !== this.element.val() ) {
  14026. this._trigger( "change" );
  14027. }
  14028. };
  14029. }
  14030. $.widget( "ui.spinner", {
  14031. version: "1.12.1",
  14032. defaultElement: "<input>",
  14033. widgetEventPrefix: "spin",
  14034. options: {
  14035. classes: {
  14036. "ui-spinner": "ui-corner-all",
  14037. "ui-spinner-down": "ui-corner-br",
  14038. "ui-spinner-up": "ui-corner-tr"
  14039. },
  14040. culture: null,
  14041. icons: {
  14042. down: "ui-icon-triangle-1-s",
  14043. up: "ui-icon-triangle-1-n"
  14044. },
  14045. incremental: true,
  14046. max: null,
  14047. min: null,
  14048. numberFormat: null,
  14049. page: 10,
  14050. step: 1,
  14051. change: null,
  14052. spin: null,
  14053. start: null,
  14054. stop: null
  14055. },
  14056. _create: function() {
  14057. // handle string values that need to be parsed
  14058. this._setOption( "max", this.options.max );
  14059. this._setOption( "min", this.options.min );
  14060. this._setOption( "step", this.options.step );
  14061. // Only format if there is a value, prevents the field from being marked
  14062. // as invalid in Firefox, see #9573.
  14063. if ( this.value() !== "" ) {
  14064. // Format the value, but don't constrain.
  14065. this._value( this.element.val(), true );
  14066. }
  14067. this._draw();
  14068. this._on( this._events );
  14069. this._refresh();
  14070. // Turning off autocomplete prevents the browser from remembering the
  14071. // value when navigating through history, so we re-enable autocomplete
  14072. // if the page is unloaded before the widget is destroyed. #7790
  14073. this._on( this.window, {
  14074. beforeunload: function() {
  14075. this.element.removeAttr( "autocomplete" );
  14076. }
  14077. } );
  14078. },
  14079. _getCreateOptions: function() {
  14080. var options = this._super();
  14081. var element = this.element;
  14082. $.each( [ "min", "max", "step" ], function( i, option ) {
  14083. var value = element.attr( option );
  14084. if ( value != null && value.length ) {
  14085. options[ option ] = value;
  14086. }
  14087. } );
  14088. return options;
  14089. },
  14090. _events: {
  14091. keydown: function( event ) {
  14092. if ( this._start( event ) && this._keydown( event ) ) {
  14093. event.preventDefault();
  14094. }
  14095. },
  14096. keyup: "_stop",
  14097. focus: function() {
  14098. this.previous = this.element.val();
  14099. },
  14100. blur: function( event ) {
  14101. if ( this.cancelBlur ) {
  14102. delete this.cancelBlur;
  14103. return;
  14104. }
  14105. this._stop();
  14106. this._refresh();
  14107. if ( this.previous !== this.element.val() ) {
  14108. this._trigger( "change", event );
  14109. }
  14110. },
  14111. mousewheel: function( event, delta ) {
  14112. if ( !delta ) {
  14113. return;
  14114. }
  14115. if ( !this.spinning && !this._start( event ) ) {
  14116. return false;
  14117. }
  14118. this._spin( ( delta > 0 ? 1 : -1 ) * this.options.step, event );
  14119. clearTimeout( this.mousewheelTimer );
  14120. this.mousewheelTimer = this._delay( function() {
  14121. if ( this.spinning ) {
  14122. this._stop( event );
  14123. }
  14124. }, 100 );
  14125. event.preventDefault();
  14126. },
  14127. "mousedown .ui-spinner-button": function( event ) {
  14128. var previous;
  14129. // We never want the buttons to have focus; whenever the user is
  14130. // interacting with the spinner, the focus should be on the input.
  14131. // If the input is focused then this.previous is properly set from
  14132. // when the input first received focus. If the input is not focused
  14133. // then we need to set this.previous based on the value before spinning.
  14134. previous = this.element[ 0 ] === $.ui.safeActiveElement( this.document[ 0 ] ) ?
  14135. this.previous : this.element.val();
  14136. function checkFocus() {
  14137. var isActive = this.element[ 0 ] === $.ui.safeActiveElement( this.document[ 0 ] );
  14138. if ( !isActive ) {
  14139. this.element.trigger( "focus" );
  14140. this.previous = previous;
  14141. // support: IE
  14142. // IE sets focus asynchronously, so we need to check if focus
  14143. // moved off of the input because the user clicked on the button.
  14144. this._delay( function() {
  14145. this.previous = previous;
  14146. } );
  14147. }
  14148. }
  14149. // Ensure focus is on (or stays on) the text field
  14150. event.preventDefault();
  14151. checkFocus.call( this );
  14152. // Support: IE
  14153. // IE doesn't prevent moving focus even with event.preventDefault()
  14154. // so we set a flag to know when we should ignore the blur event
  14155. // and check (again) if focus moved off of the input.
  14156. this.cancelBlur = true;
  14157. this._delay( function() {
  14158. delete this.cancelBlur;
  14159. checkFocus.call( this );
  14160. } );
  14161. if ( this._start( event ) === false ) {
  14162. return;
  14163. }
  14164. this._repeat( null, $( event.currentTarget )
  14165. .hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  14166. },
  14167. "mouseup .ui-spinner-button": "_stop",
  14168. "mouseenter .ui-spinner-button": function( event ) {
  14169. // button will add ui-state-active if mouse was down while mouseleave and kept down
  14170. if ( !$( event.currentTarget ).hasClass( "ui-state-active" ) ) {
  14171. return;
  14172. }
  14173. if ( this._start( event ) === false ) {
  14174. return false;
  14175. }
  14176. this._repeat( null, $( event.currentTarget )
  14177. .hasClass( "ui-spinner-up" ) ? 1 : -1, event );
  14178. },
  14179. // TODO: do we really want to consider this a stop?
  14180. // shouldn't we just stop the repeater and wait until mouseup before
  14181. // we trigger the stop event?
  14182. "mouseleave .ui-spinner-button": "_stop"
  14183. },
  14184. // Support mobile enhanced option and make backcompat more sane
  14185. _enhance: function() {
  14186. this.uiSpinner = this.element
  14187. .attr( "autocomplete", "off" )
  14188. .wrap( "<span>" )
  14189. .parent()
  14190. // Add buttons
  14191. .append(
  14192. "<a></a><a></a>"
  14193. );
  14194. },
  14195. _draw: function() {
  14196. this._enhance();
  14197. this._addClass( this.uiSpinner, "ui-spinner", "ui-widget ui-widget-content" );
  14198. this._addClass( "ui-spinner-input" );
  14199. this.element.attr( "role", "spinbutton" );
  14200. // Button bindings
  14201. this.buttons = this.uiSpinner.children( "a" )
  14202. .attr( "tabIndex", -1 )
  14203. .attr( "aria-hidden", true )
  14204. .button( {
  14205. classes: {
  14206. "ui-button": ""
  14207. }
  14208. } );
  14209. // TODO: Right now button does not support classes this is already updated in button PR
  14210. this._removeClass( this.buttons, "ui-corner-all" );
  14211. this._addClass( this.buttons.first(), "ui-spinner-button ui-spinner-up" );
  14212. this._addClass( this.buttons.last(), "ui-spinner-button ui-spinner-down" );
  14213. this.buttons.first().button( {
  14214. "icon": this.options.icons.up,
  14215. "showLabel": false
  14216. } );
  14217. this.buttons.last().button( {
  14218. "icon": this.options.icons.down,
  14219. "showLabel": false
  14220. } );
  14221. // IE 6 doesn't understand height: 50% for the buttons
  14222. // unless the wrapper has an explicit height
  14223. if ( this.buttons.height() > Math.ceil( this.uiSpinner.height() * 0.5 ) &&
  14224. this.uiSpinner.height() > 0 ) {
  14225. this.uiSpinner.height( this.uiSpinner.height() );
  14226. }
  14227. },
  14228. _keydown: function( event ) {
  14229. var options = this.options,
  14230. keyCode = $.ui.keyCode;
  14231. switch ( event.keyCode ) {
  14232. case keyCode.UP:
  14233. this._repeat( null, 1, event );
  14234. return true;
  14235. case keyCode.DOWN:
  14236. this._repeat( null, -1, event );
  14237. return true;
  14238. case keyCode.PAGE_UP:
  14239. this._repeat( null, options.page, event );
  14240. return true;
  14241. case keyCode.PAGE_DOWN:
  14242. this._repeat( null, -options.page, event );
  14243. return true;
  14244. }
  14245. return false;
  14246. },
  14247. _start: function( event ) {
  14248. if ( !this.spinning && this._trigger( "start", event ) === false ) {
  14249. return false;
  14250. }
  14251. if ( !this.counter ) {
  14252. this.counter = 1;
  14253. }
  14254. this.spinning = true;
  14255. return true;
  14256. },
  14257. _repeat: function( i, steps, event ) {
  14258. i = i || 500;
  14259. clearTimeout( this.timer );
  14260. this.timer = this._delay( function() {
  14261. this._repeat( 40, steps, event );
  14262. }, i );
  14263. this._spin( steps * this.options.step, event );
  14264. },
  14265. _spin: function( step, event ) {
  14266. var value = this.value() || 0;
  14267. if ( !this.counter ) {
  14268. this.counter = 1;
  14269. }
  14270. value = this._adjustValue( value + step * this._increment( this.counter ) );
  14271. if ( !this.spinning || this._trigger( "spin", event, { value: value } ) !== false ) {
  14272. this._value( value );
  14273. this.counter++;
  14274. }
  14275. },
  14276. _increment: function( i ) {
  14277. var incremental = this.options.incremental;
  14278. if ( incremental ) {
  14279. return $.isFunction( incremental ) ?
  14280. incremental( i ) :
  14281. Math.floor( i * i * i / 50000 - i * i / 500 + 17 * i / 200 + 1 );
  14282. }
  14283. return 1;
  14284. },
  14285. _precision: function() {
  14286. var precision = this._precisionOf( this.options.step );
  14287. if ( this.options.min !== null ) {
  14288. precision = Math.max( precision, this._precisionOf( this.options.min ) );
  14289. }
  14290. return precision;
  14291. },
  14292. _precisionOf: function( num ) {
  14293. var str = num.toString(),
  14294. decimal = str.indexOf( "." );
  14295. return decimal === -1 ? 0 : str.length - decimal - 1;
  14296. },
  14297. _adjustValue: function( value ) {
  14298. var base, aboveMin,
  14299. options = this.options;
  14300. // Make sure we're at a valid step
  14301. // - find out where we are relative to the base (min or 0)
  14302. base = options.min !== null ? options.min : 0;
  14303. aboveMin = value - base;
  14304. // - round to the nearest step
  14305. aboveMin = Math.round( aboveMin / options.step ) * options.step;
  14306. // - rounding is based on 0, so adjust back to our base
  14307. value = base + aboveMin;
  14308. // Fix precision from bad JS floating point math
  14309. value = parseFloat( value.toFixed( this._precision() ) );
  14310. // Clamp the value
  14311. if ( options.max !== null && value > options.max ) {
  14312. return options.max;
  14313. }
  14314. if ( options.min !== null && value < options.min ) {
  14315. return options.min;
  14316. }
  14317. return value;
  14318. },
  14319. _stop: function( event ) {
  14320. if ( !this.spinning ) {
  14321. return;
  14322. }
  14323. clearTimeout( this.timer );
  14324. clearTimeout( this.mousewheelTimer );
  14325. this.counter = 0;
  14326. this.spinning = false;
  14327. this._trigger( "stop", event );
  14328. },
  14329. _setOption: function( key, value ) {
  14330. var prevValue, first, last;
  14331. if ( key === "culture" || key === "numberFormat" ) {
  14332. prevValue = this._parse( this.element.val() );
  14333. this.options[ key ] = value;
  14334. this.element.val( this._format( prevValue ) );
  14335. return;
  14336. }
  14337. if ( key === "max" || key === "min" || key === "step" ) {
  14338. if ( typeof value === "string" ) {
  14339. value = this._parse( value );
  14340. }
  14341. }
  14342. if ( key === "icons" ) {
  14343. first = this.buttons.first().find( ".ui-icon" );
  14344. this._removeClass( first, null, this.options.icons.up );
  14345. this._addClass( first, null, value.up );
  14346. last = this.buttons.last().find( ".ui-icon" );
  14347. this._removeClass( last, null, this.options.icons.down );
  14348. this._addClass( last, null, value.down );
  14349. }
  14350. this._super( key, value );
  14351. },
  14352. _setOptionDisabled: function( value ) {
  14353. this._super( value );
  14354. this._toggleClass( this.uiSpinner, null, "ui-state-disabled", !!value );
  14355. this.element.prop( "disabled", !!value );
  14356. this.buttons.button( value ? "disable" : "enable" );
  14357. },
  14358. _setOptions: spinnerModifer( function( options ) {
  14359. this._super( options );
  14360. } ),
  14361. _parse: function( val ) {
  14362. if ( typeof val === "string" && val !== "" ) {
  14363. val = window.Globalize && this.options.numberFormat ?
  14364. Globalize.parseFloat( val, 10, this.options.culture ) : +val;
  14365. }
  14366. return val === "" || isNaN( val ) ? null : val;
  14367. },
  14368. _format: function( value ) {
  14369. if ( value === "" ) {
  14370. return "";
  14371. }
  14372. return window.Globalize && this.options.numberFormat ?
  14373. Globalize.format( value, this.options.numberFormat, this.options.culture ) :
  14374. value;
  14375. },
  14376. _refresh: function() {
  14377. this.element.attr( {
  14378. "aria-valuemin": this.options.min,
  14379. "aria-valuemax": this.options.max,
  14380. // TODO: what should we do with values that can't be parsed?
  14381. "aria-valuenow": this._parse( this.element.val() )
  14382. } );
  14383. },
  14384. isValid: function() {
  14385. var value = this.value();
  14386. // Null is invalid
  14387. if ( value === null ) {
  14388. return false;
  14389. }
  14390. // If value gets adjusted, it's invalid
  14391. return value === this._adjustValue( value );
  14392. },
  14393. // Update the value without triggering change
  14394. _value: function( value, allowAny ) {
  14395. var parsed;
  14396. if ( value !== "" ) {
  14397. parsed = this._parse( value );
  14398. if ( parsed !== null ) {
  14399. if ( !allowAny ) {
  14400. parsed = this._adjustValue( parsed );
  14401. }
  14402. value = this._format( parsed );
  14403. }
  14404. }
  14405. this.element.val( value );
  14406. this._refresh();
  14407. },
  14408. _destroy: function() {
  14409. this.element
  14410. .prop( "disabled", false )
  14411. .removeAttr( "autocomplete role aria-valuemin aria-valuemax aria-valuenow" );
  14412. this.uiSpinner.replaceWith( this.element );
  14413. },
  14414. stepUp: spinnerModifer( function( steps ) {
  14415. this._stepUp( steps );
  14416. } ),
  14417. _stepUp: function( steps ) {
  14418. if ( this._start() ) {
  14419. this._spin( ( steps || 1 ) * this.options.step );
  14420. this._stop();
  14421. }
  14422. },
  14423. stepDown: spinnerModifer( function( steps ) {
  14424. this._stepDown( steps );
  14425. } ),
  14426. _stepDown: function( steps ) {
  14427. if ( this._start() ) {
  14428. this._spin( ( steps || 1 ) * -this.options.step );
  14429. this._stop();
  14430. }
  14431. },
  14432. pageUp: spinnerModifer( function( pages ) {
  14433. this._stepUp( ( pages || 1 ) * this.options.page );
  14434. } ),
  14435. pageDown: spinnerModifer( function( pages ) {
  14436. this._stepDown( ( pages || 1 ) * this.options.page );
  14437. } ),
  14438. value: function( newVal ) {
  14439. if ( !arguments.length ) {
  14440. return this._parse( this.element.val() );
  14441. }
  14442. spinnerModifer( this._value ).call( this, newVal );
  14443. },
  14444. widget: function() {
  14445. return this.uiSpinner;
  14446. }
  14447. } );
  14448. // DEPRECATED
  14449. // TODO: switch return back to widget declaration at top of file when this is removed
  14450. if ( $.uiBackCompat !== false ) {
  14451. // Backcompat for spinner html extension points
  14452. $.widget( "ui.spinner", $.ui.spinner, {
  14453. _enhance: function() {
  14454. this.uiSpinner = this.element
  14455. .attr( "autocomplete", "off" )
  14456. .wrap( this._uiSpinnerHtml() )
  14457. .parent()
  14458. // Add buttons
  14459. .append( this._buttonHtml() );
  14460. },
  14461. _uiSpinnerHtml: function() {
  14462. return "<span>";
  14463. },
  14464. _buttonHtml: function() {
  14465. return "<a></a><a></a>";
  14466. }
  14467. } );
  14468. }
  14469. var widgetsSpinner = $.ui.spinner;
  14470. /*!
  14471. * jQuery UI Tabs 1.12.1
  14472. * http://jqueryui.com
  14473. *
  14474. * Copyright jQuery Foundation and other contributors
  14475. * Released under the MIT license.
  14476. * http://jquery.org/license
  14477. */
  14478. //>>label: Tabs
  14479. //>>group: Widgets
  14480. //>>description: Transforms a set of container elements into a tab structure.
  14481. //>>docs: http://api.jqueryui.com/tabs/
  14482. //>>demos: http://jqueryui.com/tabs/
  14483. //>>css.structure: ../../themes/base/core.css
  14484. //>>css.structure: ../../themes/base/tabs.css
  14485. //>>css.theme: ../../themes/base/theme.css
  14486. $.widget( "ui.tabs", {
  14487. version: "1.12.1",
  14488. delay: 300,
  14489. options: {
  14490. active: null,
  14491. classes: {
  14492. "ui-tabs": "ui-corner-all",
  14493. "ui-tabs-nav": "ui-corner-all",
  14494. "ui-tabs-panel": "ui-corner-bottom",
  14495. "ui-tabs-tab": "ui-corner-top"
  14496. },
  14497. collapsible: false,
  14498. event: "click",
  14499. heightStyle: "content",
  14500. hide: null,
  14501. show: null,
  14502. // Callbacks
  14503. activate: null,
  14504. beforeActivate: null,
  14505. beforeLoad: null,
  14506. load: null
  14507. },
  14508. _isLocal: ( function() {
  14509. var rhash = /#.*$/;
  14510. return function( anchor ) {
  14511. var anchorUrl, locationUrl;
  14512. anchorUrl = anchor.href.replace( rhash, "" );
  14513. locationUrl = location.href.replace( rhash, "" );
  14514. // Decoding may throw an error if the URL isn't UTF-8 (#9518)
  14515. try {
  14516. anchorUrl = decodeURIComponent( anchorUrl );
  14517. } catch ( error ) {}
  14518. try {
  14519. locationUrl = decodeURIComponent( locationUrl );
  14520. } catch ( error ) {}
  14521. return anchor.hash.length > 1 && anchorUrl === locationUrl;
  14522. };
  14523. } )(),
  14524. _create: function() {
  14525. var that = this,
  14526. options = this.options;
  14527. this.running = false;
  14528. this._addClass( "ui-tabs", "ui-widget ui-widget-content" );
  14529. this._toggleClass( "ui-tabs-collapsible", null, options.collapsible );
  14530. this._processTabs();
  14531. options.active = this._initialActive();
  14532. // Take disabling tabs via class attribute from HTML
  14533. // into account and update option properly.
  14534. if ( $.isArray( options.disabled ) ) {
  14535. options.disabled = $.unique( options.disabled.concat(
  14536. $.map( this.tabs.filter( ".ui-state-disabled" ), function( li ) {
  14537. return that.tabs.index( li );
  14538. } )
  14539. ) ).sort();
  14540. }
  14541. // Check for length avoids error when initializing empty list
  14542. if ( this.options.active !== false && this.anchors.length ) {
  14543. this.active = this._findActive( options.active );
  14544. } else {
  14545. this.active = $();
  14546. }
  14547. this._refresh();
  14548. if ( this.active.length ) {
  14549. this.load( options.active );
  14550. }
  14551. },
  14552. _initialActive: function() {
  14553. var active = this.options.active,
  14554. collapsible = this.options.collapsible,
  14555. locationHash = location.hash.substring( 1 );
  14556. if ( active === null ) {
  14557. // check the fragment identifier in the URL
  14558. if ( locationHash ) {
  14559. this.tabs.each( function( i, tab ) {
  14560. if ( $( tab ).attr( "aria-controls" ) === locationHash ) {
  14561. active = i;
  14562. return false;
  14563. }
  14564. } );
  14565. }
  14566. // Check for a tab marked active via a class
  14567. if ( active === null ) {
  14568. active = this.tabs.index( this.tabs.filter( ".ui-tabs-active" ) );
  14569. }
  14570. // No active tab, set to false
  14571. if ( active === null || active === -1 ) {
  14572. active = this.tabs.length ? 0 : false;
  14573. }
  14574. }
  14575. // Handle numbers: negative, out of range
  14576. if ( active !== false ) {
  14577. active = this.tabs.index( this.tabs.eq( active ) );
  14578. if ( active === -1 ) {
  14579. active = collapsible ? false : 0;
  14580. }
  14581. }
  14582. // Don't allow collapsible: false and active: false
  14583. if ( !collapsible && active === false && this.anchors.length ) {
  14584. active = 0;
  14585. }
  14586. return active;
  14587. },
  14588. _getCreateEventData: function() {
  14589. return {
  14590. tab: this.active,
  14591. panel: !this.active.length ? $() : this._getPanelForTab( this.active )
  14592. };
  14593. },
  14594. _tabKeydown: function( event ) {
  14595. var focusedTab = $( $.ui.safeActiveElement( this.document[ 0 ] ) ).closest( "li" ),
  14596. selectedIndex = this.tabs.index( focusedTab ),
  14597. goingForward = true;
  14598. if ( this._handlePageNav( event ) ) {
  14599. return;
  14600. }
  14601. switch ( event.keyCode ) {
  14602. case $.ui.keyCode.RIGHT:
  14603. case $.ui.keyCode.DOWN:
  14604. selectedIndex++;
  14605. break;
  14606. case $.ui.keyCode.UP:
  14607. case $.ui.keyCode.LEFT:
  14608. goingForward = false;
  14609. selectedIndex--;
  14610. break;
  14611. case $.ui.keyCode.END:
  14612. selectedIndex = this.anchors.length - 1;
  14613. break;
  14614. case $.ui.keyCode.HOME:
  14615. selectedIndex = 0;
  14616. break;
  14617. case $.ui.keyCode.SPACE:
  14618. // Activate only, no collapsing
  14619. event.preventDefault();
  14620. clearTimeout( this.activating );
  14621. this._activate( selectedIndex );
  14622. return;
  14623. case $.ui.keyCode.ENTER:
  14624. // Toggle (cancel delayed activation, allow collapsing)
  14625. event.preventDefault();
  14626. clearTimeout( this.activating );
  14627. // Determine if we should collapse or activate
  14628. this._activate( selectedIndex === this.options.active ? false : selectedIndex );
  14629. return;
  14630. default:
  14631. return;
  14632. }
  14633. // Focus the appropriate tab, based on which key was pressed
  14634. event.preventDefault();
  14635. clearTimeout( this.activating );
  14636. selectedIndex = this._focusNextTab( selectedIndex, goingForward );
  14637. // Navigating with control/command key will prevent automatic activation
  14638. if ( !event.ctrlKey && !event.metaKey ) {
  14639. // Update aria-selected immediately so that AT think the tab is already selected.
  14640. // Otherwise AT may confuse the user by stating that they need to activate the tab,
  14641. // but the tab will already be activated by the time the announcement finishes.
  14642. focusedTab.attr( "aria-selected", "false" );
  14643. this.tabs.eq( selectedIndex ).attr( "aria-selected", "true" );
  14644. this.activating = this._delay( function() {
  14645. this.option( "active", selectedIndex );
  14646. }, this.delay );
  14647. }
  14648. },
  14649. _panelKeydown: function( event ) {
  14650. if ( this._handlePageNav( event ) ) {
  14651. return;
  14652. }
  14653. // Ctrl+up moves focus to the current tab
  14654. if ( event.ctrlKey && event.keyCode === $.ui.keyCode.UP ) {
  14655. event.preventDefault();
  14656. this.active.trigger( "focus" );
  14657. }
  14658. },
  14659. // Alt+page up/down moves focus to the previous/next tab (and activates)
  14660. _handlePageNav: function( event ) {
  14661. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_UP ) {
  14662. this._activate( this._focusNextTab( this.options.active - 1, false ) );
  14663. return true;
  14664. }
  14665. if ( event.altKey && event.keyCode === $.ui.keyCode.PAGE_DOWN ) {
  14666. this._activate( this._focusNextTab( this.options.active + 1, true ) );
  14667. return true;
  14668. }
  14669. },
  14670. _findNextTab: function( index, goingForward ) {
  14671. var lastTabIndex = this.tabs.length - 1;
  14672. function constrain() {
  14673. if ( index > lastTabIndex ) {
  14674. index = 0;
  14675. }
  14676. if ( index < 0 ) {
  14677. index = lastTabIndex;
  14678. }
  14679. return index;
  14680. }
  14681. while ( $.inArray( constrain(), this.options.disabled ) !== -1 ) {
  14682. index = goingForward ? index + 1 : index - 1;
  14683. }
  14684. return index;
  14685. },
  14686. _focusNextTab: function( index, goingForward ) {
  14687. index = this._findNextTab( index, goingForward );
  14688. this.tabs.eq( index ).trigger( "focus" );
  14689. return index;
  14690. },
  14691. _setOption: function( key, value ) {
  14692. if ( key === "active" ) {
  14693. // _activate() will handle invalid values and update this.options
  14694. this._activate( value );
  14695. return;
  14696. }
  14697. this._super( key, value );
  14698. if ( key === "collapsible" ) {
  14699. this._toggleClass( "ui-tabs-collapsible", null, value );
  14700. // Setting collapsible: false while collapsed; open first panel
  14701. if ( !value && this.options.active === false ) {
  14702. this._activate( 0 );
  14703. }
  14704. }
  14705. if ( key === "event" ) {
  14706. this._setupEvents( value );
  14707. }
  14708. if ( key === "heightStyle" ) {
  14709. this._setupHeightStyle( value );
  14710. }
  14711. },
  14712. _sanitizeSelector: function( hash ) {
  14713. return hash ? hash.replace( /[!"$%&'()*+,.\/:;<=>?@\[\]\^`{|}~]/g, "\\$&" ) : "";
  14714. },
  14715. refresh: function() {
  14716. var options = this.options,
  14717. lis = this.tablist.children( ":has(a[href])" );
  14718. // Get disabled tabs from class attribute from HTML
  14719. // this will get converted to a boolean if needed in _refresh()
  14720. options.disabled = $.map( lis.filter( ".ui-state-disabled" ), function( tab ) {
  14721. return lis.index( tab );
  14722. } );
  14723. this._processTabs();
  14724. // Was collapsed or no tabs
  14725. if ( options.active === false || !this.anchors.length ) {
  14726. options.active = false;
  14727. this.active = $();
  14728. // was active, but active tab is gone
  14729. } else if ( this.active.length && !$.contains( this.tablist[ 0 ], this.active[ 0 ] ) ) {
  14730. // all remaining tabs are disabled
  14731. if ( this.tabs.length === options.disabled.length ) {
  14732. options.active = false;
  14733. this.active = $();
  14734. // activate previous tab
  14735. } else {
  14736. this._activate( this._findNextTab( Math.max( 0, options.active - 1 ), false ) );
  14737. }
  14738. // was active, active tab still exists
  14739. } else {
  14740. // make sure active index is correct
  14741. options.active = this.tabs.index( this.active );
  14742. }
  14743. this._refresh();
  14744. },
  14745. _refresh: function() {
  14746. this._setOptionDisabled( this.options.disabled );
  14747. this._setupEvents( this.options.event );
  14748. this._setupHeightStyle( this.options.heightStyle );
  14749. this.tabs.not( this.active ).attr( {
  14750. "aria-selected": "false",
  14751. "aria-expanded": "false",
  14752. tabIndex: -1
  14753. } );
  14754. this.panels.not( this._getPanelForTab( this.active ) )
  14755. .hide()
  14756. .attr( {
  14757. "aria-hidden": "true"
  14758. } );
  14759. // Make sure one tab is in the tab order
  14760. if ( !this.active.length ) {
  14761. this.tabs.eq( 0 ).attr( "tabIndex", 0 );
  14762. } else {
  14763. this.active
  14764. .attr( {
  14765. "aria-selected": "true",
  14766. "aria-expanded": "true",
  14767. tabIndex: 0
  14768. } );
  14769. this._addClass( this.active, "ui-tabs-active", "ui-state-active" );
  14770. this._getPanelForTab( this.active )
  14771. .show()
  14772. .attr( {
  14773. "aria-hidden": "false"
  14774. } );
  14775. }
  14776. },
  14777. _processTabs: function() {
  14778. var that = this,
  14779. prevTabs = this.tabs,
  14780. prevAnchors = this.anchors,
  14781. prevPanels = this.panels;
  14782. this.tablist = this._getList().attr( "role", "tablist" );
  14783. this._addClass( this.tablist, "ui-tabs-nav",
  14784. "ui-helper-reset ui-helper-clearfix ui-widget-header" );
  14785. // Prevent users from focusing disabled tabs via click
  14786. this.tablist
  14787. .on( "mousedown" + this.eventNamespace, "> li", function( event ) {
  14788. if ( $( this ).is( ".ui-state-disabled" ) ) {
  14789. event.preventDefault();
  14790. }
  14791. } )
  14792. // Support: IE <9
  14793. // Preventing the default action in mousedown doesn't prevent IE
  14794. // from focusing the element, so if the anchor gets focused, blur.
  14795. // We don't have to worry about focusing the previously focused
  14796. // element since clicking on a non-focusable element should focus
  14797. // the body anyway.
  14798. .on( "focus" + this.eventNamespace, ".ui-tabs-anchor", function() {
  14799. if ( $( this ).closest( "li" ).is( ".ui-state-disabled" ) ) {
  14800. this.blur();
  14801. }
  14802. } );
  14803. this.tabs = this.tablist.find( "> li:has(a[href])" )
  14804. .attr( {
  14805. role: "tab",
  14806. tabIndex: -1
  14807. } );
  14808. this._addClass( this.tabs, "ui-tabs-tab", "ui-state-default" );
  14809. this.anchors = this.tabs.map( function() {
  14810. return $( "a", this )[ 0 ];
  14811. } )
  14812. .attr( {
  14813. role: "presentation",
  14814. tabIndex: -1
  14815. } );
  14816. this._addClass( this.anchors, "ui-tabs-anchor" );
  14817. this.panels = $();
  14818. this.anchors.each( function( i, anchor ) {
  14819. var selector, panel, panelId,
  14820. anchorId = $( anchor ).uniqueId().attr( "id" ),
  14821. tab = $( anchor ).closest( "li" ),
  14822. originalAriaControls = tab.attr( "aria-controls" );
  14823. // Inline tab
  14824. if ( that._isLocal( anchor ) ) {
  14825. selector = anchor.hash;
  14826. panelId = selector.substring( 1 );
  14827. panel = that.element.find( that._sanitizeSelector( selector ) );
  14828. // remote tab
  14829. } else {
  14830. // If the tab doesn't already have aria-controls,
  14831. // generate an id by using a throw-away element
  14832. panelId = tab.attr( "aria-controls" ) || $( {} ).uniqueId()[ 0 ].id;
  14833. selector = "#" + panelId;
  14834. panel = that.element.find( selector );
  14835. if ( !panel.length ) {
  14836. panel = that._createPanel( panelId );
  14837. panel.insertAfter( that.panels[ i - 1 ] || that.tablist );
  14838. }
  14839. panel.attr( "aria-live", "polite" );
  14840. }
  14841. if ( panel.length ) {
  14842. that.panels = that.panels.add( panel );
  14843. }
  14844. if ( originalAriaControls ) {
  14845. tab.data( "ui-tabs-aria-controls", originalAriaControls );
  14846. }
  14847. tab.attr( {
  14848. "aria-controls": panelId,
  14849. "aria-labelledby": anchorId
  14850. } );
  14851. panel.attr( "aria-labelledby", anchorId );
  14852. } );
  14853. this.panels.attr( "role", "tabpanel" );
  14854. this._addClass( this.panels, "ui-tabs-panel", "ui-widget-content" );
  14855. // Avoid memory leaks (#10056)
  14856. if ( prevTabs ) {
  14857. this._off( prevTabs.not( this.tabs ) );
  14858. this._off( prevAnchors.not( this.anchors ) );
  14859. this._off( prevPanels.not( this.panels ) );
  14860. }
  14861. },
  14862. // Allow overriding how to find the list for rare usage scenarios (#7715)
  14863. _getList: function() {
  14864. return this.tablist || this.element.find( "ol, ul" ).eq( 0 );
  14865. },
  14866. _createPanel: function( id ) {
  14867. return $( "<div>" )
  14868. .attr( "id", id )
  14869. .data( "ui-tabs-destroy", true );
  14870. },
  14871. _setOptionDisabled: function( disabled ) {
  14872. var currentItem, li, i;
  14873. if ( $.isArray( disabled ) ) {
  14874. if ( !disabled.length ) {
  14875. disabled = false;
  14876. } else if ( disabled.length === this.anchors.length ) {
  14877. disabled = true;
  14878. }
  14879. }
  14880. // Disable tabs
  14881. for ( i = 0; ( li = this.tabs[ i ] ); i++ ) {
  14882. currentItem = $( li );
  14883. if ( disabled === true || $.inArray( i, disabled ) !== -1 ) {
  14884. currentItem.attr( "aria-disabled", "true" );
  14885. this._addClass( currentItem, null, "ui-state-disabled" );
  14886. } else {
  14887. currentItem.removeAttr( "aria-disabled" );
  14888. this._removeClass( currentItem, null, "ui-state-disabled" );
  14889. }
  14890. }
  14891. this.options.disabled = disabled;
  14892. this._toggleClass( this.widget(), this.widgetFullName + "-disabled", null,
  14893. disabled === true );
  14894. },
  14895. _setupEvents: function( event ) {
  14896. var events = {};
  14897. if ( event ) {
  14898. $.each( event.split( " " ), function( index, eventName ) {
  14899. events[ eventName ] = "_eventHandler";
  14900. } );
  14901. }
  14902. this._off( this.anchors.add( this.tabs ).add( this.panels ) );
  14903. // Always prevent the default action, even when disabled
  14904. this._on( true, this.anchors, {
  14905. click: function( event ) {
  14906. event.preventDefault();
  14907. }
  14908. } );
  14909. this._on( this.anchors, events );
  14910. this._on( this.tabs, { keydown: "_tabKeydown" } );
  14911. this._on( this.panels, { keydown: "_panelKeydown" } );
  14912. this._focusable( this.tabs );
  14913. this._hoverable( this.tabs );
  14914. },
  14915. _setupHeightStyle: function( heightStyle ) {
  14916. var maxHeight,
  14917. parent = this.element.parent();
  14918. if ( heightStyle === "fill" ) {
  14919. maxHeight = parent.height();
  14920. maxHeight -= this.element.outerHeight() - this.element.height();
  14921. this.element.siblings( ":visible" ).each( function() {
  14922. var elem = $( this ),
  14923. position = elem.css( "position" );
  14924. if ( position === "absolute" || position === "fixed" ) {
  14925. return;
  14926. }
  14927. maxHeight -= elem.outerHeight( true );
  14928. } );
  14929. this.element.children().not( this.panels ).each( function() {
  14930. maxHeight -= $( this ).outerHeight( true );
  14931. } );
  14932. this.panels.each( function() {
  14933. $( this ).height( Math.max( 0, maxHeight -
  14934. $( this ).innerHeight() + $( this ).height() ) );
  14935. } )
  14936. .css( "overflow", "auto" );
  14937. } else if ( heightStyle === "auto" ) {
  14938. maxHeight = 0;
  14939. this.panels.each( function() {
  14940. maxHeight = Math.max( maxHeight, $( this ).height( "" ).height() );
  14941. } ).height( maxHeight );
  14942. }
  14943. },
  14944. _eventHandler: function( event ) {
  14945. var options = this.options,
  14946. active = this.active,
  14947. anchor = $( event.currentTarget ),
  14948. tab = anchor.closest( "li" ),
  14949. clickedIsActive = tab[ 0 ] === active[ 0 ],
  14950. collapsing = clickedIsActive && options.collapsible,
  14951. toShow = collapsing ? $() : this._getPanelForTab( tab ),
  14952. toHide = !active.length ? $() : this._getPanelForTab( active ),
  14953. eventData = {
  14954. oldTab: active,
  14955. oldPanel: toHide,
  14956. newTab: collapsing ? $() : tab,
  14957. newPanel: toShow
  14958. };
  14959. event.preventDefault();
  14960. if ( tab.hasClass( "ui-state-disabled" ) ||
  14961. // tab is already loading
  14962. tab.hasClass( "ui-tabs-loading" ) ||
  14963. // can't switch durning an animation
  14964. this.running ||
  14965. // click on active header, but not collapsible
  14966. ( clickedIsActive && !options.collapsible ) ||
  14967. // allow canceling activation
  14968. ( this._trigger( "beforeActivate", event, eventData ) === false ) ) {
  14969. return;
  14970. }
  14971. options.active = collapsing ? false : this.tabs.index( tab );
  14972. this.active = clickedIsActive ? $() : tab;
  14973. if ( this.xhr ) {
  14974. this.xhr.abort();
  14975. }
  14976. if ( !toHide.length && !toShow.length ) {
  14977. $.error( "jQuery UI Tabs: Mismatching fragment identifier." );
  14978. }
  14979. if ( toShow.length ) {
  14980. this.load( this.tabs.index( tab ), event );
  14981. }
  14982. this._toggle( event, eventData );
  14983. },
  14984. // Handles show/hide for selecting tabs
  14985. _toggle: function( event, eventData ) {
  14986. var that = this,
  14987. toShow = eventData.newPanel,
  14988. toHide = eventData.oldPanel;
  14989. this.running = true;
  14990. function complete() {
  14991. that.running = false;
  14992. that._trigger( "activate", event, eventData );
  14993. }
  14994. function show() {
  14995. that._addClass( eventData.newTab.closest( "li" ), "ui-tabs-active", "ui-state-active" );
  14996. if ( toShow.length && that.options.show ) {
  14997. that._show( toShow, that.options.show, complete );
  14998. } else {
  14999. toShow.show();
  15000. complete();
  15001. }
  15002. }
  15003. // Start out by hiding, then showing, then completing
  15004. if ( toHide.length && this.options.hide ) {
  15005. this._hide( toHide, this.options.hide, function() {
  15006. that._removeClass( eventData.oldTab.closest( "li" ),
  15007. "ui-tabs-active", "ui-state-active" );
  15008. show();
  15009. } );
  15010. } else {
  15011. this._removeClass( eventData.oldTab.closest( "li" ),
  15012. "ui-tabs-active", "ui-state-active" );
  15013. toHide.hide();
  15014. show();
  15015. }
  15016. toHide.attr( "aria-hidden", "true" );
  15017. eventData.oldTab.attr( {
  15018. "aria-selected": "false",
  15019. "aria-expanded": "false"
  15020. } );
  15021. // If we're switching tabs, remove the old tab from the tab order.
  15022. // If we're opening from collapsed state, remove the previous tab from the tab order.
  15023. // If we're collapsing, then keep the collapsing tab in the tab order.
  15024. if ( toShow.length && toHide.length ) {
  15025. eventData.oldTab.attr( "tabIndex", -1 );
  15026. } else if ( toShow.length ) {
  15027. this.tabs.filter( function() {
  15028. return $( this ).attr( "tabIndex" ) === 0;
  15029. } )
  15030. .attr( "tabIndex", -1 );
  15031. }
  15032. toShow.attr( "aria-hidden", "false" );
  15033. eventData.newTab.attr( {
  15034. "aria-selected": "true",
  15035. "aria-expanded": "true",
  15036. tabIndex: 0
  15037. } );
  15038. },
  15039. _activate: function( index ) {
  15040. var anchor,
  15041. active = this._findActive( index );
  15042. // Trying to activate the already active panel
  15043. if ( active[ 0 ] === this.active[ 0 ] ) {
  15044. return;
  15045. }
  15046. // Trying to collapse, simulate a click on the current active header
  15047. if ( !active.length ) {
  15048. active = this.active;
  15049. }
  15050. anchor = active.find( ".ui-tabs-anchor" )[ 0 ];
  15051. this._eventHandler( {
  15052. target: anchor,
  15053. currentTarget: anchor,
  15054. preventDefault: $.noop
  15055. } );
  15056. },
  15057. _findActive: function( index ) {
  15058. return index === false ? $() : this.tabs.eq( index );
  15059. },
  15060. _getIndex: function( index ) {
  15061. // meta-function to give users option to provide a href string instead of a numerical index.
  15062. if ( typeof index === "string" ) {
  15063. index = this.anchors.index( this.anchors.filter( "[href$='" +
  15064. $.ui.escapeSelector( index ) + "']" ) );
  15065. }
  15066. return index;
  15067. },
  15068. _destroy: function() {
  15069. if ( this.xhr ) {
  15070. this.xhr.abort();
  15071. }
  15072. this.tablist
  15073. .removeAttr( "role" )
  15074. .off( this.eventNamespace );
  15075. this.anchors
  15076. .removeAttr( "role tabIndex" )
  15077. .removeUniqueId();
  15078. this.tabs.add( this.panels ).each( function() {
  15079. if ( $.data( this, "ui-tabs-destroy" ) ) {
  15080. $( this ).remove();
  15081. } else {
  15082. $( this ).removeAttr( "role tabIndex " +
  15083. "aria-live aria-busy aria-selected aria-labelledby aria-hidden aria-expanded" );
  15084. }
  15085. } );
  15086. this.tabs.each( function() {
  15087. var li = $( this ),
  15088. prev = li.data( "ui-tabs-aria-controls" );
  15089. if ( prev ) {
  15090. li
  15091. .attr( "aria-controls", prev )
  15092. .removeData( "ui-tabs-aria-controls" );
  15093. } else {
  15094. li.removeAttr( "aria-controls" );
  15095. }
  15096. } );
  15097. this.panels.show();
  15098. if ( this.options.heightStyle !== "content" ) {
  15099. this.panels.css( "height", "" );
  15100. }
  15101. },
  15102. enable: function( index ) {
  15103. var disabled = this.options.disabled;
  15104. if ( disabled === false ) {
  15105. return;
  15106. }
  15107. if ( index === undefined ) {
  15108. disabled = false;
  15109. } else {
  15110. index = this._getIndex( index );
  15111. if ( $.isArray( disabled ) ) {
  15112. disabled = $.map( disabled, function( num ) {
  15113. return num !== index ? num : null;
  15114. } );
  15115. } else {
  15116. disabled = $.map( this.tabs, function( li, num ) {
  15117. return num !== index ? num : null;
  15118. } );
  15119. }
  15120. }
  15121. this._setOptionDisabled( disabled );
  15122. },
  15123. disable: function( index ) {
  15124. var disabled = this.options.disabled;
  15125. if ( disabled === true ) {
  15126. return;
  15127. }
  15128. if ( index === undefined ) {
  15129. disabled = true;
  15130. } else {
  15131. index = this._getIndex( index );
  15132. if ( $.inArray( index, disabled ) !== -1 ) {
  15133. return;
  15134. }
  15135. if ( $.isArray( disabled ) ) {
  15136. disabled = $.merge( [ index ], disabled ).sort();
  15137. } else {
  15138. disabled = [ index ];
  15139. }
  15140. }
  15141. this._setOptionDisabled( disabled );
  15142. },
  15143. load: function( index, event ) {
  15144. index = this._getIndex( index );
  15145. var that = this,
  15146. tab = this.tabs.eq( index ),
  15147. anchor = tab.find( ".ui-tabs-anchor" ),
  15148. panel = this._getPanelForTab( tab ),
  15149. eventData = {
  15150. tab: tab,
  15151. panel: panel
  15152. },
  15153. complete = function( jqXHR, status ) {
  15154. if ( status === "abort" ) {
  15155. that.panels.stop( false, true );
  15156. }
  15157. that._removeClass( tab, "ui-tabs-loading" );
  15158. panel.removeAttr( "aria-busy" );
  15159. if ( jqXHR === that.xhr ) {
  15160. delete that.xhr;
  15161. }
  15162. };
  15163. // Not remote
  15164. if ( this._isLocal( anchor[ 0 ] ) ) {
  15165. return;
  15166. }
  15167. this.xhr = $.ajax( this._ajaxSettings( anchor, event, eventData ) );
  15168. // Support: jQuery <1.8
  15169. // jQuery <1.8 returns false if the request is canceled in beforeSend,
  15170. // but as of 1.8, $.ajax() always returns a jqXHR object.
  15171. if ( this.xhr && this.xhr.statusText !== "canceled" ) {
  15172. this._addClass( tab, "ui-tabs-loading" );
  15173. panel.attr( "aria-busy", "true" );
  15174. this.xhr
  15175. .done( function( response, status, jqXHR ) {
  15176. // support: jQuery <1.8
  15177. // http://bugs.jquery.com/ticket/11778
  15178. setTimeout( function() {
  15179. panel.html( response );
  15180. that._trigger( "load", event, eventData );
  15181. complete( jqXHR, status );
  15182. }, 1 );
  15183. } )
  15184. .fail( function( jqXHR, status ) {
  15185. // support: jQuery <1.8
  15186. // http://bugs.jquery.com/ticket/11778
  15187. setTimeout( function() {
  15188. complete( jqXHR, status );
  15189. }, 1 );
  15190. } );
  15191. }
  15192. },
  15193. _ajaxSettings: function( anchor, event, eventData ) {
  15194. var that = this;
  15195. return {
  15196. // Support: IE <11 only
  15197. // Strip any hash that exists to prevent errors with the Ajax request
  15198. url: anchor.attr( "href" ).replace( /#.*$/, "" ),
  15199. beforeSend: function( jqXHR, settings ) {
  15200. return that._trigger( "beforeLoad", event,
  15201. $.extend( { jqXHR: jqXHR, ajaxSettings: settings }, eventData ) );
  15202. }
  15203. };
  15204. },
  15205. _getPanelForTab: function( tab ) {
  15206. var id = $( tab ).attr( "aria-controls" );
  15207. return this.element.find( this._sanitizeSelector( "#" + id ) );
  15208. }
  15209. } );
  15210. // DEPRECATED
  15211. // TODO: Switch return back to widget declaration at top of file when this is removed
  15212. if ( $.uiBackCompat !== false ) {
  15213. // Backcompat for ui-tab class (now ui-tabs-tab)
  15214. $.widget( "ui.tabs", $.ui.tabs, {
  15215. _processTabs: function() {
  15216. this._superApply( arguments );
  15217. this._addClass( this.tabs, "ui-tab" );
  15218. }
  15219. } );
  15220. }
  15221. var widgetsTabs = $.ui.tabs;
  15222. /*!
  15223. * jQuery UI Tooltip 1.12.1
  15224. * http://jqueryui.com
  15225. *
  15226. * Copyright jQuery Foundation and other contributors
  15227. * Released under the MIT license.
  15228. * http://jquery.org/license
  15229. */
  15230. //>>label: Tooltip
  15231. //>>group: Widgets
  15232. //>>description: Shows additional information for any element on hover or focus.
  15233. //>>docs: http://api.jqueryui.com/tooltip/
  15234. //>>demos: http://jqueryui.com/tooltip/
  15235. //>>css.structure: ../../themes/base/core.css
  15236. //>>css.structure: ../../themes/base/tooltip.css
  15237. //>>css.theme: ../../themes/base/theme.css
  15238. $.widget( "ui.tooltip", {
  15239. version: "1.12.1",
  15240. options: {
  15241. classes: {
  15242. "ui-tooltip": "ui-corner-all ui-widget-shadow"
  15243. },
  15244. content: function() {
  15245. // support: IE<9, Opera in jQuery <1.7
  15246. // .text() can't accept undefined, so coerce to a string
  15247. var title = $( this ).attr( "title" ) || "";
  15248. // Escape title, since we're going from an attribute to raw HTML
  15249. return $( "<a>" ).text( title ).html();
  15250. },
  15251. hide: true,
  15252. // Disabled elements have inconsistent behavior across browsers (#8661)
  15253. items: "[title]:not([disabled])",
  15254. position: {
  15255. my: "left top+15",
  15256. at: "left bottom",
  15257. collision: "flipfit flip"
  15258. },
  15259. show: true,
  15260. track: false,
  15261. // Callbacks
  15262. close: null,
  15263. open: null
  15264. },
  15265. _addDescribedBy: function( elem, id ) {
  15266. var describedby = ( elem.attr( "aria-describedby" ) || "" ).split( /\s+/ );
  15267. describedby.push( id );
  15268. elem
  15269. .data( "ui-tooltip-id", id )
  15270. .attr( "aria-describedby", $.trim( describedby.join( " " ) ) );
  15271. },
  15272. _removeDescribedBy: function( elem ) {
  15273. var id = elem.data( "ui-tooltip-id" ),
  15274. describedby = ( elem.attr( "aria-describedby" ) || "" ).split( /\s+/ ),
  15275. index = $.inArray( id, describedby );
  15276. if ( index !== -1 ) {
  15277. describedby.splice( index, 1 );
  15278. }
  15279. elem.removeData( "ui-tooltip-id" );
  15280. describedby = $.trim( describedby.join( " " ) );
  15281. if ( describedby ) {
  15282. elem.attr( "aria-describedby", describedby );
  15283. } else {
  15284. elem.removeAttr( "aria-describedby" );
  15285. }
  15286. },
  15287. _create: function() {
  15288. this._on( {
  15289. mouseover: "open",
  15290. focusin: "open"
  15291. } );
  15292. // IDs of generated tooltips, needed for destroy
  15293. this.tooltips = {};
  15294. // IDs of parent tooltips where we removed the title attribute
  15295. this.parents = {};
  15296. // Append the aria-live region so tooltips announce correctly
  15297. this.liveRegion = $( "<div>" )
  15298. .attr( {
  15299. role: "log",
  15300. "aria-live": "assertive",
  15301. "aria-relevant": "additions"
  15302. } )
  15303. .appendTo( this.document[ 0 ].body );
  15304. this._addClass( this.liveRegion, null, "ui-helper-hidden-accessible" );
  15305. this.disabledTitles = $( [] );
  15306. },
  15307. _setOption: function( key, value ) {
  15308. var that = this;
  15309. this._super( key, value );
  15310. if ( key === "content" ) {
  15311. $.each( this.tooltips, function( id, tooltipData ) {
  15312. that._updateContent( tooltipData.element );
  15313. } );
  15314. }
  15315. },
  15316. _setOptionDisabled: function( value ) {
  15317. this[ value ? "_disable" : "_enable" ]();
  15318. },
  15319. _disable: function() {
  15320. var that = this;
  15321. // Close open tooltips
  15322. $.each( this.tooltips, function( id, tooltipData ) {
  15323. var event = $.Event( "blur" );
  15324. event.target = event.currentTarget = tooltipData.element[ 0 ];
  15325. that.close( event, true );
  15326. } );
  15327. // Remove title attributes to prevent native tooltips
  15328. this.disabledTitles = this.disabledTitles.add(
  15329. this.element.find( this.options.items ).addBack()
  15330. .filter( function() {
  15331. var element = $( this );
  15332. if ( element.is( "[title]" ) ) {
  15333. return element
  15334. .data( "ui-tooltip-title", element.attr( "title" ) )
  15335. .removeAttr( "title" );
  15336. }
  15337. } )
  15338. );
  15339. },
  15340. _enable: function() {
  15341. // restore title attributes
  15342. this.disabledTitles.each( function() {
  15343. var element = $( this );
  15344. if ( element.data( "ui-tooltip-title" ) ) {
  15345. element.attr( "title", element.data( "ui-tooltip-title" ) );
  15346. }
  15347. } );
  15348. this.disabledTitles = $( [] );
  15349. },
  15350. open: function( event ) {
  15351. var that = this,
  15352. target = $( event ? event.target : this.element )
  15353. // we need closest here due to mouseover bubbling,
  15354. // but always pointing at the same event target
  15355. .closest( this.options.items );
  15356. // No element to show a tooltip for or the tooltip is already open
  15357. if ( !target.length || target.data( "ui-tooltip-id" ) ) {
  15358. return;
  15359. }
  15360. if ( target.attr( "title" ) ) {
  15361. target.data( "ui-tooltip-title", target.attr( "title" ) );
  15362. }
  15363. target.data( "ui-tooltip-open", true );
  15364. // Kill parent tooltips, custom or native, for hover
  15365. if ( event && event.type === "mouseover" ) {
  15366. target.parents().each( function() {
  15367. var parent = $( this ),
  15368. blurEvent;
  15369. if ( parent.data( "ui-tooltip-open" ) ) {
  15370. blurEvent = $.Event( "blur" );
  15371. blurEvent.target = blurEvent.currentTarget = this;
  15372. that.close( blurEvent, true );
  15373. }
  15374. if ( parent.attr( "title" ) ) {
  15375. parent.uniqueId();
  15376. that.parents[ this.id ] = {
  15377. element: this,
  15378. title: parent.attr( "title" )
  15379. };
  15380. parent.attr( "title", "" );
  15381. }
  15382. } );
  15383. }
  15384. this._registerCloseHandlers( event, target );
  15385. this._updateContent( target, event );
  15386. },
  15387. _updateContent: function( target, event ) {
  15388. var content,
  15389. contentOption = this.options.content,
  15390. that = this,
  15391. eventType = event ? event.type : null;
  15392. if ( typeof contentOption === "string" || contentOption.nodeType ||
  15393. contentOption.jquery ) {
  15394. return this._open( event, target, contentOption );
  15395. }
  15396. content = contentOption.call( target[ 0 ], function( response ) {
  15397. // IE may instantly serve a cached response for ajax requests
  15398. // delay this call to _open so the other call to _open runs first
  15399. that._delay( function() {
  15400. // Ignore async response if tooltip was closed already
  15401. if ( !target.data( "ui-tooltip-open" ) ) {
  15402. return;
  15403. }
  15404. // JQuery creates a special event for focusin when it doesn't
  15405. // exist natively. To improve performance, the native event
  15406. // object is reused and the type is changed. Therefore, we can't
  15407. // rely on the type being correct after the event finished
  15408. // bubbling, so we set it back to the previous value. (#8740)
  15409. if ( event ) {
  15410. event.type = eventType;
  15411. }
  15412. this._open( event, target, response );
  15413. } );
  15414. } );
  15415. if ( content ) {
  15416. this._open( event, target, content );
  15417. }
  15418. },
  15419. _open: function( event, target, content ) {
  15420. var tooltipData, tooltip, delayedShow, a11yContent,
  15421. positionOption = $.extend( {}, this.options.position );
  15422. if ( !content ) {
  15423. return;
  15424. }
  15425. // Content can be updated multiple times. If the tooltip already
  15426. // exists, then just update the content and bail.
  15427. tooltipData = this._find( target );
  15428. if ( tooltipData ) {
  15429. tooltipData.tooltip.find( ".ui-tooltip-content" ).html( content );
  15430. return;
  15431. }
  15432. // If we have a title, clear it to prevent the native tooltip
  15433. // we have to check first to avoid defining a title if none exists
  15434. // (we don't want to cause an element to start matching [title])
  15435. //
  15436. // We use removeAttr only for key events, to allow IE to export the correct
  15437. // accessible attributes. For mouse events, set to empty string to avoid
  15438. // native tooltip showing up (happens only when removing inside mouseover).
  15439. if ( target.is( "[title]" ) ) {
  15440. if ( event && event.type === "mouseover" ) {
  15441. target.attr( "title", "" );
  15442. } else {
  15443. target.removeAttr( "title" );
  15444. }
  15445. }
  15446. tooltipData = this._tooltip( target );
  15447. tooltip = tooltipData.tooltip;
  15448. this._addDescribedBy( target, tooltip.attr( "id" ) );
  15449. tooltip.find( ".ui-tooltip-content" ).html( content );
  15450. // Support: Voiceover on OS X, JAWS on IE <= 9
  15451. // JAWS announces deletions even when aria-relevant="additions"
  15452. // Voiceover will sometimes re-read the entire log region's contents from the beginning
  15453. this.liveRegion.children().hide();
  15454. a11yContent = $( "<div>" ).html( tooltip.find( ".ui-tooltip-content" ).html() );
  15455. a11yContent.removeAttr( "name" ).find( "[name]" ).removeAttr( "name" );
  15456. a11yContent.removeAttr( "id" ).find( "[id]" ).removeAttr( "id" );
  15457. a11yContent.appendTo( this.liveRegion );
  15458. function position( event ) {
  15459. positionOption.of = event;
  15460. if ( tooltip.is( ":hidden" ) ) {
  15461. return;
  15462. }
  15463. tooltip.position( positionOption );
  15464. }
  15465. if ( this.options.track && event && /^mouse/.test( event.type ) ) {
  15466. this._on( this.document, {
  15467. mousemove: position
  15468. } );
  15469. // trigger once to override element-relative positioning
  15470. position( event );
  15471. } else {
  15472. tooltip.position( $.extend( {
  15473. of: target
  15474. }, this.options.position ) );
  15475. }
  15476. tooltip.hide();
  15477. this._show( tooltip, this.options.show );
  15478. // Handle tracking tooltips that are shown with a delay (#8644). As soon
  15479. // as the tooltip is visible, position the tooltip using the most recent
  15480. // event.
  15481. // Adds the check to add the timers only when both delay and track options are set (#14682)
  15482. if ( this.options.track && this.options.show && this.options.show.delay ) {
  15483. delayedShow = this.delayedShow = setInterval( function() {
  15484. if ( tooltip.is( ":visible" ) ) {
  15485. position( positionOption.of );
  15486. clearInterval( delayedShow );
  15487. }
  15488. }, $.fx.interval );
  15489. }
  15490. this._trigger( "open", event, { tooltip: tooltip } );
  15491. },
  15492. _registerCloseHandlers: function( event, target ) {
  15493. var events = {
  15494. keyup: function( event ) {
  15495. if ( event.keyCode === $.ui.keyCode.ESCAPE ) {
  15496. var fakeEvent = $.Event( event );
  15497. fakeEvent.currentTarget = target[ 0 ];
  15498. this.close( fakeEvent, true );
  15499. }
  15500. }
  15501. };
  15502. // Only bind remove handler for delegated targets. Non-delegated
  15503. // tooltips will handle this in destroy.
  15504. if ( target[ 0 ] !== this.element[ 0 ] ) {
  15505. events.remove = function() {
  15506. this._removeTooltip( this._find( target ).tooltip );
  15507. };
  15508. }
  15509. if ( !event || event.type === "mouseover" ) {
  15510. events.mouseleave = "close";
  15511. }
  15512. if ( !event || event.type === "focusin" ) {
  15513. events.focusout = "close";
  15514. }
  15515. this._on( true, target, events );
  15516. },
  15517. close: function( event ) {
  15518. var tooltip,
  15519. that = this,
  15520. target = $( event ? event.currentTarget : this.element ),
  15521. tooltipData = this._find( target );
  15522. // The tooltip may already be closed
  15523. if ( !tooltipData ) {
  15524. // We set ui-tooltip-open immediately upon open (in open()), but only set the
  15525. // additional data once there's actually content to show (in _open()). So even if the
  15526. // tooltip doesn't have full data, we always remove ui-tooltip-open in case we're in
  15527. // the period between open() and _open().
  15528. target.removeData( "ui-tooltip-open" );
  15529. return;
  15530. }
  15531. tooltip = tooltipData.tooltip;
  15532. // Disabling closes the tooltip, so we need to track when we're closing
  15533. // to avoid an infinite loop in case the tooltip becomes disabled on close
  15534. if ( tooltipData.closing ) {
  15535. return;
  15536. }
  15537. // Clear the interval for delayed tracking tooltips
  15538. clearInterval( this.delayedShow );
  15539. // Only set title if we had one before (see comment in _open())
  15540. // If the title attribute has changed since open(), don't restore
  15541. if ( target.data( "ui-tooltip-title" ) && !target.attr( "title" ) ) {
  15542. target.attr( "title", target.data( "ui-tooltip-title" ) );
  15543. }
  15544. this._removeDescribedBy( target );
  15545. tooltipData.hiding = true;
  15546. tooltip.stop( true );
  15547. this._hide( tooltip, this.options.hide, function() {
  15548. that._removeTooltip( $( this ) );
  15549. } );
  15550. target.removeData( "ui-tooltip-open" );
  15551. this._off( target, "mouseleave focusout keyup" );
  15552. // Remove 'remove' binding only on delegated targets
  15553. if ( target[ 0 ] !== this.element[ 0 ] ) {
  15554. this._off( target, "remove" );
  15555. }
  15556. this._off( this.document, "mousemove" );
  15557. if ( event && event.type === "mouseleave" ) {
  15558. $.each( this.parents, function( id, parent ) {
  15559. $( parent.element ).attr( "title", parent.title );
  15560. delete that.parents[ id ];
  15561. } );
  15562. }
  15563. tooltipData.closing = true;
  15564. this._trigger( "close", event, { tooltip: tooltip } );
  15565. if ( !tooltipData.hiding ) {
  15566. tooltipData.closing = false;
  15567. }
  15568. },
  15569. _tooltip: function( element ) {
  15570. var tooltip = $( "<div>" ).attr( "role", "tooltip" ),
  15571. content = $( "<div>" ).appendTo( tooltip ),
  15572. id = tooltip.uniqueId().attr( "id" );
  15573. this._addClass( content, "ui-tooltip-content" );
  15574. this._addClass( tooltip, "ui-tooltip", "ui-widget ui-widget-content" );
  15575. tooltip.appendTo( this._appendTo( element ) );
  15576. return this.tooltips[ id ] = {
  15577. element: element,
  15578. tooltip: tooltip
  15579. };
  15580. },
  15581. _find: function( target ) {
  15582. var id = target.data( "ui-tooltip-id" );
  15583. return id ? this.tooltips[ id ] : null;
  15584. },
  15585. _removeTooltip: function( tooltip ) {
  15586. tooltip.remove();
  15587. delete this.tooltips[ tooltip.attr( "id" ) ];
  15588. },
  15589. _appendTo: function( target ) {
  15590. var element = target.closest( ".ui-front, dialog" );
  15591. if ( !element.length ) {
  15592. element = this.document[ 0 ].body;
  15593. }
  15594. return element;
  15595. },
  15596. _destroy: function() {
  15597. var that = this;
  15598. // Close open tooltips
  15599. $.each( this.tooltips, function( id, tooltipData ) {
  15600. // Delegate to close method to handle common cleanup
  15601. var event = $.Event( "blur" ),
  15602. element = tooltipData.element;
  15603. event.target = event.currentTarget = element[ 0 ];
  15604. that.close( event, true );
  15605. // Remove immediately; destroying an open tooltip doesn't use the
  15606. // hide animation
  15607. $( "#" + id ).remove();
  15608. // Restore the title
  15609. if ( element.data( "ui-tooltip-title" ) ) {
  15610. // If the title attribute has changed since open(), don't restore
  15611. if ( !element.attr( "title" ) ) {
  15612. element.attr( "title", element.data( "ui-tooltip-title" ) );
  15613. }
  15614. element.removeData( "ui-tooltip-title" );
  15615. }
  15616. } );
  15617. this.liveRegion.remove();
  15618. }
  15619. } );
  15620. // DEPRECATED
  15621. // TODO: Switch return back to widget declaration at top of file when this is removed
  15622. if ( $.uiBackCompat !== false ) {
  15623. // Backcompat for tooltipClass option
  15624. $.widget( "ui.tooltip", $.ui.tooltip, {
  15625. options: {
  15626. tooltipClass: null
  15627. },
  15628. _tooltip: function() {
  15629. var tooltipData = this._superApply( arguments );
  15630. if ( this.options.tooltipClass ) {
  15631. tooltipData.tooltip.addClass( this.options.tooltipClass );
  15632. }
  15633. return tooltipData;
  15634. }
  15635. } );
  15636. }
  15637. var widgetsTooltip = $.ui.tooltip;
  15638. }));