jquery-ui.js 174 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446
  1. /*! jQuery UI - v1.12.1 - 2016-12-14
  2. * http://jqueryui.com
  3. * Includes: widget.js, position.js, data.js, disable-selection.js, focusable.js, form-reset-mixin.js, jquery-1-7.js, keycode.js, labels.js, scroll-parent.js, tabbable.js, unique-id.js, widgets/draggable.js, widgets/droppable.js, widgets/resizable.js, widgets/sortable.js, widgets/mouse.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 Focusable 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: :focusable Selector
  1102. //>>group: Core
  1103. //>>description: Selects elements which can be focused.
  1104. //>>docs: http://api.jqueryui.com/focusable-selector/
  1105. // Selectors
  1106. $.ui.focusable = function( element, hasTabindex ) {
  1107. var map, mapName, img, focusableIfVisible, fieldset,
  1108. nodeName = element.nodeName.toLowerCase();
  1109. if ( "area" === nodeName ) {
  1110. map = element.parentNode;
  1111. mapName = map.name;
  1112. if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
  1113. return false;
  1114. }
  1115. img = $( "img[usemap='#" + mapName + "']" );
  1116. return img.length > 0 && img.is( ":visible" );
  1117. }
  1118. if ( /^(input|select|textarea|button|object)$/.test( nodeName ) ) {
  1119. focusableIfVisible = !element.disabled;
  1120. if ( focusableIfVisible ) {
  1121. // Form controls within a disabled fieldset are disabled.
  1122. // However, controls within the fieldset's legend do not get disabled.
  1123. // Since controls generally aren't placed inside legends, we skip
  1124. // this portion of the check.
  1125. fieldset = $( element ).closest( "fieldset" )[ 0 ];
  1126. if ( fieldset ) {
  1127. focusableIfVisible = !fieldset.disabled;
  1128. }
  1129. }
  1130. } else if ( "a" === nodeName ) {
  1131. focusableIfVisible = element.href || hasTabindex;
  1132. } else {
  1133. focusableIfVisible = hasTabindex;
  1134. }
  1135. return focusableIfVisible && $( element ).is( ":visible" ) && visible( $( element ) );
  1136. };
  1137. // Support: IE 8 only
  1138. // IE 8 doesn't resolve inherit to visible/hidden for computed values
  1139. function visible( element ) {
  1140. var visibility = element.css( "visibility" );
  1141. while ( visibility === "inherit" ) {
  1142. element = element.parent();
  1143. visibility = element.css( "visibility" );
  1144. }
  1145. return visibility !== "hidden";
  1146. }
  1147. $.extend( $.expr[ ":" ], {
  1148. focusable: function( element ) {
  1149. return $.ui.focusable( element, $.attr( element, "tabindex" ) != null );
  1150. }
  1151. } );
  1152. var focusable = $.ui.focusable;
  1153. // Support: IE8 Only
  1154. // IE8 does not support the form attribute and when it is supplied. It overwrites the form prop
  1155. // with a string, so we need to find the proper form.
  1156. var form = $.fn.form = function() {
  1157. return typeof this[ 0 ].form === "string" ? this.closest( "form" ) : $( this[ 0 ].form );
  1158. };
  1159. /*!
  1160. * jQuery UI Form Reset Mixin 1.12.1
  1161. * http://jqueryui.com
  1162. *
  1163. * Copyright jQuery Foundation and other contributors
  1164. * Released under the MIT license.
  1165. * http://jquery.org/license
  1166. */
  1167. //>>label: Form Reset Mixin
  1168. //>>group: Core
  1169. //>>description: Refresh input widgets when their form is reset
  1170. //>>docs: http://api.jqueryui.com/form-reset-mixin/
  1171. var formResetMixin = $.ui.formResetMixin = {
  1172. _formResetHandler: function() {
  1173. var form = $( this );
  1174. // Wait for the form reset to actually happen before refreshing
  1175. setTimeout( function() {
  1176. var instances = form.data( "ui-form-reset-instances" );
  1177. $.each( instances, function() {
  1178. this.refresh();
  1179. } );
  1180. } );
  1181. },
  1182. _bindFormResetHandler: function() {
  1183. this.form = this.element.form();
  1184. if ( !this.form.length ) {
  1185. return;
  1186. }
  1187. var instances = this.form.data( "ui-form-reset-instances" ) || [];
  1188. if ( !instances.length ) {
  1189. // We don't use _on() here because we use a single event handler per form
  1190. this.form.on( "reset.ui-form-reset", this._formResetHandler );
  1191. }
  1192. instances.push( this );
  1193. this.form.data( "ui-form-reset-instances", instances );
  1194. },
  1195. _unbindFormResetHandler: function() {
  1196. if ( !this.form.length ) {
  1197. return;
  1198. }
  1199. var instances = this.form.data( "ui-form-reset-instances" );
  1200. instances.splice( $.inArray( this, instances ), 1 );
  1201. if ( instances.length ) {
  1202. this.form.data( "ui-form-reset-instances", instances );
  1203. } else {
  1204. this.form
  1205. .removeData( "ui-form-reset-instances" )
  1206. .off( "reset.ui-form-reset" );
  1207. }
  1208. }
  1209. };
  1210. /*!
  1211. * jQuery UI Support for jQuery core 1.7.x 1.12.1
  1212. * http://jqueryui.com
  1213. *
  1214. * Copyright jQuery Foundation and other contributors
  1215. * Released under the MIT license.
  1216. * http://jquery.org/license
  1217. *
  1218. */
  1219. //>>label: jQuery 1.7 Support
  1220. //>>group: Core
  1221. //>>description: Support version 1.7.x of jQuery core
  1222. // Support: jQuery 1.7 only
  1223. // Not a great way to check versions, but since we only support 1.7+ and only
  1224. // need to detect <1.8, this is a simple check that should suffice. Checking
  1225. // for "1.7." would be a bit safer, but the version string is 1.7, not 1.7.0
  1226. // and we'll never reach 1.70.0 (if we do, we certainly won't be supporting
  1227. // 1.7 anymore). See #11197 for why we're not using feature detection.
  1228. if ( $.fn.jquery.substring( 0, 3 ) === "1.7" ) {
  1229. // Setters for .innerWidth(), .innerHeight(), .outerWidth(), .outerHeight()
  1230. // Unlike jQuery Core 1.8+, these only support numeric values to set the
  1231. // dimensions in pixels
  1232. $.each( [ "Width", "Height" ], function( i, name ) {
  1233. var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
  1234. type = name.toLowerCase(),
  1235. orig = {
  1236. innerWidth: $.fn.innerWidth,
  1237. innerHeight: $.fn.innerHeight,
  1238. outerWidth: $.fn.outerWidth,
  1239. outerHeight: $.fn.outerHeight
  1240. };
  1241. function reduce( elem, size, border, margin ) {
  1242. $.each( side, function() {
  1243. size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
  1244. if ( border ) {
  1245. size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
  1246. }
  1247. if ( margin ) {
  1248. size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
  1249. }
  1250. } );
  1251. return size;
  1252. }
  1253. $.fn[ "inner" + name ] = function( size ) {
  1254. if ( size === undefined ) {
  1255. return orig[ "inner" + name ].call( this );
  1256. }
  1257. return this.each( function() {
  1258. $( this ).css( type, reduce( this, size ) + "px" );
  1259. } );
  1260. };
  1261. $.fn[ "outer" + name ] = function( size, margin ) {
  1262. if ( typeof size !== "number" ) {
  1263. return orig[ "outer" + name ].call( this, size );
  1264. }
  1265. return this.each( function() {
  1266. $( this ).css( type, reduce( this, size, true, margin ) + "px" );
  1267. } );
  1268. };
  1269. } );
  1270. $.fn.addBack = function( selector ) {
  1271. return this.add( selector == null ?
  1272. this.prevObject : this.prevObject.filter( selector )
  1273. );
  1274. };
  1275. }
  1276. ;
  1277. /*!
  1278. * jQuery UI Keycode 1.12.1
  1279. * http://jqueryui.com
  1280. *
  1281. * Copyright jQuery Foundation and other contributors
  1282. * Released under the MIT license.
  1283. * http://jquery.org/license
  1284. */
  1285. //>>label: Keycode
  1286. //>>group: Core
  1287. //>>description: Provide keycodes as keynames
  1288. //>>docs: http://api.jqueryui.com/jQuery.ui.keyCode/
  1289. var keycode = $.ui.keyCode = {
  1290. BACKSPACE: 8,
  1291. COMMA: 188,
  1292. DELETE: 46,
  1293. DOWN: 40,
  1294. END: 35,
  1295. ENTER: 13,
  1296. ESCAPE: 27,
  1297. HOME: 36,
  1298. LEFT: 37,
  1299. PAGE_DOWN: 34,
  1300. PAGE_UP: 33,
  1301. PERIOD: 190,
  1302. RIGHT: 39,
  1303. SPACE: 32,
  1304. TAB: 9,
  1305. UP: 38
  1306. };
  1307. // Internal use only
  1308. var escapeSelector = $.ui.escapeSelector = ( function() {
  1309. var selectorEscape = /([!"#$%&'()*+,./:;<=>?@[\]^`{|}~])/g;
  1310. return function( selector ) {
  1311. return selector.replace( selectorEscape, "\\$1" );
  1312. };
  1313. } )();
  1314. /*!
  1315. * jQuery UI Labels 1.12.1
  1316. * http://jqueryui.com
  1317. *
  1318. * Copyright jQuery Foundation and other contributors
  1319. * Released under the MIT license.
  1320. * http://jquery.org/license
  1321. */
  1322. //>>label: labels
  1323. //>>group: Core
  1324. //>>description: Find all the labels associated with a given input
  1325. //>>docs: http://api.jqueryui.com/labels/
  1326. var labels = $.fn.labels = function() {
  1327. var ancestor, selector, id, labels, ancestors;
  1328. // Check control.labels first
  1329. if ( this[ 0 ].labels && this[ 0 ].labels.length ) {
  1330. return this.pushStack( this[ 0 ].labels );
  1331. }
  1332. // Support: IE <= 11, FF <= 37, Android <= 2.3 only
  1333. // Above browsers do not support control.labels. Everything below is to support them
  1334. // as well as document fragments. control.labels does not work on document fragments
  1335. labels = this.eq( 0 ).parents( "label" );
  1336. // Look for the label based on the id
  1337. id = this.attr( "id" );
  1338. if ( id ) {
  1339. // We don't search against the document in case the element
  1340. // is disconnected from the DOM
  1341. ancestor = this.eq( 0 ).parents().last();
  1342. // Get a full set of top level ancestors
  1343. ancestors = ancestor.add( ancestor.length ? ancestor.siblings() : this.siblings() );
  1344. // Create a selector for the label based on the id
  1345. selector = "label[for='" + $.ui.escapeSelector( id ) + "']";
  1346. labels = labels.add( ancestors.find( selector ).addBack( selector ) );
  1347. }
  1348. // Return whatever we have found for labels
  1349. return this.pushStack( labels );
  1350. };
  1351. /*!
  1352. * jQuery UI Scroll Parent 1.12.1
  1353. * http://jqueryui.com
  1354. *
  1355. * Copyright jQuery Foundation and other contributors
  1356. * Released under the MIT license.
  1357. * http://jquery.org/license
  1358. */
  1359. //>>label: scrollParent
  1360. //>>group: Core
  1361. //>>description: Get the closest ancestor element that is scrollable.
  1362. //>>docs: http://api.jqueryui.com/scrollParent/
  1363. var scrollParent = $.fn.scrollParent = function( includeHidden ) {
  1364. var position = this.css( "position" ),
  1365. excludeStaticParent = position === "absolute",
  1366. overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/,
  1367. scrollParent = this.parents().filter( function() {
  1368. var parent = $( this );
  1369. if ( excludeStaticParent && parent.css( "position" ) === "static" ) {
  1370. return false;
  1371. }
  1372. return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) +
  1373. parent.css( "overflow-x" ) );
  1374. } ).eq( 0 );
  1375. return position === "fixed" || !scrollParent.length ?
  1376. $( this[ 0 ].ownerDocument || document ) :
  1377. scrollParent;
  1378. };
  1379. /*!
  1380. * jQuery UI Tabbable 1.12.1
  1381. * http://jqueryui.com
  1382. *
  1383. * Copyright jQuery Foundation and other contributors
  1384. * Released under the MIT license.
  1385. * http://jquery.org/license
  1386. */
  1387. //>>label: :tabbable Selector
  1388. //>>group: Core
  1389. //>>description: Selects elements which can be tabbed to.
  1390. //>>docs: http://api.jqueryui.com/tabbable-selector/
  1391. var tabbable = $.extend( $.expr[ ":" ], {
  1392. tabbable: function( element ) {
  1393. var tabIndex = $.attr( element, "tabindex" ),
  1394. hasTabindex = tabIndex != null;
  1395. return ( !hasTabindex || tabIndex >= 0 ) && $.ui.focusable( element, hasTabindex );
  1396. }
  1397. } );
  1398. /*!
  1399. * jQuery UI Unique ID 1.12.1
  1400. * http://jqueryui.com
  1401. *
  1402. * Copyright jQuery Foundation and other contributors
  1403. * Released under the MIT license.
  1404. * http://jquery.org/license
  1405. */
  1406. //>>label: uniqueId
  1407. //>>group: Core
  1408. //>>description: Functions to generate and remove uniqueId's
  1409. //>>docs: http://api.jqueryui.com/uniqueId/
  1410. var uniqueId = $.fn.extend( {
  1411. uniqueId: ( function() {
  1412. var uuid = 0;
  1413. return function() {
  1414. return this.each( function() {
  1415. if ( !this.id ) {
  1416. this.id = "ui-id-" + ( ++uuid );
  1417. }
  1418. } );
  1419. };
  1420. } )(),
  1421. removeUniqueId: function() {
  1422. return this.each( function() {
  1423. if ( /^ui-id-\d+$/.test( this.id ) ) {
  1424. $( this ).removeAttr( "id" );
  1425. }
  1426. } );
  1427. }
  1428. } );
  1429. // This file is deprecated
  1430. var ie = $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
  1431. /*!
  1432. * jQuery UI Mouse 1.12.1
  1433. * http://jqueryui.com
  1434. *
  1435. * Copyright jQuery Foundation and other contributors
  1436. * Released under the MIT license.
  1437. * http://jquery.org/license
  1438. */
  1439. //>>label: Mouse
  1440. //>>group: Widgets
  1441. //>>description: Abstracts mouse-based interactions to assist in creating certain widgets.
  1442. //>>docs: http://api.jqueryui.com/mouse/
  1443. var mouseHandled = false;
  1444. $( document ).on( "mouseup", function() {
  1445. mouseHandled = false;
  1446. } );
  1447. var widgetsMouse = $.widget( "ui.mouse", {
  1448. version: "1.12.1",
  1449. options: {
  1450. cancel: "input, textarea, button, select, option",
  1451. distance: 1,
  1452. delay: 0
  1453. },
  1454. _mouseInit: function() {
  1455. var that = this;
  1456. this.element
  1457. .on( "mousedown." + this.widgetName, function( event ) {
  1458. return that._mouseDown( event );
  1459. } )
  1460. .on( "click." + this.widgetName, function( event ) {
  1461. if ( true === $.data( event.target, that.widgetName + ".preventClickEvent" ) ) {
  1462. $.removeData( event.target, that.widgetName + ".preventClickEvent" );
  1463. event.stopImmediatePropagation();
  1464. return false;
  1465. }
  1466. } );
  1467. this.started = false;
  1468. },
  1469. // TODO: make sure destroying one instance of mouse doesn't mess with
  1470. // other instances of mouse
  1471. _mouseDestroy: function() {
  1472. this.element.off( "." + this.widgetName );
  1473. if ( this._mouseMoveDelegate ) {
  1474. this.document
  1475. .off( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  1476. .off( "mouseup." + this.widgetName, this._mouseUpDelegate );
  1477. }
  1478. },
  1479. _mouseDown: function( event ) {
  1480. // don't let more than one widget handle mouseStart
  1481. if ( mouseHandled ) {
  1482. return;
  1483. }
  1484. this._mouseMoved = false;
  1485. // We may have missed mouseup (out of window)
  1486. ( this._mouseStarted && this._mouseUp( event ) );
  1487. this._mouseDownEvent = event;
  1488. var that = this,
  1489. btnIsLeft = ( event.which === 1 ),
  1490. // event.target.nodeName works around a bug in IE 8 with
  1491. // disabled inputs (#7620)
  1492. elIsCancel = ( typeof this.options.cancel === "string" && event.target.nodeName ?
  1493. $( event.target ).closest( this.options.cancel ).length : false );
  1494. if ( !btnIsLeft || elIsCancel || !this._mouseCapture( event ) ) {
  1495. return true;
  1496. }
  1497. this.mouseDelayMet = !this.options.delay;
  1498. if ( !this.mouseDelayMet ) {
  1499. this._mouseDelayTimer = setTimeout( function() {
  1500. that.mouseDelayMet = true;
  1501. }, this.options.delay );
  1502. }
  1503. if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) {
  1504. this._mouseStarted = ( this._mouseStart( event ) !== false );
  1505. if ( !this._mouseStarted ) {
  1506. event.preventDefault();
  1507. return true;
  1508. }
  1509. }
  1510. // Click event may never have fired (Gecko & Opera)
  1511. if ( true === $.data( event.target, this.widgetName + ".preventClickEvent" ) ) {
  1512. $.removeData( event.target, this.widgetName + ".preventClickEvent" );
  1513. }
  1514. // These delegates are required to keep context
  1515. this._mouseMoveDelegate = function( event ) {
  1516. return that._mouseMove( event );
  1517. };
  1518. this._mouseUpDelegate = function( event ) {
  1519. return that._mouseUp( event );
  1520. };
  1521. this.document
  1522. .on( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  1523. .on( "mouseup." + this.widgetName, this._mouseUpDelegate );
  1524. event.preventDefault();
  1525. mouseHandled = true;
  1526. return true;
  1527. },
  1528. _mouseMove: function( event ) {
  1529. // Only check for mouseups outside the document if you've moved inside the document
  1530. // at least once. This prevents the firing of mouseup in the case of IE<9, which will
  1531. // fire a mousemove event if content is placed under the cursor. See #7778
  1532. // Support: IE <9
  1533. if ( this._mouseMoved ) {
  1534. // IE mouseup check - mouseup happened when mouse was out of window
  1535. if ( $.ui.ie && ( !document.documentMode || document.documentMode < 9 ) &&
  1536. !event.button ) {
  1537. return this._mouseUp( event );
  1538. // Iframe mouseup check - mouseup occurred in another document
  1539. } else if ( !event.which ) {
  1540. // Support: Safari <=8 - 9
  1541. // Safari sets which to 0 if you press any of the following keys
  1542. // during a drag (#14461)
  1543. if ( event.originalEvent.altKey || event.originalEvent.ctrlKey ||
  1544. event.originalEvent.metaKey || event.originalEvent.shiftKey ) {
  1545. this.ignoreMissingWhich = true;
  1546. } else if ( !this.ignoreMissingWhich ) {
  1547. return this._mouseUp( event );
  1548. }
  1549. }
  1550. }
  1551. if ( event.which || event.button ) {
  1552. this._mouseMoved = true;
  1553. }
  1554. if ( this._mouseStarted ) {
  1555. this._mouseDrag( event );
  1556. return event.preventDefault();
  1557. }
  1558. if ( this._mouseDistanceMet( event ) && this._mouseDelayMet( event ) ) {
  1559. this._mouseStarted =
  1560. ( this._mouseStart( this._mouseDownEvent, event ) !== false );
  1561. ( this._mouseStarted ? this._mouseDrag( event ) : this._mouseUp( event ) );
  1562. }
  1563. return !this._mouseStarted;
  1564. },
  1565. _mouseUp: function( event ) {
  1566. this.document
  1567. .off( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  1568. .off( "mouseup." + this.widgetName, this._mouseUpDelegate );
  1569. if ( this._mouseStarted ) {
  1570. this._mouseStarted = false;
  1571. if ( event.target === this._mouseDownEvent.target ) {
  1572. $.data( event.target, this.widgetName + ".preventClickEvent", true );
  1573. }
  1574. this._mouseStop( event );
  1575. }
  1576. if ( this._mouseDelayTimer ) {
  1577. clearTimeout( this._mouseDelayTimer );
  1578. delete this._mouseDelayTimer;
  1579. }
  1580. this.ignoreMissingWhich = false;
  1581. mouseHandled = false;
  1582. event.preventDefault();
  1583. },
  1584. _mouseDistanceMet: function( event ) {
  1585. return ( Math.max(
  1586. Math.abs( this._mouseDownEvent.pageX - event.pageX ),
  1587. Math.abs( this._mouseDownEvent.pageY - event.pageY )
  1588. ) >= this.options.distance
  1589. );
  1590. },
  1591. _mouseDelayMet: function( /* event */ ) {
  1592. return this.mouseDelayMet;
  1593. },
  1594. // These are placeholder methods, to be overriden by extending plugin
  1595. _mouseStart: function( /* event */ ) {},
  1596. _mouseDrag: function( /* event */ ) {},
  1597. _mouseStop: function( /* event */ ) {},
  1598. _mouseCapture: function( /* event */ ) { return true; }
  1599. } );
  1600. // $.ui.plugin is deprecated. Use $.widget() extensions instead.
  1601. var plugin = $.ui.plugin = {
  1602. add: function( module, option, set ) {
  1603. var i,
  1604. proto = $.ui[ module ].prototype;
  1605. for ( i in set ) {
  1606. proto.plugins[ i ] = proto.plugins[ i ] || [];
  1607. proto.plugins[ i ].push( [ option, set[ i ] ] );
  1608. }
  1609. },
  1610. call: function( instance, name, args, allowDisconnected ) {
  1611. var i,
  1612. set = instance.plugins[ name ];
  1613. if ( !set ) {
  1614. return;
  1615. }
  1616. if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode ||
  1617. instance.element[ 0 ].parentNode.nodeType === 11 ) ) {
  1618. return;
  1619. }
  1620. for ( i = 0; i < set.length; i++ ) {
  1621. if ( instance.options[ set[ i ][ 0 ] ] ) {
  1622. set[ i ][ 1 ].apply( instance.element, args );
  1623. }
  1624. }
  1625. }
  1626. };
  1627. var safeActiveElement = $.ui.safeActiveElement = function( document ) {
  1628. var activeElement;
  1629. // Support: IE 9 only
  1630. // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
  1631. try {
  1632. activeElement = document.activeElement;
  1633. } catch ( error ) {
  1634. activeElement = document.body;
  1635. }
  1636. // Support: IE 9 - 11 only
  1637. // IE may return null instead of an element
  1638. // Interestingly, this only seems to occur when NOT in an iframe
  1639. if ( !activeElement ) {
  1640. activeElement = document.body;
  1641. }
  1642. // Support: IE 11 only
  1643. // IE11 returns a seemingly empty object in some cases when accessing
  1644. // document.activeElement from an <iframe>
  1645. if ( !activeElement.nodeName ) {
  1646. activeElement = document.body;
  1647. }
  1648. return activeElement;
  1649. };
  1650. var safeBlur = $.ui.safeBlur = function( element ) {
  1651. // Support: IE9 - 10 only
  1652. // If the <body> is blurred, IE will switch windows, see #9420
  1653. if ( element && element.nodeName.toLowerCase() !== "body" ) {
  1654. $( element ).trigger( "blur" );
  1655. }
  1656. };
  1657. /*!
  1658. * jQuery UI Draggable 1.12.1
  1659. * http://jqueryui.com
  1660. *
  1661. * Copyright jQuery Foundation and other contributors
  1662. * Released under the MIT license.
  1663. * http://jquery.org/license
  1664. */
  1665. //>>label: Draggable
  1666. //>>group: Interactions
  1667. //>>description: Enables dragging functionality for any element.
  1668. //>>docs: http://api.jqueryui.com/draggable/
  1669. //>>demos: http://jqueryui.com/draggable/
  1670. //>>css.structure: ../../themes/base/draggable.css
  1671. $.widget( "ui.draggable", $.ui.mouse, {
  1672. version: "1.12.1",
  1673. widgetEventPrefix: "drag",
  1674. options: {
  1675. addClasses: true,
  1676. appendTo: "parent",
  1677. axis: false,
  1678. connectToSortable: false,
  1679. containment: false,
  1680. cursor: "auto",
  1681. cursorAt: false,
  1682. grid: false,
  1683. handle: false,
  1684. helper: "original",
  1685. iframeFix: false,
  1686. opacity: false,
  1687. refreshPositions: false,
  1688. revert: false,
  1689. revertDuration: 500,
  1690. scope: "default",
  1691. scroll: true,
  1692. scrollSensitivity: 20,
  1693. scrollSpeed: 20,
  1694. snap: false,
  1695. snapMode: "both",
  1696. snapTolerance: 20,
  1697. stack: false,
  1698. zIndex: false,
  1699. // Callbacks
  1700. drag: null,
  1701. start: null,
  1702. stop: null
  1703. },
  1704. _create: function() {
  1705. if ( this.options.helper === "original" ) {
  1706. this._setPositionRelative();
  1707. }
  1708. if ( this.options.addClasses ) {
  1709. this._addClass( "ui-draggable" );
  1710. }
  1711. this._setHandleClassName();
  1712. this._mouseInit();
  1713. },
  1714. _setOption: function( key, value ) {
  1715. this._super( key, value );
  1716. if ( key === "handle" ) {
  1717. this._removeHandleClassName();
  1718. this._setHandleClassName();
  1719. }
  1720. },
  1721. _destroy: function() {
  1722. if ( ( this.helper || this.element ).is( ".ui-draggable-dragging" ) ) {
  1723. this.destroyOnClear = true;
  1724. return;
  1725. }
  1726. this._removeHandleClassName();
  1727. this._mouseDestroy();
  1728. },
  1729. _mouseCapture: function( event ) {
  1730. var o = this.options;
  1731. // Among others, prevent a drag on a resizable-handle
  1732. if ( this.helper || o.disabled ||
  1733. $( event.target ).closest( ".ui-resizable-handle" ).length > 0 ) {
  1734. return false;
  1735. }
  1736. //Quit if we're not on a valid handle
  1737. this.handle = this._getHandle( event );
  1738. if ( !this.handle ) {
  1739. return false;
  1740. }
  1741. this._blurActiveElement( event );
  1742. this._blockFrames( o.iframeFix === true ? "iframe" : o.iframeFix );
  1743. return true;
  1744. },
  1745. _blockFrames: function( selector ) {
  1746. this.iframeBlocks = this.document.find( selector ).map( function() {
  1747. var iframe = $( this );
  1748. return $( "<div>" )
  1749. .css( "position", "absolute" )
  1750. .appendTo( iframe.parent() )
  1751. .outerWidth( iframe.outerWidth() )
  1752. .outerHeight( iframe.outerHeight() )
  1753. .offset( iframe.offset() )[ 0 ];
  1754. } );
  1755. },
  1756. _unblockFrames: function() {
  1757. if ( this.iframeBlocks ) {
  1758. this.iframeBlocks.remove();
  1759. delete this.iframeBlocks;
  1760. }
  1761. },
  1762. _blurActiveElement: function( event ) {
  1763. var activeElement = $.ui.safeActiveElement( this.document[ 0 ] ),
  1764. target = $( event.target );
  1765. // Don't blur if the event occurred on an element that is within
  1766. // the currently focused element
  1767. // See #10527, #12472
  1768. if ( target.closest( activeElement ).length ) {
  1769. return;
  1770. }
  1771. // Blur any element that currently has focus, see #4261
  1772. $.ui.safeBlur( activeElement );
  1773. },
  1774. _mouseStart: function( event ) {
  1775. var o = this.options;
  1776. //Create and append the visible helper
  1777. this.helper = this._createHelper( event );
  1778. this._addClass( this.helper, "ui-draggable-dragging" );
  1779. //Cache the helper size
  1780. this._cacheHelperProportions();
  1781. //If ddmanager is used for droppables, set the global draggable
  1782. if ( $.ui.ddmanager ) {
  1783. $.ui.ddmanager.current = this;
  1784. }
  1785. /*
  1786. * - Position generation -
  1787. * This block generates everything position related - it's the core of draggables.
  1788. */
  1789. //Cache the margins of the original element
  1790. this._cacheMargins();
  1791. //Store the helper's css position
  1792. this.cssPosition = this.helper.css( "position" );
  1793. this.scrollParent = this.helper.scrollParent( true );
  1794. this.offsetParent = this.helper.offsetParent();
  1795. this.hasFixedAncestor = this.helper.parents().filter( function() {
  1796. return $( this ).css( "position" ) === "fixed";
  1797. } ).length > 0;
  1798. //The element's absolute position on the page minus margins
  1799. this.positionAbs = this.element.offset();
  1800. this._refreshOffsets( event );
  1801. //Generate the original position
  1802. this.originalPosition = this.position = this._generatePosition( event, false );
  1803. this.originalPageX = event.pageX;
  1804. this.originalPageY = event.pageY;
  1805. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  1806. ( o.cursorAt && this._adjustOffsetFromHelper( o.cursorAt ) );
  1807. //Set a containment if given in the options
  1808. this._setContainment();
  1809. //Trigger event + callbacks
  1810. if ( this._trigger( "start", event ) === false ) {
  1811. this._clear();
  1812. return false;
  1813. }
  1814. //Recache the helper size
  1815. this._cacheHelperProportions();
  1816. //Prepare the droppable offsets
  1817. if ( $.ui.ddmanager && !o.dropBehaviour ) {
  1818. $.ui.ddmanager.prepareOffsets( this, event );
  1819. }
  1820. // Execute the drag once - this causes the helper not to be visible before getting its
  1821. // correct position
  1822. this._mouseDrag( event, true );
  1823. // If the ddmanager is used for droppables, inform the manager that dragging has started
  1824. // (see #5003)
  1825. if ( $.ui.ddmanager ) {
  1826. $.ui.ddmanager.dragStart( this, event );
  1827. }
  1828. return true;
  1829. },
  1830. _refreshOffsets: function( event ) {
  1831. this.offset = {
  1832. top: this.positionAbs.top - this.margins.top,
  1833. left: this.positionAbs.left - this.margins.left,
  1834. scroll: false,
  1835. parent: this._getParentOffset(),
  1836. relative: this._getRelativeOffset()
  1837. };
  1838. this.offset.click = {
  1839. left: event.pageX - this.offset.left,
  1840. top: event.pageY - this.offset.top
  1841. };
  1842. },
  1843. _mouseDrag: function( event, noPropagation ) {
  1844. // reset any necessary cached properties (see #5009)
  1845. if ( this.hasFixedAncestor ) {
  1846. this.offset.parent = this._getParentOffset();
  1847. }
  1848. //Compute the helpers position
  1849. this.position = this._generatePosition( event, true );
  1850. this.positionAbs = this._convertPositionTo( "absolute" );
  1851. //Call plugins and callbacks and use the resulting position if something is returned
  1852. if ( !noPropagation ) {
  1853. var ui = this._uiHash();
  1854. if ( this._trigger( "drag", event, ui ) === false ) {
  1855. this._mouseUp( new $.Event( "mouseup", event ) );
  1856. return false;
  1857. }
  1858. this.position = ui.position;
  1859. }
  1860. this.helper[ 0 ].style.left = this.position.left + "px";
  1861. this.helper[ 0 ].style.top = this.position.top + "px";
  1862. if ( $.ui.ddmanager ) {
  1863. $.ui.ddmanager.drag( this, event );
  1864. }
  1865. return false;
  1866. },
  1867. _mouseStop: function( event ) {
  1868. //If we are using droppables, inform the manager about the drop
  1869. var that = this,
  1870. dropped = false;
  1871. if ( $.ui.ddmanager && !this.options.dropBehaviour ) {
  1872. dropped = $.ui.ddmanager.drop( this, event );
  1873. }
  1874. //if a drop comes from outside (a sortable)
  1875. if ( this.dropped ) {
  1876. dropped = this.dropped;
  1877. this.dropped = false;
  1878. }
  1879. if ( ( this.options.revert === "invalid" && !dropped ) ||
  1880. ( this.options.revert === "valid" && dropped ) ||
  1881. this.options.revert === true || ( $.isFunction( this.options.revert ) &&
  1882. this.options.revert.call( this.element, dropped ) )
  1883. ) {
  1884. $( this.helper ).animate(
  1885. this.originalPosition,
  1886. parseInt( this.options.revertDuration, 10 ),
  1887. function() {
  1888. if ( that._trigger( "stop", event ) !== false ) {
  1889. that._clear();
  1890. }
  1891. }
  1892. );
  1893. } else {
  1894. if ( this._trigger( "stop", event ) !== false ) {
  1895. this._clear();
  1896. }
  1897. }
  1898. return false;
  1899. },
  1900. _mouseUp: function( event ) {
  1901. this._unblockFrames();
  1902. // If the ddmanager is used for droppables, inform the manager that dragging has stopped
  1903. // (see #5003)
  1904. if ( $.ui.ddmanager ) {
  1905. $.ui.ddmanager.dragStop( this, event );
  1906. }
  1907. // Only need to focus if the event occurred on the draggable itself, see #10527
  1908. if ( this.handleElement.is( event.target ) ) {
  1909. // The interaction is over; whether or not the click resulted in a drag,
  1910. // focus the element
  1911. this.element.trigger( "focus" );
  1912. }
  1913. return $.ui.mouse.prototype._mouseUp.call( this, event );
  1914. },
  1915. cancel: function() {
  1916. if ( this.helper.is( ".ui-draggable-dragging" ) ) {
  1917. this._mouseUp( new $.Event( "mouseup", { target: this.element[ 0 ] } ) );
  1918. } else {
  1919. this._clear();
  1920. }
  1921. return this;
  1922. },
  1923. _getHandle: function( event ) {
  1924. return this.options.handle ?
  1925. !!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
  1926. true;
  1927. },
  1928. _setHandleClassName: function() {
  1929. this.handleElement = this.options.handle ?
  1930. this.element.find( this.options.handle ) : this.element;
  1931. this._addClass( this.handleElement, "ui-draggable-handle" );
  1932. },
  1933. _removeHandleClassName: function() {
  1934. this._removeClass( this.handleElement, "ui-draggable-handle" );
  1935. },
  1936. _createHelper: function( event ) {
  1937. var o = this.options,
  1938. helperIsFunction = $.isFunction( o.helper ),
  1939. helper = helperIsFunction ?
  1940. $( o.helper.apply( this.element[ 0 ], [ event ] ) ) :
  1941. ( o.helper === "clone" ?
  1942. this.element.clone().removeAttr( "id" ) :
  1943. this.element );
  1944. if ( !helper.parents( "body" ).length ) {
  1945. helper.appendTo( ( o.appendTo === "parent" ?
  1946. this.element[ 0 ].parentNode :
  1947. o.appendTo ) );
  1948. }
  1949. // Http://bugs.jqueryui.com/ticket/9446
  1950. // a helper function can return the original element
  1951. // which wouldn't have been set to relative in _create
  1952. if ( helperIsFunction && helper[ 0 ] === this.element[ 0 ] ) {
  1953. this._setPositionRelative();
  1954. }
  1955. if ( helper[ 0 ] !== this.element[ 0 ] &&
  1956. !( /(fixed|absolute)/ ).test( helper.css( "position" ) ) ) {
  1957. helper.css( "position", "absolute" );
  1958. }
  1959. return helper;
  1960. },
  1961. _setPositionRelative: function() {
  1962. if ( !( /^(?:r|a|f)/ ).test( this.element.css( "position" ) ) ) {
  1963. this.element[ 0 ].style.position = "relative";
  1964. }
  1965. },
  1966. _adjustOffsetFromHelper: function( obj ) {
  1967. if ( typeof obj === "string" ) {
  1968. obj = obj.split( " " );
  1969. }
  1970. if ( $.isArray( obj ) ) {
  1971. obj = { left: +obj[ 0 ], top: +obj[ 1 ] || 0 };
  1972. }
  1973. if ( "left" in obj ) {
  1974. this.offset.click.left = obj.left + this.margins.left;
  1975. }
  1976. if ( "right" in obj ) {
  1977. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  1978. }
  1979. if ( "top" in obj ) {
  1980. this.offset.click.top = obj.top + this.margins.top;
  1981. }
  1982. if ( "bottom" in obj ) {
  1983. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  1984. }
  1985. },
  1986. _isRootNode: function( element ) {
  1987. return ( /(html|body)/i ).test( element.tagName ) || element === this.document[ 0 ];
  1988. },
  1989. _getParentOffset: function() {
  1990. //Get the offsetParent and cache its position
  1991. var po = this.offsetParent.offset(),
  1992. document = this.document[ 0 ];
  1993. // This is a special case where we need to modify a offset calculated on start, since the
  1994. // following happened:
  1995. // 1. The position of the helper is absolute, so it's position is calculated based on the
  1996. // next positioned parent
  1997. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't
  1998. // the document, which means that the scroll is included in the initial calculation of the
  1999. // offset of the parent, and never recalculated upon drag
  2000. if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== document &&
  2001. $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) {
  2002. po.left += this.scrollParent.scrollLeft();
  2003. po.top += this.scrollParent.scrollTop();
  2004. }
  2005. if ( this._isRootNode( this.offsetParent[ 0 ] ) ) {
  2006. po = { top: 0, left: 0 };
  2007. }
  2008. return {
  2009. top: po.top + ( parseInt( this.offsetParent.css( "borderTopWidth" ), 10 ) || 0 ),
  2010. left: po.left + ( parseInt( this.offsetParent.css( "borderLeftWidth" ), 10 ) || 0 )
  2011. };
  2012. },
  2013. _getRelativeOffset: function() {
  2014. if ( this.cssPosition !== "relative" ) {
  2015. return { top: 0, left: 0 };
  2016. }
  2017. var p = this.element.position(),
  2018. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
  2019. return {
  2020. top: p.top - ( parseInt( this.helper.css( "top" ), 10 ) || 0 ) +
  2021. ( !scrollIsRootNode ? this.scrollParent.scrollTop() : 0 ),
  2022. left: p.left - ( parseInt( this.helper.css( "left" ), 10 ) || 0 ) +
  2023. ( !scrollIsRootNode ? this.scrollParent.scrollLeft() : 0 )
  2024. };
  2025. },
  2026. _cacheMargins: function() {
  2027. this.margins = {
  2028. left: ( parseInt( this.element.css( "marginLeft" ), 10 ) || 0 ),
  2029. top: ( parseInt( this.element.css( "marginTop" ), 10 ) || 0 ),
  2030. right: ( parseInt( this.element.css( "marginRight" ), 10 ) || 0 ),
  2031. bottom: ( parseInt( this.element.css( "marginBottom" ), 10 ) || 0 )
  2032. };
  2033. },
  2034. _cacheHelperProportions: function() {
  2035. this.helperProportions = {
  2036. width: this.helper.outerWidth(),
  2037. height: this.helper.outerHeight()
  2038. };
  2039. },
  2040. _setContainment: function() {
  2041. var isUserScrollable, c, ce,
  2042. o = this.options,
  2043. document = this.document[ 0 ];
  2044. this.relativeContainer = null;
  2045. if ( !o.containment ) {
  2046. this.containment = null;
  2047. return;
  2048. }
  2049. if ( o.containment === "window" ) {
  2050. this.containment = [
  2051. $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
  2052. $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top,
  2053. $( window ).scrollLeft() + $( window ).width() -
  2054. this.helperProportions.width - this.margins.left,
  2055. $( window ).scrollTop() +
  2056. ( $( window ).height() || document.body.parentNode.scrollHeight ) -
  2057. this.helperProportions.height - this.margins.top
  2058. ];
  2059. return;
  2060. }
  2061. if ( o.containment === "document" ) {
  2062. this.containment = [
  2063. 0,
  2064. 0,
  2065. $( document ).width() - this.helperProportions.width - this.margins.left,
  2066. ( $( document ).height() || document.body.parentNode.scrollHeight ) -
  2067. this.helperProportions.height - this.margins.top
  2068. ];
  2069. return;
  2070. }
  2071. if ( o.containment.constructor === Array ) {
  2072. this.containment = o.containment;
  2073. return;
  2074. }
  2075. if ( o.containment === "parent" ) {
  2076. o.containment = this.helper[ 0 ].parentNode;
  2077. }
  2078. c = $( o.containment );
  2079. ce = c[ 0 ];
  2080. if ( !ce ) {
  2081. return;
  2082. }
  2083. isUserScrollable = /(scroll|auto)/.test( c.css( "overflow" ) );
  2084. this.containment = [
  2085. ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) +
  2086. ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ),
  2087. ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) +
  2088. ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ),
  2089. ( isUserScrollable ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) -
  2090. ( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) -
  2091. ( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) -
  2092. this.helperProportions.width -
  2093. this.margins.left -
  2094. this.margins.right,
  2095. ( isUserScrollable ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) -
  2096. ( parseInt( c.css( "borderBottomWidth" ), 10 ) || 0 ) -
  2097. ( parseInt( c.css( "paddingBottom" ), 10 ) || 0 ) -
  2098. this.helperProportions.height -
  2099. this.margins.top -
  2100. this.margins.bottom
  2101. ];
  2102. this.relativeContainer = c;
  2103. },
  2104. _convertPositionTo: function( d, pos ) {
  2105. if ( !pos ) {
  2106. pos = this.position;
  2107. }
  2108. var mod = d === "absolute" ? 1 : -1,
  2109. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
  2110. return {
  2111. top: (
  2112. // The absolute mouse position
  2113. pos.top +
  2114. // Only for relative positioned nodes: Relative offset from element to offset parent
  2115. this.offset.relative.top * mod +
  2116. // The offsetParent's offset without borders (offset + border)
  2117. this.offset.parent.top * mod -
  2118. ( ( this.cssPosition === "fixed" ?
  2119. -this.offset.scroll.top :
  2120. ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) * mod )
  2121. ),
  2122. left: (
  2123. // The absolute mouse position
  2124. pos.left +
  2125. // Only for relative positioned nodes: Relative offset from element to offset parent
  2126. this.offset.relative.left * mod +
  2127. // The offsetParent's offset without borders (offset + border)
  2128. this.offset.parent.left * mod -
  2129. ( ( this.cssPosition === "fixed" ?
  2130. -this.offset.scroll.left :
  2131. ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) * mod )
  2132. )
  2133. };
  2134. },
  2135. _generatePosition: function( event, constrainPosition ) {
  2136. var containment, co, top, left,
  2137. o = this.options,
  2138. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] ),
  2139. pageX = event.pageX,
  2140. pageY = event.pageY;
  2141. // Cache the scroll
  2142. if ( !scrollIsRootNode || !this.offset.scroll ) {
  2143. this.offset.scroll = {
  2144. top: this.scrollParent.scrollTop(),
  2145. left: this.scrollParent.scrollLeft()
  2146. };
  2147. }
  2148. /*
  2149. * - Position constraining -
  2150. * Constrain the position to a mix of grid, containment.
  2151. */
  2152. // If we are not dragging yet, we won't check for options
  2153. if ( constrainPosition ) {
  2154. if ( this.containment ) {
  2155. if ( this.relativeContainer ) {
  2156. co = this.relativeContainer.offset();
  2157. containment = [
  2158. this.containment[ 0 ] + co.left,
  2159. this.containment[ 1 ] + co.top,
  2160. this.containment[ 2 ] + co.left,
  2161. this.containment[ 3 ] + co.top
  2162. ];
  2163. } else {
  2164. containment = this.containment;
  2165. }
  2166. if ( event.pageX - this.offset.click.left < containment[ 0 ] ) {
  2167. pageX = containment[ 0 ] + this.offset.click.left;
  2168. }
  2169. if ( event.pageY - this.offset.click.top < containment[ 1 ] ) {
  2170. pageY = containment[ 1 ] + this.offset.click.top;
  2171. }
  2172. if ( event.pageX - this.offset.click.left > containment[ 2 ] ) {
  2173. pageX = containment[ 2 ] + this.offset.click.left;
  2174. }
  2175. if ( event.pageY - this.offset.click.top > containment[ 3 ] ) {
  2176. pageY = containment[ 3 ] + this.offset.click.top;
  2177. }
  2178. }
  2179. if ( o.grid ) {
  2180. //Check for grid elements set to 0 to prevent divide by 0 error causing invalid
  2181. // argument errors in IE (see ticket #6950)
  2182. top = o.grid[ 1 ] ? this.originalPageY + Math.round( ( pageY -
  2183. this.originalPageY ) / o.grid[ 1 ] ) * o.grid[ 1 ] : this.originalPageY;
  2184. pageY = containment ? ( ( top - this.offset.click.top >= containment[ 1 ] ||
  2185. top - this.offset.click.top > containment[ 3 ] ) ?
  2186. top :
  2187. ( ( top - this.offset.click.top >= containment[ 1 ] ) ?
  2188. top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) : top;
  2189. left = o.grid[ 0 ] ? this.originalPageX +
  2190. Math.round( ( pageX - this.originalPageX ) / o.grid[ 0 ] ) * o.grid[ 0 ] :
  2191. this.originalPageX;
  2192. pageX = containment ? ( ( left - this.offset.click.left >= containment[ 0 ] ||
  2193. left - this.offset.click.left > containment[ 2 ] ) ?
  2194. left :
  2195. ( ( left - this.offset.click.left >= containment[ 0 ] ) ?
  2196. left - o.grid[ 0 ] : left + o.grid[ 0 ] ) ) : left;
  2197. }
  2198. if ( o.axis === "y" ) {
  2199. pageX = this.originalPageX;
  2200. }
  2201. if ( o.axis === "x" ) {
  2202. pageY = this.originalPageY;
  2203. }
  2204. }
  2205. return {
  2206. top: (
  2207. // The absolute mouse position
  2208. pageY -
  2209. // Click offset (relative to the element)
  2210. this.offset.click.top -
  2211. // Only for relative positioned nodes: Relative offset from element to offset parent
  2212. this.offset.relative.top -
  2213. // The offsetParent's offset without borders (offset + border)
  2214. this.offset.parent.top +
  2215. ( this.cssPosition === "fixed" ?
  2216. -this.offset.scroll.top :
  2217. ( scrollIsRootNode ? 0 : this.offset.scroll.top ) )
  2218. ),
  2219. left: (
  2220. // The absolute mouse position
  2221. pageX -
  2222. // Click offset (relative to the element)
  2223. this.offset.click.left -
  2224. // Only for relative positioned nodes: Relative offset from element to offset parent
  2225. this.offset.relative.left -
  2226. // The offsetParent's offset without borders (offset + border)
  2227. this.offset.parent.left +
  2228. ( this.cssPosition === "fixed" ?
  2229. -this.offset.scroll.left :
  2230. ( scrollIsRootNode ? 0 : this.offset.scroll.left ) )
  2231. )
  2232. };
  2233. },
  2234. _clear: function() {
  2235. this._removeClass( this.helper, "ui-draggable-dragging" );
  2236. if ( this.helper[ 0 ] !== this.element[ 0 ] && !this.cancelHelperRemoval ) {
  2237. this.helper.remove();
  2238. }
  2239. this.helper = null;
  2240. this.cancelHelperRemoval = false;
  2241. if ( this.destroyOnClear ) {
  2242. this.destroy();
  2243. }
  2244. },
  2245. // From now on bulk stuff - mainly helpers
  2246. _trigger: function( type, event, ui ) {
  2247. ui = ui || this._uiHash();
  2248. $.ui.plugin.call( this, type, [ event, ui, this ], true );
  2249. // Absolute position and offset (see #6884 ) have to be recalculated after plugins
  2250. if ( /^(drag|start|stop)/.test( type ) ) {
  2251. this.positionAbs = this._convertPositionTo( "absolute" );
  2252. ui.offset = this.positionAbs;
  2253. }
  2254. return $.Widget.prototype._trigger.call( this, type, event, ui );
  2255. },
  2256. plugins: {},
  2257. _uiHash: function() {
  2258. return {
  2259. helper: this.helper,
  2260. position: this.position,
  2261. originalPosition: this.originalPosition,
  2262. offset: this.positionAbs
  2263. };
  2264. }
  2265. } );
  2266. $.ui.plugin.add( "draggable", "connectToSortable", {
  2267. start: function( event, ui, draggable ) {
  2268. var uiSortable = $.extend( {}, ui, {
  2269. item: draggable.element
  2270. } );
  2271. draggable.sortables = [];
  2272. $( draggable.options.connectToSortable ).each( function() {
  2273. var sortable = $( this ).sortable( "instance" );
  2274. if ( sortable && !sortable.options.disabled ) {
  2275. draggable.sortables.push( sortable );
  2276. // RefreshPositions is called at drag start to refresh the containerCache
  2277. // which is used in drag. This ensures it's initialized and synchronized
  2278. // with any changes that might have happened on the page since initialization.
  2279. sortable.refreshPositions();
  2280. sortable._trigger( "activate", event, uiSortable );
  2281. }
  2282. } );
  2283. },
  2284. stop: function( event, ui, draggable ) {
  2285. var uiSortable = $.extend( {}, ui, {
  2286. item: draggable.element
  2287. } );
  2288. draggable.cancelHelperRemoval = false;
  2289. $.each( draggable.sortables, function() {
  2290. var sortable = this;
  2291. if ( sortable.isOver ) {
  2292. sortable.isOver = 0;
  2293. // Allow this sortable to handle removing the helper
  2294. draggable.cancelHelperRemoval = true;
  2295. sortable.cancelHelperRemoval = false;
  2296. // Use _storedCSS To restore properties in the sortable,
  2297. // as this also handles revert (#9675) since the draggable
  2298. // may have modified them in unexpected ways (#8809)
  2299. sortable._storedCSS = {
  2300. position: sortable.placeholder.css( "position" ),
  2301. top: sortable.placeholder.css( "top" ),
  2302. left: sortable.placeholder.css( "left" )
  2303. };
  2304. sortable._mouseStop( event );
  2305. // Once drag has ended, the sortable should return to using
  2306. // its original helper, not the shared helper from draggable
  2307. sortable.options.helper = sortable.options._helper;
  2308. } else {
  2309. // Prevent this Sortable from removing the helper.
  2310. // However, don't set the draggable to remove the helper
  2311. // either as another connected Sortable may yet handle the removal.
  2312. sortable.cancelHelperRemoval = true;
  2313. sortable._trigger( "deactivate", event, uiSortable );
  2314. }
  2315. } );
  2316. },
  2317. drag: function( event, ui, draggable ) {
  2318. $.each( draggable.sortables, function() {
  2319. var innermostIntersecting = false,
  2320. sortable = this;
  2321. // Copy over variables that sortable's _intersectsWith uses
  2322. sortable.positionAbs = draggable.positionAbs;
  2323. sortable.helperProportions = draggable.helperProportions;
  2324. sortable.offset.click = draggable.offset.click;
  2325. if ( sortable._intersectsWith( sortable.containerCache ) ) {
  2326. innermostIntersecting = true;
  2327. $.each( draggable.sortables, function() {
  2328. // Copy over variables that sortable's _intersectsWith uses
  2329. this.positionAbs = draggable.positionAbs;
  2330. this.helperProportions = draggable.helperProportions;
  2331. this.offset.click = draggable.offset.click;
  2332. if ( this !== sortable &&
  2333. this._intersectsWith( this.containerCache ) &&
  2334. $.contains( sortable.element[ 0 ], this.element[ 0 ] ) ) {
  2335. innermostIntersecting = false;
  2336. }
  2337. return innermostIntersecting;
  2338. } );
  2339. }
  2340. if ( innermostIntersecting ) {
  2341. // If it intersects, we use a little isOver variable and set it once,
  2342. // so that the move-in stuff gets fired only once.
  2343. if ( !sortable.isOver ) {
  2344. sortable.isOver = 1;
  2345. // Store draggable's parent in case we need to reappend to it later.
  2346. draggable._parent = ui.helper.parent();
  2347. sortable.currentItem = ui.helper
  2348. .appendTo( sortable.element )
  2349. .data( "ui-sortable-item", true );
  2350. // Store helper option to later restore it
  2351. sortable.options._helper = sortable.options.helper;
  2352. sortable.options.helper = function() {
  2353. return ui.helper[ 0 ];
  2354. };
  2355. // Fire the start events of the sortable with our passed browser event,
  2356. // and our own helper (so it doesn't create a new one)
  2357. event.target = sortable.currentItem[ 0 ];
  2358. sortable._mouseCapture( event, true );
  2359. sortable._mouseStart( event, true, true );
  2360. // Because the browser event is way off the new appended portlet,
  2361. // modify necessary variables to reflect the changes
  2362. sortable.offset.click.top = draggable.offset.click.top;
  2363. sortable.offset.click.left = draggable.offset.click.left;
  2364. sortable.offset.parent.left -= draggable.offset.parent.left -
  2365. sortable.offset.parent.left;
  2366. sortable.offset.parent.top -= draggable.offset.parent.top -
  2367. sortable.offset.parent.top;
  2368. draggable._trigger( "toSortable", event );
  2369. // Inform draggable that the helper is in a valid drop zone,
  2370. // used solely in the revert option to handle "valid/invalid".
  2371. draggable.dropped = sortable.element;
  2372. // Need to refreshPositions of all sortables in the case that
  2373. // adding to one sortable changes the location of the other sortables (#9675)
  2374. $.each( draggable.sortables, function() {
  2375. this.refreshPositions();
  2376. } );
  2377. // Hack so receive/update callbacks work (mostly)
  2378. draggable.currentItem = draggable.element;
  2379. sortable.fromOutside = draggable;
  2380. }
  2381. if ( sortable.currentItem ) {
  2382. sortable._mouseDrag( event );
  2383. // Copy the sortable's position because the draggable's can potentially reflect
  2384. // a relative position, while sortable is always absolute, which the dragged
  2385. // element has now become. (#8809)
  2386. ui.position = sortable.position;
  2387. }
  2388. } else {
  2389. // If it doesn't intersect with the sortable, and it intersected before,
  2390. // we fake the drag stop of the sortable, but make sure it doesn't remove
  2391. // the helper by using cancelHelperRemoval.
  2392. if ( sortable.isOver ) {
  2393. sortable.isOver = 0;
  2394. sortable.cancelHelperRemoval = true;
  2395. // Calling sortable's mouseStop would trigger a revert,
  2396. // so revert must be temporarily false until after mouseStop is called.
  2397. sortable.options._revert = sortable.options.revert;
  2398. sortable.options.revert = false;
  2399. sortable._trigger( "out", event, sortable._uiHash( sortable ) );
  2400. sortable._mouseStop( event, true );
  2401. // Restore sortable behaviors that were modfied
  2402. // when the draggable entered the sortable area (#9481)
  2403. sortable.options.revert = sortable.options._revert;
  2404. sortable.options.helper = sortable.options._helper;
  2405. if ( sortable.placeholder ) {
  2406. sortable.placeholder.remove();
  2407. }
  2408. // Restore and recalculate the draggable's offset considering the sortable
  2409. // may have modified them in unexpected ways. (#8809, #10669)
  2410. ui.helper.appendTo( draggable._parent );
  2411. draggable._refreshOffsets( event );
  2412. ui.position = draggable._generatePosition( event, true );
  2413. draggable._trigger( "fromSortable", event );
  2414. // Inform draggable that the helper is no longer in a valid drop zone
  2415. draggable.dropped = false;
  2416. // Need to refreshPositions of all sortables just in case removing
  2417. // from one sortable changes the location of other sortables (#9675)
  2418. $.each( draggable.sortables, function() {
  2419. this.refreshPositions();
  2420. } );
  2421. }
  2422. }
  2423. } );
  2424. }
  2425. } );
  2426. $.ui.plugin.add( "draggable", "cursor", {
  2427. start: function( event, ui, instance ) {
  2428. var t = $( "body" ),
  2429. o = instance.options;
  2430. if ( t.css( "cursor" ) ) {
  2431. o._cursor = t.css( "cursor" );
  2432. }
  2433. t.css( "cursor", o.cursor );
  2434. },
  2435. stop: function( event, ui, instance ) {
  2436. var o = instance.options;
  2437. if ( o._cursor ) {
  2438. $( "body" ).css( "cursor", o._cursor );
  2439. }
  2440. }
  2441. } );
  2442. $.ui.plugin.add( "draggable", "opacity", {
  2443. start: function( event, ui, instance ) {
  2444. var t = $( ui.helper ),
  2445. o = instance.options;
  2446. if ( t.css( "opacity" ) ) {
  2447. o._opacity = t.css( "opacity" );
  2448. }
  2449. t.css( "opacity", o.opacity );
  2450. },
  2451. stop: function( event, ui, instance ) {
  2452. var o = instance.options;
  2453. if ( o._opacity ) {
  2454. $( ui.helper ).css( "opacity", o._opacity );
  2455. }
  2456. }
  2457. } );
  2458. $.ui.plugin.add( "draggable", "scroll", {
  2459. start: function( event, ui, i ) {
  2460. if ( !i.scrollParentNotHidden ) {
  2461. i.scrollParentNotHidden = i.helper.scrollParent( false );
  2462. }
  2463. if ( i.scrollParentNotHidden[ 0 ] !== i.document[ 0 ] &&
  2464. i.scrollParentNotHidden[ 0 ].tagName !== "HTML" ) {
  2465. i.overflowOffset = i.scrollParentNotHidden.offset();
  2466. }
  2467. },
  2468. drag: function( event, ui, i ) {
  2469. var o = i.options,
  2470. scrolled = false,
  2471. scrollParent = i.scrollParentNotHidden[ 0 ],
  2472. document = i.document[ 0 ];
  2473. if ( scrollParent !== document && scrollParent.tagName !== "HTML" ) {
  2474. if ( !o.axis || o.axis !== "x" ) {
  2475. if ( ( i.overflowOffset.top + scrollParent.offsetHeight ) - event.pageY <
  2476. o.scrollSensitivity ) {
  2477. scrollParent.scrollTop = scrolled = scrollParent.scrollTop + o.scrollSpeed;
  2478. } else if ( event.pageY - i.overflowOffset.top < o.scrollSensitivity ) {
  2479. scrollParent.scrollTop = scrolled = scrollParent.scrollTop - o.scrollSpeed;
  2480. }
  2481. }
  2482. if ( !o.axis || o.axis !== "y" ) {
  2483. if ( ( i.overflowOffset.left + scrollParent.offsetWidth ) - event.pageX <
  2484. o.scrollSensitivity ) {
  2485. scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft + o.scrollSpeed;
  2486. } else if ( event.pageX - i.overflowOffset.left < o.scrollSensitivity ) {
  2487. scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft - o.scrollSpeed;
  2488. }
  2489. }
  2490. } else {
  2491. if ( !o.axis || o.axis !== "x" ) {
  2492. if ( event.pageY - $( document ).scrollTop() < o.scrollSensitivity ) {
  2493. scrolled = $( document ).scrollTop( $( document ).scrollTop() - o.scrollSpeed );
  2494. } else if ( $( window ).height() - ( event.pageY - $( document ).scrollTop() ) <
  2495. o.scrollSensitivity ) {
  2496. scrolled = $( document ).scrollTop( $( document ).scrollTop() + o.scrollSpeed );
  2497. }
  2498. }
  2499. if ( !o.axis || o.axis !== "y" ) {
  2500. if ( event.pageX - $( document ).scrollLeft() < o.scrollSensitivity ) {
  2501. scrolled = $( document ).scrollLeft(
  2502. $( document ).scrollLeft() - o.scrollSpeed
  2503. );
  2504. } else if ( $( window ).width() - ( event.pageX - $( document ).scrollLeft() ) <
  2505. o.scrollSensitivity ) {
  2506. scrolled = $( document ).scrollLeft(
  2507. $( document ).scrollLeft() + o.scrollSpeed
  2508. );
  2509. }
  2510. }
  2511. }
  2512. if ( scrolled !== false && $.ui.ddmanager && !o.dropBehaviour ) {
  2513. $.ui.ddmanager.prepareOffsets( i, event );
  2514. }
  2515. }
  2516. } );
  2517. $.ui.plugin.add( "draggable", "snap", {
  2518. start: function( event, ui, i ) {
  2519. var o = i.options;
  2520. i.snapElements = [];
  2521. $( o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap )
  2522. .each( function() {
  2523. var $t = $( this ),
  2524. $o = $t.offset();
  2525. if ( this !== i.element[ 0 ] ) {
  2526. i.snapElements.push( {
  2527. item: this,
  2528. width: $t.outerWidth(), height: $t.outerHeight(),
  2529. top: $o.top, left: $o.left
  2530. } );
  2531. }
  2532. } );
  2533. },
  2534. drag: function( event, ui, inst ) {
  2535. var ts, bs, ls, rs, l, r, t, b, i, first,
  2536. o = inst.options,
  2537. d = o.snapTolerance,
  2538. x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
  2539. y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
  2540. for ( i = inst.snapElements.length - 1; i >= 0; i-- ) {
  2541. l = inst.snapElements[ i ].left - inst.margins.left;
  2542. r = l + inst.snapElements[ i ].width;
  2543. t = inst.snapElements[ i ].top - inst.margins.top;
  2544. b = t + inst.snapElements[ i ].height;
  2545. if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d ||
  2546. !$.contains( inst.snapElements[ i ].item.ownerDocument,
  2547. inst.snapElements[ i ].item ) ) {
  2548. if ( inst.snapElements[ i ].snapping ) {
  2549. ( inst.options.snap.release &&
  2550. inst.options.snap.release.call(
  2551. inst.element,
  2552. event,
  2553. $.extend( inst._uiHash(), { snapItem: inst.snapElements[ i ].item } )
  2554. ) );
  2555. }
  2556. inst.snapElements[ i ].snapping = false;
  2557. continue;
  2558. }
  2559. if ( o.snapMode !== "inner" ) {
  2560. ts = Math.abs( t - y2 ) <= d;
  2561. bs = Math.abs( b - y1 ) <= d;
  2562. ls = Math.abs( l - x2 ) <= d;
  2563. rs = Math.abs( r - x1 ) <= d;
  2564. if ( ts ) {
  2565. ui.position.top = inst._convertPositionTo( "relative", {
  2566. top: t - inst.helperProportions.height,
  2567. left: 0
  2568. } ).top;
  2569. }
  2570. if ( bs ) {
  2571. ui.position.top = inst._convertPositionTo( "relative", {
  2572. top: b,
  2573. left: 0
  2574. } ).top;
  2575. }
  2576. if ( ls ) {
  2577. ui.position.left = inst._convertPositionTo( "relative", {
  2578. top: 0,
  2579. left: l - inst.helperProportions.width
  2580. } ).left;
  2581. }
  2582. if ( rs ) {
  2583. ui.position.left = inst._convertPositionTo( "relative", {
  2584. top: 0,
  2585. left: r
  2586. } ).left;
  2587. }
  2588. }
  2589. first = ( ts || bs || ls || rs );
  2590. if ( o.snapMode !== "outer" ) {
  2591. ts = Math.abs( t - y1 ) <= d;
  2592. bs = Math.abs( b - y2 ) <= d;
  2593. ls = Math.abs( l - x1 ) <= d;
  2594. rs = Math.abs( r - x2 ) <= d;
  2595. if ( ts ) {
  2596. ui.position.top = inst._convertPositionTo( "relative", {
  2597. top: t,
  2598. left: 0
  2599. } ).top;
  2600. }
  2601. if ( bs ) {
  2602. ui.position.top = inst._convertPositionTo( "relative", {
  2603. top: b - inst.helperProportions.height,
  2604. left: 0
  2605. } ).top;
  2606. }
  2607. if ( ls ) {
  2608. ui.position.left = inst._convertPositionTo( "relative", {
  2609. top: 0,
  2610. left: l
  2611. } ).left;
  2612. }
  2613. if ( rs ) {
  2614. ui.position.left = inst._convertPositionTo( "relative", {
  2615. top: 0,
  2616. left: r - inst.helperProportions.width
  2617. } ).left;
  2618. }
  2619. }
  2620. if ( !inst.snapElements[ i ].snapping && ( ts || bs || ls || rs || first ) ) {
  2621. ( inst.options.snap.snap &&
  2622. inst.options.snap.snap.call(
  2623. inst.element,
  2624. event,
  2625. $.extend( inst._uiHash(), {
  2626. snapItem: inst.snapElements[ i ].item
  2627. } ) ) );
  2628. }
  2629. inst.snapElements[ i ].snapping = ( ts || bs || ls || rs || first );
  2630. }
  2631. }
  2632. } );
  2633. $.ui.plugin.add( "draggable", "stack", {
  2634. start: function( event, ui, instance ) {
  2635. var min,
  2636. o = instance.options,
  2637. group = $.makeArray( $( o.stack ) ).sort( function( a, b ) {
  2638. return ( parseInt( $( a ).css( "zIndex" ), 10 ) || 0 ) -
  2639. ( parseInt( $( b ).css( "zIndex" ), 10 ) || 0 );
  2640. } );
  2641. if ( !group.length ) { return; }
  2642. min = parseInt( $( group[ 0 ] ).css( "zIndex" ), 10 ) || 0;
  2643. $( group ).each( function( i ) {
  2644. $( this ).css( "zIndex", min + i );
  2645. } );
  2646. this.css( "zIndex", ( min + group.length ) );
  2647. }
  2648. } );
  2649. $.ui.plugin.add( "draggable", "zIndex", {
  2650. start: function( event, ui, instance ) {
  2651. var t = $( ui.helper ),
  2652. o = instance.options;
  2653. if ( t.css( "zIndex" ) ) {
  2654. o._zIndex = t.css( "zIndex" );
  2655. }
  2656. t.css( "zIndex", o.zIndex );
  2657. },
  2658. stop: function( event, ui, instance ) {
  2659. var o = instance.options;
  2660. if ( o._zIndex ) {
  2661. $( ui.helper ).css( "zIndex", o._zIndex );
  2662. }
  2663. }
  2664. } );
  2665. var widgetsDraggable = $.ui.draggable;
  2666. /*!
  2667. * jQuery UI Droppable 1.12.1
  2668. * http://jqueryui.com
  2669. *
  2670. * Copyright jQuery Foundation and other contributors
  2671. * Released under the MIT license.
  2672. * http://jquery.org/license
  2673. */
  2674. //>>label: Droppable
  2675. //>>group: Interactions
  2676. //>>description: Enables drop targets for draggable elements.
  2677. //>>docs: http://api.jqueryui.com/droppable/
  2678. //>>demos: http://jqueryui.com/droppable/
  2679. $.widget( "ui.droppable", {
  2680. version: "1.12.1",
  2681. widgetEventPrefix: "drop",
  2682. options: {
  2683. accept: "*",
  2684. addClasses: true,
  2685. greedy: false,
  2686. scope: "default",
  2687. tolerance: "intersect",
  2688. // Callbacks
  2689. activate: null,
  2690. deactivate: null,
  2691. drop: null,
  2692. out: null,
  2693. over: null
  2694. },
  2695. _create: function() {
  2696. var proportions,
  2697. o = this.options,
  2698. accept = o.accept;
  2699. this.isover = false;
  2700. this.isout = true;
  2701. this.accept = $.isFunction( accept ) ? accept : function( d ) {
  2702. return d.is( accept );
  2703. };
  2704. this.proportions = function( /* valueToWrite */ ) {
  2705. if ( arguments.length ) {
  2706. // Store the droppable's proportions
  2707. proportions = arguments[ 0 ];
  2708. } else {
  2709. // Retrieve or derive the droppable's proportions
  2710. return proportions ?
  2711. proportions :
  2712. proportions = {
  2713. width: this.element[ 0 ].offsetWidth,
  2714. height: this.element[ 0 ].offsetHeight
  2715. };
  2716. }
  2717. };
  2718. this._addToManager( o.scope );
  2719. o.addClasses && this._addClass( "ui-droppable" );
  2720. },
  2721. _addToManager: function( scope ) {
  2722. // Add the reference and positions to the manager
  2723. $.ui.ddmanager.droppables[ scope ] = $.ui.ddmanager.droppables[ scope ] || [];
  2724. $.ui.ddmanager.droppables[ scope ].push( this );
  2725. },
  2726. _splice: function( drop ) {
  2727. var i = 0;
  2728. for ( ; i < drop.length; i++ ) {
  2729. if ( drop[ i ] === this ) {
  2730. drop.splice( i, 1 );
  2731. }
  2732. }
  2733. },
  2734. _destroy: function() {
  2735. var drop = $.ui.ddmanager.droppables[ this.options.scope ];
  2736. this._splice( drop );
  2737. },
  2738. _setOption: function( key, value ) {
  2739. if ( key === "accept" ) {
  2740. this.accept = $.isFunction( value ) ? value : function( d ) {
  2741. return d.is( value );
  2742. };
  2743. } else if ( key === "scope" ) {
  2744. var drop = $.ui.ddmanager.droppables[ this.options.scope ];
  2745. this._splice( drop );
  2746. this._addToManager( value );
  2747. }
  2748. this._super( key, value );
  2749. },
  2750. _activate: function( event ) {
  2751. var draggable = $.ui.ddmanager.current;
  2752. this._addActiveClass();
  2753. if ( draggable ) {
  2754. this._trigger( "activate", event, this.ui( draggable ) );
  2755. }
  2756. },
  2757. _deactivate: function( event ) {
  2758. var draggable = $.ui.ddmanager.current;
  2759. this._removeActiveClass();
  2760. if ( draggable ) {
  2761. this._trigger( "deactivate", event, this.ui( draggable ) );
  2762. }
  2763. },
  2764. _over: function( event ) {
  2765. var draggable = $.ui.ddmanager.current;
  2766. // Bail if draggable and droppable are same element
  2767. if ( !draggable || ( draggable.currentItem ||
  2768. draggable.element )[ 0 ] === this.element[ 0 ] ) {
  2769. return;
  2770. }
  2771. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem ||
  2772. draggable.element ) ) ) {
  2773. this._addHoverClass();
  2774. this._trigger( "over", event, this.ui( draggable ) );
  2775. }
  2776. },
  2777. _out: function( event ) {
  2778. var draggable = $.ui.ddmanager.current;
  2779. // Bail if draggable and droppable are same element
  2780. if ( !draggable || ( draggable.currentItem ||
  2781. draggable.element )[ 0 ] === this.element[ 0 ] ) {
  2782. return;
  2783. }
  2784. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem ||
  2785. draggable.element ) ) ) {
  2786. this._removeHoverClass();
  2787. this._trigger( "out", event, this.ui( draggable ) );
  2788. }
  2789. },
  2790. _drop: function( event, custom ) {
  2791. var draggable = custom || $.ui.ddmanager.current,
  2792. childrenIntersection = false;
  2793. // Bail if draggable and droppable are same element
  2794. if ( !draggable || ( draggable.currentItem ||
  2795. draggable.element )[ 0 ] === this.element[ 0 ] ) {
  2796. return false;
  2797. }
  2798. this.element
  2799. .find( ":data(ui-droppable)" )
  2800. .not( ".ui-draggable-dragging" )
  2801. .each( function() {
  2802. var inst = $( this ).droppable( "instance" );
  2803. if (
  2804. inst.options.greedy &&
  2805. !inst.options.disabled &&
  2806. inst.options.scope === draggable.options.scope &&
  2807. inst.accept.call(
  2808. inst.element[ 0 ], ( draggable.currentItem || draggable.element )
  2809. ) &&
  2810. intersect(
  2811. draggable,
  2812. $.extend( inst, { offset: inst.element.offset() } ),
  2813. inst.options.tolerance, event
  2814. )
  2815. ) {
  2816. childrenIntersection = true;
  2817. return false; }
  2818. } );
  2819. if ( childrenIntersection ) {
  2820. return false;
  2821. }
  2822. if ( this.accept.call( this.element[ 0 ],
  2823. ( draggable.currentItem || draggable.element ) ) ) {
  2824. this._removeActiveClass();
  2825. this._removeHoverClass();
  2826. this._trigger( "drop", event, this.ui( draggable ) );
  2827. return this.element;
  2828. }
  2829. return false;
  2830. },
  2831. ui: function( c ) {
  2832. return {
  2833. draggable: ( c.currentItem || c.element ),
  2834. helper: c.helper,
  2835. position: c.position,
  2836. offset: c.positionAbs
  2837. };
  2838. },
  2839. // Extension points just to make backcompat sane and avoid duplicating logic
  2840. // TODO: Remove in 1.13 along with call to it below
  2841. _addHoverClass: function() {
  2842. this._addClass( "ui-droppable-hover" );
  2843. },
  2844. _removeHoverClass: function() {
  2845. this._removeClass( "ui-droppable-hover" );
  2846. },
  2847. _addActiveClass: function() {
  2848. this._addClass( "ui-droppable-active" );
  2849. },
  2850. _removeActiveClass: function() {
  2851. this._removeClass( "ui-droppable-active" );
  2852. }
  2853. } );
  2854. var intersect = $.ui.intersect = ( function() {
  2855. function isOverAxis( x, reference, size ) {
  2856. return ( x >= reference ) && ( x < ( reference + size ) );
  2857. }
  2858. return function( draggable, droppable, toleranceMode, event ) {
  2859. if ( !droppable.offset ) {
  2860. return false;
  2861. }
  2862. var x1 = ( draggable.positionAbs ||
  2863. draggable.position.absolute ).left + draggable.margins.left,
  2864. y1 = ( draggable.positionAbs ||
  2865. draggable.position.absolute ).top + draggable.margins.top,
  2866. x2 = x1 + draggable.helperProportions.width,
  2867. y2 = y1 + draggable.helperProportions.height,
  2868. l = droppable.offset.left,
  2869. t = droppable.offset.top,
  2870. r = l + droppable.proportions().width,
  2871. b = t + droppable.proportions().height;
  2872. switch ( toleranceMode ) {
  2873. case "fit":
  2874. return ( l <= x1 && x2 <= r && t <= y1 && y2 <= b );
  2875. case "intersect":
  2876. return ( l < x1 + ( draggable.helperProportions.width / 2 ) && // Right Half
  2877. x2 - ( draggable.helperProportions.width / 2 ) < r && // Left Half
  2878. t < y1 + ( draggable.helperProportions.height / 2 ) && // Bottom Half
  2879. y2 - ( draggable.helperProportions.height / 2 ) < b ); // Top Half
  2880. case "pointer":
  2881. return isOverAxis( event.pageY, t, droppable.proportions().height ) &&
  2882. isOverAxis( event.pageX, l, droppable.proportions().width );
  2883. case "touch":
  2884. return (
  2885. ( y1 >= t && y1 <= b ) || // Top edge touching
  2886. ( y2 >= t && y2 <= b ) || // Bottom edge touching
  2887. ( y1 < t && y2 > b ) // Surrounded vertically
  2888. ) && (
  2889. ( x1 >= l && x1 <= r ) || // Left edge touching
  2890. ( x2 >= l && x2 <= r ) || // Right edge touching
  2891. ( x1 < l && x2 > r ) // Surrounded horizontally
  2892. );
  2893. default:
  2894. return false;
  2895. }
  2896. };
  2897. } )();
  2898. /*
  2899. This manager tracks offsets of draggables and droppables
  2900. */
  2901. $.ui.ddmanager = {
  2902. current: null,
  2903. droppables: { "default": [] },
  2904. prepareOffsets: function( t, event ) {
  2905. var i, j,
  2906. m = $.ui.ddmanager.droppables[ t.options.scope ] || [],
  2907. type = event ? event.type : null, // workaround for #2317
  2908. list = ( t.currentItem || t.element ).find( ":data(ui-droppable)" ).addBack();
  2909. droppablesLoop: for ( i = 0; i < m.length; i++ ) {
  2910. // No disabled and non-accepted
  2911. if ( m[ i ].options.disabled || ( t && !m[ i ].accept.call( m[ i ].element[ 0 ],
  2912. ( t.currentItem || t.element ) ) ) ) {
  2913. continue;
  2914. }
  2915. // Filter out elements in the current dragged item
  2916. for ( j = 0; j < list.length; j++ ) {
  2917. if ( list[ j ] === m[ i ].element[ 0 ] ) {
  2918. m[ i ].proportions().height = 0;
  2919. continue droppablesLoop;
  2920. }
  2921. }
  2922. m[ i ].visible = m[ i ].element.css( "display" ) !== "none";
  2923. if ( !m[ i ].visible ) {
  2924. continue;
  2925. }
  2926. // Activate the droppable if used directly from draggables
  2927. if ( type === "mousedown" ) {
  2928. m[ i ]._activate.call( m[ i ], event );
  2929. }
  2930. m[ i ].offset = m[ i ].element.offset();
  2931. m[ i ].proportions( {
  2932. width: m[ i ].element[ 0 ].offsetWidth,
  2933. height: m[ i ].element[ 0 ].offsetHeight
  2934. } );
  2935. }
  2936. },
  2937. drop: function( draggable, event ) {
  2938. var dropped = false;
  2939. // Create a copy of the droppables in case the list changes during the drop (#9116)
  2940. $.each( ( $.ui.ddmanager.droppables[ draggable.options.scope ] || [] ).slice(), function() {
  2941. if ( !this.options ) {
  2942. return;
  2943. }
  2944. if ( !this.options.disabled && this.visible &&
  2945. intersect( draggable, this, this.options.tolerance, event ) ) {
  2946. dropped = this._drop.call( this, event ) || dropped;
  2947. }
  2948. if ( !this.options.disabled && this.visible && this.accept.call( this.element[ 0 ],
  2949. ( draggable.currentItem || draggable.element ) ) ) {
  2950. this.isout = true;
  2951. this.isover = false;
  2952. this._deactivate.call( this, event );
  2953. }
  2954. } );
  2955. return dropped;
  2956. },
  2957. dragStart: function( draggable, event ) {
  2958. // Listen for scrolling so that if the dragging causes scrolling the position of the
  2959. // droppables can be recalculated (see #5003)
  2960. draggable.element.parentsUntil( "body" ).on( "scroll.droppable", function() {
  2961. if ( !draggable.options.refreshPositions ) {
  2962. $.ui.ddmanager.prepareOffsets( draggable, event );
  2963. }
  2964. } );
  2965. },
  2966. drag: function( draggable, event ) {
  2967. // If you have a highly dynamic page, you might try this option. It renders positions
  2968. // every time you move the mouse.
  2969. if ( draggable.options.refreshPositions ) {
  2970. $.ui.ddmanager.prepareOffsets( draggable, event );
  2971. }
  2972. // Run through all droppables and check their positions based on specific tolerance options
  2973. $.each( $.ui.ddmanager.droppables[ draggable.options.scope ] || [], function() {
  2974. if ( this.options.disabled || this.greedyChild || !this.visible ) {
  2975. return;
  2976. }
  2977. var parentInstance, scope, parent,
  2978. intersects = intersect( draggable, this, this.options.tolerance, event ),
  2979. c = !intersects && this.isover ?
  2980. "isout" :
  2981. ( intersects && !this.isover ? "isover" : null );
  2982. if ( !c ) {
  2983. return;
  2984. }
  2985. if ( this.options.greedy ) {
  2986. // find droppable parents with same scope
  2987. scope = this.options.scope;
  2988. parent = this.element.parents( ":data(ui-droppable)" ).filter( function() {
  2989. return $( this ).droppable( "instance" ).options.scope === scope;
  2990. } );
  2991. if ( parent.length ) {
  2992. parentInstance = $( parent[ 0 ] ).droppable( "instance" );
  2993. parentInstance.greedyChild = ( c === "isover" );
  2994. }
  2995. }
  2996. // We just moved into a greedy child
  2997. if ( parentInstance && c === "isover" ) {
  2998. parentInstance.isover = false;
  2999. parentInstance.isout = true;
  3000. parentInstance._out.call( parentInstance, event );
  3001. }
  3002. this[ c ] = true;
  3003. this[ c === "isout" ? "isover" : "isout" ] = false;
  3004. this[ c === "isover" ? "_over" : "_out" ].call( this, event );
  3005. // We just moved out of a greedy child
  3006. if ( parentInstance && c === "isout" ) {
  3007. parentInstance.isout = false;
  3008. parentInstance.isover = true;
  3009. parentInstance._over.call( parentInstance, event );
  3010. }
  3011. } );
  3012. },
  3013. dragStop: function( draggable, event ) {
  3014. draggable.element.parentsUntil( "body" ).off( "scroll.droppable" );
  3015. // Call prepareOffsets one final time since IE does not fire return scroll events when
  3016. // overflow was caused by drag (see #5003)
  3017. if ( !draggable.options.refreshPositions ) {
  3018. $.ui.ddmanager.prepareOffsets( draggable, event );
  3019. }
  3020. }
  3021. };
  3022. // DEPRECATED
  3023. // TODO: switch return back to widget declaration at top of file when this is removed
  3024. if ( $.uiBackCompat !== false ) {
  3025. // Backcompat for activeClass and hoverClass options
  3026. $.widget( "ui.droppable", $.ui.droppable, {
  3027. options: {
  3028. hoverClass: false,
  3029. activeClass: false
  3030. },
  3031. _addActiveClass: function() {
  3032. this._super();
  3033. if ( this.options.activeClass ) {
  3034. this.element.addClass( this.options.activeClass );
  3035. }
  3036. },
  3037. _removeActiveClass: function() {
  3038. this._super();
  3039. if ( this.options.activeClass ) {
  3040. this.element.removeClass( this.options.activeClass );
  3041. }
  3042. },
  3043. _addHoverClass: function() {
  3044. this._super();
  3045. if ( this.options.hoverClass ) {
  3046. this.element.addClass( this.options.hoverClass );
  3047. }
  3048. },
  3049. _removeHoverClass: function() {
  3050. this._super();
  3051. if ( this.options.hoverClass ) {
  3052. this.element.removeClass( this.options.hoverClass );
  3053. }
  3054. }
  3055. } );
  3056. }
  3057. var widgetsDroppable = $.ui.droppable;
  3058. /*!
  3059. * jQuery UI Resizable 1.12.1
  3060. * http://jqueryui.com
  3061. *
  3062. * Copyright jQuery Foundation and other contributors
  3063. * Released under the MIT license.
  3064. * http://jquery.org/license
  3065. */
  3066. //>>label: Resizable
  3067. //>>group: Interactions
  3068. //>>description: Enables resize functionality for any element.
  3069. //>>docs: http://api.jqueryui.com/resizable/
  3070. //>>demos: http://jqueryui.com/resizable/
  3071. //>>css.structure: ../../themes/base/core.css
  3072. //>>css.structure: ../../themes/base/resizable.css
  3073. //>>css.theme: ../../themes/base/theme.css
  3074. $.widget( "ui.resizable", $.ui.mouse, {
  3075. version: "1.12.1",
  3076. widgetEventPrefix: "resize",
  3077. options: {
  3078. alsoResize: false,
  3079. animate: false,
  3080. animateDuration: "slow",
  3081. animateEasing: "swing",
  3082. aspectRatio: false,
  3083. autoHide: false,
  3084. classes: {
  3085. "ui-resizable-se": "ui-icon ui-icon-gripsmall-diagonal-se"
  3086. },
  3087. containment: false,
  3088. ghost: false,
  3089. grid: false,
  3090. handles: "e,s,se",
  3091. helper: false,
  3092. maxHeight: null,
  3093. maxWidth: null,
  3094. minHeight: 10,
  3095. minWidth: 10,
  3096. // See #7960
  3097. zIndex: 90,
  3098. // Callbacks
  3099. resize: null,
  3100. start: null,
  3101. stop: null
  3102. },
  3103. _num: function( value ) {
  3104. return parseFloat( value ) || 0;
  3105. },
  3106. _isNumber: function( value ) {
  3107. return !isNaN( parseFloat( value ) );
  3108. },
  3109. _hasScroll: function( el, a ) {
  3110. if ( $( el ).css( "overflow" ) === "hidden" ) {
  3111. return false;
  3112. }
  3113. var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
  3114. has = false;
  3115. if ( el[ scroll ] > 0 ) {
  3116. return true;
  3117. }
  3118. // TODO: determine which cases actually cause this to happen
  3119. // if the element doesn't have the scroll set, see if it's possible to
  3120. // set the scroll
  3121. el[ scroll ] = 1;
  3122. has = ( el[ scroll ] > 0 );
  3123. el[ scroll ] = 0;
  3124. return has;
  3125. },
  3126. _create: function() {
  3127. var margins,
  3128. o = this.options,
  3129. that = this;
  3130. this._addClass( "ui-resizable" );
  3131. $.extend( this, {
  3132. _aspectRatio: !!( o.aspectRatio ),
  3133. aspectRatio: o.aspectRatio,
  3134. originalElement: this.element,
  3135. _proportionallyResizeElements: [],
  3136. _helper: o.helper || o.ghost || o.animate ? o.helper || "ui-resizable-helper" : null
  3137. } );
  3138. // Wrap the element if it cannot hold child nodes
  3139. if ( this.element[ 0 ].nodeName.match( /^(canvas|textarea|input|select|button|img)$/i ) ) {
  3140. this.element.wrap(
  3141. $( "<div class='ui-wrapper' style='overflow: hidden;'></div>" ).css( {
  3142. position: this.element.css( "position" ),
  3143. width: this.element.outerWidth(),
  3144. height: this.element.outerHeight(),
  3145. top: this.element.css( "top" ),
  3146. left: this.element.css( "left" )
  3147. } )
  3148. );
  3149. this.element = this.element.parent().data(
  3150. "ui-resizable", this.element.resizable( "instance" )
  3151. );
  3152. this.elementIsWrapper = true;
  3153. margins = {
  3154. marginTop: this.originalElement.css( "marginTop" ),
  3155. marginRight: this.originalElement.css( "marginRight" ),
  3156. marginBottom: this.originalElement.css( "marginBottom" ),
  3157. marginLeft: this.originalElement.css( "marginLeft" )
  3158. };
  3159. this.element.css( margins );
  3160. this.originalElement.css( "margin", 0 );
  3161. // support: Safari
  3162. // Prevent Safari textarea resize
  3163. this.originalResizeStyle = this.originalElement.css( "resize" );
  3164. this.originalElement.css( "resize", "none" );
  3165. this._proportionallyResizeElements.push( this.originalElement.css( {
  3166. position: "static",
  3167. zoom: 1,
  3168. display: "block"
  3169. } ) );
  3170. // Support: IE9
  3171. // avoid IE jump (hard set the margin)
  3172. this.originalElement.css( margins );
  3173. this._proportionallyResize();
  3174. }
  3175. this._setupHandles();
  3176. if ( o.autoHide ) {
  3177. $( this.element )
  3178. .on( "mouseenter", function() {
  3179. if ( o.disabled ) {
  3180. return;
  3181. }
  3182. that._removeClass( "ui-resizable-autohide" );
  3183. that._handles.show();
  3184. } )
  3185. .on( "mouseleave", function() {
  3186. if ( o.disabled ) {
  3187. return;
  3188. }
  3189. if ( !that.resizing ) {
  3190. that._addClass( "ui-resizable-autohide" );
  3191. that._handles.hide();
  3192. }
  3193. } );
  3194. }
  3195. this._mouseInit();
  3196. },
  3197. _destroy: function() {
  3198. this._mouseDestroy();
  3199. var wrapper,
  3200. _destroy = function( exp ) {
  3201. $( exp )
  3202. .removeData( "resizable" )
  3203. .removeData( "ui-resizable" )
  3204. .off( ".resizable" )
  3205. .find( ".ui-resizable-handle" )
  3206. .remove();
  3207. };
  3208. // TODO: Unwrap at same DOM position
  3209. if ( this.elementIsWrapper ) {
  3210. _destroy( this.element );
  3211. wrapper = this.element;
  3212. this.originalElement.css( {
  3213. position: wrapper.css( "position" ),
  3214. width: wrapper.outerWidth(),
  3215. height: wrapper.outerHeight(),
  3216. top: wrapper.css( "top" ),
  3217. left: wrapper.css( "left" )
  3218. } ).insertAfter( wrapper );
  3219. wrapper.remove();
  3220. }
  3221. this.originalElement.css( "resize", this.originalResizeStyle );
  3222. _destroy( this.originalElement );
  3223. return this;
  3224. },
  3225. _setOption: function( key, value ) {
  3226. this._super( key, value );
  3227. switch ( key ) {
  3228. case "handles":
  3229. this._removeHandles();
  3230. this._setupHandles();
  3231. break;
  3232. default:
  3233. break;
  3234. }
  3235. },
  3236. _setupHandles: function() {
  3237. var o = this.options, handle, i, n, hname, axis, that = this;
  3238. this.handles = o.handles ||
  3239. ( !$( ".ui-resizable-handle", this.element ).length ?
  3240. "e,s,se" : {
  3241. n: ".ui-resizable-n",
  3242. e: ".ui-resizable-e",
  3243. s: ".ui-resizable-s",
  3244. w: ".ui-resizable-w",
  3245. se: ".ui-resizable-se",
  3246. sw: ".ui-resizable-sw",
  3247. ne: ".ui-resizable-ne",
  3248. nw: ".ui-resizable-nw"
  3249. } );
  3250. this._handles = $();
  3251. if ( this.handles.constructor === String ) {
  3252. if ( this.handles === "all" ) {
  3253. this.handles = "n,e,s,w,se,sw,ne,nw";
  3254. }
  3255. n = this.handles.split( "," );
  3256. this.handles = {};
  3257. for ( i = 0; i < n.length; i++ ) {
  3258. handle = $.trim( n[ i ] );
  3259. hname = "ui-resizable-" + handle;
  3260. axis = $( "<div>" );
  3261. this._addClass( axis, "ui-resizable-handle " + hname );
  3262. axis.css( { zIndex: o.zIndex } );
  3263. this.handles[ handle ] = ".ui-resizable-" + handle;
  3264. this.element.append( axis );
  3265. }
  3266. }
  3267. this._renderAxis = function( target ) {
  3268. var i, axis, padPos, padWrapper;
  3269. target = target || this.element;
  3270. for ( i in this.handles ) {
  3271. if ( this.handles[ i ].constructor === String ) {
  3272. this.handles[ i ] = this.element.children( this.handles[ i ] ).first().show();
  3273. } else if ( this.handles[ i ].jquery || this.handles[ i ].nodeType ) {
  3274. this.handles[ i ] = $( this.handles[ i ] );
  3275. this._on( this.handles[ i ], { "mousedown": that._mouseDown } );
  3276. }
  3277. if ( this.elementIsWrapper &&
  3278. this.originalElement[ 0 ]
  3279. .nodeName
  3280. .match( /^(textarea|input|select|button)$/i ) ) {
  3281. axis = $( this.handles[ i ], this.element );
  3282. padWrapper = /sw|ne|nw|se|n|s/.test( i ) ?
  3283. axis.outerHeight() :
  3284. axis.outerWidth();
  3285. padPos = [ "padding",
  3286. /ne|nw|n/.test( i ) ? "Top" :
  3287. /se|sw|s/.test( i ) ? "Bottom" :
  3288. /^e$/.test( i ) ? "Right" : "Left" ].join( "" );
  3289. target.css( padPos, padWrapper );
  3290. this._proportionallyResize();
  3291. }
  3292. this._handles = this._handles.add( this.handles[ i ] );
  3293. }
  3294. };
  3295. // TODO: make renderAxis a prototype function
  3296. this._renderAxis( this.element );
  3297. this._handles = this._handles.add( this.element.find( ".ui-resizable-handle" ) );
  3298. this._handles.disableSelection();
  3299. this._handles.on( "mouseover", function() {
  3300. if ( !that.resizing ) {
  3301. if ( this.className ) {
  3302. axis = this.className.match( /ui-resizable-(se|sw|ne|nw|n|e|s|w)/i );
  3303. }
  3304. that.axis = axis && axis[ 1 ] ? axis[ 1 ] : "se";
  3305. }
  3306. } );
  3307. if ( o.autoHide ) {
  3308. this._handles.hide();
  3309. this._addClass( "ui-resizable-autohide" );
  3310. }
  3311. },
  3312. _removeHandles: function() {
  3313. this._handles.remove();
  3314. },
  3315. _mouseCapture: function( event ) {
  3316. var i, handle,
  3317. capture = false;
  3318. for ( i in this.handles ) {
  3319. handle = $( this.handles[ i ] )[ 0 ];
  3320. if ( handle === event.target || $.contains( handle, event.target ) ) {
  3321. capture = true;
  3322. }
  3323. }
  3324. return !this.options.disabled && capture;
  3325. },
  3326. _mouseStart: function( event ) {
  3327. var curleft, curtop, cursor,
  3328. o = this.options,
  3329. el = this.element;
  3330. this.resizing = true;
  3331. this._renderProxy();
  3332. curleft = this._num( this.helper.css( "left" ) );
  3333. curtop = this._num( this.helper.css( "top" ) );
  3334. if ( o.containment ) {
  3335. curleft += $( o.containment ).scrollLeft() || 0;
  3336. curtop += $( o.containment ).scrollTop() || 0;
  3337. }
  3338. this.offset = this.helper.offset();
  3339. this.position = { left: curleft, top: curtop };
  3340. this.size = this._helper ? {
  3341. width: this.helper.width(),
  3342. height: this.helper.height()
  3343. } : {
  3344. width: el.width(),
  3345. height: el.height()
  3346. };
  3347. this.originalSize = this._helper ? {
  3348. width: el.outerWidth(),
  3349. height: el.outerHeight()
  3350. } : {
  3351. width: el.width(),
  3352. height: el.height()
  3353. };
  3354. this.sizeDiff = {
  3355. width: el.outerWidth() - el.width(),
  3356. height: el.outerHeight() - el.height()
  3357. };
  3358. this.originalPosition = { left: curleft, top: curtop };
  3359. this.originalMousePosition = { left: event.pageX, top: event.pageY };
  3360. this.aspectRatio = ( typeof o.aspectRatio === "number" ) ?
  3361. o.aspectRatio :
  3362. ( ( this.originalSize.width / this.originalSize.height ) || 1 );
  3363. cursor = $( ".ui-resizable-" + this.axis ).css( "cursor" );
  3364. $( "body" ).css( "cursor", cursor === "auto" ? this.axis + "-resize" : cursor );
  3365. this._addClass( "ui-resizable-resizing" );
  3366. this._propagate( "start", event );
  3367. return true;
  3368. },
  3369. _mouseDrag: function( event ) {
  3370. var data, props,
  3371. smp = this.originalMousePosition,
  3372. a = this.axis,
  3373. dx = ( event.pageX - smp.left ) || 0,
  3374. dy = ( event.pageY - smp.top ) || 0,
  3375. trigger = this._change[ a ];
  3376. this._updatePrevProperties();
  3377. if ( !trigger ) {
  3378. return false;
  3379. }
  3380. data = trigger.apply( this, [ event, dx, dy ] );
  3381. this._updateVirtualBoundaries( event.shiftKey );
  3382. if ( this._aspectRatio || event.shiftKey ) {
  3383. data = this._updateRatio( data, event );
  3384. }
  3385. data = this._respectSize( data, event );
  3386. this._updateCache( data );
  3387. this._propagate( "resize", event );
  3388. props = this._applyChanges();
  3389. if ( !this._helper && this._proportionallyResizeElements.length ) {
  3390. this._proportionallyResize();
  3391. }
  3392. if ( !$.isEmptyObject( props ) ) {
  3393. this._updatePrevProperties();
  3394. this._trigger( "resize", event, this.ui() );
  3395. this._applyChanges();
  3396. }
  3397. return false;
  3398. },
  3399. _mouseStop: function( event ) {
  3400. this.resizing = false;
  3401. var pr, ista, soffseth, soffsetw, s, left, top,
  3402. o = this.options, that = this;
  3403. if ( this._helper ) {
  3404. pr = this._proportionallyResizeElements;
  3405. ista = pr.length && ( /textarea/i ).test( pr[ 0 ].nodeName );
  3406. soffseth = ista && this._hasScroll( pr[ 0 ], "left" ) ? 0 : that.sizeDiff.height;
  3407. soffsetw = ista ? 0 : that.sizeDiff.width;
  3408. s = {
  3409. width: ( that.helper.width() - soffsetw ),
  3410. height: ( that.helper.height() - soffseth )
  3411. };
  3412. left = ( parseFloat( that.element.css( "left" ) ) +
  3413. ( that.position.left - that.originalPosition.left ) ) || null;
  3414. top = ( parseFloat( that.element.css( "top" ) ) +
  3415. ( that.position.top - that.originalPosition.top ) ) || null;
  3416. if ( !o.animate ) {
  3417. this.element.css( $.extend( s, { top: top, left: left } ) );
  3418. }
  3419. that.helper.height( that.size.height );
  3420. that.helper.width( that.size.width );
  3421. if ( this._helper && !o.animate ) {
  3422. this._proportionallyResize();
  3423. }
  3424. }
  3425. $( "body" ).css( "cursor", "auto" );
  3426. this._removeClass( "ui-resizable-resizing" );
  3427. this._propagate( "stop", event );
  3428. if ( this._helper ) {
  3429. this.helper.remove();
  3430. }
  3431. return false;
  3432. },
  3433. _updatePrevProperties: function() {
  3434. this.prevPosition = {
  3435. top: this.position.top,
  3436. left: this.position.left
  3437. };
  3438. this.prevSize = {
  3439. width: this.size.width,
  3440. height: this.size.height
  3441. };
  3442. },
  3443. _applyChanges: function() {
  3444. var props = {};
  3445. if ( this.position.top !== this.prevPosition.top ) {
  3446. props.top = this.position.top + "px";
  3447. }
  3448. if ( this.position.left !== this.prevPosition.left ) {
  3449. props.left = this.position.left + "px";
  3450. }
  3451. if ( this.size.width !== this.prevSize.width ) {
  3452. props.width = this.size.width + "px";
  3453. }
  3454. if ( this.size.height !== this.prevSize.height ) {
  3455. props.height = this.size.height + "px";
  3456. }
  3457. this.helper.css( props );
  3458. return props;
  3459. },
  3460. _updateVirtualBoundaries: function( forceAspectRatio ) {
  3461. var pMinWidth, pMaxWidth, pMinHeight, pMaxHeight, b,
  3462. o = this.options;
  3463. b = {
  3464. minWidth: this._isNumber( o.minWidth ) ? o.minWidth : 0,
  3465. maxWidth: this._isNumber( o.maxWidth ) ? o.maxWidth : Infinity,
  3466. minHeight: this._isNumber( o.minHeight ) ? o.minHeight : 0,
  3467. maxHeight: this._isNumber( o.maxHeight ) ? o.maxHeight : Infinity
  3468. };
  3469. if ( this._aspectRatio || forceAspectRatio ) {
  3470. pMinWidth = b.minHeight * this.aspectRatio;
  3471. pMinHeight = b.minWidth / this.aspectRatio;
  3472. pMaxWidth = b.maxHeight * this.aspectRatio;
  3473. pMaxHeight = b.maxWidth / this.aspectRatio;
  3474. if ( pMinWidth > b.minWidth ) {
  3475. b.minWidth = pMinWidth;
  3476. }
  3477. if ( pMinHeight > b.minHeight ) {
  3478. b.minHeight = pMinHeight;
  3479. }
  3480. if ( pMaxWidth < b.maxWidth ) {
  3481. b.maxWidth = pMaxWidth;
  3482. }
  3483. if ( pMaxHeight < b.maxHeight ) {
  3484. b.maxHeight = pMaxHeight;
  3485. }
  3486. }
  3487. this._vBoundaries = b;
  3488. },
  3489. _updateCache: function( data ) {
  3490. this.offset = this.helper.offset();
  3491. if ( this._isNumber( data.left ) ) {
  3492. this.position.left = data.left;
  3493. }
  3494. if ( this._isNumber( data.top ) ) {
  3495. this.position.top = data.top;
  3496. }
  3497. if ( this._isNumber( data.height ) ) {
  3498. this.size.height = data.height;
  3499. }
  3500. if ( this._isNumber( data.width ) ) {
  3501. this.size.width = data.width;
  3502. }
  3503. },
  3504. _updateRatio: function( data ) {
  3505. var cpos = this.position,
  3506. csize = this.size,
  3507. a = this.axis;
  3508. if ( this._isNumber( data.height ) ) {
  3509. data.width = ( data.height * this.aspectRatio );
  3510. } else if ( this._isNumber( data.width ) ) {
  3511. data.height = ( data.width / this.aspectRatio );
  3512. }
  3513. if ( a === "sw" ) {
  3514. data.left = cpos.left + ( csize.width - data.width );
  3515. data.top = null;
  3516. }
  3517. if ( a === "nw" ) {
  3518. data.top = cpos.top + ( csize.height - data.height );
  3519. data.left = cpos.left + ( csize.width - data.width );
  3520. }
  3521. return data;
  3522. },
  3523. _respectSize: function( data ) {
  3524. var o = this._vBoundaries,
  3525. a = this.axis,
  3526. ismaxw = this._isNumber( data.width ) && o.maxWidth && ( o.maxWidth < data.width ),
  3527. ismaxh = this._isNumber( data.height ) && o.maxHeight && ( o.maxHeight < data.height ),
  3528. isminw = this._isNumber( data.width ) && o.minWidth && ( o.minWidth > data.width ),
  3529. isminh = this._isNumber( data.height ) && o.minHeight && ( o.minHeight > data.height ),
  3530. dw = this.originalPosition.left + this.originalSize.width,
  3531. dh = this.originalPosition.top + this.originalSize.height,
  3532. cw = /sw|nw|w/.test( a ), ch = /nw|ne|n/.test( a );
  3533. if ( isminw ) {
  3534. data.width = o.minWidth;
  3535. }
  3536. if ( isminh ) {
  3537. data.height = o.minHeight;
  3538. }
  3539. if ( ismaxw ) {
  3540. data.width = o.maxWidth;
  3541. }
  3542. if ( ismaxh ) {
  3543. data.height = o.maxHeight;
  3544. }
  3545. if ( isminw && cw ) {
  3546. data.left = dw - o.minWidth;
  3547. }
  3548. if ( ismaxw && cw ) {
  3549. data.left = dw - o.maxWidth;
  3550. }
  3551. if ( isminh && ch ) {
  3552. data.top = dh - o.minHeight;
  3553. }
  3554. if ( ismaxh && ch ) {
  3555. data.top = dh - o.maxHeight;
  3556. }
  3557. // Fixing jump error on top/left - bug #2330
  3558. if ( !data.width && !data.height && !data.left && data.top ) {
  3559. data.top = null;
  3560. } else if ( !data.width && !data.height && !data.top && data.left ) {
  3561. data.left = null;
  3562. }
  3563. return data;
  3564. },
  3565. _getPaddingPlusBorderDimensions: function( element ) {
  3566. var i = 0,
  3567. widths = [],
  3568. borders = [
  3569. element.css( "borderTopWidth" ),
  3570. element.css( "borderRightWidth" ),
  3571. element.css( "borderBottomWidth" ),
  3572. element.css( "borderLeftWidth" )
  3573. ],
  3574. paddings = [
  3575. element.css( "paddingTop" ),
  3576. element.css( "paddingRight" ),
  3577. element.css( "paddingBottom" ),
  3578. element.css( "paddingLeft" )
  3579. ];
  3580. for ( ; i < 4; i++ ) {
  3581. widths[ i ] = ( parseFloat( borders[ i ] ) || 0 );
  3582. widths[ i ] += ( parseFloat( paddings[ i ] ) || 0 );
  3583. }
  3584. return {
  3585. height: widths[ 0 ] + widths[ 2 ],
  3586. width: widths[ 1 ] + widths[ 3 ]
  3587. };
  3588. },
  3589. _proportionallyResize: function() {
  3590. if ( !this._proportionallyResizeElements.length ) {
  3591. return;
  3592. }
  3593. var prel,
  3594. i = 0,
  3595. element = this.helper || this.element;
  3596. for ( ; i < this._proportionallyResizeElements.length; i++ ) {
  3597. prel = this._proportionallyResizeElements[ i ];
  3598. // TODO: Seems like a bug to cache this.outerDimensions
  3599. // considering that we are in a loop.
  3600. if ( !this.outerDimensions ) {
  3601. this.outerDimensions = this._getPaddingPlusBorderDimensions( prel );
  3602. }
  3603. prel.css( {
  3604. height: ( element.height() - this.outerDimensions.height ) || 0,
  3605. width: ( element.width() - this.outerDimensions.width ) || 0
  3606. } );
  3607. }
  3608. },
  3609. _renderProxy: function() {
  3610. var el = this.element, o = this.options;
  3611. this.elementOffset = el.offset();
  3612. if ( this._helper ) {
  3613. this.helper = this.helper || $( "<div style='overflow:hidden;'></div>" );
  3614. this._addClass( this.helper, this._helper );
  3615. this.helper.css( {
  3616. width: this.element.outerWidth(),
  3617. height: this.element.outerHeight(),
  3618. position: "absolute",
  3619. left: this.elementOffset.left + "px",
  3620. top: this.elementOffset.top + "px",
  3621. zIndex: ++o.zIndex //TODO: Don't modify option
  3622. } );
  3623. this.helper
  3624. .appendTo( "body" )
  3625. .disableSelection();
  3626. } else {
  3627. this.helper = this.element;
  3628. }
  3629. },
  3630. _change: {
  3631. e: function( event, dx ) {
  3632. return { width: this.originalSize.width + dx };
  3633. },
  3634. w: function( event, dx ) {
  3635. var cs = this.originalSize, sp = this.originalPosition;
  3636. return { left: sp.left + dx, width: cs.width - dx };
  3637. },
  3638. n: function( event, dx, dy ) {
  3639. var cs = this.originalSize, sp = this.originalPosition;
  3640. return { top: sp.top + dy, height: cs.height - dy };
  3641. },
  3642. s: function( event, dx, dy ) {
  3643. return { height: this.originalSize.height + dy };
  3644. },
  3645. se: function( event, dx, dy ) {
  3646. return $.extend( this._change.s.apply( this, arguments ),
  3647. this._change.e.apply( this, [ event, dx, dy ] ) );
  3648. },
  3649. sw: function( event, dx, dy ) {
  3650. return $.extend( this._change.s.apply( this, arguments ),
  3651. this._change.w.apply( this, [ event, dx, dy ] ) );
  3652. },
  3653. ne: function( event, dx, dy ) {
  3654. return $.extend( this._change.n.apply( this, arguments ),
  3655. this._change.e.apply( this, [ event, dx, dy ] ) );
  3656. },
  3657. nw: function( event, dx, dy ) {
  3658. return $.extend( this._change.n.apply( this, arguments ),
  3659. this._change.w.apply( this, [ event, dx, dy ] ) );
  3660. }
  3661. },
  3662. _propagate: function( n, event ) {
  3663. $.ui.plugin.call( this, n, [ event, this.ui() ] );
  3664. ( n !== "resize" && this._trigger( n, event, this.ui() ) );
  3665. },
  3666. plugins: {},
  3667. ui: function() {
  3668. return {
  3669. originalElement: this.originalElement,
  3670. element: this.element,
  3671. helper: this.helper,
  3672. position: this.position,
  3673. size: this.size,
  3674. originalSize: this.originalSize,
  3675. originalPosition: this.originalPosition
  3676. };
  3677. }
  3678. } );
  3679. /*
  3680. * Resizable Extensions
  3681. */
  3682. $.ui.plugin.add( "resizable", "animate", {
  3683. stop: function( event ) {
  3684. var that = $( this ).resizable( "instance" ),
  3685. o = that.options,
  3686. pr = that._proportionallyResizeElements,
  3687. ista = pr.length && ( /textarea/i ).test( pr[ 0 ].nodeName ),
  3688. soffseth = ista && that._hasScroll( pr[ 0 ], "left" ) ? 0 : that.sizeDiff.height,
  3689. soffsetw = ista ? 0 : that.sizeDiff.width,
  3690. style = {
  3691. width: ( that.size.width - soffsetw ),
  3692. height: ( that.size.height - soffseth )
  3693. },
  3694. left = ( parseFloat( that.element.css( "left" ) ) +
  3695. ( that.position.left - that.originalPosition.left ) ) || null,
  3696. top = ( parseFloat( that.element.css( "top" ) ) +
  3697. ( that.position.top - that.originalPosition.top ) ) || null;
  3698. that.element.animate(
  3699. $.extend( style, top && left ? { top: top, left: left } : {} ), {
  3700. duration: o.animateDuration,
  3701. easing: o.animateEasing,
  3702. step: function() {
  3703. var data = {
  3704. width: parseFloat( that.element.css( "width" ) ),
  3705. height: parseFloat( that.element.css( "height" ) ),
  3706. top: parseFloat( that.element.css( "top" ) ),
  3707. left: parseFloat( that.element.css( "left" ) )
  3708. };
  3709. if ( pr && pr.length ) {
  3710. $( pr[ 0 ] ).css( { width: data.width, height: data.height } );
  3711. }
  3712. // Propagating resize, and updating values for each animation step
  3713. that._updateCache( data );
  3714. that._propagate( "resize", event );
  3715. }
  3716. }
  3717. );
  3718. }
  3719. } );
  3720. $.ui.plugin.add( "resizable", "containment", {
  3721. start: function() {
  3722. var element, p, co, ch, cw, width, height,
  3723. that = $( this ).resizable( "instance" ),
  3724. o = that.options,
  3725. el = that.element,
  3726. oc = o.containment,
  3727. ce = ( oc instanceof $ ) ?
  3728. oc.get( 0 ) :
  3729. ( /parent/.test( oc ) ) ? el.parent().get( 0 ) : oc;
  3730. if ( !ce ) {
  3731. return;
  3732. }
  3733. that.containerElement = $( ce );
  3734. if ( /document/.test( oc ) || oc === document ) {
  3735. that.containerOffset = {
  3736. left: 0,
  3737. top: 0
  3738. };
  3739. that.containerPosition = {
  3740. left: 0,
  3741. top: 0
  3742. };
  3743. that.parentData = {
  3744. element: $( document ),
  3745. left: 0,
  3746. top: 0,
  3747. width: $( document ).width(),
  3748. height: $( document ).height() || document.body.parentNode.scrollHeight
  3749. };
  3750. } else {
  3751. element = $( ce );
  3752. p = [];
  3753. $( [ "Top", "Right", "Left", "Bottom" ] ).each( function( i, name ) {
  3754. p[ i ] = that._num( element.css( "padding" + name ) );
  3755. } );
  3756. that.containerOffset = element.offset();
  3757. that.containerPosition = element.position();
  3758. that.containerSize = {
  3759. height: ( element.innerHeight() - p[ 3 ] ),
  3760. width: ( element.innerWidth() - p[ 1 ] )
  3761. };
  3762. co = that.containerOffset;
  3763. ch = that.containerSize.height;
  3764. cw = that.containerSize.width;
  3765. width = ( that._hasScroll ( ce, "left" ) ? ce.scrollWidth : cw );
  3766. height = ( that._hasScroll ( ce ) ? ce.scrollHeight : ch ) ;
  3767. that.parentData = {
  3768. element: ce,
  3769. left: co.left,
  3770. top: co.top,
  3771. width: width,
  3772. height: height
  3773. };
  3774. }
  3775. },
  3776. resize: function( event ) {
  3777. var woset, hoset, isParent, isOffsetRelative,
  3778. that = $( this ).resizable( "instance" ),
  3779. o = that.options,
  3780. co = that.containerOffset,
  3781. cp = that.position,
  3782. pRatio = that._aspectRatio || event.shiftKey,
  3783. cop = {
  3784. top: 0,
  3785. left: 0
  3786. },
  3787. ce = that.containerElement,
  3788. continueResize = true;
  3789. if ( ce[ 0 ] !== document && ( /static/ ).test( ce.css( "position" ) ) ) {
  3790. cop = co;
  3791. }
  3792. if ( cp.left < ( that._helper ? co.left : 0 ) ) {
  3793. that.size.width = that.size.width +
  3794. ( that._helper ?
  3795. ( that.position.left - co.left ) :
  3796. ( that.position.left - cop.left ) );
  3797. if ( pRatio ) {
  3798. that.size.height = that.size.width / that.aspectRatio;
  3799. continueResize = false;
  3800. }
  3801. that.position.left = o.helper ? co.left : 0;
  3802. }
  3803. if ( cp.top < ( that._helper ? co.top : 0 ) ) {
  3804. that.size.height = that.size.height +
  3805. ( that._helper ?
  3806. ( that.position.top - co.top ) :
  3807. that.position.top );
  3808. if ( pRatio ) {
  3809. that.size.width = that.size.height * that.aspectRatio;
  3810. continueResize = false;
  3811. }
  3812. that.position.top = that._helper ? co.top : 0;
  3813. }
  3814. isParent = that.containerElement.get( 0 ) === that.element.parent().get( 0 );
  3815. isOffsetRelative = /relative|absolute/.test( that.containerElement.css( "position" ) );
  3816. if ( isParent && isOffsetRelative ) {
  3817. that.offset.left = that.parentData.left + that.position.left;
  3818. that.offset.top = that.parentData.top + that.position.top;
  3819. } else {
  3820. that.offset.left = that.element.offset().left;
  3821. that.offset.top = that.element.offset().top;
  3822. }
  3823. woset = Math.abs( that.sizeDiff.width +
  3824. ( that._helper ?
  3825. that.offset.left - cop.left :
  3826. ( that.offset.left - co.left ) ) );
  3827. hoset = Math.abs( that.sizeDiff.height +
  3828. ( that._helper ?
  3829. that.offset.top - cop.top :
  3830. ( that.offset.top - co.top ) ) );
  3831. if ( woset + that.size.width >= that.parentData.width ) {
  3832. that.size.width = that.parentData.width - woset;
  3833. if ( pRatio ) {
  3834. that.size.height = that.size.width / that.aspectRatio;
  3835. continueResize = false;
  3836. }
  3837. }
  3838. if ( hoset + that.size.height >= that.parentData.height ) {
  3839. that.size.height = that.parentData.height - hoset;
  3840. if ( pRatio ) {
  3841. that.size.width = that.size.height * that.aspectRatio;
  3842. continueResize = false;
  3843. }
  3844. }
  3845. if ( !continueResize ) {
  3846. that.position.left = that.prevPosition.left;
  3847. that.position.top = that.prevPosition.top;
  3848. that.size.width = that.prevSize.width;
  3849. that.size.height = that.prevSize.height;
  3850. }
  3851. },
  3852. stop: function() {
  3853. var that = $( this ).resizable( "instance" ),
  3854. o = that.options,
  3855. co = that.containerOffset,
  3856. cop = that.containerPosition,
  3857. ce = that.containerElement,
  3858. helper = $( that.helper ),
  3859. ho = helper.offset(),
  3860. w = helper.outerWidth() - that.sizeDiff.width,
  3861. h = helper.outerHeight() - that.sizeDiff.height;
  3862. if ( that._helper && !o.animate && ( /relative/ ).test( ce.css( "position" ) ) ) {
  3863. $( this ).css( {
  3864. left: ho.left - cop.left - co.left,
  3865. width: w,
  3866. height: h
  3867. } );
  3868. }
  3869. if ( that._helper && !o.animate && ( /static/ ).test( ce.css( "position" ) ) ) {
  3870. $( this ).css( {
  3871. left: ho.left - cop.left - co.left,
  3872. width: w,
  3873. height: h
  3874. } );
  3875. }
  3876. }
  3877. } );
  3878. $.ui.plugin.add( "resizable", "alsoResize", {
  3879. start: function() {
  3880. var that = $( this ).resizable( "instance" ),
  3881. o = that.options;
  3882. $( o.alsoResize ).each( function() {
  3883. var el = $( this );
  3884. el.data( "ui-resizable-alsoresize", {
  3885. width: parseFloat( el.width() ), height: parseFloat( el.height() ),
  3886. left: parseFloat( el.css( "left" ) ), top: parseFloat( el.css( "top" ) )
  3887. } );
  3888. } );
  3889. },
  3890. resize: function( event, ui ) {
  3891. var that = $( this ).resizable( "instance" ),
  3892. o = that.options,
  3893. os = that.originalSize,
  3894. op = that.originalPosition,
  3895. delta = {
  3896. height: ( that.size.height - os.height ) || 0,
  3897. width: ( that.size.width - os.width ) || 0,
  3898. top: ( that.position.top - op.top ) || 0,
  3899. left: ( that.position.left - op.left ) || 0
  3900. };
  3901. $( o.alsoResize ).each( function() {
  3902. var el = $( this ), start = $( this ).data( "ui-resizable-alsoresize" ), style = {},
  3903. css = el.parents( ui.originalElement[ 0 ] ).length ?
  3904. [ "width", "height" ] :
  3905. [ "width", "height", "top", "left" ];
  3906. $.each( css, function( i, prop ) {
  3907. var sum = ( start[ prop ] || 0 ) + ( delta[ prop ] || 0 );
  3908. if ( sum && sum >= 0 ) {
  3909. style[ prop ] = sum || null;
  3910. }
  3911. } );
  3912. el.css( style );
  3913. } );
  3914. },
  3915. stop: function() {
  3916. $( this ).removeData( "ui-resizable-alsoresize" );
  3917. }
  3918. } );
  3919. $.ui.plugin.add( "resizable", "ghost", {
  3920. start: function() {
  3921. var that = $( this ).resizable( "instance" ), cs = that.size;
  3922. that.ghost = that.originalElement.clone();
  3923. that.ghost.css( {
  3924. opacity: 0.25,
  3925. display: "block",
  3926. position: "relative",
  3927. height: cs.height,
  3928. width: cs.width,
  3929. margin: 0,
  3930. left: 0,
  3931. top: 0
  3932. } );
  3933. that._addClass( that.ghost, "ui-resizable-ghost" );
  3934. // DEPRECATED
  3935. // TODO: remove after 1.12
  3936. if ( $.uiBackCompat !== false && typeof that.options.ghost === "string" ) {
  3937. // Ghost option
  3938. that.ghost.addClass( this.options.ghost );
  3939. }
  3940. that.ghost.appendTo( that.helper );
  3941. },
  3942. resize: function() {
  3943. var that = $( this ).resizable( "instance" );
  3944. if ( that.ghost ) {
  3945. that.ghost.css( {
  3946. position: "relative",
  3947. height: that.size.height,
  3948. width: that.size.width
  3949. } );
  3950. }
  3951. },
  3952. stop: function() {
  3953. var that = $( this ).resizable( "instance" );
  3954. if ( that.ghost && that.helper ) {
  3955. that.helper.get( 0 ).removeChild( that.ghost.get( 0 ) );
  3956. }
  3957. }
  3958. } );
  3959. $.ui.plugin.add( "resizable", "grid", {
  3960. resize: function() {
  3961. var outerDimensions,
  3962. that = $( this ).resizable( "instance" ),
  3963. o = that.options,
  3964. cs = that.size,
  3965. os = that.originalSize,
  3966. op = that.originalPosition,
  3967. a = that.axis,
  3968. grid = typeof o.grid === "number" ? [ o.grid, o.grid ] : o.grid,
  3969. gridX = ( grid[ 0 ] || 1 ),
  3970. gridY = ( grid[ 1 ] || 1 ),
  3971. ox = Math.round( ( cs.width - os.width ) / gridX ) * gridX,
  3972. oy = Math.round( ( cs.height - os.height ) / gridY ) * gridY,
  3973. newWidth = os.width + ox,
  3974. newHeight = os.height + oy,
  3975. isMaxWidth = o.maxWidth && ( o.maxWidth < newWidth ),
  3976. isMaxHeight = o.maxHeight && ( o.maxHeight < newHeight ),
  3977. isMinWidth = o.minWidth && ( o.minWidth > newWidth ),
  3978. isMinHeight = o.minHeight && ( o.minHeight > newHeight );
  3979. o.grid = grid;
  3980. if ( isMinWidth ) {
  3981. newWidth += gridX;
  3982. }
  3983. if ( isMinHeight ) {
  3984. newHeight += gridY;
  3985. }
  3986. if ( isMaxWidth ) {
  3987. newWidth -= gridX;
  3988. }
  3989. if ( isMaxHeight ) {
  3990. newHeight -= gridY;
  3991. }
  3992. if ( /^(se|s|e)$/.test( a ) ) {
  3993. that.size.width = newWidth;
  3994. that.size.height = newHeight;
  3995. } else if ( /^(ne)$/.test( a ) ) {
  3996. that.size.width = newWidth;
  3997. that.size.height = newHeight;
  3998. that.position.top = op.top - oy;
  3999. } else if ( /^(sw)$/.test( a ) ) {
  4000. that.size.width = newWidth;
  4001. that.size.height = newHeight;
  4002. that.position.left = op.left - ox;
  4003. } else {
  4004. if ( newHeight - gridY <= 0 || newWidth - gridX <= 0 ) {
  4005. outerDimensions = that._getPaddingPlusBorderDimensions( this );
  4006. }
  4007. if ( newHeight - gridY > 0 ) {
  4008. that.size.height = newHeight;
  4009. that.position.top = op.top - oy;
  4010. } else {
  4011. newHeight = gridY - outerDimensions.height;
  4012. that.size.height = newHeight;
  4013. that.position.top = op.top + os.height - newHeight;
  4014. }
  4015. if ( newWidth - gridX > 0 ) {
  4016. that.size.width = newWidth;
  4017. that.position.left = op.left - ox;
  4018. } else {
  4019. newWidth = gridX - outerDimensions.width;
  4020. that.size.width = newWidth;
  4021. that.position.left = op.left + os.width - newWidth;
  4022. }
  4023. }
  4024. }
  4025. } );
  4026. var widgetsResizable = $.ui.resizable;
  4027. /*!
  4028. * jQuery UI Sortable 1.12.1
  4029. * http://jqueryui.com
  4030. *
  4031. * Copyright jQuery Foundation and other contributors
  4032. * Released under the MIT license.
  4033. * http://jquery.org/license
  4034. */
  4035. //>>label: Sortable
  4036. //>>group: Interactions
  4037. //>>description: Enables items in a list to be sorted using the mouse.
  4038. //>>docs: http://api.jqueryui.com/sortable/
  4039. //>>demos: http://jqueryui.com/sortable/
  4040. //>>css.structure: ../../themes/base/sortable.css
  4041. var widgetsSortable = $.widget( "ui.sortable", $.ui.mouse, {
  4042. version: "1.12.1",
  4043. widgetEventPrefix: "sort",
  4044. ready: false,
  4045. options: {
  4046. appendTo: "parent",
  4047. axis: false,
  4048. connectWith: false,
  4049. containment: false,
  4050. cursor: "auto",
  4051. cursorAt: false,
  4052. dropOnEmpty: true,
  4053. forcePlaceholderSize: false,
  4054. forceHelperSize: false,
  4055. grid: false,
  4056. handle: false,
  4057. helper: "original",
  4058. items: "> *",
  4059. opacity: false,
  4060. placeholder: false,
  4061. revert: false,
  4062. scroll: true,
  4063. scrollSensitivity: 20,
  4064. scrollSpeed: 20,
  4065. scope: "default",
  4066. tolerance: "intersect",
  4067. zIndex: 1000,
  4068. // Callbacks
  4069. activate: null,
  4070. beforeStop: null,
  4071. change: null,
  4072. deactivate: null,
  4073. out: null,
  4074. over: null,
  4075. receive: null,
  4076. remove: null,
  4077. sort: null,
  4078. start: null,
  4079. stop: null,
  4080. update: null
  4081. },
  4082. _isOverAxis: function( x, reference, size ) {
  4083. return ( x >= reference ) && ( x < ( reference + size ) );
  4084. },
  4085. _isFloating: function( item ) {
  4086. return ( /left|right/ ).test( item.css( "float" ) ) ||
  4087. ( /inline|table-cell/ ).test( item.css( "display" ) );
  4088. },
  4089. _create: function() {
  4090. this.containerCache = {};
  4091. this._addClass( "ui-sortable" );
  4092. //Get the items
  4093. this.refresh();
  4094. //Let's determine the parent's offset
  4095. this.offset = this.element.offset();
  4096. //Initialize mouse events for interaction
  4097. this._mouseInit();
  4098. this._setHandleClassName();
  4099. //We're ready to go
  4100. this.ready = true;
  4101. },
  4102. _setOption: function( key, value ) {
  4103. this._super( key, value );
  4104. if ( key === "handle" ) {
  4105. this._setHandleClassName();
  4106. }
  4107. },
  4108. _setHandleClassName: function() {
  4109. var that = this;
  4110. this._removeClass( this.element.find( ".ui-sortable-handle" ), "ui-sortable-handle" );
  4111. $.each( this.items, function() {
  4112. that._addClass(
  4113. this.instance.options.handle ?
  4114. this.item.find( this.instance.options.handle ) :
  4115. this.item,
  4116. "ui-sortable-handle"
  4117. );
  4118. } );
  4119. },
  4120. _destroy: function() {
  4121. this._mouseDestroy();
  4122. for ( var i = this.items.length - 1; i >= 0; i-- ) {
  4123. this.items[ i ].item.removeData( this.widgetName + "-item" );
  4124. }
  4125. return this;
  4126. },
  4127. _mouseCapture: function( event, overrideHandle ) {
  4128. var currentItem = null,
  4129. validHandle = false,
  4130. that = this;
  4131. if ( this.reverting ) {
  4132. return false;
  4133. }
  4134. if ( this.options.disabled || this.options.type === "static" ) {
  4135. return false;
  4136. }
  4137. //We have to refresh the items data once first
  4138. this._refreshItems( event );
  4139. //Find out if the clicked node (or one of its parents) is a actual item in this.items
  4140. $( event.target ).parents().each( function() {
  4141. if ( $.data( this, that.widgetName + "-item" ) === that ) {
  4142. currentItem = $( this );
  4143. return false;
  4144. }
  4145. } );
  4146. if ( $.data( event.target, that.widgetName + "-item" ) === that ) {
  4147. currentItem = $( event.target );
  4148. }
  4149. if ( !currentItem ) {
  4150. return false;
  4151. }
  4152. if ( this.options.handle && !overrideHandle ) {
  4153. $( this.options.handle, currentItem ).find( "*" ).addBack().each( function() {
  4154. if ( this === event.target ) {
  4155. validHandle = true;
  4156. }
  4157. } );
  4158. if ( !validHandle ) {
  4159. return false;
  4160. }
  4161. }
  4162. this.currentItem = currentItem;
  4163. this._removeCurrentsFromItems();
  4164. return true;
  4165. },
  4166. _mouseStart: function( event, overrideHandle, noActivation ) {
  4167. var i, body,
  4168. o = this.options;
  4169. this.currentContainer = this;
  4170. //We only need to call refreshPositions, because the refreshItems call has been moved to
  4171. // mouseCapture
  4172. this.refreshPositions();
  4173. //Create and append the visible helper
  4174. this.helper = this._createHelper( event );
  4175. //Cache the helper size
  4176. this._cacheHelperProportions();
  4177. /*
  4178. * - Position generation -
  4179. * This block generates everything position related - it's the core of draggables.
  4180. */
  4181. //Cache the margins of the original element
  4182. this._cacheMargins();
  4183. //Get the next scrolling parent
  4184. this.scrollParent = this.helper.scrollParent();
  4185. //The element's absolute position on the page minus margins
  4186. this.offset = this.currentItem.offset();
  4187. this.offset = {
  4188. top: this.offset.top - this.margins.top,
  4189. left: this.offset.left - this.margins.left
  4190. };
  4191. $.extend( this.offset, {
  4192. click: { //Where the click happened, relative to the element
  4193. left: event.pageX - this.offset.left,
  4194. top: event.pageY - this.offset.top
  4195. },
  4196. parent: this._getParentOffset(),
  4197. // This is a relative to absolute position minus the actual position calculation -
  4198. // only used for relative positioned helper
  4199. relative: this._getRelativeOffset()
  4200. } );
  4201. // Only after we got the offset, we can change the helper's position to absolute
  4202. // TODO: Still need to figure out a way to make relative sorting possible
  4203. this.helper.css( "position", "absolute" );
  4204. this.cssPosition = this.helper.css( "position" );
  4205. //Generate the original position
  4206. this.originalPosition = this._generatePosition( event );
  4207. this.originalPageX = event.pageX;
  4208. this.originalPageY = event.pageY;
  4209. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  4210. ( o.cursorAt && this._adjustOffsetFromHelper( o.cursorAt ) );
  4211. //Cache the former DOM position
  4212. this.domPosition = {
  4213. prev: this.currentItem.prev()[ 0 ],
  4214. parent: this.currentItem.parent()[ 0 ]
  4215. };
  4216. // If the helper is not the original, hide the original so it's not playing any role during
  4217. // the drag, won't cause anything bad this way
  4218. if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) {
  4219. this.currentItem.hide();
  4220. }
  4221. //Create the placeholder
  4222. this._createPlaceholder();
  4223. //Set a containment if given in the options
  4224. if ( o.containment ) {
  4225. this._setContainment();
  4226. }
  4227. if ( o.cursor && o.cursor !== "auto" ) { // cursor option
  4228. body = this.document.find( "body" );
  4229. // Support: IE
  4230. this.storedCursor = body.css( "cursor" );
  4231. body.css( "cursor", o.cursor );
  4232. this.storedStylesheet =
  4233. $( "<style>*{ cursor: " + o.cursor + " !important; }</style>" ).appendTo( body );
  4234. }
  4235. if ( o.opacity ) { // opacity option
  4236. if ( this.helper.css( "opacity" ) ) {
  4237. this._storedOpacity = this.helper.css( "opacity" );
  4238. }
  4239. this.helper.css( "opacity", o.opacity );
  4240. }
  4241. if ( o.zIndex ) { // zIndex option
  4242. if ( this.helper.css( "zIndex" ) ) {
  4243. this._storedZIndex = this.helper.css( "zIndex" );
  4244. }
  4245. this.helper.css( "zIndex", o.zIndex );
  4246. }
  4247. //Prepare scrolling
  4248. if ( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  4249. this.scrollParent[ 0 ].tagName !== "HTML" ) {
  4250. this.overflowOffset = this.scrollParent.offset();
  4251. }
  4252. //Call callbacks
  4253. this._trigger( "start", event, this._uiHash() );
  4254. //Recache the helper size
  4255. if ( !this._preserveHelperProportions ) {
  4256. this._cacheHelperProportions();
  4257. }
  4258. //Post "activate" events to possible containers
  4259. if ( !noActivation ) {
  4260. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  4261. this.containers[ i ]._trigger( "activate", event, this._uiHash( this ) );
  4262. }
  4263. }
  4264. //Prepare possible droppables
  4265. if ( $.ui.ddmanager ) {
  4266. $.ui.ddmanager.current = this;
  4267. }
  4268. if ( $.ui.ddmanager && !o.dropBehaviour ) {
  4269. $.ui.ddmanager.prepareOffsets( this, event );
  4270. }
  4271. this.dragging = true;
  4272. this._addClass( this.helper, "ui-sortable-helper" );
  4273. // Execute the drag once - this causes the helper not to be visiblebefore getting its
  4274. // correct position
  4275. this._mouseDrag( event );
  4276. return true;
  4277. },
  4278. _mouseDrag: function( event ) {
  4279. var i, item, itemElement, intersection,
  4280. o = this.options,
  4281. scrolled = false;
  4282. //Compute the helpers position
  4283. this.position = this._generatePosition( event );
  4284. this.positionAbs = this._convertPositionTo( "absolute" );
  4285. if ( !this.lastPositionAbs ) {
  4286. this.lastPositionAbs = this.positionAbs;
  4287. }
  4288. //Do scrolling
  4289. if ( this.options.scroll ) {
  4290. if ( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  4291. this.scrollParent[ 0 ].tagName !== "HTML" ) {
  4292. if ( ( this.overflowOffset.top + this.scrollParent[ 0 ].offsetHeight ) -
  4293. event.pageY < o.scrollSensitivity ) {
  4294. this.scrollParent[ 0 ].scrollTop =
  4295. scrolled = this.scrollParent[ 0 ].scrollTop + o.scrollSpeed;
  4296. } else if ( event.pageY - this.overflowOffset.top < o.scrollSensitivity ) {
  4297. this.scrollParent[ 0 ].scrollTop =
  4298. scrolled = this.scrollParent[ 0 ].scrollTop - o.scrollSpeed;
  4299. }
  4300. if ( ( this.overflowOffset.left + this.scrollParent[ 0 ].offsetWidth ) -
  4301. event.pageX < o.scrollSensitivity ) {
  4302. this.scrollParent[ 0 ].scrollLeft = scrolled =
  4303. this.scrollParent[ 0 ].scrollLeft + o.scrollSpeed;
  4304. } else if ( event.pageX - this.overflowOffset.left < o.scrollSensitivity ) {
  4305. this.scrollParent[ 0 ].scrollLeft = scrolled =
  4306. this.scrollParent[ 0 ].scrollLeft - o.scrollSpeed;
  4307. }
  4308. } else {
  4309. if ( event.pageY - this.document.scrollTop() < o.scrollSensitivity ) {
  4310. scrolled = this.document.scrollTop( this.document.scrollTop() - o.scrollSpeed );
  4311. } else if ( this.window.height() - ( event.pageY - this.document.scrollTop() ) <
  4312. o.scrollSensitivity ) {
  4313. scrolled = this.document.scrollTop( this.document.scrollTop() + o.scrollSpeed );
  4314. }
  4315. if ( event.pageX - this.document.scrollLeft() < o.scrollSensitivity ) {
  4316. scrolled = this.document.scrollLeft(
  4317. this.document.scrollLeft() - o.scrollSpeed
  4318. );
  4319. } else if ( this.window.width() - ( event.pageX - this.document.scrollLeft() ) <
  4320. o.scrollSensitivity ) {
  4321. scrolled = this.document.scrollLeft(
  4322. this.document.scrollLeft() + o.scrollSpeed
  4323. );
  4324. }
  4325. }
  4326. if ( scrolled !== false && $.ui.ddmanager && !o.dropBehaviour ) {
  4327. $.ui.ddmanager.prepareOffsets( this, event );
  4328. }
  4329. }
  4330. //Regenerate the absolute position used for position checks
  4331. this.positionAbs = this._convertPositionTo( "absolute" );
  4332. //Set the helper position
  4333. if ( !this.options.axis || this.options.axis !== "y" ) {
  4334. this.helper[ 0 ].style.left = this.position.left + "px";
  4335. }
  4336. if ( !this.options.axis || this.options.axis !== "x" ) {
  4337. this.helper[ 0 ].style.top = this.position.top + "px";
  4338. }
  4339. //Rearrange
  4340. for ( i = this.items.length - 1; i >= 0; i-- ) {
  4341. //Cache variables and intersection, continue if no intersection
  4342. item = this.items[ i ];
  4343. itemElement = item.item[ 0 ];
  4344. intersection = this._intersectsWithPointer( item );
  4345. if ( !intersection ) {
  4346. continue;
  4347. }
  4348. // Only put the placeholder inside the current Container, skip all
  4349. // items from other containers. This works because when moving
  4350. // an item from one container to another the
  4351. // currentContainer is switched before the placeholder is moved.
  4352. //
  4353. // Without this, moving items in "sub-sortables" can cause
  4354. // the placeholder to jitter between the outer and inner container.
  4355. if ( item.instance !== this.currentContainer ) {
  4356. continue;
  4357. }
  4358. // Cannot intersect with itself
  4359. // no useless actions that have been done before
  4360. // no action if the item moved is the parent of the item checked
  4361. if ( itemElement !== this.currentItem[ 0 ] &&
  4362. this.placeholder[ intersection === 1 ? "next" : "prev" ]()[ 0 ] !== itemElement &&
  4363. !$.contains( this.placeholder[ 0 ], itemElement ) &&
  4364. ( this.options.type === "semi-dynamic" ?
  4365. !$.contains( this.element[ 0 ], itemElement ) :
  4366. true
  4367. )
  4368. ) {
  4369. this.direction = intersection === 1 ? "down" : "up";
  4370. if ( this.options.tolerance === "pointer" || this._intersectsWithSides( item ) ) {
  4371. this._rearrange( event, item );
  4372. } else {
  4373. break;
  4374. }
  4375. this._trigger( "change", event, this._uiHash() );
  4376. break;
  4377. }
  4378. }
  4379. //Post events to containers
  4380. this._contactContainers( event );
  4381. //Interconnect with droppables
  4382. if ( $.ui.ddmanager ) {
  4383. $.ui.ddmanager.drag( this, event );
  4384. }
  4385. //Call callbacks
  4386. this._trigger( "sort", event, this._uiHash() );
  4387. this.lastPositionAbs = this.positionAbs;
  4388. return false;
  4389. },
  4390. _mouseStop: function( event, noPropagation ) {
  4391. if ( !event ) {
  4392. return;
  4393. }
  4394. //If we are using droppables, inform the manager about the drop
  4395. if ( $.ui.ddmanager && !this.options.dropBehaviour ) {
  4396. $.ui.ddmanager.drop( this, event );
  4397. }
  4398. if ( this.options.revert ) {
  4399. var that = this,
  4400. cur = this.placeholder.offset(),
  4401. axis = this.options.axis,
  4402. animation = {};
  4403. if ( !axis || axis === "x" ) {
  4404. animation.left = cur.left - this.offset.parent.left - this.margins.left +
  4405. ( this.offsetParent[ 0 ] === this.document[ 0 ].body ?
  4406. 0 :
  4407. this.offsetParent[ 0 ].scrollLeft
  4408. );
  4409. }
  4410. if ( !axis || axis === "y" ) {
  4411. animation.top = cur.top - this.offset.parent.top - this.margins.top +
  4412. ( this.offsetParent[ 0 ] === this.document[ 0 ].body ?
  4413. 0 :
  4414. this.offsetParent[ 0 ].scrollTop
  4415. );
  4416. }
  4417. this.reverting = true;
  4418. $( this.helper ).animate(
  4419. animation,
  4420. parseInt( this.options.revert, 10 ) || 500,
  4421. function() {
  4422. that._clear( event );
  4423. }
  4424. );
  4425. } else {
  4426. this._clear( event, noPropagation );
  4427. }
  4428. return false;
  4429. },
  4430. cancel: function() {
  4431. if ( this.dragging ) {
  4432. this._mouseUp( new $.Event( "mouseup", { target: null } ) );
  4433. if ( this.options.helper === "original" ) {
  4434. this.currentItem.css( this._storedCSS );
  4435. this._removeClass( this.currentItem, "ui-sortable-helper" );
  4436. } else {
  4437. this.currentItem.show();
  4438. }
  4439. //Post deactivating events to containers
  4440. for ( var i = this.containers.length - 1; i >= 0; i-- ) {
  4441. this.containers[ i ]._trigger( "deactivate", null, this._uiHash( this ) );
  4442. if ( this.containers[ i ].containerCache.over ) {
  4443. this.containers[ i ]._trigger( "out", null, this._uiHash( this ) );
  4444. this.containers[ i ].containerCache.over = 0;
  4445. }
  4446. }
  4447. }
  4448. if ( this.placeholder ) {
  4449. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately,
  4450. // it unbinds ALL events from the original node!
  4451. if ( this.placeholder[ 0 ].parentNode ) {
  4452. this.placeholder[ 0 ].parentNode.removeChild( this.placeholder[ 0 ] );
  4453. }
  4454. if ( this.options.helper !== "original" && this.helper &&
  4455. this.helper[ 0 ].parentNode ) {
  4456. this.helper.remove();
  4457. }
  4458. $.extend( this, {
  4459. helper: null,
  4460. dragging: false,
  4461. reverting: false,
  4462. _noFinalSort: null
  4463. } );
  4464. if ( this.domPosition.prev ) {
  4465. $( this.domPosition.prev ).after( this.currentItem );
  4466. } else {
  4467. $( this.domPosition.parent ).prepend( this.currentItem );
  4468. }
  4469. }
  4470. return this;
  4471. },
  4472. serialize: function( o ) {
  4473. var items = this._getItemsAsjQuery( o && o.connected ),
  4474. str = [];
  4475. o = o || {};
  4476. $( items ).each( function() {
  4477. var res = ( $( o.item || this ).attr( o.attribute || "id" ) || "" )
  4478. .match( o.expression || ( /(.+)[\-=_](.+)/ ) );
  4479. if ( res ) {
  4480. str.push(
  4481. ( o.key || res[ 1 ] + "[]" ) +
  4482. "=" + ( o.key && o.expression ? res[ 1 ] : res[ 2 ] ) );
  4483. }
  4484. } );
  4485. if ( !str.length && o.key ) {
  4486. str.push( o.key + "=" );
  4487. }
  4488. return str.join( "&" );
  4489. },
  4490. toArray: function( o ) {
  4491. var items = this._getItemsAsjQuery( o && o.connected ),
  4492. ret = [];
  4493. o = o || {};
  4494. items.each( function() {
  4495. ret.push( $( o.item || this ).attr( o.attribute || "id" ) || "" );
  4496. } );
  4497. return ret;
  4498. },
  4499. /* Be careful with the following core functions */
  4500. _intersectsWith: function( item ) {
  4501. var x1 = this.positionAbs.left,
  4502. x2 = x1 + this.helperProportions.width,
  4503. y1 = this.positionAbs.top,
  4504. y2 = y1 + this.helperProportions.height,
  4505. l = item.left,
  4506. r = l + item.width,
  4507. t = item.top,
  4508. b = t + item.height,
  4509. dyClick = this.offset.click.top,
  4510. dxClick = this.offset.click.left,
  4511. isOverElementHeight = ( this.options.axis === "x" ) || ( ( y1 + dyClick ) > t &&
  4512. ( y1 + dyClick ) < b ),
  4513. isOverElementWidth = ( this.options.axis === "y" ) || ( ( x1 + dxClick ) > l &&
  4514. ( x1 + dxClick ) < r ),
  4515. isOverElement = isOverElementHeight && isOverElementWidth;
  4516. if ( this.options.tolerance === "pointer" ||
  4517. this.options.forcePointerForContainers ||
  4518. ( this.options.tolerance !== "pointer" &&
  4519. this.helperProportions[ this.floating ? "width" : "height" ] >
  4520. item[ this.floating ? "width" : "height" ] )
  4521. ) {
  4522. return isOverElement;
  4523. } else {
  4524. return ( l < x1 + ( this.helperProportions.width / 2 ) && // Right Half
  4525. x2 - ( this.helperProportions.width / 2 ) < r && // Left Half
  4526. t < y1 + ( this.helperProportions.height / 2 ) && // Bottom Half
  4527. y2 - ( this.helperProportions.height / 2 ) < b ); // Top Half
  4528. }
  4529. },
  4530. _intersectsWithPointer: function( item ) {
  4531. var verticalDirection, horizontalDirection,
  4532. isOverElementHeight = ( this.options.axis === "x" ) ||
  4533. this._isOverAxis(
  4534. this.positionAbs.top + this.offset.click.top, item.top, item.height ),
  4535. isOverElementWidth = ( this.options.axis === "y" ) ||
  4536. this._isOverAxis(
  4537. this.positionAbs.left + this.offset.click.left, item.left, item.width ),
  4538. isOverElement = isOverElementHeight && isOverElementWidth;
  4539. if ( !isOverElement ) {
  4540. return false;
  4541. }
  4542. verticalDirection = this._getDragVerticalDirection();
  4543. horizontalDirection = this._getDragHorizontalDirection();
  4544. return this.floating ?
  4545. ( ( horizontalDirection === "right" || verticalDirection === "down" ) ? 2 : 1 )
  4546. : ( verticalDirection && ( verticalDirection === "down" ? 2 : 1 ) );
  4547. },
  4548. _intersectsWithSides: function( item ) {
  4549. var isOverBottomHalf = this._isOverAxis( this.positionAbs.top +
  4550. this.offset.click.top, item.top + ( item.height / 2 ), item.height ),
  4551. isOverRightHalf = this._isOverAxis( this.positionAbs.left +
  4552. this.offset.click.left, item.left + ( item.width / 2 ), item.width ),
  4553. verticalDirection = this._getDragVerticalDirection(),
  4554. horizontalDirection = this._getDragHorizontalDirection();
  4555. if ( this.floating && horizontalDirection ) {
  4556. return ( ( horizontalDirection === "right" && isOverRightHalf ) ||
  4557. ( horizontalDirection === "left" && !isOverRightHalf ) );
  4558. } else {
  4559. return verticalDirection && ( ( verticalDirection === "down" && isOverBottomHalf ) ||
  4560. ( verticalDirection === "up" && !isOverBottomHalf ) );
  4561. }
  4562. },
  4563. _getDragVerticalDirection: function() {
  4564. var delta = this.positionAbs.top - this.lastPositionAbs.top;
  4565. return delta !== 0 && ( delta > 0 ? "down" : "up" );
  4566. },
  4567. _getDragHorizontalDirection: function() {
  4568. var delta = this.positionAbs.left - this.lastPositionAbs.left;
  4569. return delta !== 0 && ( delta > 0 ? "right" : "left" );
  4570. },
  4571. refresh: function( event ) {
  4572. this._refreshItems( event );
  4573. this._setHandleClassName();
  4574. this.refreshPositions();
  4575. return this;
  4576. },
  4577. _connectWith: function() {
  4578. var options = this.options;
  4579. return options.connectWith.constructor === String ?
  4580. [ options.connectWith ] :
  4581. options.connectWith;
  4582. },
  4583. _getItemsAsjQuery: function( connected ) {
  4584. var i, j, cur, inst,
  4585. items = [],
  4586. queries = [],
  4587. connectWith = this._connectWith();
  4588. if ( connectWith && connected ) {
  4589. for ( i = connectWith.length - 1; i >= 0; i-- ) {
  4590. cur = $( connectWith[ i ], this.document[ 0 ] );
  4591. for ( j = cur.length - 1; j >= 0; j-- ) {
  4592. inst = $.data( cur[ j ], this.widgetFullName );
  4593. if ( inst && inst !== this && !inst.options.disabled ) {
  4594. queries.push( [ $.isFunction( inst.options.items ) ?
  4595. inst.options.items.call( inst.element ) :
  4596. $( inst.options.items, inst.element )
  4597. .not( ".ui-sortable-helper" )
  4598. .not( ".ui-sortable-placeholder" ), inst ] );
  4599. }
  4600. }
  4601. }
  4602. }
  4603. queries.push( [ $.isFunction( this.options.items ) ?
  4604. this.options.items
  4605. .call( this.element, null, { options: this.options, item: this.currentItem } ) :
  4606. $( this.options.items, this.element )
  4607. .not( ".ui-sortable-helper" )
  4608. .not( ".ui-sortable-placeholder" ), this ] );
  4609. function addItems() {
  4610. items.push( this );
  4611. }
  4612. for ( i = queries.length - 1; i >= 0; i-- ) {
  4613. queries[ i ][ 0 ].each( addItems );
  4614. }
  4615. return $( items );
  4616. },
  4617. _removeCurrentsFromItems: function() {
  4618. var list = this.currentItem.find( ":data(" + this.widgetName + "-item)" );
  4619. this.items = $.grep( this.items, function( item ) {
  4620. for ( var j = 0; j < list.length; j++ ) {
  4621. if ( list[ j ] === item.item[ 0 ] ) {
  4622. return false;
  4623. }
  4624. }
  4625. return true;
  4626. } );
  4627. },
  4628. _refreshItems: function( event ) {
  4629. this.items = [];
  4630. this.containers = [ this ];
  4631. var i, j, cur, inst, targetData, _queries, item, queriesLength,
  4632. items = this.items,
  4633. queries = [ [ $.isFunction( this.options.items ) ?
  4634. this.options.items.call( this.element[ 0 ], event, { item: this.currentItem } ) :
  4635. $( this.options.items, this.element ), this ] ],
  4636. connectWith = this._connectWith();
  4637. //Shouldn't be run the first time through due to massive slow-down
  4638. if ( connectWith && this.ready ) {
  4639. for ( i = connectWith.length - 1; i >= 0; i-- ) {
  4640. cur = $( connectWith[ i ], this.document[ 0 ] );
  4641. for ( j = cur.length - 1; j >= 0; j-- ) {
  4642. inst = $.data( cur[ j ], this.widgetFullName );
  4643. if ( inst && inst !== this && !inst.options.disabled ) {
  4644. queries.push( [ $.isFunction( inst.options.items ) ?
  4645. inst.options.items
  4646. .call( inst.element[ 0 ], event, { item: this.currentItem } ) :
  4647. $( inst.options.items, inst.element ), inst ] );
  4648. this.containers.push( inst );
  4649. }
  4650. }
  4651. }
  4652. }
  4653. for ( i = queries.length - 1; i >= 0; i-- ) {
  4654. targetData = queries[ i ][ 1 ];
  4655. _queries = queries[ i ][ 0 ];
  4656. for ( j = 0, queriesLength = _queries.length; j < queriesLength; j++ ) {
  4657. item = $( _queries[ j ] );
  4658. // Data for target checking (mouse manager)
  4659. item.data( this.widgetName + "-item", targetData );
  4660. items.push( {
  4661. item: item,
  4662. instance: targetData,
  4663. width: 0, height: 0,
  4664. left: 0, top: 0
  4665. } );
  4666. }
  4667. }
  4668. },
  4669. refreshPositions: function( fast ) {
  4670. // Determine whether items are being displayed horizontally
  4671. this.floating = this.items.length ?
  4672. this.options.axis === "x" || this._isFloating( this.items[ 0 ].item ) :
  4673. false;
  4674. //This has to be redone because due to the item being moved out/into the offsetParent,
  4675. // the offsetParent's position will change
  4676. if ( this.offsetParent && this.helper ) {
  4677. this.offset.parent = this._getParentOffset();
  4678. }
  4679. var i, item, t, p;
  4680. for ( i = this.items.length - 1; i >= 0; i-- ) {
  4681. item = this.items[ i ];
  4682. //We ignore calculating positions of all connected containers when we're not over them
  4683. if ( item.instance !== this.currentContainer && this.currentContainer &&
  4684. item.item[ 0 ] !== this.currentItem[ 0 ] ) {
  4685. continue;
  4686. }
  4687. t = this.options.toleranceElement ?
  4688. $( this.options.toleranceElement, item.item ) :
  4689. item.item;
  4690. if ( !fast ) {
  4691. item.width = t.outerWidth();
  4692. item.height = t.outerHeight();
  4693. }
  4694. p = t.offset();
  4695. item.left = p.left;
  4696. item.top = p.top;
  4697. }
  4698. if ( this.options.custom && this.options.custom.refreshContainers ) {
  4699. this.options.custom.refreshContainers.call( this );
  4700. } else {
  4701. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  4702. p = this.containers[ i ].element.offset();
  4703. this.containers[ i ].containerCache.left = p.left;
  4704. this.containers[ i ].containerCache.top = p.top;
  4705. this.containers[ i ].containerCache.width =
  4706. this.containers[ i ].element.outerWidth();
  4707. this.containers[ i ].containerCache.height =
  4708. this.containers[ i ].element.outerHeight();
  4709. }
  4710. }
  4711. return this;
  4712. },
  4713. _createPlaceholder: function( that ) {
  4714. that = that || this;
  4715. var className,
  4716. o = that.options;
  4717. if ( !o.placeholder || o.placeholder.constructor === String ) {
  4718. className = o.placeholder;
  4719. o.placeholder = {
  4720. element: function() {
  4721. var nodeName = that.currentItem[ 0 ].nodeName.toLowerCase(),
  4722. element = $( "<" + nodeName + ">", that.document[ 0 ] );
  4723. that._addClass( element, "ui-sortable-placeholder",
  4724. className || that.currentItem[ 0 ].className )
  4725. ._removeClass( element, "ui-sortable-helper" );
  4726. if ( nodeName === "tbody" ) {
  4727. that._createTrPlaceholder(
  4728. that.currentItem.find( "tr" ).eq( 0 ),
  4729. $( "<tr>", that.document[ 0 ] ).appendTo( element )
  4730. );
  4731. } else if ( nodeName === "tr" ) {
  4732. that._createTrPlaceholder( that.currentItem, element );
  4733. } else if ( nodeName === "img" ) {
  4734. element.attr( "src", that.currentItem.attr( "src" ) );
  4735. }
  4736. if ( !className ) {
  4737. element.css( "visibility", "hidden" );
  4738. }
  4739. return element;
  4740. },
  4741. update: function( container, p ) {
  4742. // 1. If a className is set as 'placeholder option, we don't force sizes -
  4743. // the class is responsible for that
  4744. // 2. The option 'forcePlaceholderSize can be enabled to force it even if a
  4745. // class name is specified
  4746. if ( className && !o.forcePlaceholderSize ) {
  4747. return;
  4748. }
  4749. //If the element doesn't have a actual height by itself (without styles coming
  4750. // from a stylesheet), it receives the inline height from the dragged item
  4751. if ( !p.height() ) {
  4752. p.height(
  4753. that.currentItem.innerHeight() -
  4754. parseInt( that.currentItem.css( "paddingTop" ) || 0, 10 ) -
  4755. parseInt( that.currentItem.css( "paddingBottom" ) || 0, 10 ) );
  4756. }
  4757. if ( !p.width() ) {
  4758. p.width(
  4759. that.currentItem.innerWidth() -
  4760. parseInt( that.currentItem.css( "paddingLeft" ) || 0, 10 ) -
  4761. parseInt( that.currentItem.css( "paddingRight" ) || 0, 10 ) );
  4762. }
  4763. }
  4764. };
  4765. }
  4766. //Create the placeholder
  4767. that.placeholder = $( o.placeholder.element.call( that.element, that.currentItem ) );
  4768. //Append it after the actual current item
  4769. that.currentItem.after( that.placeholder );
  4770. //Update the size of the placeholder (TODO: Logic to fuzzy, see line 316/317)
  4771. o.placeholder.update( that, that.placeholder );
  4772. },
  4773. _createTrPlaceholder: function( sourceTr, targetTr ) {
  4774. var that = this;
  4775. sourceTr.children().each( function() {
  4776. $( "<td>&#160;</td>", that.document[ 0 ] )
  4777. .attr( "colspan", $( this ).attr( "colspan" ) || 1 )
  4778. .appendTo( targetTr );
  4779. } );
  4780. },
  4781. _contactContainers: function( event ) {
  4782. var i, j, dist, itemWithLeastDistance, posProperty, sizeProperty, cur, nearBottom,
  4783. floating, axis,
  4784. innermostContainer = null,
  4785. innermostIndex = null;
  4786. // Get innermost container that intersects with item
  4787. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  4788. // Never consider a container that's located within the item itself
  4789. if ( $.contains( this.currentItem[ 0 ], this.containers[ i ].element[ 0 ] ) ) {
  4790. continue;
  4791. }
  4792. if ( this._intersectsWith( this.containers[ i ].containerCache ) ) {
  4793. // If we've already found a container and it's more "inner" than this, then continue
  4794. if ( innermostContainer &&
  4795. $.contains(
  4796. this.containers[ i ].element[ 0 ],
  4797. innermostContainer.element[ 0 ] ) ) {
  4798. continue;
  4799. }
  4800. innermostContainer = this.containers[ i ];
  4801. innermostIndex = i;
  4802. } else {
  4803. // container doesn't intersect. trigger "out" event if necessary
  4804. if ( this.containers[ i ].containerCache.over ) {
  4805. this.containers[ i ]._trigger( "out", event, this._uiHash( this ) );
  4806. this.containers[ i ].containerCache.over = 0;
  4807. }
  4808. }
  4809. }
  4810. // If no intersecting containers found, return
  4811. if ( !innermostContainer ) {
  4812. return;
  4813. }
  4814. // Move the item into the container if it's not there already
  4815. if ( this.containers.length === 1 ) {
  4816. if ( !this.containers[ innermostIndex ].containerCache.over ) {
  4817. this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash( this ) );
  4818. this.containers[ innermostIndex ].containerCache.over = 1;
  4819. }
  4820. } else {
  4821. // When entering a new container, we will find the item with the least distance and
  4822. // append our item near it
  4823. dist = 10000;
  4824. itemWithLeastDistance = null;
  4825. floating = innermostContainer.floating || this._isFloating( this.currentItem );
  4826. posProperty = floating ? "left" : "top";
  4827. sizeProperty = floating ? "width" : "height";
  4828. axis = floating ? "pageX" : "pageY";
  4829. for ( j = this.items.length - 1; j >= 0; j-- ) {
  4830. if ( !$.contains(
  4831. this.containers[ innermostIndex ].element[ 0 ], this.items[ j ].item[ 0 ] )
  4832. ) {
  4833. continue;
  4834. }
  4835. if ( this.items[ j ].item[ 0 ] === this.currentItem[ 0 ] ) {
  4836. continue;
  4837. }
  4838. cur = this.items[ j ].item.offset()[ posProperty ];
  4839. nearBottom = false;
  4840. if ( event[ axis ] - cur > this.items[ j ][ sizeProperty ] / 2 ) {
  4841. nearBottom = true;
  4842. }
  4843. if ( Math.abs( event[ axis ] - cur ) < dist ) {
  4844. dist = Math.abs( event[ axis ] - cur );
  4845. itemWithLeastDistance = this.items[ j ];
  4846. this.direction = nearBottom ? "up" : "down";
  4847. }
  4848. }
  4849. //Check if dropOnEmpty is enabled
  4850. if ( !itemWithLeastDistance && !this.options.dropOnEmpty ) {
  4851. return;
  4852. }
  4853. if ( this.currentContainer === this.containers[ innermostIndex ] ) {
  4854. if ( !this.currentContainer.containerCache.over ) {
  4855. this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash() );
  4856. this.currentContainer.containerCache.over = 1;
  4857. }
  4858. return;
  4859. }
  4860. itemWithLeastDistance ?
  4861. this._rearrange( event, itemWithLeastDistance, null, true ) :
  4862. this._rearrange( event, null, this.containers[ innermostIndex ].element, true );
  4863. this._trigger( "change", event, this._uiHash() );
  4864. this.containers[ innermostIndex ]._trigger( "change", event, this._uiHash( this ) );
  4865. this.currentContainer = this.containers[ innermostIndex ];
  4866. //Update the placeholder
  4867. this.options.placeholder.update( this.currentContainer, this.placeholder );
  4868. this.containers[ innermostIndex ]._trigger( "over", event, this._uiHash( this ) );
  4869. this.containers[ innermostIndex ].containerCache.over = 1;
  4870. }
  4871. },
  4872. _createHelper: function( event ) {
  4873. var o = this.options,
  4874. helper = $.isFunction( o.helper ) ?
  4875. $( o.helper.apply( this.element[ 0 ], [ event, this.currentItem ] ) ) :
  4876. ( o.helper === "clone" ? this.currentItem.clone() : this.currentItem );
  4877. //Add the helper to the DOM if that didn't happen already
  4878. if ( !helper.parents( "body" ).length ) {
  4879. $( o.appendTo !== "parent" ?
  4880. o.appendTo :
  4881. this.currentItem[ 0 ].parentNode )[ 0 ].appendChild( helper[ 0 ] );
  4882. }
  4883. if ( helper[ 0 ] === this.currentItem[ 0 ] ) {
  4884. this._storedCSS = {
  4885. width: this.currentItem[ 0 ].style.width,
  4886. height: this.currentItem[ 0 ].style.height,
  4887. position: this.currentItem.css( "position" ),
  4888. top: this.currentItem.css( "top" ),
  4889. left: this.currentItem.css( "left" )
  4890. };
  4891. }
  4892. if ( !helper[ 0 ].style.width || o.forceHelperSize ) {
  4893. helper.width( this.currentItem.width() );
  4894. }
  4895. if ( !helper[ 0 ].style.height || o.forceHelperSize ) {
  4896. helper.height( this.currentItem.height() );
  4897. }
  4898. return helper;
  4899. },
  4900. _adjustOffsetFromHelper: function( obj ) {
  4901. if ( typeof obj === "string" ) {
  4902. obj = obj.split( " " );
  4903. }
  4904. if ( $.isArray( obj ) ) {
  4905. obj = { left: +obj[ 0 ], top: +obj[ 1 ] || 0 };
  4906. }
  4907. if ( "left" in obj ) {
  4908. this.offset.click.left = obj.left + this.margins.left;
  4909. }
  4910. if ( "right" in obj ) {
  4911. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  4912. }
  4913. if ( "top" in obj ) {
  4914. this.offset.click.top = obj.top + this.margins.top;
  4915. }
  4916. if ( "bottom" in obj ) {
  4917. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  4918. }
  4919. },
  4920. _getParentOffset: function() {
  4921. //Get the offsetParent and cache its position
  4922. this.offsetParent = this.helper.offsetParent();
  4923. var po = this.offsetParent.offset();
  4924. // This is a special case where we need to modify a offset calculated on start, since the
  4925. // following happened:
  4926. // 1. The position of the helper is absolute, so it's position is calculated based on the
  4927. // next positioned parent
  4928. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't
  4929. // the document, which means that the scroll is included in the initial calculation of the
  4930. // offset of the parent, and never recalculated upon drag
  4931. if ( this.cssPosition === "absolute" && this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  4932. $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) {
  4933. po.left += this.scrollParent.scrollLeft();
  4934. po.top += this.scrollParent.scrollTop();
  4935. }
  4936. // This needs to be actually done for all browsers, since pageX/pageY includes this
  4937. // information with an ugly IE fix
  4938. if ( this.offsetParent[ 0 ] === this.document[ 0 ].body ||
  4939. ( this.offsetParent[ 0 ].tagName &&
  4940. this.offsetParent[ 0 ].tagName.toLowerCase() === "html" && $.ui.ie ) ) {
  4941. po = { top: 0, left: 0 };
  4942. }
  4943. return {
  4944. top: po.top + ( parseInt( this.offsetParent.css( "borderTopWidth" ), 10 ) || 0 ),
  4945. left: po.left + ( parseInt( this.offsetParent.css( "borderLeftWidth" ), 10 ) || 0 )
  4946. };
  4947. },
  4948. _getRelativeOffset: function() {
  4949. if ( this.cssPosition === "relative" ) {
  4950. var p = this.currentItem.position();
  4951. return {
  4952. top: p.top - ( parseInt( this.helper.css( "top" ), 10 ) || 0 ) +
  4953. this.scrollParent.scrollTop(),
  4954. left: p.left - ( parseInt( this.helper.css( "left" ), 10 ) || 0 ) +
  4955. this.scrollParent.scrollLeft()
  4956. };
  4957. } else {
  4958. return { top: 0, left: 0 };
  4959. }
  4960. },
  4961. _cacheMargins: function() {
  4962. this.margins = {
  4963. left: ( parseInt( this.currentItem.css( "marginLeft" ), 10 ) || 0 ),
  4964. top: ( parseInt( this.currentItem.css( "marginTop" ), 10 ) || 0 )
  4965. };
  4966. },
  4967. _cacheHelperProportions: function() {
  4968. this.helperProportions = {
  4969. width: this.helper.outerWidth(),
  4970. height: this.helper.outerHeight()
  4971. };
  4972. },
  4973. _setContainment: function() {
  4974. var ce, co, over,
  4975. o = this.options;
  4976. if ( o.containment === "parent" ) {
  4977. o.containment = this.helper[ 0 ].parentNode;
  4978. }
  4979. if ( o.containment === "document" || o.containment === "window" ) {
  4980. this.containment = [
  4981. 0 - this.offset.relative.left - this.offset.parent.left,
  4982. 0 - this.offset.relative.top - this.offset.parent.top,
  4983. o.containment === "document" ?
  4984. this.document.width() :
  4985. this.window.width() - this.helperProportions.width - this.margins.left,
  4986. ( o.containment === "document" ?
  4987. ( this.document.height() || document.body.parentNode.scrollHeight ) :
  4988. this.window.height() || this.document[ 0 ].body.parentNode.scrollHeight
  4989. ) - this.helperProportions.height - this.margins.top
  4990. ];
  4991. }
  4992. if ( !( /^(document|window|parent)$/ ).test( o.containment ) ) {
  4993. ce = $( o.containment )[ 0 ];
  4994. co = $( o.containment ).offset();
  4995. over = ( $( ce ).css( "overflow" ) !== "hidden" );
  4996. this.containment = [
  4997. co.left + ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) +
  4998. ( parseInt( $( ce ).css( "paddingLeft" ), 10 ) || 0 ) - this.margins.left,
  4999. co.top + ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) +
  5000. ( parseInt( $( ce ).css( "paddingTop" ), 10 ) || 0 ) - this.margins.top,
  5001. co.left + ( over ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) -
  5002. ( parseInt( $( ce ).css( "borderLeftWidth" ), 10 ) || 0 ) -
  5003. ( parseInt( $( ce ).css( "paddingRight" ), 10 ) || 0 ) -
  5004. this.helperProportions.width - this.margins.left,
  5005. co.top + ( over ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) -
  5006. ( parseInt( $( ce ).css( "borderTopWidth" ), 10 ) || 0 ) -
  5007. ( parseInt( $( ce ).css( "paddingBottom" ), 10 ) || 0 ) -
  5008. this.helperProportions.height - this.margins.top
  5009. ];
  5010. }
  5011. },
  5012. _convertPositionTo: function( d, pos ) {
  5013. if ( !pos ) {
  5014. pos = this.position;
  5015. }
  5016. var mod = d === "absolute" ? 1 : -1,
  5017. scroll = this.cssPosition === "absolute" &&
  5018. !( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  5019. $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ?
  5020. this.offsetParent :
  5021. this.scrollParent,
  5022. scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName );
  5023. return {
  5024. top: (
  5025. // The absolute mouse position
  5026. pos.top +
  5027. // Only for relative positioned nodes: Relative offset from element to offset parent
  5028. this.offset.relative.top * mod +
  5029. // The offsetParent's offset without borders (offset + border)
  5030. this.offset.parent.top * mod -
  5031. ( ( this.cssPosition === "fixed" ?
  5032. -this.scrollParent.scrollTop() :
  5033. ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) * mod )
  5034. ),
  5035. left: (
  5036. // The absolute mouse position
  5037. pos.left +
  5038. // Only for relative positioned nodes: Relative offset from element to offset parent
  5039. this.offset.relative.left * mod +
  5040. // The offsetParent's offset without borders (offset + border)
  5041. this.offset.parent.left * mod -
  5042. ( ( this.cssPosition === "fixed" ?
  5043. -this.scrollParent.scrollLeft() : scrollIsRootNode ? 0 :
  5044. scroll.scrollLeft() ) * mod )
  5045. )
  5046. };
  5047. },
  5048. _generatePosition: function( event ) {
  5049. var top, left,
  5050. o = this.options,
  5051. pageX = event.pageX,
  5052. pageY = event.pageY,
  5053. scroll = this.cssPosition === "absolute" &&
  5054. !( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  5055. $.contains( this.scrollParent[ 0 ], this.offsetParent[ 0 ] ) ) ?
  5056. this.offsetParent :
  5057. this.scrollParent,
  5058. scrollIsRootNode = ( /(html|body)/i ).test( scroll[ 0 ].tagName );
  5059. // This is another very weird special case that only happens for relative elements:
  5060. // 1. If the css position is relative
  5061. // 2. and the scroll parent is the document or similar to the offset parent
  5062. // we have to refresh the relative offset during the scroll so there are no jumps
  5063. if ( this.cssPosition === "relative" && !( this.scrollParent[ 0 ] !== this.document[ 0 ] &&
  5064. this.scrollParent[ 0 ] !== this.offsetParent[ 0 ] ) ) {
  5065. this.offset.relative = this._getRelativeOffset();
  5066. }
  5067. /*
  5068. * - Position constraining -
  5069. * Constrain the position to a mix of grid, containment.
  5070. */
  5071. if ( this.originalPosition ) { //If we are not dragging yet, we won't check for options
  5072. if ( this.containment ) {
  5073. if ( event.pageX - this.offset.click.left < this.containment[ 0 ] ) {
  5074. pageX = this.containment[ 0 ] + this.offset.click.left;
  5075. }
  5076. if ( event.pageY - this.offset.click.top < this.containment[ 1 ] ) {
  5077. pageY = this.containment[ 1 ] + this.offset.click.top;
  5078. }
  5079. if ( event.pageX - this.offset.click.left > this.containment[ 2 ] ) {
  5080. pageX = this.containment[ 2 ] + this.offset.click.left;
  5081. }
  5082. if ( event.pageY - this.offset.click.top > this.containment[ 3 ] ) {
  5083. pageY = this.containment[ 3 ] + this.offset.click.top;
  5084. }
  5085. }
  5086. if ( o.grid ) {
  5087. top = this.originalPageY + Math.round( ( pageY - this.originalPageY ) /
  5088. o.grid[ 1 ] ) * o.grid[ 1 ];
  5089. pageY = this.containment ?
  5090. ( ( top - this.offset.click.top >= this.containment[ 1 ] &&
  5091. top - this.offset.click.top <= this.containment[ 3 ] ) ?
  5092. top :
  5093. ( ( top - this.offset.click.top >= this.containment[ 1 ] ) ?
  5094. top - o.grid[ 1 ] : top + o.grid[ 1 ] ) ) :
  5095. top;
  5096. left = this.originalPageX + Math.round( ( pageX - this.originalPageX ) /
  5097. o.grid[ 0 ] ) * o.grid[ 0 ];
  5098. pageX = this.containment ?
  5099. ( ( left - this.offset.click.left >= this.containment[ 0 ] &&
  5100. left - this.offset.click.left <= this.containment[ 2 ] ) ?
  5101. left :
  5102. ( ( left - this.offset.click.left >= this.containment[ 0 ] ) ?
  5103. left - o.grid[ 0 ] : left + o.grid[ 0 ] ) ) :
  5104. left;
  5105. }
  5106. }
  5107. return {
  5108. top: (
  5109. // The absolute mouse position
  5110. pageY -
  5111. // Click offset (relative to the element)
  5112. this.offset.click.top -
  5113. // Only for relative positioned nodes: Relative offset from element to offset parent
  5114. this.offset.relative.top -
  5115. // The offsetParent's offset without borders (offset + border)
  5116. this.offset.parent.top +
  5117. ( ( this.cssPosition === "fixed" ?
  5118. -this.scrollParent.scrollTop() :
  5119. ( scrollIsRootNode ? 0 : scroll.scrollTop() ) ) )
  5120. ),
  5121. left: (
  5122. // The absolute mouse position
  5123. pageX -
  5124. // Click offset (relative to the element)
  5125. this.offset.click.left -
  5126. // Only for relative positioned nodes: Relative offset from element to offset parent
  5127. this.offset.relative.left -
  5128. // The offsetParent's offset without borders (offset + border)
  5129. this.offset.parent.left +
  5130. ( ( this.cssPosition === "fixed" ?
  5131. -this.scrollParent.scrollLeft() :
  5132. scrollIsRootNode ? 0 : scroll.scrollLeft() ) )
  5133. )
  5134. };
  5135. },
  5136. _rearrange: function( event, i, a, hardRefresh ) {
  5137. a ? a[ 0 ].appendChild( this.placeholder[ 0 ] ) :
  5138. i.item[ 0 ].parentNode.insertBefore( this.placeholder[ 0 ],
  5139. ( this.direction === "down" ? i.item[ 0 ] : i.item[ 0 ].nextSibling ) );
  5140. //Various things done here to improve the performance:
  5141. // 1. we create a setTimeout, that calls refreshPositions
  5142. // 2. on the instance, we have a counter variable, that get's higher after every append
  5143. // 3. on the local scope, we copy the counter variable, and check in the timeout,
  5144. // if it's still the same
  5145. // 4. this lets only the last addition to the timeout stack through
  5146. this.counter = this.counter ? ++this.counter : 1;
  5147. var counter = this.counter;
  5148. this._delay( function() {
  5149. if ( counter === this.counter ) {
  5150. //Precompute after each DOM insertion, NOT on mousemove
  5151. this.refreshPositions( !hardRefresh );
  5152. }
  5153. } );
  5154. },
  5155. _clear: function( event, noPropagation ) {
  5156. this.reverting = false;
  5157. // We delay all events that have to be triggered to after the point where the placeholder
  5158. // has been removed and everything else normalized again
  5159. var i,
  5160. delayedTriggers = [];
  5161. // We first have to update the dom position of the actual currentItem
  5162. // Note: don't do it if the current item is already removed (by a user), or it gets
  5163. // reappended (see #4088)
  5164. if ( !this._noFinalSort && this.currentItem.parent().length ) {
  5165. this.placeholder.before( this.currentItem );
  5166. }
  5167. this._noFinalSort = null;
  5168. if ( this.helper[ 0 ] === this.currentItem[ 0 ] ) {
  5169. for ( i in this._storedCSS ) {
  5170. if ( this._storedCSS[ i ] === "auto" || this._storedCSS[ i ] === "static" ) {
  5171. this._storedCSS[ i ] = "";
  5172. }
  5173. }
  5174. this.currentItem.css( this._storedCSS );
  5175. this._removeClass( this.currentItem, "ui-sortable-helper" );
  5176. } else {
  5177. this.currentItem.show();
  5178. }
  5179. if ( this.fromOutside && !noPropagation ) {
  5180. delayedTriggers.push( function( event ) {
  5181. this._trigger( "receive", event, this._uiHash( this.fromOutside ) );
  5182. } );
  5183. }
  5184. if ( ( this.fromOutside ||
  5185. this.domPosition.prev !==
  5186. this.currentItem.prev().not( ".ui-sortable-helper" )[ 0 ] ||
  5187. this.domPosition.parent !== this.currentItem.parent()[ 0 ] ) && !noPropagation ) {
  5188. // Trigger update callback if the DOM position has changed
  5189. delayedTriggers.push( function( event ) {
  5190. this._trigger( "update", event, this._uiHash() );
  5191. } );
  5192. }
  5193. // Check if the items Container has Changed and trigger appropriate
  5194. // events.
  5195. if ( this !== this.currentContainer ) {
  5196. if ( !noPropagation ) {
  5197. delayedTriggers.push( function( event ) {
  5198. this._trigger( "remove", event, this._uiHash() );
  5199. } );
  5200. delayedTriggers.push( ( function( c ) {
  5201. return function( event ) {
  5202. c._trigger( "receive", event, this._uiHash( this ) );
  5203. };
  5204. } ).call( this, this.currentContainer ) );
  5205. delayedTriggers.push( ( function( c ) {
  5206. return function( event ) {
  5207. c._trigger( "update", event, this._uiHash( this ) );
  5208. };
  5209. } ).call( this, this.currentContainer ) );
  5210. }
  5211. }
  5212. //Post events to containers
  5213. function delayEvent( type, instance, container ) {
  5214. return function( event ) {
  5215. container._trigger( type, event, instance._uiHash( instance ) );
  5216. };
  5217. }
  5218. for ( i = this.containers.length - 1; i >= 0; i-- ) {
  5219. if ( !noPropagation ) {
  5220. delayedTriggers.push( delayEvent( "deactivate", this, this.containers[ i ] ) );
  5221. }
  5222. if ( this.containers[ i ].containerCache.over ) {
  5223. delayedTriggers.push( delayEvent( "out", this, this.containers[ i ] ) );
  5224. this.containers[ i ].containerCache.over = 0;
  5225. }
  5226. }
  5227. //Do what was originally in plugins
  5228. if ( this.storedCursor ) {
  5229. this.document.find( "body" ).css( "cursor", this.storedCursor );
  5230. this.storedStylesheet.remove();
  5231. }
  5232. if ( this._storedOpacity ) {
  5233. this.helper.css( "opacity", this._storedOpacity );
  5234. }
  5235. if ( this._storedZIndex ) {
  5236. this.helper.css( "zIndex", this._storedZIndex === "auto" ? "" : this._storedZIndex );
  5237. }
  5238. this.dragging = false;
  5239. if ( !noPropagation ) {
  5240. this._trigger( "beforeStop", event, this._uiHash() );
  5241. }
  5242. //$(this.placeholder[0]).remove(); would have been the jQuery way - unfortunately,
  5243. // it unbinds ALL events from the original node!
  5244. this.placeholder[ 0 ].parentNode.removeChild( this.placeholder[ 0 ] );
  5245. if ( !this.cancelHelperRemoval ) {
  5246. if ( this.helper[ 0 ] !== this.currentItem[ 0 ] ) {
  5247. this.helper.remove();
  5248. }
  5249. this.helper = null;
  5250. }
  5251. if ( !noPropagation ) {
  5252. for ( i = 0; i < delayedTriggers.length; i++ ) {
  5253. // Trigger all delayed events
  5254. delayedTriggers[ i ].call( this, event );
  5255. }
  5256. this._trigger( "stop", event, this._uiHash() );
  5257. }
  5258. this.fromOutside = false;
  5259. return !this.cancelHelperRemoval;
  5260. },
  5261. _trigger: function() {
  5262. if ( $.Widget.prototype._trigger.apply( this, arguments ) === false ) {
  5263. this.cancel();
  5264. }
  5265. },
  5266. _uiHash: function( _inst ) {
  5267. var inst = _inst || this;
  5268. return {
  5269. helper: inst.helper,
  5270. placeholder: inst.placeholder || $( [] ),
  5271. position: inst.position,
  5272. originalPosition: inst.originalPosition,
  5273. offset: inst.positionAbs,
  5274. item: inst.currentItem,
  5275. sender: _inst ? _inst.element : null
  5276. };
  5277. }
  5278. } );
  5279. }));