jquery-layout.js 270 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487
  1. /*! jQuery UI - v1.11.4 - 2016-02-10
  2. * http://jqueryui.com
  3. * Includes: core.js, widget.js, mouse.js, draggable.js, droppable.js
  4. * Copyright jQuery Foundation and other contributors; Licensed MIT */
  5. /*!
  6. * jQuery UI Core 1.11.4
  7. * http://jqueryui.com
  8. *
  9. * Copyright jQuery Foundation and other contributors
  10. * Released under the MIT license.
  11. * http://jquery.org/license
  12. *
  13. * http://api.jqueryui.com/category/ui-core/
  14. */
  15. // $.ui might exist from components with no dependencies, e.g., $.ui.position
  16. $.ui = $.ui || {};
  17. $.extend( $.ui, {
  18. version: "1.11.4",
  19. keyCode: {
  20. BACKSPACE: 8,
  21. COMMA: 188,
  22. DELETE: 46,
  23. DOWN: 40,
  24. END: 35,
  25. ENTER: 13,
  26. ESCAPE: 27,
  27. HOME: 36,
  28. LEFT: 37,
  29. PAGE_DOWN: 34,
  30. PAGE_UP: 33,
  31. PERIOD: 190,
  32. RIGHT: 39,
  33. SPACE: 32,
  34. TAB: 9,
  35. UP: 38
  36. }
  37. });
  38. // plugins
  39. $.fn.extend({
  40. scrollParent: function( includeHidden ) {
  41. var position = this.css( "position" ),
  42. excludeStaticParent = position === "absolute",
  43. overflowRegex = includeHidden ? /(auto|scroll|hidden)/ : /(auto|scroll)/,
  44. scrollParent = this.parents().filter( function() {
  45. var parent = $( this );
  46. if ( excludeStaticParent && parent.css( "position" ) === "static" ) {
  47. return false;
  48. }
  49. return overflowRegex.test( parent.css( "overflow" ) + parent.css( "overflow-y" ) + parent.css( "overflow-x" ) );
  50. }).eq( 0 );
  51. return position === "fixed" || !scrollParent.length ? $( this[ 0 ].ownerDocument || document ) : scrollParent;
  52. },
  53. uniqueId: (function() {
  54. var uuid = 0;
  55. return function() {
  56. return this.each(function() {
  57. if ( !this.id ) {
  58. this.id = "ui-id-" + ( ++uuid );
  59. }
  60. });
  61. };
  62. })(),
  63. removeUniqueId: function() {
  64. return this.each(function() {
  65. if ( /^ui-id-\d+$/.test( this.id ) ) {
  66. $( this ).removeAttr( "id" );
  67. }
  68. });
  69. }
  70. });
  71. // selectors
  72. function focusable( element, isTabIndexNotNaN ) {
  73. var map, mapName, img,
  74. nodeName = element.nodeName.toLowerCase();
  75. if ( "area" === nodeName ) {
  76. map = element.parentNode;
  77. mapName = map.name;
  78. if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
  79. return false;
  80. }
  81. img = $( "img[usemap='#" + mapName + "']" )[ 0 ];
  82. return !!img && visible( img );
  83. }
  84. return ( /^(input|select|textarea|button|object)$/.test( nodeName ) ?
  85. !element.disabled :
  86. "a" === nodeName ?
  87. element.href || isTabIndexNotNaN :
  88. isTabIndexNotNaN) &&
  89. // the element and all of its ancestors must be visible
  90. visible( element );
  91. }
  92. function visible( element ) {
  93. return $.expr.filters.visible( element ) &&
  94. !$( element ).parents().addBack().filter(function() {
  95. return $.css( this, "visibility" ) === "hidden";
  96. }).length;
  97. }
  98. $.extend( $.expr[ ":" ], {
  99. data: $.expr.createPseudo ?
  100. $.expr.createPseudo(function( dataName ) {
  101. return function( elem ) {
  102. return !!$.data( elem, dataName );
  103. };
  104. }) :
  105. // support: jQuery <1.8
  106. function( elem, i, match ) {
  107. return !!$.data( elem, match[ 3 ] );
  108. },
  109. focusable: function( element ) {
  110. return focusable( element, !isNaN( $.attr( element, "tabindex" ) ) );
  111. },
  112. tabbable: function( element ) {
  113. var tabIndex = $.attr( element, "tabindex" ),
  114. isTabIndexNaN = isNaN( tabIndex );
  115. return ( isTabIndexNaN || tabIndex >= 0 ) && focusable( element, !isTabIndexNaN );
  116. }
  117. });
  118. // support: jQuery <1.8
  119. if ( !$( "<a>" ).outerWidth( 1 ).jquery ) {
  120. $.each( [ "Width", "Height" ], function( i, name ) {
  121. var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
  122. type = name.toLowerCase(),
  123. orig = {
  124. innerWidth: $.fn.innerWidth,
  125. innerHeight: $.fn.innerHeight,
  126. outerWidth: $.fn.outerWidth,
  127. outerHeight: $.fn.outerHeight
  128. };
  129. function reduce( elem, size, border, margin ) {
  130. $.each( side, function() {
  131. size -= parseFloat( $.css( elem, "padding" + this ) ) || 0;
  132. if ( border ) {
  133. size -= parseFloat( $.css( elem, "border" + this + "Width" ) ) || 0;
  134. }
  135. if ( margin ) {
  136. size -= parseFloat( $.css( elem, "margin" + this ) ) || 0;
  137. }
  138. });
  139. return size;
  140. }
  141. $.fn[ "inner" + name ] = function( size ) {
  142. if ( size === undefined ) {
  143. return orig[ "inner" + name ].call( this );
  144. }
  145. return this.each(function() {
  146. $( this ).css( type, reduce( this, size ) + "px" );
  147. });
  148. };
  149. $.fn[ "outer" + name] = function( size, margin ) {
  150. if ( typeof size !== "number" ) {
  151. return orig[ "outer" + name ].call( this, size );
  152. }
  153. return this.each(function() {
  154. $( this).css( type, reduce( this, size, true, margin ) + "px" );
  155. });
  156. };
  157. });
  158. }
  159. // support: jQuery <1.8
  160. if ( !$.fn.addBack ) {
  161. $.fn.addBack = function( selector ) {
  162. return this.add( selector == null ?
  163. this.prevObject : this.prevObject.filter( selector )
  164. );
  165. };
  166. }
  167. // support: jQuery 1.6.1, 1.6.2 (http://bugs.jquery.com/ticket/9413)
  168. if ( $( "<a>" ).data( "a-b", "a" ).removeData( "a-b" ).data( "a-b" ) ) {
  169. $.fn.removeData = (function( removeData ) {
  170. return function( key ) {
  171. if ( arguments.length ) {
  172. return removeData.call( this, $.camelCase( key ) );
  173. } else {
  174. return removeData.call( this );
  175. }
  176. };
  177. })( $.fn.removeData );
  178. }
  179. // deprecated
  180. $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() );
  181. $.fn.extend({
  182. focus: (function( orig ) {
  183. return function( delay, fn ) {
  184. return typeof delay === "number" ?
  185. this.each(function() {
  186. var elem = this;
  187. setTimeout(function() {
  188. $( elem ).focus();
  189. if ( fn ) {
  190. fn.call( elem );
  191. }
  192. }, delay );
  193. }) :
  194. orig.apply( this, arguments );
  195. };
  196. })( $.fn.focus ),
  197. disableSelection: (function() {
  198. var eventType = "onselectstart" in document.createElement( "div" ) ?
  199. "selectstart" :
  200. "mousedown";
  201. return function() {
  202. return this.bind( eventType + ".ui-disableSelection", function( event ) {
  203. event.preventDefault();
  204. });
  205. };
  206. })(),
  207. enableSelection: function() {
  208. return this.unbind( ".ui-disableSelection" );
  209. },
  210. zIndex: function( zIndex ) {
  211. if ( zIndex !== undefined ) {
  212. return this.css( "zIndex", zIndex );
  213. }
  214. if ( this.length ) {
  215. var elem = $( this[ 0 ] ), position, value;
  216. while ( elem.length && elem[ 0 ] !== document ) {
  217. // Ignore z-index if position is set to a value where z-index is ignored by the browser
  218. // This makes behavior of this function consistent across browsers
  219. // WebKit always returns auto if the element is positioned
  220. position = elem.css( "position" );
  221. if ( position === "absolute" || position === "relative" || position === "fixed" ) {
  222. // IE returns 0 when zIndex is not specified
  223. // other browsers return a string
  224. // we ignore the case of nested elements with an explicit value of 0
  225. // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
  226. value = parseInt( elem.css( "zIndex" ), 10 );
  227. if ( !isNaN( value ) && value !== 0 ) {
  228. return value;
  229. }
  230. }
  231. elem = elem.parent();
  232. }
  233. }
  234. return 0;
  235. }
  236. });
  237. // $.ui.plugin is deprecated. Use $.widget() extensions instead.
  238. $.ui.plugin = {
  239. add: function( module, option, set ) {
  240. var i,
  241. proto = $.ui[ module ].prototype;
  242. for ( i in set ) {
  243. proto.plugins[ i ] = proto.plugins[ i ] || [];
  244. proto.plugins[ i ].push( [ option, set[ i ] ] );
  245. }
  246. },
  247. call: function( instance, name, args, allowDisconnected ) {
  248. var i,
  249. set = instance.plugins[ name ];
  250. if ( !set ) {
  251. return;
  252. }
  253. if ( !allowDisconnected && ( !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) ) {
  254. return;
  255. }
  256. for ( i = 0; i < set.length; i++ ) {
  257. if ( instance.options[ set[ i ][ 0 ] ] ) {
  258. set[ i ][ 1 ].apply( instance.element, args );
  259. }
  260. }
  261. }
  262. };
  263. /*!
  264. * jQuery UI Widget 1.11.4
  265. * http://jqueryui.com
  266. *
  267. * Copyright jQuery Foundation and other contributors
  268. * Released under the MIT license.
  269. * http://jquery.org/license
  270. *
  271. * http://api.jqueryui.com/jQuery.widget/
  272. */
  273. var widget_uuid = 0,
  274. widget_slice = Array.prototype.slice;
  275. $.cleanData = (function( orig ) {
  276. return function( elems ) {
  277. var events, elem, i;
  278. for ( i = 0; (elem = elems[i]) != null; i++ ) {
  279. try {
  280. // Only trigger remove when necessary to save time
  281. events = $._data( elem, "events" );
  282. if ( events && events.remove ) {
  283. $( elem ).triggerHandler( "remove" );
  284. }
  285. // http://bugs.jquery.com/ticket/8235
  286. } catch ( e ) {}
  287. }
  288. orig( elems );
  289. };
  290. })( $.cleanData );
  291. $.widget = function( name, base, prototype ) {
  292. var fullName, existingConstructor, constructor, basePrototype,
  293. // proxiedPrototype allows the provided prototype to remain unmodified
  294. // so that it can be used as a mixin for multiple widgets (#8876)
  295. proxiedPrototype = {},
  296. namespace = name.split( "." )[ 0 ];
  297. name = name.split( "." )[ 1 ];
  298. fullName = namespace + "-" + name;
  299. if ( !prototype ) {
  300. prototype = base;
  301. base = $.Widget;
  302. }
  303. // create selector for plugin
  304. $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) {
  305. return !!$.data( elem, fullName );
  306. };
  307. $[ namespace ] = $[ namespace ] || {};
  308. existingConstructor = $[ namespace ][ name ];
  309. constructor = $[ namespace ][ name ] = function( options, element ) {
  310. // allow instantiation without "new" keyword
  311. if ( !this._createWidget ) {
  312. return new constructor( options, element );
  313. }
  314. // allow instantiation without initializing for simple inheritance
  315. // must use "new" keyword (the code above always passes args)
  316. if ( arguments.length ) {
  317. this._createWidget( options, element );
  318. }
  319. };
  320. // extend with the existing constructor to carry over any static properties
  321. $.extend( constructor, existingConstructor, {
  322. version: prototype.version,
  323. // copy the object used to create the prototype in case we need to
  324. // redefine the widget later
  325. _proto: $.extend( {}, prototype ),
  326. // track widgets that inherit from this widget in case this widget is
  327. // redefined after a widget inherits from it
  328. _childConstructors: []
  329. });
  330. basePrototype = new base();
  331. // we need to make the options hash a property directly on the new instance
  332. // otherwise we'll modify the options hash on the prototype that we're
  333. // inheriting from
  334. basePrototype.options = $.widget.extend( {}, basePrototype.options );
  335. $.each( prototype, function( prop, value ) {
  336. if ( !$.isFunction( value ) ) {
  337. proxiedPrototype[ prop ] = value;
  338. return;
  339. }
  340. proxiedPrototype[ prop ] = (function() {
  341. var _super = function() {
  342. return base.prototype[ prop ].apply( this, arguments );
  343. },
  344. _superApply = function( args ) {
  345. return base.prototype[ prop ].apply( this, args );
  346. };
  347. return function() {
  348. var __super = this._super,
  349. __superApply = this._superApply,
  350. returnValue;
  351. this._super = _super;
  352. this._superApply = _superApply;
  353. returnValue = value.apply( this, arguments );
  354. this._super = __super;
  355. this._superApply = __superApply;
  356. return returnValue;
  357. };
  358. })();
  359. });
  360. constructor.prototype = $.widget.extend( basePrototype, {
  361. // TODO: remove support for widgetEventPrefix
  362. // always use the name + a colon as the prefix, e.g., draggable:start
  363. // don't prefix for widgets that aren't DOM-based
  364. widgetEventPrefix: existingConstructor ? (basePrototype.widgetEventPrefix || name) : name
  365. }, proxiedPrototype, {
  366. constructor: constructor,
  367. namespace: namespace,
  368. widgetName: name,
  369. widgetFullName: fullName
  370. });
  371. // If this widget is being redefined then we need to find all widgets that
  372. // are inheriting from it and redefine all of them so that they inherit from
  373. // the new version of this widget. We're essentially trying to replace one
  374. // level in the prototype chain.
  375. if ( existingConstructor ) {
  376. $.each( existingConstructor._childConstructors, function( i, child ) {
  377. var childPrototype = child.prototype;
  378. // redefine the child widget using the same prototype that was
  379. // originally used, but inherit from the new version of the base
  380. $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto );
  381. });
  382. // remove the list of existing child constructors from the old constructor
  383. // so the old child constructors can be garbage collected
  384. delete existingConstructor._childConstructors;
  385. } else {
  386. base._childConstructors.push( constructor );
  387. }
  388. $.widget.bridge( name, constructor );
  389. return constructor;
  390. };
  391. $.widget.extend = function( target ) {
  392. var input = widget_slice.call( arguments, 1 ),
  393. inputIndex = 0,
  394. inputLength = input.length,
  395. key,
  396. value;
  397. for ( ; inputIndex < inputLength; inputIndex++ ) {
  398. for ( key in input[ inputIndex ] ) {
  399. value = input[ inputIndex ][ key ];
  400. if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) {
  401. // Clone objects
  402. if ( $.isPlainObject( value ) ) {
  403. target[ key ] = $.isPlainObject( target[ key ] ) ?
  404. $.widget.extend( {}, target[ key ], value ) :
  405. // Don't extend strings, arrays, etc. with objects
  406. $.widget.extend( {}, value );
  407. // Copy everything else by reference
  408. } else {
  409. target[ key ] = value;
  410. }
  411. }
  412. }
  413. }
  414. return target;
  415. };
  416. $.widget.bridge = function( name, object ) {
  417. var fullName = object.prototype.widgetFullName || name;
  418. $.fn[ name ] = function( options ) {
  419. var isMethodCall = typeof options === "string",
  420. args = widget_slice.call( arguments, 1 ),
  421. returnValue = this;
  422. if ( isMethodCall ) {
  423. this.each(function() {
  424. var methodValue,
  425. instance = $.data( this, fullName );
  426. if ( options === "instance" ) {
  427. returnValue = instance;
  428. return false;
  429. }
  430. if ( !instance ) {
  431. return $.error( "cannot call methods on " + name + " prior to initialization; " +
  432. "attempted to call method '" + options + "'" );
  433. }
  434. if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) {
  435. return $.error( "no such method '" + options + "' for " + name + " widget instance" );
  436. }
  437. methodValue = instance[ options ].apply( instance, args );
  438. if ( methodValue !== instance && methodValue !== undefined ) {
  439. returnValue = methodValue && methodValue.jquery ?
  440. returnValue.pushStack( methodValue.get() ) :
  441. methodValue;
  442. return false;
  443. }
  444. });
  445. } else {
  446. // Allow multiple hashes to be passed on init
  447. if ( args.length ) {
  448. options = $.widget.extend.apply( null, [ options ].concat(args) );
  449. }
  450. this.each(function() {
  451. var instance = $.data( this, fullName );
  452. if ( instance ) {
  453. instance.option( options || {} );
  454. if ( instance._init ) {
  455. instance._init();
  456. }
  457. } else {
  458. $.data( this, fullName, new object( options, this ) );
  459. }
  460. });
  461. }
  462. return returnValue;
  463. };
  464. };
  465. $.Widget = function( /* options, element */ ) {};
  466. $.Widget._childConstructors = [];
  467. $.Widget.prototype = {
  468. widgetName: "widget",
  469. widgetEventPrefix: "",
  470. defaultElement: "<div>",
  471. options: {
  472. disabled: false,
  473. // callbacks
  474. create: null
  475. },
  476. _createWidget: function( options, element ) {
  477. element = $( element || this.defaultElement || this )[ 0 ];
  478. this.element = $( element );
  479. this.uuid = widget_uuid++;
  480. this.eventNamespace = "." + this.widgetName + this.uuid;
  481. this.bindings = $();
  482. this.hoverable = $();
  483. this.focusable = $();
  484. if ( element !== this ) {
  485. $.data( element, this.widgetFullName, this );
  486. this._on( true, this.element, {
  487. remove: function( event ) {
  488. if ( event.target === element ) {
  489. this.destroy();
  490. }
  491. }
  492. });
  493. this.document = $( element.style ?
  494. // element within the document
  495. element.ownerDocument :
  496. // element is window or document
  497. element.document || element );
  498. this.window = $( this.document[0].defaultView || this.document[0].parentWindow );
  499. }
  500. this.options = $.widget.extend( {},
  501. this.options,
  502. this._getCreateOptions(),
  503. options );
  504. this._create();
  505. this._trigger( "create", null, this._getCreateEventData() );
  506. this._init();
  507. },
  508. _getCreateOptions: $.noop,
  509. _getCreateEventData: $.noop,
  510. _create: $.noop,
  511. _init: $.noop,
  512. destroy: function() {
  513. this._destroy();
  514. // we can probably remove the unbind calls in 2.0
  515. // all event bindings should go through this._on()
  516. this.element
  517. .unbind( this.eventNamespace )
  518. .removeData( this.widgetFullName )
  519. // support: jquery <1.6.3
  520. // http://bugs.jquery.com/ticket/9413
  521. .removeData( $.camelCase( this.widgetFullName ) );
  522. this.widget()
  523. .unbind( this.eventNamespace )
  524. .removeAttr( "aria-disabled" )
  525. .removeClass(
  526. this.widgetFullName + "-disabled " +
  527. "ui-state-disabled" );
  528. // clean up events and states
  529. this.bindings.unbind( this.eventNamespace );
  530. this.hoverable.removeClass( "ui-state-hover" );
  531. this.focusable.removeClass( "ui-state-focus" );
  532. },
  533. _destroy: $.noop,
  534. widget: function() {
  535. return this.element;
  536. },
  537. option: function( key, value ) {
  538. var options = key,
  539. parts,
  540. curOption,
  541. i;
  542. if ( arguments.length === 0 ) {
  543. // don't return a reference to the internal hash
  544. return $.widget.extend( {}, this.options );
  545. }
  546. if ( typeof key === "string" ) {
  547. // handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
  548. options = {};
  549. parts = key.split( "." );
  550. key = parts.shift();
  551. if ( parts.length ) {
  552. curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] );
  553. for ( i = 0; i < parts.length - 1; i++ ) {
  554. curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {};
  555. curOption = curOption[ parts[ i ] ];
  556. }
  557. key = parts.pop();
  558. if ( arguments.length === 1 ) {
  559. return curOption[ key ] === undefined ? null : curOption[ key ];
  560. }
  561. curOption[ key ] = value;
  562. } else {
  563. if ( arguments.length === 1 ) {
  564. return this.options[ key ] === undefined ? null : this.options[ key ];
  565. }
  566. options[ key ] = value;
  567. }
  568. }
  569. this._setOptions( options );
  570. return this;
  571. },
  572. _setOptions: function( options ) {
  573. var key;
  574. for ( key in options ) {
  575. this._setOption( key, options[ key ] );
  576. }
  577. return this;
  578. },
  579. _setOption: function( key, value ) {
  580. this.options[ key ] = value;
  581. if ( key === "disabled" ) {
  582. this.widget()
  583. .toggleClass( this.widgetFullName + "-disabled", !!value );
  584. // If the widget is becoming disabled, then nothing is interactive
  585. if ( value ) {
  586. this.hoverable.removeClass( "ui-state-hover" );
  587. this.focusable.removeClass( "ui-state-focus" );
  588. }
  589. }
  590. return this;
  591. },
  592. enable: function() {
  593. return this._setOptions({ disabled: false });
  594. },
  595. disable: function() {
  596. return this._setOptions({ disabled: true });
  597. },
  598. _on: function( suppressDisabledCheck, element, handlers ) {
  599. var delegateElement,
  600. instance = this;
  601. // no suppressDisabledCheck flag, shuffle arguments
  602. if ( typeof suppressDisabledCheck !== "boolean" ) {
  603. handlers = element;
  604. element = suppressDisabledCheck;
  605. suppressDisabledCheck = false;
  606. }
  607. // no element argument, shuffle and use this.element
  608. if ( !handlers ) {
  609. handlers = element;
  610. element = this.element;
  611. delegateElement = this.widget();
  612. } else {
  613. element = delegateElement = $( element );
  614. this.bindings = this.bindings.add( element );
  615. }
  616. $.each( handlers, function( event, handler ) {
  617. function handlerProxy() {
  618. // allow widgets to customize the disabled handling
  619. // - disabled as an array instead of boolean
  620. // - disabled class as method for disabling individual parts
  621. if ( !suppressDisabledCheck &&
  622. ( instance.options.disabled === true ||
  623. $( this ).hasClass( "ui-state-disabled" ) ) ) {
  624. return;
  625. }
  626. return ( typeof handler === "string" ? instance[ handler ] : handler )
  627. .apply( instance, arguments );
  628. }
  629. // copy the guid so direct unbinding works
  630. if ( typeof handler !== "string" ) {
  631. handlerProxy.guid = handler.guid =
  632. handler.guid || handlerProxy.guid || $.guid++;
  633. }
  634. var match = event.match( /^([\w:-]*)\s*(.*)$/ ),
  635. eventName = match[1] + instance.eventNamespace,
  636. selector = match[2];
  637. if ( selector ) {
  638. delegateElement.delegate( selector, eventName, handlerProxy );
  639. } else {
  640. element.bind( eventName, handlerProxy );
  641. }
  642. });
  643. },
  644. _off: function( element, eventName ) {
  645. eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) +
  646. this.eventNamespace;
  647. element.unbind( eventName ).undelegate( eventName );
  648. // Clear the stack to avoid memory leaks (#10056)
  649. this.bindings = $( this.bindings.not( element ).get() );
  650. this.focusable = $( this.focusable.not( element ).get() );
  651. this.hoverable = $( this.hoverable.not( element ).get() );
  652. },
  653. _delay: function( handler, delay ) {
  654. function handlerProxy() {
  655. return ( typeof handler === "string" ? instance[ handler ] : handler )
  656. .apply( instance, arguments );
  657. }
  658. var instance = this;
  659. return setTimeout( handlerProxy, delay || 0 );
  660. },
  661. _hoverable: function( element ) {
  662. this.hoverable = this.hoverable.add( element );
  663. this._on( element, {
  664. mouseenter: function( event ) {
  665. $( event.currentTarget ).addClass( "ui-state-hover" );
  666. },
  667. mouseleave: function( event ) {
  668. $( event.currentTarget ).removeClass( "ui-state-hover" );
  669. }
  670. });
  671. },
  672. _focusable: function( element ) {
  673. this.focusable = this.focusable.add( element );
  674. this._on( element, {
  675. focusin: function( event ) {
  676. $( event.currentTarget ).addClass( "ui-state-focus" );
  677. },
  678. focusout: function( event ) {
  679. $( event.currentTarget ).removeClass( "ui-state-focus" );
  680. }
  681. });
  682. },
  683. _trigger: function( type, event, data ) {
  684. var prop, orig,
  685. callback = this.options[ type ];
  686. data = data || {};
  687. event = $.Event( event );
  688. event.type = ( type === this.widgetEventPrefix ?
  689. type :
  690. this.widgetEventPrefix + type ).toLowerCase();
  691. // the original event may come from any element
  692. // so we need to reset the target on the new event
  693. event.target = this.element[ 0 ];
  694. // copy original event properties over to the new event
  695. orig = event.originalEvent;
  696. if ( orig ) {
  697. for ( prop in orig ) {
  698. if ( !( prop in event ) ) {
  699. event[ prop ] = orig[ prop ];
  700. }
  701. }
  702. }
  703. this.element.trigger( event, data );
  704. return !( $.isFunction( callback ) &&
  705. callback.apply( this.element[0], [ event ].concat( data ) ) === false ||
  706. event.isDefaultPrevented() );
  707. }
  708. };
  709. $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) {
  710. $.Widget.prototype[ "_" + method ] = function( element, options, callback ) {
  711. if ( typeof options === "string" ) {
  712. options = { effect: options };
  713. }
  714. var hasOptions,
  715. effectName = !options ?
  716. method :
  717. options === true || typeof options === "number" ?
  718. defaultEffect :
  719. options.effect || defaultEffect;
  720. options = options || {};
  721. if ( typeof options === "number" ) {
  722. options = { duration: options };
  723. }
  724. hasOptions = !$.isEmptyObject( options );
  725. options.complete = callback;
  726. if ( options.delay ) {
  727. element.delay( options.delay );
  728. }
  729. if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) {
  730. element[ method ]( options );
  731. } else if ( effectName !== method && element[ effectName ] ) {
  732. element[ effectName ]( options.duration, options.easing, callback );
  733. } else {
  734. element.queue(function( next ) {
  735. $( this )[ method ]();
  736. if ( callback ) {
  737. callback.call( element[ 0 ] );
  738. }
  739. next();
  740. });
  741. }
  742. };
  743. });
  744. var widget = $.widget;
  745. /*!
  746. * jQuery UI Mouse 1.11.4
  747. * http://jqueryui.com
  748. *
  749. * Copyright jQuery Foundation and other contributors
  750. * Released under the MIT license.
  751. * http://jquery.org/license
  752. *
  753. * http://api.jqueryui.com/mouse/
  754. */
  755. var mouseHandled = false;
  756. $( document ).mouseup( function() {
  757. mouseHandled = false;
  758. });
  759. var mouse = $.widget("ui.mouse", {
  760. version: "1.11.4",
  761. options: {
  762. cancel: "input,textarea,button,select,option",
  763. distance: 1,
  764. delay: 0
  765. },
  766. _mouseInit: function() {
  767. var that = this;
  768. this.element
  769. .bind("mousedown." + this.widgetName, function(event) {
  770. return that._mouseDown(event);
  771. })
  772. .bind("click." + this.widgetName, function(event) {
  773. if (true === $.data(event.target, that.widgetName + ".preventClickEvent")) {
  774. $.removeData(event.target, that.widgetName + ".preventClickEvent");
  775. event.stopImmediatePropagation();
  776. return false;
  777. }
  778. });
  779. this.started = false;
  780. },
  781. // TODO: make sure destroying one instance of mouse doesn't mess with
  782. // other instances of mouse
  783. _mouseDestroy: function() {
  784. this.element.unbind("." + this.widgetName);
  785. if ( this._mouseMoveDelegate ) {
  786. this.document
  787. .unbind("mousemove." + this.widgetName, this._mouseMoveDelegate)
  788. .unbind("mouseup." + this.widgetName, this._mouseUpDelegate);
  789. }
  790. },
  791. _mouseDown: function(event) {
  792. // don't let more than one widget handle mouseStart
  793. if ( mouseHandled ) {
  794. return;
  795. }
  796. this._mouseMoved = false;
  797. // we may have missed mouseup (out of window)
  798. (this._mouseStarted && this._mouseUp(event));
  799. this._mouseDownEvent = event;
  800. var that = this,
  801. btnIsLeft = (event.which === 1),
  802. // event.target.nodeName works around a bug in IE 8 with
  803. // disabled inputs (#7620)
  804. elIsCancel = (typeof this.options.cancel === "string" && event.target.nodeName ? $(event.target).closest(this.options.cancel).length : false);
  805. if (!btnIsLeft || elIsCancel || !this._mouseCapture(event)) {
  806. return true;
  807. }
  808. this.mouseDelayMet = !this.options.delay;
  809. if (!this.mouseDelayMet) {
  810. this._mouseDelayTimer = setTimeout(function() {
  811. that.mouseDelayMet = true;
  812. }, this.options.delay);
  813. }
  814. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  815. this._mouseStarted = (this._mouseStart(event) !== false);
  816. if (!this._mouseStarted) {
  817. event.preventDefault();
  818. return true;
  819. }
  820. }
  821. // Click event may never have fired (Gecko & Opera)
  822. if (true === $.data(event.target, this.widgetName + ".preventClickEvent")) {
  823. $.removeData(event.target, this.widgetName + ".preventClickEvent");
  824. }
  825. // these delegates are required to keep context
  826. this._mouseMoveDelegate = function(event) {
  827. return that._mouseMove(event);
  828. };
  829. this._mouseUpDelegate = function(event) {
  830. return that._mouseUp(event);
  831. };
  832. this.document
  833. .bind( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  834. .bind( "mouseup." + this.widgetName, this._mouseUpDelegate );
  835. event.preventDefault();
  836. mouseHandled = true;
  837. return true;
  838. },
  839. _mouseMove: function(event) {
  840. // Only check for mouseups outside the document if you've moved inside the document
  841. // at least once. This prevents the firing of mouseup in the case of IE<9, which will
  842. // fire a mousemove event if content is placed under the cursor. See #7778
  843. // Support: IE <9
  844. if ( this._mouseMoved ) {
  845. // IE mouseup check - mouseup happened when mouse was out of window
  846. if ($.ui.ie && ( !document.documentMode || document.documentMode < 9 ) && !event.button) {
  847. return this._mouseUp(event);
  848. // Iframe mouseup check - mouseup occurred in another document
  849. } else if ( !event.which ) {
  850. return this._mouseUp( event );
  851. }
  852. }
  853. if ( event.which || event.button ) {
  854. this._mouseMoved = true;
  855. }
  856. if (this._mouseStarted) {
  857. this._mouseDrag(event);
  858. return event.preventDefault();
  859. }
  860. if (this._mouseDistanceMet(event) && this._mouseDelayMet(event)) {
  861. this._mouseStarted =
  862. (this._mouseStart(this._mouseDownEvent, event) !== false);
  863. (this._mouseStarted ? this._mouseDrag(event) : this._mouseUp(event));
  864. }
  865. return !this._mouseStarted;
  866. },
  867. _mouseUp: function(event) {
  868. this.document
  869. .unbind( "mousemove." + this.widgetName, this._mouseMoveDelegate )
  870. .unbind( "mouseup." + this.widgetName, this._mouseUpDelegate );
  871. if (this._mouseStarted) {
  872. this._mouseStarted = false;
  873. if (event.target === this._mouseDownEvent.target) {
  874. $.data(event.target, this.widgetName + ".preventClickEvent", true);
  875. }
  876. this._mouseStop(event);
  877. }
  878. mouseHandled = false;
  879. return false;
  880. },
  881. _mouseDistanceMet: function(event) {
  882. return (Math.max(
  883. Math.abs(this._mouseDownEvent.pageX - event.pageX),
  884. Math.abs(this._mouseDownEvent.pageY - event.pageY)
  885. ) >= this.options.distance
  886. );
  887. },
  888. _mouseDelayMet: function(/* event */) {
  889. return this.mouseDelayMet;
  890. },
  891. // These are placeholder methods, to be overriden by extending plugin
  892. _mouseStart: function(/* event */) {},
  893. _mouseDrag: function(/* event */) {},
  894. _mouseStop: function(/* event */) {},
  895. _mouseCapture: function(/* event */) { return true; }
  896. });
  897. /*!
  898. * jQuery UI Draggable 1.11.4
  899. * http://jqueryui.com
  900. *
  901. * Copyright jQuery Foundation and other contributors
  902. * Released under the MIT license.
  903. * http://jquery.org/license
  904. *
  905. * http://api.jqueryui.com/draggable/
  906. */
  907. $.widget("ui.draggable", $.ui.mouse, {
  908. version: "1.11.4",
  909. widgetEventPrefix: "drag",
  910. options: {
  911. addClasses: true,
  912. appendTo: "parent",
  913. axis: false,
  914. connectToSortable: false,
  915. containment: false,
  916. cursor: "auto",
  917. cursorAt: false,
  918. grid: false,
  919. handle: false,
  920. helper: "original",
  921. iframeFix: false,
  922. opacity: false,
  923. refreshPositions: false,
  924. revert: false,
  925. revertDuration: 500,
  926. scope: "default",
  927. scroll: true,
  928. scrollSensitivity: 20,
  929. scrollSpeed: 20,
  930. snap: false,
  931. snapMode: "both",
  932. snapTolerance: 20,
  933. stack: false,
  934. zIndex: false,
  935. // callbacks
  936. drag: null,
  937. start: null,
  938. stop: null
  939. },
  940. _create: function() {
  941. if ( this.options.helper === "original" ) {
  942. this._setPositionRelative();
  943. }
  944. if (this.options.addClasses){
  945. this.element.addClass("ui-draggable");
  946. }
  947. if (this.options.disabled){
  948. this.element.addClass("ui-draggable-disabled");
  949. }
  950. this._setHandleClassName();
  951. this._mouseInit();
  952. },
  953. _setOption: function( key, value ) {
  954. this._super( key, value );
  955. if ( key === "handle" ) {
  956. this._removeHandleClassName();
  957. this._setHandleClassName();
  958. }
  959. },
  960. _destroy: function() {
  961. if ( ( this.helper || this.element ).is( ".ui-draggable-dragging" ) ) {
  962. this.destroyOnClear = true;
  963. return;
  964. }
  965. this.element.removeClass( "ui-draggable ui-draggable-dragging ui-draggable-disabled" );
  966. this._removeHandleClassName();
  967. this._mouseDestroy();
  968. },
  969. _mouseCapture: function(event) {
  970. var o = this.options;
  971. this._blurActiveElement( event );
  972. // among others, prevent a drag on a resizable-handle
  973. if (this.helper || o.disabled || $(event.target).closest(".ui-resizable-handle").length > 0) {
  974. return false;
  975. }
  976. //Quit if we're not on a valid handle
  977. this.handle = this._getHandle(event);
  978. if (!this.handle) {
  979. return false;
  980. }
  981. this._blockFrames( o.iframeFix === true ? "iframe" : o.iframeFix );
  982. return true;
  983. },
  984. _blockFrames: function( selector ) {
  985. this.iframeBlocks = this.document.find( selector ).map(function() {
  986. var iframe = $( this );
  987. return $( "<div>" )
  988. .css( "position", "absolute" )
  989. .appendTo( iframe.parent() )
  990. .outerWidth( iframe.outerWidth() )
  991. .outerHeight( iframe.outerHeight() )
  992. .offset( iframe.offset() )[ 0 ];
  993. });
  994. },
  995. _unblockFrames: function() {
  996. if ( this.iframeBlocks ) {
  997. this.iframeBlocks.remove();
  998. delete this.iframeBlocks;
  999. }
  1000. },
  1001. _blurActiveElement: function( event ) {
  1002. var document = this.document[ 0 ];
  1003. // Only need to blur if the event occurred on the draggable itself, see #10527
  1004. if ( !this.handleElement.is( event.target ) ) {
  1005. return;
  1006. }
  1007. // support: IE9
  1008. // IE9 throws an "Unspecified error" accessing document.activeElement from an <iframe>
  1009. try {
  1010. // Support: IE9, IE10
  1011. // If the <body> is blurred, IE will switch windows, see #9520
  1012. if ( document.activeElement && document.activeElement.nodeName.toLowerCase() !== "body" ) {
  1013. // Blur any element that currently has focus, see #4261
  1014. $( document.activeElement ).blur();
  1015. }
  1016. } catch ( error ) {}
  1017. },
  1018. _mouseStart: function(event) {
  1019. var o = this.options;
  1020. //Create and append the visible helper
  1021. this.helper = this._createHelper(event);
  1022. this.helper.addClass("ui-draggable-dragging");
  1023. //Cache the helper size
  1024. this._cacheHelperProportions();
  1025. //If ddmanager is used for droppables, set the global draggable
  1026. if ($.ui.ddmanager) {
  1027. $.ui.ddmanager.current = this;
  1028. }
  1029. /*
  1030. * - Position generation -
  1031. * This block generates everything position related - it's the core of draggables.
  1032. */
  1033. //Cache the margins of the original element
  1034. this._cacheMargins();
  1035. //Store the helper's css position
  1036. this.cssPosition = this.helper.css( "position" );
  1037. this.scrollParent = this.helper.scrollParent( true );
  1038. this.offsetParent = this.helper.offsetParent();
  1039. this.hasFixedAncestor = this.helper.parents().filter(function() {
  1040. return $( this ).css( "position" ) === "fixed";
  1041. }).length > 0;
  1042. //The element's absolute position on the page minus margins
  1043. this.positionAbs = this.element.offset();
  1044. this._refreshOffsets( event );
  1045. //Generate the original position
  1046. this.originalPosition = this.position = this._generatePosition( event, false );
  1047. this.originalPageX = event.pageX;
  1048. this.originalPageY = event.pageY;
  1049. //Adjust the mouse offset relative to the helper if "cursorAt" is supplied
  1050. (o.cursorAt && this._adjustOffsetFromHelper(o.cursorAt));
  1051. //Set a containment if given in the options
  1052. this._setContainment();
  1053. //Trigger event + callbacks
  1054. if (this._trigger("start", event) === false) {
  1055. this._clear();
  1056. return false;
  1057. }
  1058. //Recache the helper size
  1059. this._cacheHelperProportions();
  1060. //Prepare the droppable offsets
  1061. if ($.ui.ddmanager && !o.dropBehaviour) {
  1062. $.ui.ddmanager.prepareOffsets(this, event);
  1063. }
  1064. // Reset helper's right/bottom css if they're set and set explicit width/height instead
  1065. // as this prevents resizing of elements with right/bottom set (see #7772)
  1066. this._normalizeRightBottom();
  1067. this._mouseDrag(event, true); //Execute the drag once - this causes the helper not to be visible before getting its correct position
  1068. //If the ddmanager is used for droppables, inform the manager that dragging has started (see #5003)
  1069. if ( $.ui.ddmanager ) {
  1070. $.ui.ddmanager.dragStart(this, event);
  1071. }
  1072. return true;
  1073. },
  1074. _refreshOffsets: function( event ) {
  1075. this.offset = {
  1076. top: this.positionAbs.top - this.margins.top,
  1077. left: this.positionAbs.left - this.margins.left,
  1078. scroll: false,
  1079. parent: this._getParentOffset(),
  1080. relative: this._getRelativeOffset()
  1081. };
  1082. this.offset.click = {
  1083. left: event.pageX - this.offset.left,
  1084. top: event.pageY - this.offset.top
  1085. };
  1086. },
  1087. _mouseDrag: function(event, noPropagation) {
  1088. // reset any necessary cached properties (see #5009)
  1089. if ( this.hasFixedAncestor ) {
  1090. this.offset.parent = this._getParentOffset();
  1091. }
  1092. //Compute the helpers position
  1093. this.position = this._generatePosition( event, true );
  1094. this.positionAbs = this._convertPositionTo("absolute");
  1095. //Call plugins and callbacks and use the resulting position if something is returned
  1096. if (!noPropagation) {
  1097. var ui = this._uiHash();
  1098. if (this._trigger("drag", event, ui) === false) {
  1099. this._mouseUp({});
  1100. return false;
  1101. }
  1102. this.position = ui.position;
  1103. }
  1104. this.helper[ 0 ].style.left = this.position.left + "px";
  1105. this.helper[ 0 ].style.top = this.position.top + "px";
  1106. if ($.ui.ddmanager) {
  1107. $.ui.ddmanager.drag(this, event);
  1108. }
  1109. return false;
  1110. },
  1111. _mouseStop: function(event) {
  1112. //If we are using droppables, inform the manager about the drop
  1113. var that = this,
  1114. dropped = false;
  1115. if ($.ui.ddmanager && !this.options.dropBehaviour) {
  1116. dropped = $.ui.ddmanager.drop(this, event);
  1117. }
  1118. //if a drop comes from outside (a sortable)
  1119. if (this.dropped) {
  1120. dropped = this.dropped;
  1121. this.dropped = false;
  1122. }
  1123. if ((this.options.revert === "invalid" && !dropped) || (this.options.revert === "valid" && dropped) || this.options.revert === true || ($.isFunction(this.options.revert) && this.options.revert.call(this.element, dropped))) {
  1124. $(this.helper).animate(this.originalPosition, parseInt(this.options.revertDuration, 10), function() {
  1125. if (that._trigger("stop", event) !== false) {
  1126. that._clear();
  1127. }
  1128. });
  1129. } else {
  1130. if (this._trigger("stop", event) !== false) {
  1131. this._clear();
  1132. }
  1133. }
  1134. return false;
  1135. },
  1136. _mouseUp: function( event ) {
  1137. this._unblockFrames();
  1138. //If the ddmanager is used for droppables, inform the manager that dragging has stopped (see #5003)
  1139. if ( $.ui.ddmanager ) {
  1140. $.ui.ddmanager.dragStop(this, event);
  1141. }
  1142. // Only need to focus if the event occurred on the draggable itself, see #10527
  1143. if ( this.handleElement.is( event.target ) ) {
  1144. // The interaction is over; whether or not the click resulted in a drag, focus the element
  1145. this.element.focus();
  1146. }
  1147. return $.ui.mouse.prototype._mouseUp.call(this, event);
  1148. },
  1149. cancel: function() {
  1150. if (this.helper.is(".ui-draggable-dragging")) {
  1151. this._mouseUp({});
  1152. } else {
  1153. this._clear();
  1154. }
  1155. return this;
  1156. },
  1157. _getHandle: function(event) {
  1158. return this.options.handle ?
  1159. !!$( event.target ).closest( this.element.find( this.options.handle ) ).length :
  1160. true;
  1161. },
  1162. _setHandleClassName: function() {
  1163. this.handleElement = this.options.handle ?
  1164. this.element.find( this.options.handle ) : this.element;
  1165. this.handleElement.addClass( "ui-draggable-handle" );
  1166. },
  1167. _removeHandleClassName: function() {
  1168. this.handleElement.removeClass( "ui-draggable-handle" );
  1169. },
  1170. _createHelper: function(event) {
  1171. var o = this.options,
  1172. helperIsFunction = $.isFunction( o.helper ),
  1173. helper = helperIsFunction ?
  1174. $( o.helper.apply( this.element[ 0 ], [ event ] ) ) :
  1175. ( o.helper === "clone" ?
  1176. this.element.clone().removeAttr( "id" ) :
  1177. this.element );
  1178. if (!helper.parents("body").length) {
  1179. helper.appendTo((o.appendTo === "parent" ? this.element[0].parentNode : o.appendTo));
  1180. }
  1181. // http://bugs.jqueryui.com/ticket/9446
  1182. // a helper function can return the original element
  1183. // which wouldn't have been set to relative in _create
  1184. if ( helperIsFunction && helper[ 0 ] === this.element[ 0 ] ) {
  1185. this._setPositionRelative();
  1186. }
  1187. if (helper[0] !== this.element[0] && !(/(fixed|absolute)/).test(helper.css("position"))) {
  1188. helper.css("position", "absolute");
  1189. }
  1190. return helper;
  1191. },
  1192. _setPositionRelative: function() {
  1193. if ( !( /^(?:r|a|f)/ ).test( this.element.css( "position" ) ) ) {
  1194. this.element[ 0 ].style.position = "relative";
  1195. }
  1196. },
  1197. _adjustOffsetFromHelper: function(obj) {
  1198. if (typeof obj === "string") {
  1199. obj = obj.split(" ");
  1200. }
  1201. if ($.isArray(obj)) {
  1202. obj = { left: +obj[0], top: +obj[1] || 0 };
  1203. }
  1204. if ("left" in obj) {
  1205. this.offset.click.left = obj.left + this.margins.left;
  1206. }
  1207. if ("right" in obj) {
  1208. this.offset.click.left = this.helperProportions.width - obj.right + this.margins.left;
  1209. }
  1210. if ("top" in obj) {
  1211. this.offset.click.top = obj.top + this.margins.top;
  1212. }
  1213. if ("bottom" in obj) {
  1214. this.offset.click.top = this.helperProportions.height - obj.bottom + this.margins.top;
  1215. }
  1216. },
  1217. _isRootNode: function( element ) {
  1218. return ( /(html|body)/i ).test( element.tagName ) || element === this.document[ 0 ];
  1219. },
  1220. _getParentOffset: function() {
  1221. //Get the offsetParent and cache its position
  1222. var po = this.offsetParent.offset(),
  1223. document = this.document[ 0 ];
  1224. // This is a special case where we need to modify a offset calculated on start, since the following happened:
  1225. // 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
  1226. // 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
  1227. // the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
  1228. if (this.cssPosition === "absolute" && this.scrollParent[0] !== document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
  1229. po.left += this.scrollParent.scrollLeft();
  1230. po.top += this.scrollParent.scrollTop();
  1231. }
  1232. if ( this._isRootNode( this.offsetParent[ 0 ] ) ) {
  1233. po = { top: 0, left: 0 };
  1234. }
  1235. return {
  1236. top: po.top + (parseInt(this.offsetParent.css("borderTopWidth"), 10) || 0),
  1237. left: po.left + (parseInt(this.offsetParent.css("borderLeftWidth"), 10) || 0)
  1238. };
  1239. },
  1240. _getRelativeOffset: function() {
  1241. if ( this.cssPosition !== "relative" ) {
  1242. return { top: 0, left: 0 };
  1243. }
  1244. var p = this.element.position(),
  1245. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
  1246. return {
  1247. top: p.top - ( parseInt(this.helper.css( "top" ), 10) || 0 ) + ( !scrollIsRootNode ? this.scrollParent.scrollTop() : 0 ),
  1248. left: p.left - ( parseInt(this.helper.css( "left" ), 10) || 0 ) + ( !scrollIsRootNode ? this.scrollParent.scrollLeft() : 0 )
  1249. };
  1250. },
  1251. _cacheMargins: function() {
  1252. this.margins = {
  1253. left: (parseInt(this.element.css("marginLeft"), 10) || 0),
  1254. top: (parseInt(this.element.css("marginTop"), 10) || 0),
  1255. right: (parseInt(this.element.css("marginRight"), 10) || 0),
  1256. bottom: (parseInt(this.element.css("marginBottom"), 10) || 0)
  1257. };
  1258. },
  1259. _cacheHelperProportions: function() {
  1260. this.helperProportions = {
  1261. width: this.helper.outerWidth(),
  1262. height: this.helper.outerHeight()
  1263. };
  1264. },
  1265. _setContainment: function() {
  1266. var isUserScrollable, c, ce,
  1267. o = this.options,
  1268. document = this.document[ 0 ];
  1269. this.relativeContainer = null;
  1270. if ( !o.containment ) {
  1271. this.containment = null;
  1272. return;
  1273. }
  1274. if ( o.containment === "window" ) {
  1275. this.containment = [
  1276. $( window ).scrollLeft() - this.offset.relative.left - this.offset.parent.left,
  1277. $( window ).scrollTop() - this.offset.relative.top - this.offset.parent.top,
  1278. $( window ).scrollLeft() + $( window ).width() - this.helperProportions.width - this.margins.left,
  1279. $( window ).scrollTop() + ( $( window ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
  1280. ];
  1281. return;
  1282. }
  1283. if ( o.containment === "document") {
  1284. this.containment = [
  1285. 0,
  1286. 0,
  1287. $( document ).width() - this.helperProportions.width - this.margins.left,
  1288. ( $( document ).height() || document.body.parentNode.scrollHeight ) - this.helperProportions.height - this.margins.top
  1289. ];
  1290. return;
  1291. }
  1292. if ( o.containment.constructor === Array ) {
  1293. this.containment = o.containment;
  1294. return;
  1295. }
  1296. if ( o.containment === "parent" ) {
  1297. o.containment = this.helper[ 0 ].parentNode;
  1298. }
  1299. c = $( o.containment );
  1300. ce = c[ 0 ];
  1301. if ( !ce ) {
  1302. return;
  1303. }
  1304. isUserScrollable = /(scroll|auto)/.test( c.css( "overflow" ) );
  1305. this.containment = [
  1306. ( parseInt( c.css( "borderLeftWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingLeft" ), 10 ) || 0 ),
  1307. ( parseInt( c.css( "borderTopWidth" ), 10 ) || 0 ) + ( parseInt( c.css( "paddingTop" ), 10 ) || 0 ),
  1308. ( isUserScrollable ? Math.max( ce.scrollWidth, ce.offsetWidth ) : ce.offsetWidth ) -
  1309. ( parseInt( c.css( "borderRightWidth" ), 10 ) || 0 ) -
  1310. ( parseInt( c.css( "paddingRight" ), 10 ) || 0 ) -
  1311. this.helperProportions.width -
  1312. this.margins.left -
  1313. this.margins.right,
  1314. ( isUserScrollable ? Math.max( ce.scrollHeight, ce.offsetHeight ) : ce.offsetHeight ) -
  1315. ( parseInt( c.css( "borderBottomWidth" ), 10 ) || 0 ) -
  1316. ( parseInt( c.css( "paddingBottom" ), 10 ) || 0 ) -
  1317. this.helperProportions.height -
  1318. this.margins.top -
  1319. this.margins.bottom
  1320. ];
  1321. this.relativeContainer = c;
  1322. },
  1323. _convertPositionTo: function(d, pos) {
  1324. if (!pos) {
  1325. pos = this.position;
  1326. }
  1327. var mod = d === "absolute" ? 1 : -1,
  1328. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] );
  1329. return {
  1330. top: (
  1331. pos.top + // The absolute mouse position
  1332. this.offset.relative.top * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  1333. this.offset.parent.top * mod - // The offsetParent's offset without borders (offset + border)
  1334. ( ( this.cssPosition === "fixed" ? -this.offset.scroll.top : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) ) * mod)
  1335. ),
  1336. left: (
  1337. pos.left + // The absolute mouse position
  1338. this.offset.relative.left * mod + // Only for relative positioned nodes: Relative offset from element to offset parent
  1339. this.offset.parent.left * mod - // The offsetParent's offset without borders (offset + border)
  1340. ( ( this.cssPosition === "fixed" ? -this.offset.scroll.left : ( scrollIsRootNode ? 0 : this.offset.scroll.left ) ) * mod)
  1341. )
  1342. };
  1343. },
  1344. _generatePosition: function( event, constrainPosition ) {
  1345. var containment, co, top, left,
  1346. o = this.options,
  1347. scrollIsRootNode = this._isRootNode( this.scrollParent[ 0 ] ),
  1348. pageX = event.pageX,
  1349. pageY = event.pageY;
  1350. // Cache the scroll
  1351. if ( !scrollIsRootNode || !this.offset.scroll ) {
  1352. this.offset.scroll = {
  1353. top: this.scrollParent.scrollTop(),
  1354. left: this.scrollParent.scrollLeft()
  1355. };
  1356. }
  1357. /*
  1358. * - Position constraining -
  1359. * Constrain the position to a mix of grid, containment.
  1360. */
  1361. // If we are not dragging yet, we won't check for options
  1362. if ( constrainPosition ) {
  1363. if ( this.containment ) {
  1364. if ( this.relativeContainer ){
  1365. co = this.relativeContainer.offset();
  1366. containment = [
  1367. this.containment[ 0 ] + co.left,
  1368. this.containment[ 1 ] + co.top,
  1369. this.containment[ 2 ] + co.left,
  1370. this.containment[ 3 ] + co.top
  1371. ];
  1372. } else {
  1373. containment = this.containment;
  1374. }
  1375. if (event.pageX - this.offset.click.left < containment[0]) {
  1376. pageX = containment[0] + this.offset.click.left;
  1377. }
  1378. if (event.pageY - this.offset.click.top < containment[1]) {
  1379. pageY = containment[1] + this.offset.click.top;
  1380. }
  1381. if (event.pageX - this.offset.click.left > containment[2]) {
  1382. pageX = containment[2] + this.offset.click.left;
  1383. }
  1384. if (event.pageY - this.offset.click.top > containment[3]) {
  1385. pageY = containment[3] + this.offset.click.top;
  1386. }
  1387. }
  1388. if (o.grid) {
  1389. //Check for grid elements set to 0 to prevent divide by 0 error causing invalid argument errors in IE (see ticket #6950)
  1390. top = o.grid[1] ? this.originalPageY + Math.round((pageY - this.originalPageY) / o.grid[1]) * o.grid[1] : this.originalPageY;
  1391. pageY = containment ? ((top - this.offset.click.top >= containment[1] || top - this.offset.click.top > containment[3]) ? top : ((top - this.offset.click.top >= containment[1]) ? top - o.grid[1] : top + o.grid[1])) : top;
  1392. left = o.grid[0] ? this.originalPageX + Math.round((pageX - this.originalPageX) / o.grid[0]) * o.grid[0] : this.originalPageX;
  1393. pageX = containment ? ((left - this.offset.click.left >= containment[0] || left - this.offset.click.left > containment[2]) ? left : ((left - this.offset.click.left >= containment[0]) ? left - o.grid[0] : left + o.grid[0])) : left;
  1394. }
  1395. if ( o.axis === "y" ) {
  1396. pageX = this.originalPageX;
  1397. }
  1398. if ( o.axis === "x" ) {
  1399. pageY = this.originalPageY;
  1400. }
  1401. }
  1402. return {
  1403. top: (
  1404. pageY - // The absolute mouse position
  1405. this.offset.click.top - // Click offset (relative to the element)
  1406. this.offset.relative.top - // Only for relative positioned nodes: Relative offset from element to offset parent
  1407. this.offset.parent.top + // The offsetParent's offset without borders (offset + border)
  1408. ( this.cssPosition === "fixed" ? -this.offset.scroll.top : ( scrollIsRootNode ? 0 : this.offset.scroll.top ) )
  1409. ),
  1410. left: (
  1411. pageX - // The absolute mouse position
  1412. this.offset.click.left - // Click offset (relative to the element)
  1413. this.offset.relative.left - // Only for relative positioned nodes: Relative offset from element to offset parent
  1414. this.offset.parent.left + // The offsetParent's offset without borders (offset + border)
  1415. ( this.cssPosition === "fixed" ? -this.offset.scroll.left : ( scrollIsRootNode ? 0 : this.offset.scroll.left ) )
  1416. )
  1417. };
  1418. },
  1419. _clear: function() {
  1420. this.helper.removeClass("ui-draggable-dragging");
  1421. if (this.helper[0] !== this.element[0] && !this.cancelHelperRemoval) {
  1422. this.helper.remove();
  1423. }
  1424. this.helper = null;
  1425. this.cancelHelperRemoval = false;
  1426. if ( this.destroyOnClear ) {
  1427. this.destroy();
  1428. }
  1429. },
  1430. _normalizeRightBottom: function() {
  1431. if ( this.options.axis !== "y" && this.helper.css( "right" ) !== "auto" ) {
  1432. this.helper.width( this.helper.width() );
  1433. this.helper.css( "right", "auto" );
  1434. }
  1435. if ( this.options.axis !== "x" && this.helper.css( "bottom" ) !== "auto" ) {
  1436. this.helper.height( this.helper.height() );
  1437. this.helper.css( "bottom", "auto" );
  1438. }
  1439. },
  1440. // From now on bulk stuff - mainly helpers
  1441. _trigger: function( type, event, ui ) {
  1442. ui = ui || this._uiHash();
  1443. $.ui.plugin.call( this, type, [ event, ui, this ], true );
  1444. // Absolute position and offset (see #6884 ) have to be recalculated after plugins
  1445. if ( /^(drag|start|stop)/.test( type ) ) {
  1446. this.positionAbs = this._convertPositionTo( "absolute" );
  1447. ui.offset = this.positionAbs;
  1448. }
  1449. return $.Widget.prototype._trigger.call( this, type, event, ui );
  1450. },
  1451. plugins: {},
  1452. _uiHash: function() {
  1453. return {
  1454. helper: this.helper,
  1455. position: this.position,
  1456. originalPosition: this.originalPosition,
  1457. offset: this.positionAbs
  1458. };
  1459. }
  1460. });
  1461. $.ui.plugin.add( "draggable", "connectToSortable", {
  1462. start: function( event, ui, draggable ) {
  1463. var uiSortable = $.extend( {}, ui, {
  1464. item: draggable.element
  1465. });
  1466. draggable.sortables = [];
  1467. $( draggable.options.connectToSortable ).each(function() {
  1468. var sortable = $( this ).sortable( "instance" );
  1469. if ( sortable && !sortable.options.disabled ) {
  1470. draggable.sortables.push( sortable );
  1471. // refreshPositions is called at drag start to refresh the containerCache
  1472. // which is used in drag. This ensures it's initialized and synchronized
  1473. // with any changes that might have happened on the page since initialization.
  1474. sortable.refreshPositions();
  1475. sortable._trigger("activate", event, uiSortable);
  1476. }
  1477. });
  1478. },
  1479. stop: function( event, ui, draggable ) {
  1480. var uiSortable = $.extend( {}, ui, {
  1481. item: draggable.element
  1482. });
  1483. draggable.cancelHelperRemoval = false;
  1484. $.each( draggable.sortables, function() {
  1485. var sortable = this;
  1486. if ( sortable.isOver ) {
  1487. sortable.isOver = 0;
  1488. // Allow this sortable to handle removing the helper
  1489. draggable.cancelHelperRemoval = true;
  1490. sortable.cancelHelperRemoval = false;
  1491. // Use _storedCSS To restore properties in the sortable,
  1492. // as this also handles revert (#9675) since the draggable
  1493. // may have modified them in unexpected ways (#8809)
  1494. sortable._storedCSS = {
  1495. position: sortable.placeholder.css( "position" ),
  1496. top: sortable.placeholder.css( "top" ),
  1497. left: sortable.placeholder.css( "left" )
  1498. };
  1499. sortable._mouseStop(event);
  1500. // Once drag has ended, the sortable should return to using
  1501. // its original helper, not the shared helper from draggable
  1502. sortable.options.helper = sortable.options._helper;
  1503. } else {
  1504. // Prevent this Sortable from removing the helper.
  1505. // However, don't set the draggable to remove the helper
  1506. // either as another connected Sortable may yet handle the removal.
  1507. sortable.cancelHelperRemoval = true;
  1508. sortable._trigger( "deactivate", event, uiSortable );
  1509. }
  1510. });
  1511. },
  1512. drag: function( event, ui, draggable ) {
  1513. $.each( draggable.sortables, function() {
  1514. var innermostIntersecting = false,
  1515. sortable = this;
  1516. // Copy over variables that sortable's _intersectsWith uses
  1517. sortable.positionAbs = draggable.positionAbs;
  1518. sortable.helperProportions = draggable.helperProportions;
  1519. sortable.offset.click = draggable.offset.click;
  1520. if ( sortable._intersectsWith( sortable.containerCache ) ) {
  1521. innermostIntersecting = true;
  1522. $.each( draggable.sortables, function() {
  1523. // Copy over variables that sortable's _intersectsWith uses
  1524. this.positionAbs = draggable.positionAbs;
  1525. this.helperProportions = draggable.helperProportions;
  1526. this.offset.click = draggable.offset.click;
  1527. if ( this !== sortable &&
  1528. this._intersectsWith( this.containerCache ) &&
  1529. $.contains( sortable.element[ 0 ], this.element[ 0 ] ) ) {
  1530. innermostIntersecting = false;
  1531. }
  1532. return innermostIntersecting;
  1533. });
  1534. }
  1535. if ( innermostIntersecting ) {
  1536. // If it intersects, we use a little isOver variable and set it once,
  1537. // so that the move-in stuff gets fired only once.
  1538. if ( !sortable.isOver ) {
  1539. sortable.isOver = 1;
  1540. // Store draggable's parent in case we need to reappend to it later.
  1541. draggable._parent = ui.helper.parent();
  1542. sortable.currentItem = ui.helper
  1543. .appendTo( sortable.element )
  1544. .data( "ui-sortable-item", true );
  1545. // Store helper option to later restore it
  1546. sortable.options._helper = sortable.options.helper;
  1547. sortable.options.helper = function() {
  1548. return ui.helper[ 0 ];
  1549. };
  1550. // Fire the start events of the sortable with our passed browser event,
  1551. // and our own helper (so it doesn't create a new one)
  1552. event.target = sortable.currentItem[ 0 ];
  1553. sortable._mouseCapture( event, true );
  1554. sortable._mouseStart( event, true, true );
  1555. // Because the browser event is way off the new appended portlet,
  1556. // modify necessary variables to reflect the changes
  1557. sortable.offset.click.top = draggable.offset.click.top;
  1558. sortable.offset.click.left = draggable.offset.click.left;
  1559. sortable.offset.parent.left -= draggable.offset.parent.left -
  1560. sortable.offset.parent.left;
  1561. sortable.offset.parent.top -= draggable.offset.parent.top -
  1562. sortable.offset.parent.top;
  1563. draggable._trigger( "toSortable", event );
  1564. // Inform draggable that the helper is in a valid drop zone,
  1565. // used solely in the revert option to handle "valid/invalid".
  1566. draggable.dropped = sortable.element;
  1567. // Need to refreshPositions of all sortables in the case that
  1568. // adding to one sortable changes the location of the other sortables (#9675)
  1569. $.each( draggable.sortables, function() {
  1570. this.refreshPositions();
  1571. });
  1572. // hack so receive/update callbacks work (mostly)
  1573. draggable.currentItem = draggable.element;
  1574. sortable.fromOutside = draggable;
  1575. }
  1576. if ( sortable.currentItem ) {
  1577. sortable._mouseDrag( event );
  1578. // Copy the sortable's position because the draggable's can potentially reflect
  1579. // a relative position, while sortable is always absolute, which the dragged
  1580. // element has now become. (#8809)
  1581. ui.position = sortable.position;
  1582. }
  1583. } else {
  1584. // If it doesn't intersect with the sortable, and it intersected before,
  1585. // we fake the drag stop of the sortable, but make sure it doesn't remove
  1586. // the helper by using cancelHelperRemoval.
  1587. if ( sortable.isOver ) {
  1588. sortable.isOver = 0;
  1589. sortable.cancelHelperRemoval = true;
  1590. // Calling sortable's mouseStop would trigger a revert,
  1591. // so revert must be temporarily false until after mouseStop is called.
  1592. sortable.options._revert = sortable.options.revert;
  1593. sortable.options.revert = false;
  1594. sortable._trigger( "out", event, sortable._uiHash( sortable ) );
  1595. sortable._mouseStop( event, true );
  1596. // restore sortable behaviors that were modfied
  1597. // when the draggable entered the sortable area (#9481)
  1598. sortable.options.revert = sortable.options._revert;
  1599. sortable.options.helper = sortable.options._helper;
  1600. if ( sortable.placeholder ) {
  1601. sortable.placeholder.remove();
  1602. }
  1603. // Restore and recalculate the draggable's offset considering the sortable
  1604. // may have modified them in unexpected ways. (#8809, #10669)
  1605. ui.helper.appendTo( draggable._parent );
  1606. draggable._refreshOffsets( event );
  1607. ui.position = draggable._generatePosition( event, true );
  1608. draggable._trigger( "fromSortable", event );
  1609. // Inform draggable that the helper is no longer in a valid drop zone
  1610. draggable.dropped = false;
  1611. // Need to refreshPositions of all sortables just in case removing
  1612. // from one sortable changes the location of other sortables (#9675)
  1613. $.each( draggable.sortables, function() {
  1614. this.refreshPositions();
  1615. });
  1616. }
  1617. }
  1618. });
  1619. }
  1620. });
  1621. $.ui.plugin.add("draggable", "cursor", {
  1622. start: function( event, ui, instance ) {
  1623. var t = $( "body" ),
  1624. o = instance.options;
  1625. if (t.css("cursor")) {
  1626. o._cursor = t.css("cursor");
  1627. }
  1628. t.css("cursor", o.cursor);
  1629. },
  1630. stop: function( event, ui, instance ) {
  1631. var o = instance.options;
  1632. if (o._cursor) {
  1633. $("body").css("cursor", o._cursor);
  1634. }
  1635. }
  1636. });
  1637. $.ui.plugin.add("draggable", "opacity", {
  1638. start: function( event, ui, instance ) {
  1639. var t = $( ui.helper ),
  1640. o = instance.options;
  1641. if (t.css("opacity")) {
  1642. o._opacity = t.css("opacity");
  1643. }
  1644. t.css("opacity", o.opacity);
  1645. },
  1646. stop: function( event, ui, instance ) {
  1647. var o = instance.options;
  1648. if (o._opacity) {
  1649. $(ui.helper).css("opacity", o._opacity);
  1650. }
  1651. }
  1652. });
  1653. $.ui.plugin.add("draggable", "scroll", {
  1654. start: function( event, ui, i ) {
  1655. if ( !i.scrollParentNotHidden ) {
  1656. i.scrollParentNotHidden = i.helper.scrollParent( false );
  1657. }
  1658. if ( i.scrollParentNotHidden[ 0 ] !== i.document[ 0 ] && i.scrollParentNotHidden[ 0 ].tagName !== "HTML" ) {
  1659. i.overflowOffset = i.scrollParentNotHidden.offset();
  1660. }
  1661. },
  1662. drag: function( event, ui, i ) {
  1663. var o = i.options,
  1664. scrolled = false,
  1665. scrollParent = i.scrollParentNotHidden[ 0 ],
  1666. document = i.document[ 0 ];
  1667. if ( scrollParent !== document && scrollParent.tagName !== "HTML" ) {
  1668. if ( !o.axis || o.axis !== "x" ) {
  1669. if ( ( i.overflowOffset.top + scrollParent.offsetHeight ) - event.pageY < o.scrollSensitivity ) {
  1670. scrollParent.scrollTop = scrolled = scrollParent.scrollTop + o.scrollSpeed;
  1671. } else if ( event.pageY - i.overflowOffset.top < o.scrollSensitivity ) {
  1672. scrollParent.scrollTop = scrolled = scrollParent.scrollTop - o.scrollSpeed;
  1673. }
  1674. }
  1675. if ( !o.axis || o.axis !== "y" ) {
  1676. if ( ( i.overflowOffset.left + scrollParent.offsetWidth ) - event.pageX < o.scrollSensitivity ) {
  1677. scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft + o.scrollSpeed;
  1678. } else if ( event.pageX - i.overflowOffset.left < o.scrollSensitivity ) {
  1679. scrollParent.scrollLeft = scrolled = scrollParent.scrollLeft - o.scrollSpeed;
  1680. }
  1681. }
  1682. } else {
  1683. if (!o.axis || o.axis !== "x") {
  1684. if (event.pageY - $(document).scrollTop() < o.scrollSensitivity) {
  1685. scrolled = $(document).scrollTop($(document).scrollTop() - o.scrollSpeed);
  1686. } else if ($(window).height() - (event.pageY - $(document).scrollTop()) < o.scrollSensitivity) {
  1687. scrolled = $(document).scrollTop($(document).scrollTop() + o.scrollSpeed);
  1688. }
  1689. }
  1690. if (!o.axis || o.axis !== "y") {
  1691. if (event.pageX - $(document).scrollLeft() < o.scrollSensitivity) {
  1692. scrolled = $(document).scrollLeft($(document).scrollLeft() - o.scrollSpeed);
  1693. } else if ($(window).width() - (event.pageX - $(document).scrollLeft()) < o.scrollSensitivity) {
  1694. scrolled = $(document).scrollLeft($(document).scrollLeft() + o.scrollSpeed);
  1695. }
  1696. }
  1697. }
  1698. if (scrolled !== false && $.ui.ddmanager && !o.dropBehaviour) {
  1699. $.ui.ddmanager.prepareOffsets(i, event);
  1700. }
  1701. }
  1702. });
  1703. $.ui.plugin.add("draggable", "snap", {
  1704. start: function( event, ui, i ) {
  1705. var o = i.options;
  1706. i.snapElements = [];
  1707. $(o.snap.constructor !== String ? ( o.snap.items || ":data(ui-draggable)" ) : o.snap).each(function() {
  1708. var $t = $(this),
  1709. $o = $t.offset();
  1710. if (this !== i.element[0]) {
  1711. i.snapElements.push({
  1712. item: this,
  1713. width: $t.outerWidth(), height: $t.outerHeight(),
  1714. top: $o.top, left: $o.left
  1715. });
  1716. }
  1717. });
  1718. },
  1719. drag: function( event, ui, inst ) {
  1720. var ts, bs, ls, rs, l, r, t, b, i, first,
  1721. o = inst.options,
  1722. d = o.snapTolerance,
  1723. x1 = ui.offset.left, x2 = x1 + inst.helperProportions.width,
  1724. y1 = ui.offset.top, y2 = y1 + inst.helperProportions.height;
  1725. for (i = inst.snapElements.length - 1; i >= 0; i--){
  1726. l = inst.snapElements[i].left - inst.margins.left;
  1727. r = l + inst.snapElements[i].width;
  1728. t = inst.snapElements[i].top - inst.margins.top;
  1729. b = t + inst.snapElements[i].height;
  1730. if ( x2 < l - d || x1 > r + d || y2 < t - d || y1 > b + d || !$.contains( inst.snapElements[ i ].item.ownerDocument, inst.snapElements[ i ].item ) ) {
  1731. if (inst.snapElements[i].snapping) {
  1732. (inst.options.snap.release && inst.options.snap.release.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  1733. }
  1734. inst.snapElements[i].snapping = false;
  1735. continue;
  1736. }
  1737. if (o.snapMode !== "inner") {
  1738. ts = Math.abs(t - y2) <= d;
  1739. bs = Math.abs(b - y1) <= d;
  1740. ls = Math.abs(l - x2) <= d;
  1741. rs = Math.abs(r - x1) <= d;
  1742. if (ts) {
  1743. ui.position.top = inst._convertPositionTo("relative", { top: t - inst.helperProportions.height, left: 0 }).top;
  1744. }
  1745. if (bs) {
  1746. ui.position.top = inst._convertPositionTo("relative", { top: b, left: 0 }).top;
  1747. }
  1748. if (ls) {
  1749. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l - inst.helperProportions.width }).left;
  1750. }
  1751. if (rs) {
  1752. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r }).left;
  1753. }
  1754. }
  1755. first = (ts || bs || ls || rs);
  1756. if (o.snapMode !== "outer") {
  1757. ts = Math.abs(t - y1) <= d;
  1758. bs = Math.abs(b - y2) <= d;
  1759. ls = Math.abs(l - x1) <= d;
  1760. rs = Math.abs(r - x2) <= d;
  1761. if (ts) {
  1762. ui.position.top = inst._convertPositionTo("relative", { top: t, left: 0 }).top;
  1763. }
  1764. if (bs) {
  1765. ui.position.top = inst._convertPositionTo("relative", { top: b - inst.helperProportions.height, left: 0 }).top;
  1766. }
  1767. if (ls) {
  1768. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: l }).left;
  1769. }
  1770. if (rs) {
  1771. ui.position.left = inst._convertPositionTo("relative", { top: 0, left: r - inst.helperProportions.width }).left;
  1772. }
  1773. }
  1774. if (!inst.snapElements[i].snapping && (ts || bs || ls || rs || first)) {
  1775. (inst.options.snap.snap && inst.options.snap.snap.call(inst.element, event, $.extend(inst._uiHash(), { snapItem: inst.snapElements[i].item })));
  1776. }
  1777. inst.snapElements[i].snapping = (ts || bs || ls || rs || first);
  1778. }
  1779. }
  1780. });
  1781. $.ui.plugin.add("draggable", "stack", {
  1782. start: function( event, ui, instance ) {
  1783. var min,
  1784. o = instance.options,
  1785. group = $.makeArray($(o.stack)).sort(function(a, b) {
  1786. return (parseInt($(a).css("zIndex"), 10) || 0) - (parseInt($(b).css("zIndex"), 10) || 0);
  1787. });
  1788. if (!group.length) { return; }
  1789. min = parseInt($(group[0]).css("zIndex"), 10) || 0;
  1790. $(group).each(function(i) {
  1791. $(this).css("zIndex", min + i);
  1792. });
  1793. this.css("zIndex", (min + group.length));
  1794. }
  1795. });
  1796. $.ui.plugin.add("draggable", "zIndex", {
  1797. start: function( event, ui, instance ) {
  1798. var t = $( ui.helper ),
  1799. o = instance.options;
  1800. if (t.css("zIndex")) {
  1801. o._zIndex = t.css("zIndex");
  1802. }
  1803. t.css("zIndex", o.zIndex);
  1804. },
  1805. stop: function( event, ui, instance ) {
  1806. var o = instance.options;
  1807. if (o._zIndex) {
  1808. $(ui.helper).css("zIndex", o._zIndex);
  1809. }
  1810. }
  1811. });
  1812. var draggable = $.ui.draggable;
  1813. /*!
  1814. * jQuery UI Droppable 1.11.4
  1815. * http://jqueryui.com
  1816. *
  1817. * Copyright jQuery Foundation and other contributors
  1818. * Released under the MIT license.
  1819. * http://jquery.org/license
  1820. *
  1821. * http://api.jqueryui.com/droppable/
  1822. */
  1823. $.widget( "ui.droppable", {
  1824. version: "1.11.4",
  1825. widgetEventPrefix: "drop",
  1826. options: {
  1827. accept: "*",
  1828. activeClass: false,
  1829. addClasses: true,
  1830. greedy: false,
  1831. hoverClass: false,
  1832. scope: "default",
  1833. tolerance: "intersect",
  1834. // callbacks
  1835. activate: null,
  1836. deactivate: null,
  1837. drop: null,
  1838. out: null,
  1839. over: null
  1840. },
  1841. _create: function() {
  1842. var proportions,
  1843. o = this.options,
  1844. accept = o.accept;
  1845. this.isover = false;
  1846. this.isout = true;
  1847. this.accept = $.isFunction( accept ) ? accept : function( d ) {
  1848. return d.is( accept );
  1849. };
  1850. this.proportions = function( /* valueToWrite */ ) {
  1851. if ( arguments.length ) {
  1852. // Store the droppable's proportions
  1853. proportions = arguments[ 0 ];
  1854. } else {
  1855. // Retrieve or derive the droppable's proportions
  1856. return proportions ?
  1857. proportions :
  1858. proportions = {
  1859. width: this.element[ 0 ].offsetWidth,
  1860. height: this.element[ 0 ].offsetHeight
  1861. };
  1862. }
  1863. };
  1864. this._addToManager( o.scope );
  1865. o.addClasses && this.element.addClass( "ui-droppable" );
  1866. },
  1867. _addToManager: function( scope ) {
  1868. // Add the reference and positions to the manager
  1869. $.ui.ddmanager.droppables[ scope ] = $.ui.ddmanager.droppables[ scope ] || [];
  1870. $.ui.ddmanager.droppables[ scope ].push( this );
  1871. },
  1872. _splice: function( drop ) {
  1873. var i = 0;
  1874. for ( ; i < drop.length; i++ ) {
  1875. if ( drop[ i ] === this ) {
  1876. drop.splice( i, 1 );
  1877. }
  1878. }
  1879. },
  1880. _destroy: function() {
  1881. var drop = $.ui.ddmanager.droppables[ this.options.scope ];
  1882. this._splice( drop );
  1883. this.element.removeClass( "ui-droppable ui-droppable-disabled" );
  1884. },
  1885. _setOption: function( key, value ) {
  1886. if ( key === "accept" ) {
  1887. this.accept = $.isFunction( value ) ? value : function( d ) {
  1888. return d.is( value );
  1889. };
  1890. } else if ( key === "scope" ) {
  1891. var drop = $.ui.ddmanager.droppables[ this.options.scope ];
  1892. this._splice( drop );
  1893. this._addToManager( value );
  1894. }
  1895. this._super( key, value );
  1896. },
  1897. _activate: function( event ) {
  1898. var draggable = $.ui.ddmanager.current;
  1899. if ( this.options.activeClass ) {
  1900. this.element.addClass( this.options.activeClass );
  1901. }
  1902. if ( draggable ){
  1903. this._trigger( "activate", event, this.ui( draggable ) );
  1904. }
  1905. },
  1906. _deactivate: function( event ) {
  1907. var draggable = $.ui.ddmanager.current;
  1908. if ( this.options.activeClass ) {
  1909. this.element.removeClass( this.options.activeClass );
  1910. }
  1911. if ( draggable ){
  1912. this._trigger( "deactivate", event, this.ui( draggable ) );
  1913. }
  1914. },
  1915. _over: function( event ) {
  1916. var draggable = $.ui.ddmanager.current;
  1917. // Bail if draggable and droppable are same element
  1918. if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
  1919. return;
  1920. }
  1921. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  1922. if ( this.options.hoverClass ) {
  1923. this.element.addClass( this.options.hoverClass );
  1924. }
  1925. this._trigger( "over", event, this.ui( draggable ) );
  1926. }
  1927. },
  1928. _out: function( event ) {
  1929. var draggable = $.ui.ddmanager.current;
  1930. // Bail if draggable and droppable are same element
  1931. if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
  1932. return;
  1933. }
  1934. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  1935. if ( this.options.hoverClass ) {
  1936. this.element.removeClass( this.options.hoverClass );
  1937. }
  1938. this._trigger( "out", event, this.ui( draggable ) );
  1939. }
  1940. },
  1941. _drop: function( event, custom ) {
  1942. var draggable = custom || $.ui.ddmanager.current,
  1943. childrenIntersection = false;
  1944. // Bail if draggable and droppable are same element
  1945. if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
  1946. return false;
  1947. }
  1948. this.element.find( ":data(ui-droppable)" ).not( ".ui-draggable-dragging" ).each(function() {
  1949. var inst = $( this ).droppable( "instance" );
  1950. if (
  1951. inst.options.greedy &&
  1952. !inst.options.disabled &&
  1953. inst.options.scope === draggable.options.scope &&
  1954. inst.accept.call( inst.element[ 0 ], ( draggable.currentItem || draggable.element ) ) &&
  1955. $.ui.intersect( draggable, $.extend( inst, { offset: inst.element.offset() } ), inst.options.tolerance, event )
  1956. ) { childrenIntersection = true; return false; }
  1957. });
  1958. if ( childrenIntersection ) {
  1959. return false;
  1960. }
  1961. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  1962. if ( this.options.activeClass ) {
  1963. this.element.removeClass( this.options.activeClass );
  1964. }
  1965. if ( this.options.hoverClass ) {
  1966. this.element.removeClass( this.options.hoverClass );
  1967. }
  1968. this._trigger( "drop", event, this.ui( draggable ) );
  1969. return this.element;
  1970. }
  1971. return false;
  1972. },
  1973. ui: function( c ) {
  1974. return {
  1975. draggable: ( c.currentItem || c.element ),
  1976. helper: c.helper,
  1977. position: c.position,
  1978. offset: c.positionAbs
  1979. };
  1980. }
  1981. });
  1982. $.ui.intersect = (function() {
  1983. function isOverAxis( x, reference, size ) {
  1984. return ( x >= reference ) && ( x < ( reference + size ) );
  1985. }
  1986. return function( draggable, droppable, toleranceMode, event ) {
  1987. if ( !droppable.offset ) {
  1988. return false;
  1989. }
  1990. var x1 = ( draggable.positionAbs || draggable.position.absolute ).left + draggable.margins.left,
  1991. y1 = ( draggable.positionAbs || draggable.position.absolute ).top + draggable.margins.top,
  1992. x2 = x1 + draggable.helperProportions.width,
  1993. y2 = y1 + draggable.helperProportions.height,
  1994. l = droppable.offset.left,
  1995. t = droppable.offset.top,
  1996. r = l + droppable.proportions().width,
  1997. b = t + droppable.proportions().height;
  1998. switch ( toleranceMode ) {
  1999. case "fit":
  2000. return ( l <= x1 && x2 <= r && t <= y1 && y2 <= b );
  2001. case "intersect":
  2002. return ( l < x1 + ( draggable.helperProportions.width / 2 ) && // Right Half
  2003. x2 - ( draggable.helperProportions.width / 2 ) < r && // Left Half
  2004. t < y1 + ( draggable.helperProportions.height / 2 ) && // Bottom Half
  2005. y2 - ( draggable.helperProportions.height / 2 ) < b ); // Top Half
  2006. case "pointer":
  2007. return isOverAxis( event.pageY, t, droppable.proportions().height ) && isOverAxis( event.pageX, l, droppable.proportions().width );
  2008. case "touch":
  2009. return (
  2010. ( y1 >= t && y1 <= b ) || // Top edge touching
  2011. ( y2 >= t && y2 <= b ) || // Bottom edge touching
  2012. ( y1 < t && y2 > b ) // Surrounded vertically
  2013. ) && (
  2014. ( x1 >= l && x1 <= r ) || // Left edge touching
  2015. ( x2 >= l && x2 <= r ) || // Right edge touching
  2016. ( x1 < l && x2 > r ) // Surrounded horizontally
  2017. );
  2018. default:
  2019. return false;
  2020. }
  2021. };
  2022. })();
  2023. /*
  2024. This manager tracks offsets of draggables and droppables
  2025. */
  2026. $.ui.ddmanager = {
  2027. current: null,
  2028. droppables: { "default": [] },
  2029. prepareOffsets: function( t, event ) {
  2030. var i, j,
  2031. m = $.ui.ddmanager.droppables[ t.options.scope ] || [],
  2032. type = event ? event.type : null, // workaround for #2317
  2033. list = ( t.currentItem || t.element ).find( ":data(ui-droppable)" ).addBack();
  2034. droppablesLoop: for ( i = 0; i < m.length; i++ ) {
  2035. // No disabled and non-accepted
  2036. if ( m[ i ].options.disabled || ( t && !m[ i ].accept.call( m[ i ].element[ 0 ], ( t.currentItem || t.element ) ) ) ) {
  2037. continue;
  2038. }
  2039. // Filter out elements in the current dragged item
  2040. for ( j = 0; j < list.length; j++ ) {
  2041. if ( list[ j ] === m[ i ].element[ 0 ] ) {
  2042. m[ i ].proportions().height = 0;
  2043. continue droppablesLoop;
  2044. }
  2045. }
  2046. m[ i ].visible = m[ i ].element.css( "display" ) !== "none";
  2047. if ( !m[ i ].visible ) {
  2048. continue;
  2049. }
  2050. // Activate the droppable if used directly from draggables
  2051. if ( type === "mousedown" ) {
  2052. m[ i ]._activate.call( m[ i ], event );
  2053. }
  2054. m[ i ].offset = m[ i ].element.offset();
  2055. m[ i ].proportions({ width: m[ i ].element[ 0 ].offsetWidth, height: m[ i ].element[ 0 ].offsetHeight });
  2056. }
  2057. },
  2058. drop: function( draggable, event ) {
  2059. var dropped = false;
  2060. // Create a copy of the droppables in case the list changes during the drop (#9116)
  2061. $.each( ( $.ui.ddmanager.droppables[ draggable.options.scope ] || [] ).slice(), function() {
  2062. if ( !this.options ) {
  2063. return;
  2064. }
  2065. if ( !this.options.disabled && this.visible && $.ui.intersect( draggable, this, this.options.tolerance, event ) ) {
  2066. dropped = this._drop.call( this, event ) || dropped;
  2067. }
  2068. if ( !this.options.disabled && this.visible && this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  2069. this.isout = true;
  2070. this.isover = false;
  2071. this._deactivate.call( this, event );
  2072. }
  2073. });
  2074. return dropped;
  2075. },
  2076. dragStart: function( draggable, event ) {
  2077. // Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003)
  2078. draggable.element.parentsUntil( "body" ).bind( "scroll.droppable", function() {
  2079. if ( !draggable.options.refreshPositions ) {
  2080. $.ui.ddmanager.prepareOffsets( draggable, event );
  2081. }
  2082. });
  2083. },
  2084. drag: function( draggable, event ) {
  2085. // If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
  2086. if ( draggable.options.refreshPositions ) {
  2087. $.ui.ddmanager.prepareOffsets( draggable, event );
  2088. }
  2089. // Run through all droppables and check their positions based on specific tolerance options
  2090. $.each( $.ui.ddmanager.droppables[ draggable.options.scope ] || [], function() {
  2091. if ( this.options.disabled || this.greedyChild || !this.visible ) {
  2092. return;
  2093. }
  2094. var parentInstance, scope, parent,
  2095. intersects = $.ui.intersect( draggable, this, this.options.tolerance, event ),
  2096. c = !intersects && this.isover ? "isout" : ( intersects && !this.isover ? "isover" : null );
  2097. if ( !c ) {
  2098. return;
  2099. }
  2100. if ( this.options.greedy ) {
  2101. // find droppable parents with same scope
  2102. scope = this.options.scope;
  2103. parent = this.element.parents( ":data(ui-droppable)" ).filter(function() {
  2104. return $( this ).droppable( "instance" ).options.scope === scope;
  2105. });
  2106. if ( parent.length ) {
  2107. parentInstance = $( parent[ 0 ] ).droppable( "instance" );
  2108. parentInstance.greedyChild = ( c === "isover" );
  2109. }
  2110. }
  2111. // we just moved into a greedy child
  2112. if ( parentInstance && c === "isover" ) {
  2113. parentInstance.isover = false;
  2114. parentInstance.isout = true;
  2115. parentInstance._out.call( parentInstance, event );
  2116. }
  2117. this[ c ] = true;
  2118. this[c === "isout" ? "isover" : "isout"] = false;
  2119. this[c === "isover" ? "_over" : "_out"].call( this, event );
  2120. // we just moved out of a greedy child
  2121. if ( parentInstance && c === "isout" ) {
  2122. parentInstance.isout = false;
  2123. parentInstance.isover = true;
  2124. parentInstance._over.call( parentInstance, event );
  2125. }
  2126. });
  2127. },
  2128. dragStop: function( draggable, event ) {
  2129. draggable.element.parentsUntil( "body" ).unbind( "scroll.droppable" );
  2130. // Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003)
  2131. if ( !draggable.options.refreshPositions ) {
  2132. $.ui.ddmanager.prepareOffsets( draggable, event );
  2133. }
  2134. }
  2135. };
  2136. var droppable = $.ui.droppable;
  2137. /**
  2138. * @preserve
  2139. * jquery.layout 1.3.0 - Release Candidate 30.79
  2140. * $Date: 2013-01-12 08:00:00 (Sat, 12 Jan 2013) $
  2141. * $Rev: 303007 $
  2142. *
  2143. * Copyright (c) 2013 Kevin Dalman (http://allpro.net)
  2144. * Based on work by Fabrizio Balliano (http://www.fabrizioballiano.net)
  2145. *
  2146. * Dual licensed under the GPL (http://www.gnu.org/licenses/gpl.html)
  2147. * and MIT (http://www.opensource.org/licenses/mit-license.php) licenses.
  2148. *
  2149. * SEE: http://layout.jquery-dev.net/LICENSE.txt
  2150. *
  2151. * Changelog: http://layout.jquery-dev.net/changelog.cfm#1.3.0.rc30.79
  2152. *
  2153. * Docs: http://layout.jquery-dev.net/documentation.html
  2154. * Tips: http://layout.jquery-dev.net/tips.html
  2155. * Help: http://groups.google.com/group/jquery-ui-layout
  2156. */
  2157. /* JavaDoc Info: http://code.google.com/closure/compiler/docs/js-for-compiler.html
  2158. * {!Object} non-nullable type (never NULL)
  2159. * {?string} nullable type (sometimes NULL) - default for {Object}
  2160. * {number=} optional parameter
  2161. * {*} ALL types
  2162. */
  2163. /* TODO for jQ 2.0
  2164. * change .andSelf() to .addBack()
  2165. * $.fn.disableSelection won't work
  2166. */
  2167. // NOTE: For best readability, view with a fixed-width font and tabs equal to 4-chars
  2168. ;(function ($) {
  2169. // alias Math methods - used a lot!
  2170. var min = Math.min
  2171. , max = Math.max
  2172. , round = Math.floor
  2173. , isStr = function (v) { return $.type(v) === "string"; }
  2174. /**
  2175. * @param {!Object} Instance
  2176. * @param {Array.<string>} a_fn
  2177. */
  2178. , runPluginCallbacks = function (Instance, a_fn) {
  2179. if ($.isArray(a_fn))
  2180. for (var i=0, c=a_fn.length; i<c; i++) {
  2181. var fn = a_fn[i];
  2182. try {
  2183. if (isStr(fn)) // 'name' of a function
  2184. fn = eval(fn);
  2185. if ($.isFunction(fn))
  2186. g(fn)( Instance );
  2187. } catch (ex) {}
  2188. }
  2189. function g (f) { return f; }; // compiler hack
  2190. }
  2191. ;
  2192. /*
  2193. * GENERIC $.layout METHODS - used by all layouts
  2194. */
  2195. $.layout = {
  2196. version: "1.3.rc30.79"
  2197. , revision: 0.033007 // 1.3.0 final = 1.0300 - major(n+).minor(nn)+patch(nn+)
  2198. // $.layout.browser REPLACES $.browser
  2199. , browser: {} // set below
  2200. // *PREDEFINED* EFFECTS & DEFAULTS
  2201. // MUST list effect here - OR MUST set an fxSettings option (can be an empty hash: {})
  2202. , effects: {
  2203. // Pane Open/Close Animations
  2204. slide: {
  2205. all: { duration: "fast" } // eg: duration: 1000, easing: "easeOutBounce"
  2206. , north: { direction: "up" }
  2207. , south: { direction: "down" }
  2208. , east: { direction: "right"}
  2209. , west: { direction: "left" }
  2210. }
  2211. , drop: {
  2212. all: { duration: "slow" }
  2213. , north: { direction: "up" }
  2214. , south: { direction: "down" }
  2215. , east: { direction: "right"}
  2216. , west: { direction: "left" }
  2217. }
  2218. , scale: {
  2219. all: { duration: "fast" }
  2220. }
  2221. // these are not recommended, but can be used
  2222. , blind: {}
  2223. , clip: {}
  2224. , explode: {}
  2225. , fade: {}
  2226. , fold: {}
  2227. , puff: {}
  2228. // Pane Resize Animations
  2229. , size: {
  2230. all: { easing: "swing" }
  2231. }
  2232. }
  2233. // INTERNAL CONFIG DATA - DO NOT CHANGE THIS!
  2234. , config: {
  2235. optionRootKeys: "effects,panes,north,south,west,east,center".split(",")
  2236. , allPanes: "north,south,west,east,center".split(",")
  2237. , borderPanes: "north,south,west,east".split(",")
  2238. , oppositeEdge: {
  2239. north: "south"
  2240. , south: "north"
  2241. , east: "west"
  2242. , west: "east"
  2243. }
  2244. // offscreen data
  2245. , offscreenCSS: { left: "-99999px", right: "auto" } // used by hide/close if useOffscreenClose=true
  2246. , offscreenReset: "offscreenReset" // key used for data
  2247. // CSS used in multiple places
  2248. , hidden: { visibility: "hidden" }
  2249. , visible: { visibility: "visible" }
  2250. // layout element settings
  2251. , resizers: {
  2252. cssReq: {
  2253. position: "absolute"
  2254. , padding: 0
  2255. , margin: 0
  2256. , fontSize: "1px"
  2257. , textAlign: "left" // to counter-act "center" alignment!
  2258. , overflow: "hidden" // prevent toggler-button from overflowing
  2259. // SEE $.layout.defaults.zIndexes.resizer_normal
  2260. }
  2261. , cssDemo: { // DEMO CSS - applied if: options.PANE.applyDemoStyles=true
  2262. background: "#DDD"
  2263. , border: "none"
  2264. }
  2265. }
  2266. , togglers: {
  2267. cssReq: {
  2268. position: "absolute"
  2269. , display: "block"
  2270. , padding: 0
  2271. , margin: 0
  2272. , overflow: "hidden"
  2273. , textAlign: "center"
  2274. , fontSize: "1px"
  2275. , cursor: "pointer"
  2276. , zIndex: 1
  2277. }
  2278. , cssDemo: { // DEMO CSS - applied if: options.PANE.applyDemoStyles=true
  2279. background: "#AAA"
  2280. }
  2281. }
  2282. , content: {
  2283. cssReq: {
  2284. position: "relative" /* contain floated or positioned elements */
  2285. }
  2286. , cssDemo: { // DEMO CSS - applied if: options.PANE.applyDemoStyles=true
  2287. overflow: "auto"
  2288. , padding: "10px"
  2289. }
  2290. , cssDemoPane: { // DEMO CSS - REMOVE scrolling from 'pane' when it has a content-div
  2291. overflow: "hidden"
  2292. , padding: 0
  2293. }
  2294. }
  2295. , panes: { // defaults for ALL panes - overridden by 'per-pane settings' below
  2296. cssReq: {
  2297. position: "absolute"
  2298. , margin: 0
  2299. // $.layout.defaults.zIndexes.pane_normal
  2300. }
  2301. , cssDemo: { // DEMO CSS - applied if: options.PANE.applyDemoStyles=true
  2302. padding: "10px"
  2303. , background: "#FFF"
  2304. , border: "1px solid #BBB"
  2305. , overflow: "auto"
  2306. }
  2307. }
  2308. , north: {
  2309. side: "top"
  2310. , sizeType: "Height"
  2311. , dir: "horz"
  2312. , cssReq: {
  2313. top: 0
  2314. , bottom: "auto"
  2315. , left: 0
  2316. , right: 0
  2317. , width: "auto"
  2318. // height: DYNAMIC
  2319. }
  2320. }
  2321. , south: {
  2322. side: "bottom"
  2323. , sizeType: "Height"
  2324. , dir: "horz"
  2325. , cssReq: {
  2326. top: "auto"
  2327. , bottom: 0
  2328. , left: 0
  2329. , right: 0
  2330. , width: "auto"
  2331. // height: DYNAMIC
  2332. }
  2333. }
  2334. , east: {
  2335. side: "right"
  2336. , sizeType: "Width"
  2337. , dir: "vert"
  2338. , cssReq: {
  2339. left: "auto"
  2340. , right: 0
  2341. , top: "auto" // DYNAMIC
  2342. , bottom: "auto" // DYNAMIC
  2343. , height: "auto"
  2344. // width: DYNAMIC
  2345. }
  2346. }
  2347. , west: {
  2348. side: "left"
  2349. , sizeType: "Width"
  2350. , dir: "vert"
  2351. , cssReq: {
  2352. left: 0
  2353. , right: "auto"
  2354. , top: "auto" // DYNAMIC
  2355. , bottom: "auto" // DYNAMIC
  2356. , height: "auto"
  2357. // width: DYNAMIC
  2358. }
  2359. }
  2360. , center: {
  2361. dir: "center"
  2362. , cssReq: {
  2363. left: "auto" // DYNAMIC
  2364. , right: "auto" // DYNAMIC
  2365. , top: "auto" // DYNAMIC
  2366. , bottom: "auto" // DYNAMIC
  2367. , height: "auto"
  2368. , width: "auto"
  2369. }
  2370. }
  2371. }
  2372. // CALLBACK FUNCTION NAMESPACE - used to store reusable callback functions
  2373. , callbacks: {}
  2374. , getParentPaneElem: function (el) {
  2375. // must pass either a container or pane element
  2376. var $el = $(el)
  2377. , layout = $el.data("layout") || $el.data("parentLayout");
  2378. if (layout) {
  2379. var $cont = layout.container;
  2380. // see if this container is directly-nested inside an outer-pane
  2381. if ($cont.data("layoutPane")) return $cont;
  2382. var $pane = $cont.closest("."+ $.layout.defaults.panes.paneClass);
  2383. // if a pane was found, return it
  2384. if ($pane.data("layoutPane")) return $pane;
  2385. }
  2386. return null;
  2387. }
  2388. , getParentPaneInstance: function (el) {
  2389. // must pass either a container or pane element
  2390. var $pane = $.layout.getParentPaneElem(el);
  2391. return $pane ? $pane.data("layoutPane") : null;
  2392. }
  2393. , getParentLayoutInstance: function (el) {
  2394. // must pass either a container or pane element
  2395. var $pane = $.layout.getParentPaneElem(el);
  2396. return $pane ? $pane.data("parentLayout") : null;
  2397. }
  2398. , getEventObject: function (evt) {
  2399. return typeof evt === "object" && evt.stopPropagation ? evt : null;
  2400. }
  2401. , parsePaneName: function (evt_or_pane) {
  2402. var evt = $.layout.getEventObject( evt_or_pane )
  2403. , pane = evt_or_pane;
  2404. if (evt) {
  2405. // ALWAYS stop propagation of events triggered in Layout!
  2406. evt.stopPropagation();
  2407. pane = $(this).data("layoutEdge");
  2408. }
  2409. if (pane && !/^(west|east|north|south|center)$/.test(pane)) {
  2410. $.layout.msg('LAYOUT ERROR - Invalid pane-name: "'+ pane +'"');
  2411. pane = "error";
  2412. }
  2413. return pane;
  2414. }
  2415. // LAYOUT-PLUGIN REGISTRATION
  2416. // more plugins can added beyond this default list
  2417. , plugins: {
  2418. draggable: !!$.fn.draggable // resizing
  2419. , effects: {
  2420. core: !!$.effects // animimations (specific effects tested by initOptions)
  2421. , slide: $.effects && ($.effects.slide || ($.effects.effect && $.effects.effect.slide)) // default effect
  2422. }
  2423. }
  2424. // arrays of plugin or other methods to be triggered for events in *each layout* - will be passed 'Instance'
  2425. , onCreate: [] // runs when layout is just starting to be created - right after options are set
  2426. , onLoad: [] // runs after layout container and global events init, but before initPanes is called
  2427. , onReady: [] // runs after initialization *completes* - ie, after initPanes completes successfully
  2428. , onDestroy: [] // runs after layout is destroyed
  2429. , onUnload: [] // runs after layout is destroyed OR when page unloads
  2430. , afterOpen: [] // runs after setAsOpen() completes
  2431. , afterClose: [] // runs after setAsClosed() completes
  2432. /*
  2433. * GENERIC UTILITY METHODS
  2434. */
  2435. // calculate and return the scrollbar width, as an integer
  2436. , scrollbarWidth: function () { return window.scrollbarWidth || $.layout.getScrollbarSize('width'); }
  2437. , scrollbarHeight: function () { return window.scrollbarHeight || $.layout.getScrollbarSize('height'); }
  2438. , getScrollbarSize: function (dim) {
  2439. var $c = $('<div style="position: absolute; top: -10000px; left: -10000px; width: 100px; height: 100px; overflow: scroll;"></div>').appendTo("body");
  2440. var d = { width: $c.css("width") - $c[0].clientWidth, height: $c.height() - $c[0].clientHeight };
  2441. $c.remove();
  2442. window.scrollbarWidth = d.width;
  2443. window.scrollbarHeight = d.height;
  2444. return dim.match(/^(width|height)$/) ? d[dim] : d;
  2445. }
  2446. /**
  2447. * Returns hash container 'display' and 'visibility'
  2448. *
  2449. * @see $.swap() - swaps CSS, runs callback, resets CSS
  2450. * @param {!Object} $E jQuery element
  2451. * @param {boolean=} [force=false] Run even if display != none
  2452. * @return {!Object} Returns current style props, if applicable
  2453. */
  2454. , showInvisibly: function ($E, force) {
  2455. if ($E && $E.length && (force || $E.css("display") === "none")) { // only if not *already hidden*
  2456. var s = $E[0].style
  2457. // save ONLY the 'style' props because that is what we must restore
  2458. , CSS = { display: s.display || '', visibility: s.visibility || '' };
  2459. // show element 'invisibly' so can be measured
  2460. $E.css({ display: "block", visibility: "hidden" });
  2461. return CSS;
  2462. }
  2463. return {};
  2464. }
  2465. /**
  2466. * Returns data for setting size of an element (container or a pane).
  2467. *
  2468. * @see _create(), onWindowResize() for container, plus others for pane
  2469. * @return JSON Returns a hash of all dimensions: top, bottom, left, right, outerWidth, innerHeight, etc
  2470. */
  2471. , getElementDimensions: function ($E, inset) {
  2472. var
  2473. // dimensions hash - start with current data IF passed
  2474. d = { css: {}, inset: {} }
  2475. , x = d.css // CSS hash
  2476. , i = { bottom: 0 } // TEMP insets (bottom = complier hack)
  2477. , N = $.layout.cssNum
  2478. , off = $E.offset()
  2479. , b, p, ei // TEMP border, padding
  2480. ;
  2481. d.offsetLeft = off.left;
  2482. d.offsetTop = off.top;
  2483. if (!inset) inset = {}; // simplify logic below
  2484. $.each("Left,Right,Top,Bottom".split(","), function (idx, e) { // e = edge
  2485. b = x["border" + e] = $.layout.borderWidth($E, e);
  2486. p = x["padding"+ e] = $.layout.cssNum($E, "padding"+e);
  2487. ei = e.toLowerCase();
  2488. d.inset[ei] = inset[ei] >= 0 ? inset[ei] : p; // any missing insetX value = paddingX
  2489. i[ei] = d.inset[ei] + b; // total offset of content from outer side
  2490. });
  2491. x.width = $E.width();
  2492. x.height = $E.height();
  2493. x.top = N($E,"top",true);
  2494. x.bottom = N($E,"bottom",true);
  2495. x.left = N($E,"left",true);
  2496. x.right = N($E,"right",true);
  2497. d.outerWidth = $E.outerWidth();
  2498. d.outerHeight = $E.outerHeight();
  2499. // calc the TRUE inner-dimensions, even in quirks-mode!
  2500. d.innerWidth = max(0, d.outerWidth - i.left - i.right);
  2501. d.innerHeight = max(0, d.outerHeight - i.top - i.bottom);
  2502. // layoutWidth/Height is used in calcs for manual resizing
  2503. // layoutW/H only differs from innerW/H when in quirks-mode - then is like outerW/H
  2504. d.layoutWidth = $E.innerWidth();
  2505. d.layoutHeight = $E.innerHeight();
  2506. //if ($E.prop('tagName') === 'BODY') { debugData( d, $E.prop('tagName') ); } // DEBUG
  2507. //d.visible = $E.is(":visible");// && x.width > 0 && x.height > 0;
  2508. return d;
  2509. }
  2510. , getElementStyles: function ($E, list) {
  2511. var
  2512. CSS = {}
  2513. , style = $E[0].style
  2514. , props = list.split(",")
  2515. , sides = "Top,Bottom,Left,Right".split(",")
  2516. , attrs = "Color,Style,Width".split(",")
  2517. , p, s, a, i, j, k
  2518. ;
  2519. for (i=0; i < props.length; i++) {
  2520. p = props[i];
  2521. if (p.match(/(border|padding|margin)$/))
  2522. for (j=0; j < 4; j++) {
  2523. s = sides[j];
  2524. if (p === "border")
  2525. for (k=0; k < 3; k++) {
  2526. a = attrs[k];
  2527. CSS[p+s+a] = style[p+s+a];
  2528. }
  2529. else
  2530. CSS[p+s] = style[p+s];
  2531. }
  2532. else
  2533. CSS[p] = style[p];
  2534. };
  2535. return CSS
  2536. }
  2537. /**
  2538. * Return the innerWidth for the current browser/doctype
  2539. *
  2540. * @see initPanes(), sizeMidPanes(), initHandles(), sizeHandles()
  2541. * @param {Array.<Object>} $E Must pass a jQuery object - first element is processed
  2542. * @param {number=} outerWidth (optional) Can pass a width, allowing calculations BEFORE element is resized
  2543. * @return {number} Returns the innerWidth of the elem by subtracting padding and borders
  2544. */
  2545. , cssWidth: function ($E, outerWidth) {
  2546. // a 'calculated' outerHeight can be passed so borders and/or padding are removed if needed
  2547. if (outerWidth <= 0) return 0;
  2548. var bs = !$.layout.browser.boxModel ? "border-box" : $.support.boxSizing ? $E.css("boxSizing") : "content-box"
  2549. , b = $.layout.borderWidth
  2550. , n = $.layout.cssNum
  2551. , W = outerWidth
  2552. ;
  2553. // strip border and/or padding from outerWidth to get CSS Width
  2554. if (bs !== "border-box")
  2555. W -= (b($E, "Left") + b($E, "Right"));
  2556. if (bs === "content-box")
  2557. W -= (n($E, "paddingLeft") + n($E, "paddingRight"));
  2558. return max(0,W);
  2559. }
  2560. /**
  2561. * Return the innerHeight for the current browser/doctype
  2562. *
  2563. * @see initPanes(), sizeMidPanes(), initHandles(), sizeHandles()
  2564. * @param {Array.<Object>} $E Must pass a jQuery object - first element is processed
  2565. * @param {number=} outerHeight (optional) Can pass a width, allowing calculations BEFORE element is resized
  2566. * @return {number} Returns the innerHeight of the elem by subtracting padding and borders
  2567. */
  2568. , cssHeight: function ($E, outerHeight) {
  2569. // a 'calculated' outerHeight can be passed so borders and/or padding are removed if needed
  2570. if (outerHeight <= 0) return 0;
  2571. var bs = !$.layout.browser.boxModel ? "border-box" : $.support.boxSizing ? $E.css("boxSizing") : "content-box"
  2572. , b = $.layout.borderWidth
  2573. , n = $.layout.cssNum
  2574. , H = outerHeight
  2575. ;
  2576. // strip border and/or padding from outerHeight to get CSS Height
  2577. if (bs !== "border-box")
  2578. H -= (b($E, "Top") + b($E, "Bottom"));
  2579. if (bs === "content-box")
  2580. H -= (n($E, "paddingTop") + n($E, "paddingBottom"));
  2581. return max(0,H);
  2582. }
  2583. /**
  2584. * Returns the 'current CSS numeric value' for a CSS property - 0 if property does not exist
  2585. *
  2586. * @see Called by many methods
  2587. * @param {Array.<Object>} $E Must pass a jQuery object - first element is processed
  2588. * @param {string} prop The name of the CSS property, eg: top, width, etc.
  2589. * @param {boolean=} [allowAuto=false] true = return 'auto' if that is value; false = return 0
  2590. * @return {(string|number)} Usually used to get an integer value for position (top, left) or size (height, width)
  2591. */
  2592. , cssNum: function ($E, prop, allowAuto) {
  2593. if (!$E.jquery) $E = $($E);
  2594. var CSS = $.layout.showInvisibly($E)
  2595. , p = $.css($E[0], prop, true)
  2596. , v = allowAuto && p=="auto" ? p : Math.round(parseFloat(p) || 0);
  2597. $E.css( CSS ); // RESET
  2598. return v;
  2599. }
  2600. , borderWidth: function (el, side) {
  2601. if (el.jquery) el = el[0];
  2602. var b = "border"+ side.substr(0,1).toUpperCase() + side.substr(1); // left => Left
  2603. return $.css(el, b+"Style", true) === "none" ? 0 : Math.round(parseFloat($.css(el, b+"Width", true)) || 0);
  2604. }
  2605. /**
  2606. * Mouse-tracking utility - FUTURE REFERENCE
  2607. *
  2608. * init: if (!window.mouse) {
  2609. * window.mouse = { x: 0, y: 0 };
  2610. * $(document).mousemove( $.layout.trackMouse );
  2611. * }
  2612. *
  2613. * @param {Object} evt
  2614. *
  2615. , trackMouse: function (evt) {
  2616. window.mouse = { x: evt.clientX, y: evt.clientY };
  2617. }
  2618. */
  2619. /**
  2620. * SUBROUTINE for preventPrematureSlideClose option
  2621. *
  2622. * @param {Object} evt
  2623. * @param {Object=} el
  2624. */
  2625. , isMouseOverElem: function (evt, el) {
  2626. var
  2627. $E = $(el || this)
  2628. , d = $E.offset()
  2629. , T = d.top
  2630. , L = d.left
  2631. , R = L + $E.outerWidth()
  2632. , B = T + $E.outerHeight()
  2633. , x = evt.pageX // evt.clientX ?
  2634. , y = evt.pageY // evt.clientY ?
  2635. ;
  2636. // if X & Y are < 0, probably means is over an open SELECT
  2637. return ($.layout.browser.msie && x < 0 && y < 0) || ((x >= L && x <= R) && (y >= T && y <= B));
  2638. }
  2639. /**
  2640. * Message/Logging Utility
  2641. *
  2642. * @example $.layout.msg("My message"); // log text
  2643. * @example $.layout.msg("My message", true); // alert text
  2644. * @example $.layout.msg({ foo: "bar" }, "Title"); // log hash-data, with custom title
  2645. * @example $.layout.msg({ foo: "bar" }, true, "Title", { sort: false }); -OR-
  2646. * @example $.layout.msg({ foo: "bar" }, "Title", { sort: false, display: true }); // alert hash-data
  2647. *
  2648. * @param {(Object|string)} info String message OR Hash/Array
  2649. * @param {(Boolean|string|Object)=} [popup=false] True means alert-box - can be skipped
  2650. * @param {(Object|string)=} [debugTitle=""] Title for Hash data - can be skipped
  2651. * @param {Object=} [debugOpts] Extra options for debug output
  2652. */
  2653. , msg: function (info, popup, debugTitle, debugOpts) {
  2654. if ($.isPlainObject(info) && window.debugData) {
  2655. if (typeof popup === "string") {
  2656. debugOpts = debugTitle;
  2657. debugTitle = popup;
  2658. }
  2659. else if (typeof debugTitle === "object") {
  2660. debugOpts = debugTitle;
  2661. debugTitle = null;
  2662. }
  2663. var t = debugTitle || "log( <object> )"
  2664. , o = $.extend({ sort: false, returnHTML: false, display: false }, debugOpts);
  2665. if (popup === true || o.display)
  2666. debugData( info, t, o );
  2667. else if (window.console)
  2668. console.log(debugData( info, t, o ));
  2669. }
  2670. else if (popup)
  2671. alert(info);
  2672. else if (window.console)
  2673. console.log(info);
  2674. else {
  2675. var id = "#layoutLogger"
  2676. , $l = $(id);
  2677. if (!$l.length)
  2678. $l = createLog();
  2679. $l.children("ul").append('<li style="padding: 4px 10px; margin: 0; border-top: 1px solid #CCC;">'+ info.replace(/\</g,"&lt;").replace(/\>/g,"&gt;") +'</li>');
  2680. }
  2681. function createLog () {
  2682. var pos = $.support.fixedPosition ? 'fixed' : 'absolute'
  2683. , $e = $('<div id="layoutLogger" style="position: '+ pos +'; top: 5px; z-index: 999999; max-width: 25%; overflow: hidden; border: 1px solid #000; border-radius: 5px; background: #FBFBFB; box-shadow: 0 2px 10px rgba(0,0,0,0.3);">'
  2684. + '<div style="font-size: 13px; font-weight: bold; padding: 5px 10px; background: #F6F6F6; border-radius: 5px 5px 0 0; cursor: move;">'
  2685. + '<span style="float: right; padding-left: 7px; cursor: pointer;" title="Remove Console" onclick="$(this).closest(\'#layoutLogger\').remove()">X</span>Layout console.log</div>'
  2686. + '<ul style="font-size: 13px; font-weight: none; list-style: none; margin: 0; padding: 0 0 2px;"></ul>'
  2687. + '</div>'
  2688. ).appendTo("body");
  2689. $e.css('left', $(window).width() - $e.outerWidth() - 5)
  2690. if ($.ui.draggable) $e.draggable({ handle: ':first-child' });
  2691. return $e;
  2692. };
  2693. }
  2694. };
  2695. /*
  2696. * $.layout.browser REPLACES removed $.browser, with extra data
  2697. * Parsing code here adapted from jQuery 1.8 $.browse
  2698. */
  2699. var u = navigator.userAgent.toLowerCase()
  2700. , m = /(chrome)[ \/]([\w.]+)/.exec( u )
  2701. || /(webkit)[ \/]([\w.]+)/.exec( u )
  2702. || /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( u )
  2703. || /(msie) ([\w.]+)/.exec( u )
  2704. || u.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( u )
  2705. || []
  2706. , b = m[1] || ""
  2707. , v = m[2] || 0
  2708. , ie = b === "msie"
  2709. ;
  2710. $.layout.browser = {
  2711. version: v
  2712. , safari: b === "webkit" // webkit (NOT chrome) = safari
  2713. , webkit: b === "chrome" // chrome = webkit
  2714. , msie: ie
  2715. , isIE6: ie && v == 6
  2716. // ONLY IE reverts to old box-model - update for older jQ onReady
  2717. , boxModel: !ie || $.support.boxModel !== false
  2718. };
  2719. if (b) $.layout.browser[b] = true; // set CURRENT browser
  2720. /* OLD versions of jQuery only set $.support.boxModel after page is loaded
  2721. * so if this is IE, use support.boxModel to test for quirks-mode (ONLY IE changes boxModel) */
  2722. if (ie) $(function(){ $.layout.browser.boxModel = $.support.boxModel; });
  2723. // DEFAULT OPTIONS
  2724. $.layout.defaults = {
  2725. /*
  2726. * LAYOUT & LAYOUT-CONTAINER OPTIONS
  2727. * - none of these options are applicable to individual panes
  2728. */
  2729. name: "" // Not required, but useful for buttons and used for the state-cookie
  2730. , containerClass: "ui-layout-container" // layout-container element
  2731. , inset: null // custom container-inset values (override padding)
  2732. , scrollToBookmarkOnLoad: true // after creating a layout, scroll to bookmark in URL (.../page.htm#myBookmark)
  2733. , resizeWithWindow: true // bind thisLayout.resizeAll() to the window.resize event
  2734. , resizeWithWindowDelay: 200 // delay calling resizeAll because makes window resizing very jerky
  2735. , resizeWithWindowMaxDelay: 0 // 0 = none - force resize every XX ms while window is being resized
  2736. , maskPanesEarly: false // true = create pane-masks on resizer.mouseDown instead of waiting for resizer.dragstart
  2737. , onresizeall_start: null // CALLBACK when resizeAll() STARTS - NOT pane-specific
  2738. , onresizeall_end: null // CALLBACK when resizeAll() ENDS - NOT pane-specific
  2739. , onload_start: null // CALLBACK when Layout inits - after options initialized, but before elements
  2740. , onload_end: null // CALLBACK when Layout inits - after EVERYTHING has been initialized
  2741. , onunload_start: null // CALLBACK when Layout is destroyed OR onWindowUnload
  2742. , onunload_end: null // CALLBACK when Layout is destroyed OR onWindowUnload
  2743. , initPanes: true // false = DO NOT initialize the panes onLoad - will init later
  2744. , showErrorMessages: true // enables fatal error messages to warn developers of common errors
  2745. , showDebugMessages: false // display console-and-alert debug msgs - IF this Layout version _has_ debugging code!
  2746. // Changing this zIndex value will cause other zIndex values to automatically change
  2747. , zIndex: null // the PANE zIndex - resizers and masks will be +1
  2748. // DO NOT CHANGE the zIndex values below unless you clearly understand their relationships
  2749. , zIndexes: { // set _default_ z-index values here...
  2750. pane_normal: 0 // normal z-index for panes
  2751. , content_mask: 1 // applied to overlays used to mask content INSIDE panes during resizing
  2752. , resizer_normal: 2 // normal z-index for resizer-bars
  2753. , pane_sliding: 100 // applied to *BOTH* the pane and its resizer when a pane is 'slid open'
  2754. , pane_animate: 1000 // applied to the pane when being animated - not applied to the resizer
  2755. , resizer_drag: 10000 // applied to the CLONED resizer-bar when being 'dragged'
  2756. }
  2757. , errors: {
  2758. pane: "pane" // description of "layout pane element" - used only in error messages
  2759. , selector: "selector" // description of "jQuery-selector" - used only in error messages
  2760. , addButtonError: "Error Adding Button\nInvalid "
  2761. , containerMissing: "UI Layout Initialization Error\nThe specified layout-container does not exist."
  2762. , centerPaneMissing: "UI Layout Initialization Error\nThe center-pane element does not exist.\nThe center-pane is a required element."
  2763. , noContainerHeight: "UI Layout Initialization Warning\nThe layout-container \"CONTAINER\" has no height.\nTherefore the layout is 0-height and hence 'invisible'!"
  2764. , callbackError: "UI Layout Callback Error\nThe EVENT callback is not a valid function."
  2765. }
  2766. /*
  2767. * PANE DEFAULT SETTINGS
  2768. * - settings under the 'panes' key become the default settings for *all panes*
  2769. * - ALL pane-options can also be set specifically for each panes, which will override these 'default values'
  2770. */
  2771. , panes: { // default options for 'all panes' - will be overridden by 'per-pane settings'
  2772. applyDemoStyles: false // NOTE: renamed from applyDefaultStyles for clarity
  2773. , closable: true // pane can open & close
  2774. , resizable: true // when open, pane can be resized
  2775. , slidable: true // when closed, pane can 'slide open' over other panes - closes on mouse-out
  2776. , initClosed: false // true = init pane as 'closed'
  2777. , initHidden: false // true = init pane as 'hidden' - no resizer-bar/spacing
  2778. // SELECTORS
  2779. //, paneSelector: "" // MUST be pane-specific - jQuery selector for pane
  2780. , contentSelector: ".ui-layout-content" // INNER div/element to auto-size so only it scrolls, not the entire pane!
  2781. , contentIgnoreSelector: ".ui-layout-ignore" // element(s) to 'ignore' when measuring 'content'
  2782. , findNestedContent: false // true = $P.find(contentSelector), false = $P.children(contentSelector)
  2783. // GENERIC ROOT-CLASSES - for auto-generated classNames
  2784. , paneClass: "ui-layout-pane" // Layout Pane
  2785. , resizerClass: "ui-layout-resizer" // Resizer Bar
  2786. , togglerClass: "ui-layout-toggler" // Toggler Button
  2787. , buttonClass: "ui-layout-button" // CUSTOM Buttons - eg: '[ui-layout-button]-toggle/-open/-close/-pin'
  2788. // ELEMENT SIZE & SPACING
  2789. //, size: 100 // MUST be pane-specific -initial size of pane
  2790. , minSize: 0 // when manually resizing a pane
  2791. , maxSize: 0 // ditto, 0 = no limit
  2792. , spacing_open: 6 // space between pane and adjacent panes - when pane is 'open'
  2793. , spacing_closed: 6 // ditto - when pane is 'closed'
  2794. , togglerLength_open: 50 // Length = WIDTH of toggler button on north/south sides - HEIGHT on east/west sides
  2795. , togglerLength_closed: 50 // 100% OR -1 means 'full height/width of resizer bar' - 0 means 'hidden'
  2796. , togglerAlign_open: "center" // top/left, bottom/right, center, OR...
  2797. , togglerAlign_closed: "center" // 1 => nn = offset from top/left, -1 => -nn == offset from bottom/right
  2798. , togglerContent_open: "" // text or HTML to put INSIDE the toggler
  2799. , togglerContent_closed: "" // ditto
  2800. // RESIZING OPTIONS
  2801. , resizerDblClickToggle: true //
  2802. , autoResize: true // IF size is 'auto' or a percentage, then recalc 'pixel size' whenever the layout resizes
  2803. , autoReopen: true // IF a pane was auto-closed due to noRoom, reopen it when there is room? False = leave it closed
  2804. , resizerDragOpacity: 1 // option for ui.draggable
  2805. //, resizerCursor: "" // MUST be pane-specific - cursor when over resizer-bar
  2806. , maskContents: false // true = add DIV-mask over-or-inside this pane so can 'drag' over IFRAMES
  2807. , maskObjects: false // true = add IFRAME-mask over-or-inside this pane to cover objects/applets - content-mask will overlay this mask
  2808. , maskZindex: null // will override zIndexes.content_mask if specified - not applicable to iframe-panes
  2809. , resizingGrid: false // grid size that the resizers will snap-to during resizing, eg: [20,20]
  2810. , livePaneResizing: false // true = LIVE Resizing as resizer is dragged
  2811. , liveContentResizing: false // true = re-measure header/footer heights as resizer is dragged
  2812. , liveResizingTolerance: 1 // how many px change before pane resizes, to control performance
  2813. // SLIDING OPTIONS
  2814. , sliderCursor: "pointer" // cursor when resizer-bar will trigger 'sliding'
  2815. , slideTrigger_open: "click" // click, dblclick, mouseenter
  2816. , slideTrigger_close: "mouseleave"// click, mouseleave
  2817. , slideDelay_open: 300 // applies only for mouseenter event - 0 = instant open
  2818. , slideDelay_close: 300 // applies only for mouseleave event (300ms is the minimum!)
  2819. , hideTogglerOnSlide: false // when pane is slid-open, should the toggler show?
  2820. , preventQuickSlideClose: $.layout.browser.webkit // Chrome triggers slideClosed as it is opening
  2821. , preventPrematureSlideClose: false // handle incorrect mouseleave trigger, like when over a SELECT-list in IE
  2822. // PANE-SPECIFIC TIPS & MESSAGES
  2823. , tips: {
  2824. Open: "Open" // eg: "Open Pane"
  2825. , Close: "Close"
  2826. , Resize: "Resize"
  2827. , Slide: "Slide Open"
  2828. , Pin: "Pin"
  2829. , Unpin: "Un-Pin"
  2830. , noRoomToOpen: "Not enough room to show this panel." // alert if user tries to open a pane that cannot
  2831. , minSizeWarning: "Panel has reached its minimum size" // displays in browser statusbar
  2832. , maxSizeWarning: "Panel has reached its maximum size" // ditto
  2833. }
  2834. // HOT-KEYS & MISC
  2835. , showOverflowOnHover: false // will bind allowOverflow() utility to pane.onMouseOver
  2836. , enableCursorHotkey: true // enabled 'cursor' hotkeys
  2837. //, customHotkey: "" // MUST be pane-specific - EITHER a charCode OR a character
  2838. , customHotkeyModifier: "SHIFT" // either 'SHIFT', 'CTRL' or 'CTRL+SHIFT' - NOT 'ALT'
  2839. // PANE ANIMATION
  2840. // NOTE: fxSss_open, fxSss_close & fxSss_size options (eg: fxName_open) are auto-generated if not passed
  2841. , fxName: "slide" // ('none' or blank), slide, drop, scale -- only relevant to 'open' & 'close', NOT 'size'
  2842. , fxSpeed: null // slow, normal, fast, 200, nnn - if passed, will OVERRIDE fxSettings.duration
  2843. , fxSettings: {} // can be passed, eg: { easing: "easeOutBounce", duration: 1500 }
  2844. , fxOpacityFix: true // tries to fix opacity in IE to restore anti-aliasing after animation
  2845. , animatePaneSizing: false // true = animate resizing after dragging resizer-bar OR sizePane() is called
  2846. /* NOTE: Action-specific FX options are auto-generated from the options above if not specifically set:
  2847. fxName_open: "slide" // 'Open' pane animation
  2848. fnName_close: "slide" // 'Close' pane animation
  2849. fxName_size: "slide" // 'Size' pane animation - when animatePaneSizing = true
  2850. fxSpeed_open: null
  2851. fxSpeed_close: null
  2852. fxSpeed_size: null
  2853. fxSettings_open: {}
  2854. fxSettings_close: {}
  2855. fxSettings_size: {}
  2856. */
  2857. // CHILD/NESTED LAYOUTS
  2858. , children: null // Layout-options for nested/child layout - even {} is valid as options
  2859. , containerSelector: '' // if child is NOT 'directly nested', a selector to find it/them (can have more than one child layout!)
  2860. , initChildren: true // true = child layout will be created as soon as _this_ layout completes initialization
  2861. , destroyChildren: true // true = destroy child-layout if this pane is destroyed
  2862. , resizeChildren: true // true = trigger child-layout.resizeAll() when this pane is resized
  2863. // EVENT TRIGGERING
  2864. , triggerEventsOnLoad: false // true = trigger onopen OR onclose callbacks when layout initializes
  2865. , triggerEventsDuringLiveResize: true // true = trigger onresize callback REPEATEDLY if livePaneResizing==true
  2866. // PANE CALLBACKS
  2867. , onshow_start: null // CALLBACK when pane STARTS to Show - BEFORE onopen/onhide_start
  2868. , onshow_end: null // CALLBACK when pane ENDS being Shown - AFTER onopen/onhide_end
  2869. , onhide_start: null // CALLBACK when pane STARTS to Close - BEFORE onclose_start
  2870. , onhide_end: null // CALLBACK when pane ENDS being Closed - AFTER onclose_end
  2871. , onopen_start: null // CALLBACK when pane STARTS to Open
  2872. , onopen_end: null // CALLBACK when pane ENDS being Opened
  2873. , onclose_start: null // CALLBACK when pane STARTS to Close
  2874. , onclose_end: null // CALLBACK when pane ENDS being Closed
  2875. , onresize_start: null // CALLBACK when pane STARTS being Resized ***FOR ANY REASON***
  2876. , onresize_end: null // CALLBACK when pane ENDS being Resized ***FOR ANY REASON***
  2877. , onsizecontent_start: null // CALLBACK when sizing of content-element STARTS
  2878. , onsizecontent_end: null // CALLBACK when sizing of content-element ENDS
  2879. , onswap_start: null // CALLBACK when pane STARTS to Swap
  2880. , onswap_end: null // CALLBACK when pane ENDS being Swapped
  2881. , ondrag_start: null // CALLBACK when pane STARTS being ***MANUALLY*** Resized
  2882. , ondrag_end: null // CALLBACK when pane ENDS being ***MANUALLY*** Resized
  2883. }
  2884. /*
  2885. * PANE-SPECIFIC SETTINGS
  2886. * - options listed below MUST be specified per-pane - they CANNOT be set under 'panes'
  2887. * - all options under the 'panes' key can also be set specifically for any pane
  2888. * - most options under the 'panes' key apply only to 'border-panes' - NOT the the center-pane
  2889. */
  2890. , north: {
  2891. paneSelector: ".ui-layout-north"
  2892. , size: "auto" // eg: "auto", "30%", .30, 200
  2893. , resizerCursor: "n-resize" // custom = url(myCursor.cur)
  2894. , customHotkey: "" // EITHER a charCode (43) OR a character ("o")
  2895. }
  2896. , south: {
  2897. paneSelector: ".ui-layout-south"
  2898. , size: "auto"
  2899. , resizerCursor: "s-resize"
  2900. , customHotkey: ""
  2901. }
  2902. , east: {
  2903. paneSelector: ".ui-layout-east"
  2904. , size: 200
  2905. , resizerCursor: "e-resize"
  2906. , customHotkey: ""
  2907. }
  2908. , west: {
  2909. paneSelector: ".ui-layout-west"
  2910. , size: 200
  2911. , resizerCursor: "w-resize"
  2912. , customHotkey: ""
  2913. }
  2914. , center: {
  2915. paneSelector: ".ui-layout-center"
  2916. , minWidth: 0
  2917. , minHeight: 0
  2918. }
  2919. };
  2920. $.layout.optionsMap = {
  2921. // layout/global options - NOT pane-options
  2922. layout: ("name,instanceKey,stateManagement,effects,inset,zIndexes,errors,"
  2923. + "zIndex,scrollToBookmarkOnLoad,showErrorMessages,maskPanesEarly,"
  2924. + "outset,resizeWithWindow,resizeWithWindowDelay,resizeWithWindowMaxDelay,"
  2925. + "onresizeall,onresizeall_start,onresizeall_end,onload,onload_start,onload_end,onunload,onunload_start,onunload_end").split(",")
  2926. // borderPanes: [ ALL options that are NOT specified as 'layout' ]
  2927. // default.panes options that apply to the center-pane (most options apply _only_ to border-panes)
  2928. , center: ("paneClass,contentSelector,contentIgnoreSelector,findNestedContent,applyDemoStyles,triggerEventsOnLoad,"
  2929. + "showOverflowOnHover,maskContents,maskObjects,liveContentResizing,"
  2930. + "containerSelector,children,initChildren,resizeChildren,destroyChildren,"
  2931. + "onresize,onresize_start,onresize_end,onsizecontent,onsizecontent_start,onsizecontent_end").split(",")
  2932. // options that MUST be specifically set 'per-pane' - CANNOT set in the panes (defaults) key
  2933. , noDefault: ("paneSelector,resizerCursor,customHotkey").split(",")
  2934. };
  2935. /**
  2936. * Processes options passed in converts flat-format data into subkey (JSON) format
  2937. * In flat-format, subkeys are _currently_ separated with 2 underscores, like north__optName
  2938. * Plugins may also call this method so they can transform their own data
  2939. *
  2940. * @param {!Object} hash Data/options passed by user - may be a single level or nested levels
  2941. * @param {boolean=} [addKeys=false] Should the primary layout.options keys be added if they do not exist?
  2942. * @return {Object} Returns hash of minWidth & minHeight
  2943. */
  2944. $.layout.transformData = function (hash, addKeys) {
  2945. var json = addKeys ? { panes: {}, center: {} } : {} // init return object
  2946. , branch, optKey, keys, key, val, i, c;
  2947. if (typeof hash !== "object") return json; // no options passed
  2948. // convert all 'flat-keys' to 'sub-key' format
  2949. for (optKey in hash) {
  2950. branch = json;
  2951. val = hash[ optKey ];
  2952. keys = optKey.split("__"); // eg: west__size or north__fxSettings__duration
  2953. c = keys.length - 1;
  2954. // convert underscore-delimited to subkeys
  2955. for (i=0; i <= c; i++) {
  2956. key = keys[i];
  2957. if (i === c) { // last key = value
  2958. if ($.isPlainObject( val ))
  2959. branch[key] = $.layout.transformData( val ); // RECURSE
  2960. else
  2961. branch[key] = val;
  2962. }
  2963. else {
  2964. if (!branch[key])
  2965. branch[key] = {}; // create the subkey
  2966. // recurse to sub-key for next loop - if not done
  2967. branch = branch[key];
  2968. }
  2969. }
  2970. }
  2971. return json;
  2972. };
  2973. // INTERNAL CONFIG DATA - DO NOT CHANGE THIS!
  2974. $.layout.backwardCompatibility = {
  2975. // data used by renameOldOptions()
  2976. map: {
  2977. // OLD Option Name: NEW Option Name
  2978. applyDefaultStyles: "applyDemoStyles"
  2979. // CHILD/NESTED LAYOUTS
  2980. , childOptions: "children"
  2981. , initChildLayout: "initChildren"
  2982. , destroyChildLayout: "destroyChildren"
  2983. , resizeChildLayout: "resizeChildren"
  2984. , resizeNestedLayout: "resizeChildren"
  2985. // MISC Options
  2986. , resizeWhileDragging: "livePaneResizing"
  2987. , resizeContentWhileDragging: "liveContentResizing"
  2988. , triggerEventsWhileDragging: "triggerEventsDuringLiveResize"
  2989. , maskIframesOnResize: "maskContents"
  2990. // STATE MANAGEMENT
  2991. , useStateCookie: "stateManagement.enabled"
  2992. , "cookie.autoLoad": "stateManagement.autoLoad"
  2993. , "cookie.autoSave": "stateManagement.autoSave"
  2994. , "cookie.keys": "stateManagement.stateKeys"
  2995. , "cookie.name": "stateManagement.cookie.name"
  2996. , "cookie.domain": "stateManagement.cookie.domain"
  2997. , "cookie.path": "stateManagement.cookie.path"
  2998. , "cookie.expires": "stateManagement.cookie.expires"
  2999. , "cookie.secure": "stateManagement.cookie.secure"
  3000. // OLD Language options
  3001. , noRoomToOpenTip: "tips.noRoomToOpen"
  3002. , togglerTip_open: "tips.Close" // open = Close
  3003. , togglerTip_closed: "tips.Open" // closed = Open
  3004. , resizerTip: "tips.Resize"
  3005. , sliderTip: "tips.Slide"
  3006. }
  3007. /**
  3008. * @param {Object} opts
  3009. */
  3010. , renameOptions: function (opts) {
  3011. var map = $.layout.backwardCompatibility.map
  3012. , oldData, newData, value
  3013. ;
  3014. for (var itemPath in map) {
  3015. oldData = getBranch( itemPath );
  3016. value = oldData.branch[ oldData.key ];
  3017. if (value !== undefined) {
  3018. newData = getBranch( map[itemPath], true );
  3019. newData.branch[ newData.key ] = value;
  3020. delete oldData.branch[ oldData.key ];
  3021. }
  3022. }
  3023. /**
  3024. * @param {string} path
  3025. * @param {boolean=} [create=false] Create path if does not exist
  3026. */
  3027. function getBranch (path, create) {
  3028. var a = path.split(".") // split keys into array
  3029. , c = a.length - 1
  3030. , D = { branch: opts, key: a[c] } // init branch at top & set key (last item)
  3031. , i = 0, k, undef;
  3032. for (; i<c; i++) { // skip the last key (data)
  3033. k = a[i];
  3034. if (D.branch[ k ] == undefined) { // child-key does not exist
  3035. if (create) {
  3036. D.branch = D.branch[ k ] = {}; // create child-branch
  3037. }
  3038. else // can't go any farther
  3039. D.branch = {}; // branch is undefined
  3040. }
  3041. else
  3042. D.branch = D.branch[ k ]; // get child-branch
  3043. }
  3044. return D;
  3045. };
  3046. }
  3047. /**
  3048. * @param {Object} opts
  3049. */
  3050. , renameAllOptions: function (opts) {
  3051. var ren = $.layout.backwardCompatibility.renameOptions;
  3052. // rename root (layout) options
  3053. ren( opts );
  3054. // rename 'defaults' to 'panes'
  3055. if (opts.defaults) {
  3056. if (typeof opts.panes !== "object")
  3057. opts.panes = {};
  3058. $.extend(true, opts.panes, opts.defaults);
  3059. delete opts.defaults;
  3060. }
  3061. // rename options in the the options.panes key
  3062. if (opts.panes) ren( opts.panes );
  3063. // rename options inside *each pane key*, eg: options.west
  3064. $.each($.layout.config.allPanes, function (i, pane) {
  3065. if (opts[pane]) ren( opts[pane] );
  3066. });
  3067. return opts;
  3068. }
  3069. };
  3070. /* ============================================================
  3071. * BEGIN WIDGET: $( selector ).layout( {options} );
  3072. * ============================================================
  3073. */
  3074. $.fn.layout = function (opts) {
  3075. var
  3076. // local aliases to global data
  3077. browser = $.layout.browser
  3078. , _c = $.layout.config
  3079. // local aliases to utlity methods
  3080. , cssW = $.layout.cssWidth
  3081. , cssH = $.layout.cssHeight
  3082. , elDims = $.layout.getElementDimensions
  3083. , styles = $.layout.getElementStyles
  3084. , evtObj = $.layout.getEventObject
  3085. , evtPane = $.layout.parsePaneName
  3086. /**
  3087. * options - populated by initOptions()
  3088. */
  3089. , options = $.extend(true, {}, $.layout.defaults)
  3090. , effects = options.effects = $.extend(true, {}, $.layout.effects)
  3091. /**
  3092. * layout-state object
  3093. */
  3094. , state = {
  3095. // generate unique ID to use for event.namespace so can unbind only events added by 'this layout'
  3096. id: "layout"+ $.now() // code uses alias: sID
  3097. , initialized: false
  3098. , paneResizing: false
  3099. , panesSliding: {}
  3100. , container: { // list all keys referenced in code to avoid compiler error msgs
  3101. innerWidth: 0
  3102. , innerHeight: 0
  3103. , outerWidth: 0
  3104. , outerHeight: 0
  3105. , layoutWidth: 0
  3106. , layoutHeight: 0
  3107. }
  3108. , north: { childIdx: 0 }
  3109. , south: { childIdx: 0 }
  3110. , east: { childIdx: 0 }
  3111. , west: { childIdx: 0 }
  3112. , center: { childIdx: 0 }
  3113. }
  3114. /**
  3115. * parent/child-layout pointers
  3116. */
  3117. //, hasParentLayout = false - exists ONLY inside Instance so can be set externally
  3118. , children = {
  3119. north: null
  3120. , south: null
  3121. , east: null
  3122. , west: null
  3123. , center: null
  3124. }
  3125. /*
  3126. * ###########################
  3127. * INTERNAL HELPER FUNCTIONS
  3128. * ###########################
  3129. */
  3130. /**
  3131. * Manages all internal timers
  3132. */
  3133. , timer = {
  3134. data: {}
  3135. , set: function (s, fn, ms) { timer.clear(s); timer.data[s] = setTimeout(fn, ms); }
  3136. , clear: function (s) { var t=timer.data; if (t[s]) {clearTimeout(t[s]); delete t[s];} }
  3137. }
  3138. /**
  3139. * Alert or console.log a message - IF option is enabled.
  3140. *
  3141. * @param {(string|!Object)} msg Message (or debug-data) to display
  3142. * @param {boolean=} [popup=false] True by default, means 'alert', false means use console.log
  3143. * @param {boolean=} [debug=false] True means is a widget debugging message
  3144. */
  3145. , _log = function (msg, popup, debug) {
  3146. var o = options;
  3147. if ((o.showErrorMessages && !debug) || (debug && o.showDebugMessages))
  3148. $.layout.msg( o.name +' / '+ msg, (popup !== false) );
  3149. return false;
  3150. }
  3151. /**
  3152. * Executes a Callback function after a trigger event, like resize, open or close
  3153. *
  3154. * @param {string} evtName Name of the layout callback, eg "onresize_start"
  3155. * @param {(string|boolean)=} [pane=""] This is passed only so we can pass the 'pane object' to the callback
  3156. * @param {(string|boolean)=} [skipBoundEvents=false] True = do not run events bound to the elements - only the callbacks set in options
  3157. */
  3158. , _runCallbacks = function (evtName, pane, skipBoundEvents) {
  3159. var hasPane = pane && isStr(pane)
  3160. , s = hasPane ? state[pane] : state
  3161. , o = hasPane ? options[pane] : options
  3162. , lName = options.name
  3163. // names like onopen and onopen_end separate are interchangeable in options...
  3164. , lng = evtName + (evtName.match(/_/) ? "" : "_end")
  3165. , shrt = lng.match(/_end$/) ? lng.substr(0, lng.length - 4) : ""
  3166. , fn = o[lng] || o[shrt]
  3167. , retVal = "NC" // NC = No Callback
  3168. , args = []
  3169. , $P
  3170. ;
  3171. if ( !hasPane && $.type(pane) === 'boolean' ) {
  3172. skipBoundEvents = pane; // allow pane param to be skipped for Layout callback
  3173. pane = "";
  3174. }
  3175. // first trigger the callback set in the options
  3176. if (fn) {
  3177. // convert function name (string) to function object
  3178. if (isStr( fn )) {
  3179. if (fn.match(/,/)) {
  3180. // function name cannot contain a comma,
  3181. // so must be a function name AND a parameter to pass
  3182. args = fn.split(",")
  3183. , fn = eval(args[0]);
  3184. }
  3185. else // just the name of an external function?
  3186. fn = eval(fn);
  3187. }
  3188. // execute the callback, if exists
  3189. if ($.isFunction( fn )) {
  3190. if (args.length)
  3191. retVal = g(fn)(args[1]); // pass the argument parsed from 'list'
  3192. else if ( hasPane )
  3193. // pass data: pane-name, pane-element, pane-state, pane-options, and layout-name
  3194. retVal = g(fn)( pane, $Ps[pane], s, o, lName );
  3195. else // must be a layout/container callback - pass suitable info
  3196. retVal = g(fn)( Instance, s, o, lName );
  3197. }
  3198. // _log( options.errors.callbackError.replace(/EVENT/, $.trim((pane || "") +" "+ lng)), false );
  3199. // if ($.type(ex) === 'string' && string.length)
  3200. // _log('Exception: '+ ex, false );
  3201. }
  3202. // trigger additional events bound directly to the pane
  3203. if (!skipBoundEvents && retVal !== false) {
  3204. if ( hasPane ) { // PANE events can be bound to each pane-elements
  3205. $P = $Ps[pane];
  3206. o = options[pane];
  3207. s = state[pane];
  3208. $P.triggerHandler('layoutpane'+ lng, [ pane, $P, s, o, lName ]);
  3209. if (shrt)
  3210. $P.triggerHandler('layoutpane'+ shrt, [ pane, $P, s, o, lName ]);
  3211. }
  3212. else { // LAYOUT events can be bound to the container-element
  3213. $N.triggerHandler('layout'+ lng, [ Instance, s, o, lName ]);
  3214. if (shrt)
  3215. $N.triggerHandler('layout'+ shrt, [ Instance, s, o, lName ]);
  3216. }
  3217. }
  3218. // ALWAYS resizeChildren after an onresize_end event - even during initialization
  3219. // IGNORE onsizecontent_end event because causes child-layouts to resize TWICE
  3220. if (hasPane && evtName === "onresize_end") // BAD: || evtName === "onsizecontent_end"
  3221. resizeChildren(pane+"", true); // compiler hack -force string
  3222. return retVal;
  3223. function g (f) { return f; }; // compiler hack
  3224. }
  3225. /**
  3226. * cure iframe display issues in IE & other browsers
  3227. */
  3228. , _fixIframe = function (pane) {
  3229. if (browser.mozilla) return; // skip FireFox - it auto-refreshes iframes onShow
  3230. var $P = $Ps[pane];
  3231. // if the 'pane' is an iframe, do it
  3232. if (state[pane].tagName === "IFRAME")
  3233. $P.css(_c.hidden).css(_c.visible);
  3234. else // ditto for any iframes INSIDE the pane
  3235. $P.find('IFRAME').css(_c.hidden).css(_c.visible);
  3236. }
  3237. /**
  3238. * @param {string} pane Can accept ONLY a 'pane' (east, west, etc)
  3239. * @param {number=} outerSize (optional) Can pass a width, allowing calculations BEFORE element is resized
  3240. * @return {number} Returns the innerHeight/Width of el by subtracting padding and borders
  3241. */
  3242. , cssSize = function (pane, outerSize) {
  3243. var fn = _c[pane].dir=="horz" ? cssH : cssW;
  3244. return fn($Ps[pane], outerSize);
  3245. }
  3246. /**
  3247. * @param {string} pane Can accept ONLY a 'pane' (east, west, etc)
  3248. * @return {Object} Returns hash of minWidth & minHeight
  3249. */
  3250. , cssMinDims = function (pane) {
  3251. // minWidth/Height means CSS width/height = 1px
  3252. var $P = $Ps[pane]
  3253. , dir = _c[pane].dir
  3254. , d = {
  3255. minWidth: 1001 - cssW($P, 1000)
  3256. , minHeight: 1001 - cssH($P, 1000)
  3257. }
  3258. ;
  3259. if (dir === "horz") d.minSize = d.minHeight;
  3260. if (dir === "vert") d.minSize = d.minWidth;
  3261. return d;
  3262. }
  3263. // TODO: see if these methods can be made more useful...
  3264. // TODO: *maybe* return cssW/H from these so caller can use this info
  3265. /**
  3266. * @param {(string|!Object)} el
  3267. * @param {number=} outerWidth
  3268. * @param {boolean=} [autoHide=false]
  3269. */
  3270. , setOuterWidth = function (el, outerWidth, autoHide) {
  3271. var $E = el, w;
  3272. if (isStr(el)) $E = $Ps[el]; // west
  3273. else if (!el.jquery) $E = $(el);
  3274. w = cssW($E, outerWidth);
  3275. $E.css({ width: w });
  3276. if (w > 0) {
  3277. if (autoHide && $E.data('autoHidden') && $E.innerHeight() > 0) {
  3278. $E.show().data('autoHidden', false);
  3279. if (!browser.mozilla) // FireFox refreshes iframes - IE does not
  3280. // make hidden, then visible to 'refresh' display after animation
  3281. $E.css(_c.hidden).css(_c.visible);
  3282. }
  3283. }
  3284. else if (autoHide && !$E.data('autoHidden'))
  3285. $E.hide().data('autoHidden', true);
  3286. }
  3287. /**
  3288. * @param {(string|!Object)} el
  3289. * @param {number=} outerHeight
  3290. * @param {boolean=} [autoHide=false]
  3291. */
  3292. , setOuterHeight = function (el, outerHeight, autoHide) {
  3293. var $E = el, h;
  3294. if (isStr(el)) $E = $Ps[el]; // west
  3295. else if (!el.jquery) $E = $(el);
  3296. h = cssH($E, outerHeight);
  3297. $E.css({ height: h, visibility: "visible" }); // may have been 'hidden' by sizeContent
  3298. if (h > 0 && $E.innerWidth() > 0) {
  3299. if (autoHide && $E.data('autoHidden')) {
  3300. $E.show().data('autoHidden', false);
  3301. if (!browser.mozilla) // FireFox refreshes iframes - IE does not
  3302. $E.css(_c.hidden).css(_c.visible);
  3303. }
  3304. }
  3305. else if (autoHide && !$E.data('autoHidden'))
  3306. $E.hide().data('autoHidden', true);
  3307. }
  3308. /**
  3309. * Converts any 'size' params to a pixel/integer size, if not already
  3310. * If 'auto' or a decimal/percentage is passed as 'size', a pixel-size is calculated
  3311. *
  3312. /**
  3313. * @param {string} pane
  3314. * @param {(string|number)=} size
  3315. * @param {string=} [dir]
  3316. * @return {number}
  3317. */
  3318. , _parseSize = function (pane, size, dir) {
  3319. if (!dir) dir = _c[pane].dir;
  3320. if (isStr(size) && size.match(/%/))
  3321. size = (size === '100%') ? -1 : parseInt(size, 10) / 100; // convert % to decimal
  3322. if (size === 0)
  3323. return 0;
  3324. else if (size >= 1)
  3325. return parseInt(size, 10);
  3326. var o = options, avail = 0;
  3327. if (dir=="horz") // north or south or center.minHeight
  3328. avail = sC.innerHeight - ($Ps.north ? o.north.spacing_open : 0) - ($Ps.south ? o.south.spacing_open : 0);
  3329. else if (dir=="vert") // east or west or center.minWidth
  3330. avail = sC.innerWidth - ($Ps.west ? o.west.spacing_open : 0) - ($Ps.east ? o.east.spacing_open : 0);
  3331. if (size === -1) // -1 == 100%
  3332. return avail;
  3333. else if (size > 0) // percentage, eg: .25
  3334. return round(avail * size);
  3335. else if (pane=="center")
  3336. return 0;
  3337. else { // size < 0 || size=='auto' || size==Missing || size==Invalid
  3338. // auto-size the pane
  3339. var dim = (dir === "horz" ? "height" : "width")
  3340. , $P = $Ps[pane]
  3341. , $C = dim === 'height' ? $Cs[pane] : false
  3342. , vis = $.layout.showInvisibly($P) // show pane invisibly if hidden
  3343. , szP = $P.css(dim) // SAVE current pane size
  3344. , szC = $C ? $C.css(dim) : 0 // SAVE current content size
  3345. ;
  3346. $P.css(dim, "auto");
  3347. if ($C) $C.css(dim, "auto");
  3348. size = (dim === "height") ? $P.outerHeight() : $P.outerWidth(); // MEASURE
  3349. $P.css(dim, szP).css(vis); // RESET size & visibility
  3350. if ($C) $C.css(dim, szC);
  3351. return size;
  3352. }
  3353. }
  3354. /**
  3355. * Calculates current 'size' (outer-width or outer-height) of a border-pane - optionally with 'pane-spacing' added
  3356. *
  3357. * @param {(string|!Object)} pane
  3358. * @param {boolean=} [inclSpace=false]
  3359. * @return {number} Returns EITHER Width for east/west panes OR Height for north/south panes
  3360. */
  3361. , getPaneSize = function (pane, inclSpace) {
  3362. var
  3363. $P = $Ps[pane]
  3364. , o = options[pane]
  3365. , s = state[pane]
  3366. , oSp = (inclSpace ? o.spacing_open : 0)
  3367. , cSp = (inclSpace ? o.spacing_closed : 0)
  3368. ;
  3369. if (!$P || s.isHidden)
  3370. return 0;
  3371. else if (s.isClosed || (s.isSliding && inclSpace))
  3372. return cSp;
  3373. else if (_c[pane].dir === "horz")
  3374. return $P.outerHeight() + oSp;
  3375. else // dir === "vert"
  3376. return $P.outerWidth() + oSp;
  3377. }
  3378. /**
  3379. * Calculate min/max pane dimensions and limits for resizing
  3380. *
  3381. * @param {string} pane
  3382. * @param {boolean=} [slide=false]
  3383. */
  3384. , setSizeLimits = function (pane, slide) {
  3385. if (!isInitialized()) return;
  3386. var
  3387. o = options[pane]
  3388. , s = state[pane]
  3389. , c = _c[pane]
  3390. , dir = c.dir
  3391. , type = c.sizeType.toLowerCase()
  3392. , isSliding = (slide != undefined ? slide : s.isSliding) // only open() passes 'slide' param
  3393. , $P = $Ps[pane]
  3394. , paneSpacing = o.spacing_open
  3395. // measure the pane on the *opposite side* from this pane
  3396. , altPane = _c.oppositeEdge[pane]
  3397. , altS = state[altPane]
  3398. , $altP = $Ps[altPane]
  3399. , altPaneSize = (!$altP || altS.isVisible===false || altS.isSliding ? 0 : (dir=="horz" ? $altP.outerHeight() : $altP.outerWidth()))
  3400. , altPaneSpacing = ((!$altP || altS.isHidden ? 0 : options[altPane][ altS.isClosed !== false ? "spacing_closed" : "spacing_open" ]) || 0)
  3401. // limitSize prevents this pane from 'overlapping' opposite pane
  3402. , containerSize = (dir=="horz" ? sC.innerHeight : sC.innerWidth)
  3403. , minCenterDims = cssMinDims("center")
  3404. , minCenterSize = dir=="horz" ? max(options.center.minHeight, minCenterDims.minHeight) : max(options.center.minWidth, minCenterDims.minWidth)
  3405. // if pane is 'sliding', then ignore center and alt-pane sizes - because 'overlays' them
  3406. , limitSize = (containerSize - paneSpacing - (isSliding ? 0 : (_parseSize("center", minCenterSize, dir) + altPaneSize + altPaneSpacing)))
  3407. , minSize = s.minSize = max( _parseSize(pane, o.minSize), cssMinDims(pane).minSize )
  3408. , maxSize = s.maxSize = min( (o.maxSize ? _parseSize(pane, o.maxSize) : 100000), limitSize )
  3409. , r = s.resizerPosition = {} // used to set resizing limits
  3410. , top = sC.inset.top
  3411. , left = sC.inset.left
  3412. , W = sC.innerWidth
  3413. , H = sC.innerHeight
  3414. , rW = o.spacing_open // subtract resizer-width to get top/left position for south/east
  3415. ;
  3416. switch (pane) {
  3417. case "north": r.min = top + minSize;
  3418. r.max = top + maxSize;
  3419. break;
  3420. case "west": r.min = left + minSize;
  3421. r.max = left + maxSize;
  3422. break;
  3423. case "south": r.min = top + H - maxSize - rW;
  3424. r.max = top + H - minSize - rW;
  3425. break;
  3426. case "east": r.min = left + W - maxSize - rW;
  3427. r.max = left + W - minSize - rW;
  3428. break;
  3429. };
  3430. }
  3431. /**
  3432. * Returns data for setting the size/position of center pane. Also used to set Height for east/west panes
  3433. *
  3434. * @return JSON Returns a hash of all dimensions: top, bottom, left, right, (outer) width and (outer) height
  3435. */
  3436. , calcNewCenterPaneDims = function () {
  3437. var d = {
  3438. top: getPaneSize("north", true) // true = include 'spacing' value for pane
  3439. , bottom: getPaneSize("south", true)
  3440. , left: getPaneSize("west", true)
  3441. , right: getPaneSize("east", true)
  3442. , width: 0
  3443. , height: 0
  3444. };
  3445. // NOTE: sC = state.container
  3446. // calc center-pane outer dimensions
  3447. d.width = sC.innerWidth - d.left - d.right; // outerWidth
  3448. d.height = sC.innerHeight - d.bottom - d.top; // outerHeight
  3449. // add the 'container border/padding' to get final positions relative to the container
  3450. d.top += sC.inset.top;
  3451. d.bottom += sC.inset.bottom;
  3452. d.left += sC.inset.left;
  3453. d.right += sC.inset.right;
  3454. return d;
  3455. }
  3456. /**
  3457. * @param {!Object} el
  3458. * @param {boolean=} [allStates=false]
  3459. */
  3460. , getHoverClasses = function (el, allStates) {
  3461. var
  3462. $El = $(el)
  3463. , type = $El.data("layoutRole")
  3464. , pane = $El.data("layoutEdge")
  3465. , o = options[pane]
  3466. , root = o[type +"Class"]
  3467. , _pane = "-"+ pane // eg: "-west"
  3468. , _open = "-open"
  3469. , _closed = "-closed"
  3470. , _slide = "-sliding"
  3471. , _hover = "-hover " // NOTE the trailing space
  3472. , _state = $El.hasClass(root+_closed) ? _closed : _open
  3473. , _alt = _state === _closed ? _open : _closed
  3474. , classes = (root+_hover) + (root+_pane+_hover) + (root+_state+_hover) + (root+_pane+_state+_hover)
  3475. ;
  3476. if (allStates) // when 'removing' classes, also remove alternate-state classes
  3477. classes += (root+_alt+_hover) + (root+_pane+_alt+_hover);
  3478. if (type=="resizer" && $El.hasClass(root+_slide))
  3479. classes += (root+_slide+_hover) + (root+_pane+_slide+_hover);
  3480. return $.trim(classes);
  3481. }
  3482. , addHover = function (evt, el) {
  3483. var $E = $(el || this);
  3484. if (evt && $E.data("layoutRole") === "toggler")
  3485. evt.stopPropagation(); // prevent triggering 'slide' on Resizer-bar
  3486. $E.addClass( getHoverClasses($E) );
  3487. }
  3488. , removeHover = function (evt, el) {
  3489. var $E = $(el || this);
  3490. $E.removeClass( getHoverClasses($E, true) );
  3491. }
  3492. , onResizerEnter = function (evt) { // ALSO called by toggler.mouseenter
  3493. var pane = $(this).data("layoutEdge")
  3494. , s = state[pane]
  3495. ;
  3496. // ignore closed-panes and mouse moving back & forth over resizer!
  3497. // also ignore if ANY pane is currently resizing
  3498. if ( s.isClosed || s.isResizing || state.paneResizing ) return;
  3499. if ($.fn.disableSelection)
  3500. $("body").disableSelection();
  3501. if (options.maskPanesEarly)
  3502. showMasks( pane, { resizing: true });
  3503. }
  3504. , onResizerLeave = function (evt, el) {
  3505. var e = el || this // el is only passed when called by the timer
  3506. , pane = $(e).data("layoutEdge")
  3507. , name = pane +"ResizerLeave"
  3508. ;
  3509. timer.clear(pane+"_openSlider"); // cancel slideOpen timer, if set
  3510. timer.clear(name); // cancel enableSelection timer - may re/set below
  3511. // this method calls itself on a timer because it needs to allow
  3512. // enough time for dragging to kick-in and set the isResizing flag
  3513. // dragging has a 100ms delay set, so this delay must be >100
  3514. if (!el) // 1st call - mouseleave event
  3515. timer.set(name, function(){ onResizerLeave(evt, e); }, 200);
  3516. // if user is resizing, then dragStop will enableSelection(), so can skip it here
  3517. else if ( !state.paneResizing ) { // 2nd call - by timer
  3518. if ($.fn.enableSelection)
  3519. $("body").enableSelection();
  3520. if (options.maskPanesEarly)
  3521. hideMasks();
  3522. }
  3523. }
  3524. /*
  3525. * ###########################
  3526. * INITIALIZATION METHODS
  3527. * ###########################
  3528. */
  3529. /**
  3530. * Initialize the layout - called automatically whenever an instance of layout is created
  3531. *
  3532. * @see none - triggered onInit
  3533. * @return mixed true = fully initialized | false = panes not initialized (yet) | 'cancel' = abort
  3534. */
  3535. , _create = function () {
  3536. // initialize config/options
  3537. initOptions();
  3538. var o = options
  3539. , s = state;
  3540. // TEMP state so isInitialized returns true during init process
  3541. s.creatingLayout = true;
  3542. // init plugins for this layout, if there are any (eg: stateManagement)
  3543. runPluginCallbacks( Instance, $.layout.onCreate );
  3544. // options & state have been initialized, so now run beforeLoad callback
  3545. // onload will CANCEL layout creation if it returns false
  3546. if (false === _runCallbacks("onload_start"))
  3547. return 'cancel';
  3548. // initialize the container element
  3549. _initContainer();
  3550. // bind hotkey function - keyDown - if required
  3551. initHotkeys();
  3552. // bind window.onunload
  3553. $(window).bind("unload."+ sID, unload);
  3554. // init plugins for this layout, if there are any (eg: customButtons)
  3555. runPluginCallbacks( Instance, $.layout.onLoad );
  3556. // if layout elements are hidden, then layout WILL NOT complete initialization!
  3557. // initLayoutElements will set initialized=true and run the onload callback IF successful
  3558. if (o.initPanes) _initLayoutElements();
  3559. delete s.creatingLayout;
  3560. return state.initialized;
  3561. }
  3562. /**
  3563. * Initialize the layout IF not already
  3564. *
  3565. * @see All methods in Instance run this test
  3566. * @return boolean true = layoutElements have been initialized | false = panes are not initialized (yet)
  3567. */
  3568. , isInitialized = function () {
  3569. if (state.initialized || state.creatingLayout) return true; // already initialized
  3570. else return _initLayoutElements(); // try to init panes NOW
  3571. }
  3572. /**
  3573. * Initialize the layout - called automatically whenever an instance of layout is created
  3574. *
  3575. * @see _create() & isInitialized
  3576. * @param {boolean=} [retry=false] // indicates this is a 2nd try
  3577. * @return An object pointer to the instance created
  3578. */
  3579. , _initLayoutElements = function (retry) {
  3580. // initialize config/options
  3581. var o = options;
  3582. // CANNOT init panes inside a hidden container!
  3583. if (!$N.is(":visible")) {
  3584. // handle Chrome bug where popup window 'has no height'
  3585. // if layout is BODY element, try again in 50ms
  3586. // SEE: http://layout.jquery-dev.net/samples/test_popup_window.html
  3587. if ( !retry && browser.webkit && $N[0].tagName === "BODY" )
  3588. setTimeout(function(){ _initLayoutElements(true); }, 50);
  3589. return false;
  3590. }
  3591. // a center pane is required, so make sure it exists
  3592. if (!getPane("center").length) {
  3593. return _log( o.errors.centerPaneMissing );
  3594. }
  3595. // TEMP state so isInitialized returns true during init process
  3596. state.creatingLayout = true;
  3597. // update Container dims
  3598. $.extend(sC, elDims( $N, o.inset )); // passing inset means DO NOT include insetX values
  3599. // initialize all layout elements
  3600. initPanes(); // size & position panes - calls initHandles() - which calls initResizable()
  3601. if (o.scrollToBookmarkOnLoad) {
  3602. var l = self.location;
  3603. if (l.hash) l.replace( l.hash ); // scrollTo Bookmark
  3604. }
  3605. // check to see if this layout 'nested' inside a pane
  3606. if (Instance.hasParentLayout)
  3607. o.resizeWithWindow = false;
  3608. // bind resizeAll() for 'this layout instance' to window.resize event
  3609. else if (o.resizeWithWindow)
  3610. $(window).bind("resize."+ sID, windowResize);
  3611. delete state.creatingLayout;
  3612. state.initialized = true;
  3613. // init plugins for this layout, if there are any
  3614. runPluginCallbacks( Instance, $.layout.onReady );
  3615. // now run the onload callback, if exists
  3616. _runCallbacks("onload_end");
  3617. return true; // elements initialized successfully
  3618. }
  3619. /**
  3620. * Initialize nested layouts for a specific pane - can optionally pass layout-options
  3621. *
  3622. * @param {(string|Object)} evt_or_pane The pane being opened, ie: north, south, east, or west
  3623. * @param {Object=} [opts] Layout-options - if passed, will OVERRRIDE options[pane].children
  3624. * @return An object pointer to the layout instance created - or null
  3625. */
  3626. , createChildren = function (evt_or_pane, opts) {
  3627. var pane = evtPane.call(this, evt_or_pane)
  3628. , $P = $Ps[pane]
  3629. ;
  3630. if (!$P) return;
  3631. var $C = $Cs[pane]
  3632. , s = state[pane]
  3633. , o = options[pane]
  3634. , sm = options.stateManagement || {}
  3635. , cos = opts ? (o.children = opts) : o.children
  3636. ;
  3637. if ( $.isPlainObject( cos ) )
  3638. cos = [ cos ]; // convert a hash to a 1-elem array
  3639. else if (!cos || !$.isArray( cos ))
  3640. return;
  3641. $.each( cos, function (idx, co) {
  3642. if ( !$.isPlainObject( co ) ) return;
  3643. // determine which element is supposed to be the 'child container'
  3644. // if pane has a 'containerSelector' OR a 'content-div', use those instead of the pane
  3645. var $containers = co.containerSelector ? $P.find( co.containerSelector ) : ($C || $P);
  3646. $containers.each(function(){
  3647. var $cont = $(this)
  3648. , child = $cont.data("layout") // see if a child-layout ALREADY exists on this element
  3649. ;
  3650. // if no layout exists, but children are set, try to create the layout now
  3651. if (!child) {
  3652. // TODO: see about moving this to the stateManagement plugin, as a method
  3653. // set a unique child-instance key for this layout, if not already set
  3654. setInstanceKey({ container: $cont, options: co }, s );
  3655. // If THIS layout has a hash in stateManagement.autoLoad,
  3656. // then see if it also contains state-data for this child-layout
  3657. // If so, copy the stateData to child.options.stateManagement.autoLoad
  3658. if ( sm.includeChildren && state.stateData[pane] ) {
  3659. // THIS layout's state was cached when its state was loaded
  3660. var paneChildren = state.stateData[pane].children || {}
  3661. , childState = paneChildren[ co.instanceKey ]
  3662. , co_sm = co.stateManagement || (co.stateManagement = { autoLoad: true })
  3663. ;
  3664. // COPY the stateData into the autoLoad key
  3665. if ( co_sm.autoLoad === true && childState ) {
  3666. co_sm.autoSave = false; // disable autoSave because saving handled by parent-layout
  3667. co_sm.includeChildren = true; // cascade option - FOR NOW
  3668. co_sm.autoLoad = $.extend(true, {}, childState); // COPY the state-hash
  3669. }
  3670. }
  3671. // create the layout
  3672. child = $cont.layout( co );
  3673. // if successful, update data
  3674. if (child) {
  3675. // add the child and update all layout-pointers
  3676. // MAY have already been done by child-layout calling parent.refreshChildren()
  3677. refreshChildren( pane, child );
  3678. }
  3679. }
  3680. });
  3681. });
  3682. }
  3683. , setInstanceKey = function (child, parentPaneState) {
  3684. // create a named key for use in state and instance branches
  3685. var $c = child.container
  3686. , o = child.options
  3687. , sm = o.stateManagement
  3688. , key = o.instanceKey || $c.data("layoutInstanceKey")
  3689. ;
  3690. if (!key) key = (sm && sm.cookie ? sm.cookie.name : '') || o.name; // look for a name/key
  3691. if (!key) key = "layout"+ (++parentPaneState.childIdx); // if no name/key found, generate one
  3692. else key = key.replace(/[^\w-]/gi, '_').replace(/_{2,}/g, '_'); // ensure is valid as a hash key
  3693. o.instanceKey = key;
  3694. $c.data("layoutInstanceKey", key); // useful if layout is destroyed and then recreated
  3695. return key;
  3696. }
  3697. /**
  3698. * @param {string} pane The pane being opened, ie: north, south, east, or west
  3699. * @param {Object=} newChild New child-layout Instance to add to this pane
  3700. */
  3701. , refreshChildren = function (pane, newChild) {
  3702. var $P = $Ps[pane]
  3703. , pC = children[pane]
  3704. , s = state[pane]
  3705. , o
  3706. ;
  3707. // check for destroy()ed layouts and update the child pointers & arrays
  3708. if ($.isPlainObject( pC )) {
  3709. $.each( pC, function (key, child) {
  3710. if (child.destroyed) delete pC[key]
  3711. });
  3712. // if no more children, remove the children hash
  3713. if ($.isEmptyObject( pC ))
  3714. pC = children[pane] = null; // clear children hash
  3715. }
  3716. // see if there is a directly-nested layout inside this pane
  3717. // if there is, then there can be only ONE child-layout, so check that...
  3718. if (!newChild && !pC) {
  3719. newChild = $P.data("layout");
  3720. }
  3721. // if a newChild instance was passed, add it to children[pane]
  3722. if (newChild) {
  3723. // update child.state
  3724. newChild.hasParentLayout = true; // set parent-flag in child
  3725. // instanceKey is a key-name used in both state and children
  3726. o = newChild.options;
  3727. // set a unique child-instance key for this layout, if not already set
  3728. setInstanceKey( newChild, s );
  3729. // add pointer to pane.children hash
  3730. if (!pC) pC = children[pane] = {}; // create an empty children hash
  3731. pC[ o.instanceKey ] = newChild.container.data("layout"); // add childLayout instance
  3732. }
  3733. // ALWAYS refresh the pane.children alias, even if null
  3734. Instance[pane].children = children[pane];
  3735. // if newChild was NOT passed - see if there is a child layout NOW
  3736. if (!newChild) {
  3737. createChildren(pane); // MAY create a child and re-call this method
  3738. }
  3739. }
  3740. , windowResize = function () {
  3741. var o = options
  3742. , delay = Number(o.resizeWithWindowDelay);
  3743. if (delay < 10) delay = 100; // MUST have a delay!
  3744. // resizing uses a delay-loop because the resize event fires repeatly - except in FF, but delay anyway
  3745. timer.clear("winResize"); // if already running
  3746. timer.set("winResize", function(){
  3747. timer.clear("winResize");
  3748. timer.clear("winResizeRepeater");
  3749. var dims = elDims( $N, o.inset );
  3750. // only trigger resizeAll() if container has changed size
  3751. if (dims.innerWidth !== sC.innerWidth || dims.innerHeight !== sC.innerHeight)
  3752. resizeAll();
  3753. }, delay);
  3754. // ALSO set fixed-delay timer, if not already running
  3755. if (!timer.data["winResizeRepeater"]) setWindowResizeRepeater();
  3756. }
  3757. , setWindowResizeRepeater = function () {
  3758. var delay = Number(options.resizeWithWindowMaxDelay);
  3759. if (delay > 0)
  3760. timer.set("winResizeRepeater", function(){ setWindowResizeRepeater(); resizeAll(); }, delay);
  3761. }
  3762. , unload = function () {
  3763. var o = options;
  3764. _runCallbacks("onunload_start");
  3765. // trigger plugin callabacks for this layout (eg: stateManagement)
  3766. runPluginCallbacks( Instance, $.layout.onUnload );
  3767. _runCallbacks("onunload_end");
  3768. }
  3769. /**
  3770. * Validate and initialize container CSS and events
  3771. *
  3772. * @see _create()
  3773. */
  3774. , _initContainer = function () {
  3775. var
  3776. N = $N[0]
  3777. , $H = $("html")
  3778. , tag = sC.tagName = N.tagName
  3779. , id = sC.id = N.id
  3780. , cls = sC.className = N.className
  3781. , o = options
  3782. , name = o.name
  3783. , props = "position,margin,padding,border"
  3784. , css = "layoutCSS"
  3785. , CSS = {}
  3786. , hid = "hidden" // used A LOT!
  3787. // see if this container is a 'pane' inside an outer-layout
  3788. , parent = $N.data("parentLayout") // parent-layout Instance
  3789. , pane = $N.data("layoutEdge") // pane-name in parent-layout
  3790. , isChild = parent && pane
  3791. , num = $.layout.cssNum
  3792. , $parent, n
  3793. ;
  3794. // sC = state.container
  3795. sC.selector = $N.selector.split(".slice")[0];
  3796. sC.ref = (o.name ? o.name +' layout / ' : '') + tag + (id ? "#"+id : cls ? '.['+cls+']' : ''); // used in messages
  3797. sC.isBody = (tag === "BODY");
  3798. // try to find a parent-layout
  3799. if (!isChild && !sC.isBody) {
  3800. $parent = $N.closest("."+ $.layout.defaults.panes.paneClass);
  3801. parent = $parent.data("parentLayout");
  3802. pane = $parent.data("layoutEdge");
  3803. isChild = parent && pane;
  3804. }
  3805. $N .data({
  3806. layout: Instance
  3807. , layoutContainer: sID // FLAG to indicate this is a layout-container - contains unique internal ID
  3808. })
  3809. .addClass(o.containerClass)
  3810. ;
  3811. var layoutMethods = {
  3812. destroy: ''
  3813. , initPanes: ''
  3814. , resizeAll: 'resizeAll'
  3815. , resize: 'resizeAll'
  3816. };
  3817. // loop hash and bind all methods - include layoutID namespacing
  3818. for (name in layoutMethods) {
  3819. $N.bind("layout"+ name.toLowerCase() +"."+ sID, Instance[ layoutMethods[name] || name ]);
  3820. }
  3821. // if this container is another layout's 'pane', then set child/parent pointers
  3822. if (isChild) {
  3823. // update parent flag
  3824. Instance.hasParentLayout = true;
  3825. // set pointers to THIS child-layout (Instance) in parent-layout
  3826. parent.refreshChildren( pane, Instance );
  3827. }
  3828. // SAVE original container CSS for use in destroy()
  3829. if (!$N.data(css)) {
  3830. // handle props like overflow different for BODY & HTML - has 'system default' values
  3831. if (sC.isBody) {
  3832. // SAVE <BODY> CSS
  3833. $N.data(css, $.extend( styles($N, props), {
  3834. height: $N.css("height")
  3835. , overflow: $N.css("overflow")
  3836. , overflowX: $N.css("overflowX")
  3837. , overflowY: $N.css("overflowY")
  3838. }));
  3839. // ALSO SAVE <HTML> CSS
  3840. $H.data(css, $.extend( styles($H, 'padding'), {
  3841. height: "auto" // FF would return a fixed px-size!
  3842. , overflow: $H.css("overflow")
  3843. , overflowX: $H.css("overflowX")
  3844. , overflowY: $H.css("overflowY")
  3845. }));
  3846. }
  3847. else // handle props normally for non-body elements
  3848. $N.data(css, styles($N, props+",top,bottom,left,right,width,height,overflow,overflowX,overflowY") );
  3849. }
  3850. try {
  3851. // common container CSS
  3852. CSS = {
  3853. overflow: hid
  3854. , overflowX: hid
  3855. , overflowY: hid
  3856. };
  3857. $N.css( CSS );
  3858. if (o.inset && !$.isPlainObject(o.inset)) {
  3859. // can specify a single number for equal outset all-around
  3860. n = parseInt(o.inset, 10) || 0
  3861. o.inset = {
  3862. top: n
  3863. , bottom: n
  3864. , left: n
  3865. , right: n
  3866. };
  3867. }
  3868. // format html & body if this is a full page layout
  3869. if (sC.isBody) {
  3870. // if HTML has padding, use this as an outer-spacing around BODY
  3871. if (!o.outset) {
  3872. // use padding from parent-elem (HTML) as outset
  3873. o.outset = {
  3874. top: num($H, "paddingTop")
  3875. , bottom: num($H, "paddingBottom")
  3876. , left: num($H, "paddingLeft")
  3877. , right: num($H, "paddingRight")
  3878. };
  3879. }
  3880. else if (!$.isPlainObject(o.outset)) {
  3881. // can specify a single number for equal outset all-around
  3882. n = parseInt(o.outset, 10) || 0
  3883. o.outset = {
  3884. top: n
  3885. , bottom: n
  3886. , left: n
  3887. , right: n
  3888. };
  3889. }
  3890. // HTML
  3891. $H.css( CSS ).css({
  3892. height: "100%"
  3893. , border: "none" // no border or padding allowed when using height = 100%
  3894. , padding: 0 // ditto
  3895. , margin: 0
  3896. });
  3897. // BODY
  3898. if (browser.isIE6) {
  3899. // IE6 CANNOT use the trick of setting absolute positioning on all 4 sides - must have 'height'
  3900. $N.css({
  3901. width: "100%"
  3902. , height: "100%"
  3903. , border: "none" // no border or padding allowed when using height = 100%
  3904. , padding: 0 // ditto
  3905. , margin: 0
  3906. , position: "relative"
  3907. });
  3908. // convert body padding to an inset option - the border cannot be measured in IE6!
  3909. if (!o.inset) o.inset = elDims( $N ).inset;
  3910. }
  3911. else { // use absolute positioning for BODY to allow borders & padding without overflow
  3912. $N.css({
  3913. width: "auto"
  3914. , height: "auto"
  3915. , margin: 0
  3916. , position: "absolute" // allows for border and padding on BODY
  3917. });
  3918. // apply edge-positioning created above
  3919. $N.css( o.outset );
  3920. }
  3921. // set current layout-container dimensions
  3922. $.extend(sC, elDims( $N, o.inset )); // passing inset means DO NOT include insetX values
  3923. }
  3924. else {
  3925. // container MUST have 'position'
  3926. var p = $N.css("position");
  3927. if (!p || !p.match(/(fixed|absolute|relative)/))
  3928. $N.css("position","relative");
  3929. // set current layout-container dimensions
  3930. if ( $N.is(":visible") ) {
  3931. $.extend(sC, elDims( $N, o.inset )); // passing inset means DO NOT change insetX (padding) values
  3932. if (sC.innerHeight < 1) // container has no 'height' - warn developer
  3933. _log( o.errors.noContainerHeight.replace(/CONTAINER/, sC.ref) );
  3934. }
  3935. }
  3936. // if container has min-width/height, then enable scrollbar(s)
  3937. if ( num($N, "minWidth") ) $N.parent().css("overflowX","auto");
  3938. if ( num($N, "minHeight") ) $N.parent().css("overflowY","auto");
  3939. } catch (ex) {}
  3940. }
  3941. /**
  3942. * Bind layout hotkeys - if options enabled
  3943. *
  3944. * @see _create() and addPane()
  3945. * @param {string=} [panes=""] The edge(s) to process
  3946. */
  3947. , initHotkeys = function (panes) {
  3948. panes = panes ? panes.split(",") : _c.borderPanes;
  3949. // bind keyDown to capture hotkeys, if option enabled for ANY pane
  3950. $.each(panes, function (i, pane) {
  3951. var o = options[pane];
  3952. if (o.enableCursorHotkey || o.customHotkey) {
  3953. $(document).bind("keydown."+ sID, keyDown); // only need to bind this ONCE
  3954. return false; // BREAK - binding was done
  3955. }
  3956. });
  3957. }
  3958. /**
  3959. * Build final OPTIONS data
  3960. *
  3961. * @see _create()
  3962. */
  3963. , initOptions = function () {
  3964. var data, d, pane, key, val, i, c, o;
  3965. // reprocess user's layout-options to have correct options sub-key structure
  3966. opts = $.layout.transformData( opts, true ); // panes = default subkey
  3967. // auto-rename old options for backward compatibility
  3968. opts = $.layout.backwardCompatibility.renameAllOptions( opts );
  3969. // if user-options has 'panes' key (pane-defaults), clean it...
  3970. if (!$.isEmptyObject(opts.panes)) {
  3971. // REMOVE any pane-defaults that MUST be set per-pane
  3972. data = $.layout.optionsMap.noDefault;
  3973. for (i=0, c=data.length; i<c; i++) {
  3974. key = data[i];
  3975. delete opts.panes[key]; // OK if does not exist
  3976. }
  3977. // REMOVE any layout-options specified under opts.panes
  3978. data = $.layout.optionsMap.layout;
  3979. for (i=0, c=data.length; i<c; i++) {
  3980. key = data[i];
  3981. delete opts.panes[key]; // OK if does not exist
  3982. }
  3983. }
  3984. // MOVE any NON-layout-options from opts-root to opts.panes
  3985. data = $.layout.optionsMap.layout;
  3986. var rootKeys = $.layout.config.optionRootKeys;
  3987. for (key in opts) {
  3988. val = opts[key];
  3989. if ($.inArray(key, rootKeys) < 0 && $.inArray(key, data) < 0) {
  3990. if (!opts.panes[key])
  3991. opts.panes[key] = $.isPlainObject(val) ? $.extend(true, {}, val) : val;
  3992. delete opts[key]
  3993. }
  3994. }
  3995. // START by updating ALL options from opts
  3996. $.extend(true, options, opts);
  3997. // CREATE final options (and config) for EACH pane
  3998. $.each(_c.allPanes, function (i, pane) {
  3999. // apply 'pane-defaults' to CONFIG.[PANE]
  4000. _c[pane] = $.extend(true, {}, _c.panes, _c[pane]);
  4001. d = options.panes;
  4002. o = options[pane];
  4003. // center-pane uses SOME keys in defaults.panes branch
  4004. if (pane === 'center') {
  4005. // ONLY copy keys from opts.panes listed in: $.layout.optionsMap.center
  4006. data = $.layout.optionsMap.center; // list of 'center-pane keys'
  4007. for (i=0, c=data.length; i<c; i++) { // loop the list...
  4008. key = data[i];
  4009. // only need to use pane-default if pane-specific value not set
  4010. if (!opts.center[key] && (opts.panes[key] || !o[key]))
  4011. o[key] = d[key]; // pane-default
  4012. }
  4013. }
  4014. else {
  4015. // border-panes use ALL keys in defaults.panes branch
  4016. o = options[pane] = $.extend(true, {}, d, o); // re-apply pane-specific opts AFTER pane-defaults
  4017. createFxOptions( pane );
  4018. // ensure all border-pane-specific base-classes exist
  4019. if (!o.resizerClass) o.resizerClass = "ui-layout-resizer";
  4020. if (!o.togglerClass) o.togglerClass = "ui-layout-toggler";
  4021. }
  4022. // ensure we have base pane-class (ALL panes)
  4023. if (!o.paneClass) o.paneClass = "ui-layout-pane";
  4024. });
  4025. // update options.zIndexes if a zIndex-option specified
  4026. var zo = opts.zIndex
  4027. , z = options.zIndexes;
  4028. if (zo > 0) {
  4029. z.pane_normal = zo;
  4030. z.content_mask = max(zo+1, z.content_mask); // MIN = +1
  4031. z.resizer_normal = max(zo+2, z.resizer_normal); // MIN = +2
  4032. }
  4033. // DELETE 'panes' key now that we are done - values were copied to EACH pane
  4034. delete options.panes;
  4035. function createFxOptions ( pane ) {
  4036. var o = options[pane]
  4037. , d = options.panes;
  4038. // ensure fxSettings key to avoid errors
  4039. if (!o.fxSettings) o.fxSettings = {};
  4040. if (!d.fxSettings) d.fxSettings = {};
  4041. $.each(["_open","_close","_size"], function (i,n) {
  4042. var
  4043. sName = "fxName"+ n
  4044. , sSpeed = "fxSpeed"+ n
  4045. , sSettings = "fxSettings"+ n
  4046. // recalculate fxName according to specificity rules
  4047. , fxName = o[sName] =
  4048. o[sName] // options.west.fxName_open
  4049. || d[sName] // options.panes.fxName_open
  4050. || o.fxName // options.west.fxName
  4051. || d.fxName // options.panes.fxName
  4052. || "none" // MEANS $.layout.defaults.panes.fxName == "" || false || null || 0
  4053. , fxExists = $.effects && ($.effects[fxName] || ($.effects.effect && $.effects.effect[fxName]))
  4054. ;
  4055. // validate fxName to ensure is valid effect - MUST have effect-config data in options.effects
  4056. if (fxName === "none" || !options.effects[fxName] || !fxExists)
  4057. fxName = o[sName] = "none"; // effect not loaded OR unrecognized fxName
  4058. // set vars for effects subkeys to simplify logic
  4059. var fx = options.effects[fxName] || {} // effects.slide
  4060. , fx_all = fx.all || null // effects.slide.all
  4061. , fx_pane = fx[pane] || null // effects.slide.west
  4062. ;
  4063. // create fxSpeed[_open|_close|_size]
  4064. o[sSpeed] =
  4065. o[sSpeed] // options.west.fxSpeed_open
  4066. || d[sSpeed] // options.west.fxSpeed_open
  4067. || o.fxSpeed // options.west.fxSpeed
  4068. || d.fxSpeed // options.panes.fxSpeed
  4069. || null // DEFAULT - let fxSetting.duration control speed
  4070. ;
  4071. // create fxSettings[_open|_close|_size]
  4072. o[sSettings] = $.extend(
  4073. true
  4074. , {}
  4075. , fx_all // effects.slide.all
  4076. , fx_pane // effects.slide.west
  4077. , d.fxSettings // options.panes.fxSettings
  4078. , o.fxSettings // options.west.fxSettings
  4079. , d[sSettings] // options.panes.fxSettings_open
  4080. , o[sSettings] // options.west.fxSettings_open
  4081. );
  4082. });
  4083. // DONE creating action-specific-settings for this pane,
  4084. // so DELETE generic options - are no longer meaningful
  4085. delete o.fxName;
  4086. delete o.fxSpeed;
  4087. delete o.fxSettings;
  4088. }
  4089. }
  4090. /**
  4091. * Initialize module objects, styling, size and position for all panes
  4092. *
  4093. * @see _initElements()
  4094. * @param {string} pane The pane to process
  4095. */
  4096. , getPane = function (pane) {
  4097. var sel = options[pane].paneSelector
  4098. if (sel.substr(0,1)==="#") // ID selector
  4099. // NOTE: elements selected 'by ID' DO NOT have to be 'children'
  4100. return $N.find(sel).eq(0);
  4101. else { // class or other selector
  4102. var $P = $N.children(sel).eq(0);
  4103. // look for the pane nested inside a 'form' element
  4104. return $P.length ? $P : $N.children("form:first").children(sel).eq(0);
  4105. }
  4106. }
  4107. /**
  4108. * @param {Object=} evt
  4109. */
  4110. , initPanes = function (evt) {
  4111. // stopPropagation if called by trigger("layoutinitpanes") - use evtPane utility
  4112. evtPane(evt);
  4113. // NOTE: do north & south FIRST so we can measure their height - do center LAST
  4114. $.each(_c.allPanes, function (idx, pane) {
  4115. addPane( pane, true );
  4116. });
  4117. // init the pane-handles NOW in case we have to hide or close the pane below
  4118. initHandles();
  4119. // now that all panes have been initialized and initially-sized,
  4120. // make sure there is really enough space available for each pane
  4121. $.each(_c.borderPanes, function (i, pane) {
  4122. if ($Ps[pane] && state[pane].isVisible) { // pane is OPEN
  4123. setSizeLimits(pane);
  4124. makePaneFit(pane); // pane may be Closed, Hidden or Resized by makePaneFit()
  4125. }
  4126. });
  4127. // size center-pane AGAIN in case we 'closed' a border-pane in loop above
  4128. sizeMidPanes("center");
  4129. // Chrome/Webkit sometimes fires callbacks BEFORE it completes resizing!
  4130. // Before RC30.3, there was a 10ms delay here, but that caused layout
  4131. // to load asynchrously, which is BAD, so try skipping delay for now
  4132. // process pane contents and callbacks, and init/resize child-layout if exists
  4133. $.each(_c.allPanes, function (idx, pane) {
  4134. afterInitPane(pane);
  4135. });
  4136. }
  4137. /**
  4138. * Add a pane to the layout - subroutine of initPanes()
  4139. *
  4140. * @see initPanes()
  4141. * @param {string} pane The pane to process
  4142. * @param {boolean=} [force=false] Size content after init
  4143. */
  4144. , addPane = function (pane, force) {
  4145. if (!force && !isInitialized()) return;
  4146. var
  4147. o = options[pane]
  4148. , s = state[pane]
  4149. , c = _c[pane]
  4150. , dir = c.dir
  4151. , fx = s.fx
  4152. , spacing = o.spacing_open || 0
  4153. , isCenter = (pane === "center")
  4154. , CSS = {}
  4155. , $P = $Ps[pane]
  4156. , size, minSize, maxSize, child
  4157. ;
  4158. // if pane-pointer already exists, remove the old one first
  4159. if ($P)
  4160. removePane( pane, false, true, false );
  4161. else
  4162. $Cs[pane] = false; // init
  4163. $P = $Ps[pane] = getPane(pane);
  4164. if (!$P.length) {
  4165. $Ps[pane] = false; // logic
  4166. return;
  4167. }
  4168. // SAVE original Pane CSS
  4169. if (!$P.data("layoutCSS")) {
  4170. var props = "position,top,left,bottom,right,width,height,overflow,zIndex,display,backgroundColor,padding,margin,border";
  4171. $P.data("layoutCSS", styles($P, props));
  4172. }
  4173. // create alias for pane data in Instance - initHandles will add more
  4174. Instance[pane] = {
  4175. name: pane
  4176. , pane: $Ps[pane]
  4177. , content: $Cs[pane]
  4178. , options: options[pane]
  4179. , state: state[pane]
  4180. , children: children[pane]
  4181. };
  4182. // add classes, attributes & events
  4183. $P .data({
  4184. parentLayout: Instance // pointer to Layout Instance
  4185. , layoutPane: Instance[pane] // NEW pointer to pane-alias-object
  4186. , layoutEdge: pane
  4187. , layoutRole: "pane"
  4188. })
  4189. .css(c.cssReq).css("zIndex", options.zIndexes.pane_normal)
  4190. .css(o.applyDemoStyles ? c.cssDemo : {}) // demo styles
  4191. .addClass( o.paneClass +" "+ o.paneClass+"-"+pane ) // default = "ui-layout-pane ui-layout-pane-west" - may be a dupe of 'paneSelector'
  4192. .bind("mouseenter."+ sID, addHover )
  4193. .bind("mouseleave."+ sID, removeHover )
  4194. ;
  4195. var paneMethods = {
  4196. hide: ''
  4197. , show: ''
  4198. , toggle: ''
  4199. , close: ''
  4200. , open: ''
  4201. , slideOpen: ''
  4202. , slideClose: ''
  4203. , slideToggle: ''
  4204. , size: 'sizePane'
  4205. , sizePane: 'sizePane'
  4206. , sizeContent: ''
  4207. , sizeHandles: ''
  4208. , enableClosable: ''
  4209. , disableClosable: ''
  4210. , enableSlideable: ''
  4211. , disableSlideable: ''
  4212. , enableResizable: ''
  4213. , disableResizable: ''
  4214. , swapPanes: 'swapPanes'
  4215. , swap: 'swapPanes'
  4216. , move: 'swapPanes'
  4217. , removePane: 'removePane'
  4218. , remove: 'removePane'
  4219. , createChildren: ''
  4220. , resizeChildren: ''
  4221. , resizeAll: 'resizeAll'
  4222. , resizeLayout: 'resizeAll'
  4223. }
  4224. , name;
  4225. // loop hash and bind all methods - include layoutID namespacing
  4226. for (name in paneMethods) {
  4227. $P.bind("layoutpane"+ name.toLowerCase() +"."+ sID, Instance[ paneMethods[name] || name ]);
  4228. }
  4229. // see if this pane has a 'scrolling-content element'
  4230. initContent(pane, false); // false = do NOT sizeContent() - called later
  4231. if (!isCenter) {
  4232. // call _parseSize AFTER applying pane classes & styles - but before making visible (if hidden)
  4233. // if o.size is auto or not valid, then MEASURE the pane and use that as its 'size'
  4234. size = s.size = _parseSize(pane, o.size);
  4235. minSize = _parseSize(pane,o.minSize) || 1;
  4236. maxSize = _parseSize(pane,o.maxSize) || 100000;
  4237. if (size > 0) size = max(min(size, maxSize), minSize);
  4238. s.autoResize = o.autoResize; // used with percentage sizes
  4239. // state for border-panes
  4240. s.isClosed = false; // true = pane is closed
  4241. s.isSliding = false; // true = pane is currently open by 'sliding' over adjacent panes
  4242. s.isResizing= false; // true = pane is in process of being resized
  4243. s.isHidden = false; // true = pane is hidden - no spacing, resizer or toggler is visible!
  4244. // array for 'pin buttons' whose classNames are auto-updated on pane-open/-close
  4245. if (!s.pins) s.pins = [];
  4246. }
  4247. // states common to ALL panes
  4248. s.tagName = $P[0].tagName;
  4249. s.edge = pane; // useful if pane is (or about to be) 'swapped' - easy find out where it is (or is going)
  4250. s.noRoom = false; // true = pane 'automatically' hidden due to insufficient room - will unhide automatically
  4251. s.isVisible = true; // false = pane is invisible - closed OR hidden - simplify logic
  4252. // init pane positioning
  4253. setPanePosition( pane );
  4254. // if pane is not visible,
  4255. if (dir === "horz") // north or south pane
  4256. CSS.height = cssH($P, size);
  4257. else if (dir === "vert") // east or west pane
  4258. CSS.width = cssW($P, size);
  4259. //else if (isCenter) {}
  4260. $P.css(CSS); // apply size -- top, bottom & height will be set by sizeMidPanes
  4261. if (dir != "horz") sizeMidPanes(pane, true); // true = skipCallback
  4262. // if manually adding a pane AFTER layout initialization, then...
  4263. if (state.initialized) {
  4264. initHandles( pane );
  4265. initHotkeys( pane );
  4266. }
  4267. // close or hide the pane if specified in settings
  4268. if (o.initClosed && o.closable && !o.initHidden)
  4269. close(pane, true, true); // true, true = force, noAnimation
  4270. else if (o.initHidden || o.initClosed)
  4271. hide(pane); // will be completely invisible - no resizer or spacing
  4272. else if (!s.noRoom)
  4273. // make the pane visible - in case was initially hidden
  4274. $P.css("display","block");
  4275. // ELSE setAsOpen() - called later by initHandles()
  4276. // RESET visibility now - pane will appear IF display:block
  4277. $P.css("visibility","visible");
  4278. // check option for auto-handling of pop-ups & drop-downs
  4279. if (o.showOverflowOnHover)
  4280. $P.hover( allowOverflow, resetOverflow );
  4281. // if manually adding a pane AFTER layout initialization, then...
  4282. if (state.initialized) {
  4283. afterInitPane( pane );
  4284. }
  4285. }
  4286. , afterInitPane = function (pane) {
  4287. var $P = $Ps[pane]
  4288. , s = state[pane]
  4289. , o = options[pane]
  4290. ;
  4291. if (!$P) return;
  4292. // see if there is a directly-nested layout inside this pane
  4293. if ($P.data("layout"))
  4294. refreshChildren( pane, $P.data("layout") );
  4295. // process pane contents and callbacks, and init/resize child-layout if exists
  4296. if (s.isVisible) { // pane is OPEN
  4297. if (state.initialized) // this pane was added AFTER layout was created
  4298. resizeAll(); // will also sizeContent
  4299. else
  4300. sizeContent(pane);
  4301. if (o.triggerEventsOnLoad)
  4302. _runCallbacks("onresize_end", pane);
  4303. else // automatic if onresize called, otherwise call it specifically
  4304. // resize child - IF inner-layout already exists (created before this layout)
  4305. resizeChildren(pane, true); // a previously existing childLayout
  4306. }
  4307. // init childLayouts - even if pane is not visible
  4308. if (o.initChildren && o.children)
  4309. createChildren(pane);
  4310. }
  4311. /**
  4312. * @param {string=} panes The pane(s) to process
  4313. */
  4314. , setPanePosition = function (panes) {
  4315. panes = panes ? panes.split(",") : _c.borderPanes;
  4316. // create toggler DIVs for each pane, and set object pointers for them, eg: $R.north = north toggler DIV
  4317. $.each(panes, function (i, pane) {
  4318. var $P = $Ps[pane]
  4319. , $R = $Rs[pane]
  4320. , o = options[pane]
  4321. , s = state[pane]
  4322. , side = _c[pane].side
  4323. , CSS = {}
  4324. ;
  4325. if (!$P) return; // pane does not exist - skip
  4326. // set css-position to account for container borders & padding
  4327. switch (pane) {
  4328. case "north": CSS.top = sC.inset.top;
  4329. CSS.left = sC.inset.left;
  4330. CSS.right = sC.inset.right;
  4331. break;
  4332. case "south": CSS.bottom = sC.inset.bottom;
  4333. CSS.left = sC.inset.left;
  4334. CSS.right = sC.inset.right;
  4335. break;
  4336. case "west": CSS.left = sC.inset.left; // top, bottom & height set by sizeMidPanes()
  4337. break;
  4338. case "east": CSS.right = sC.inset.right; // ditto
  4339. break;
  4340. case "center": // top, left, width & height set by sizeMidPanes()
  4341. }
  4342. // apply position
  4343. $P.css(CSS);
  4344. // update resizer position
  4345. if ($R && s.isClosed)
  4346. $R.css(side, sC.inset[side]);
  4347. else if ($R && !s.isHidden)
  4348. $R.css(side, sC.inset[side] + getPaneSize(pane));
  4349. });
  4350. }
  4351. /**
  4352. * Initialize module objects, styling, size and position for all resize bars and toggler buttons
  4353. *
  4354. * @see _create()
  4355. * @param {string=} [panes=""] The edge(s) to process
  4356. */
  4357. , initHandles = function (panes) {
  4358. panes = panes ? panes.split(",") : _c.borderPanes;
  4359. // create toggler DIVs for each pane, and set object pointers for them, eg: $R.north = north toggler DIV
  4360. $.each(panes, function (i, pane) {
  4361. var $P = $Ps[pane];
  4362. $Rs[pane] = false; // INIT
  4363. $Ts[pane] = false;
  4364. if (!$P) return; // pane does not exist - skip
  4365. var o = options[pane]
  4366. , s = state[pane]
  4367. , c = _c[pane]
  4368. , paneId = o.paneSelector.substr(0,1) === "#" ? o.paneSelector.substr(1) : ""
  4369. , rClass = o.resizerClass
  4370. , tClass = o.togglerClass
  4371. , spacing = (s.isVisible ? o.spacing_open : o.spacing_closed)
  4372. , _pane = "-"+ pane // used for classNames
  4373. , _state = (s.isVisible ? "-open" : "-closed") // used for classNames
  4374. , I = Instance[pane]
  4375. // INIT RESIZER BAR
  4376. , $R = I.resizer = $Rs[pane] = $("<div></div>")
  4377. // INIT TOGGLER BUTTON
  4378. , $T = I.toggler = (o.closable ? $Ts[pane] = $("<div></div>") : false)
  4379. ;
  4380. //if (s.isVisible && o.resizable) ... handled by initResizable
  4381. if (!s.isVisible && o.slidable)
  4382. $R.attr("title", o.tips.Slide).css("cursor", o.sliderCursor);
  4383. $R // if paneSelector is an ID, then create a matching ID for the resizer, eg: "#paneLeft" => "paneLeft-resizer"
  4384. .attr("id", paneId ? paneId +"-resizer" : "" )
  4385. .data({
  4386. parentLayout: Instance
  4387. , layoutPane: Instance[pane] // NEW pointer to pane-alias-object
  4388. , layoutEdge: pane
  4389. , layoutRole: "resizer"
  4390. })
  4391. .css(_c.resizers.cssReq).css("zIndex", options.zIndexes.resizer_normal)
  4392. .css(o.applyDemoStyles ? _c.resizers.cssDemo : {}) // add demo styles
  4393. .addClass(rClass +" "+ rClass+_pane)
  4394. .hover(addHover, removeHover) // ALWAYS add hover-classes, even if resizing is not enabled - handle with CSS instead
  4395. .hover(onResizerEnter, onResizerLeave) // ALWAYS NEED resizer.mouseleave to balance toggler.mouseenter
  4396. .appendTo($N) // append DIV to container
  4397. ;
  4398. if (o.resizerDblClickToggle)
  4399. $R.bind("dblclick."+ sID, toggle );
  4400. if ($T) {
  4401. $T // if paneSelector is an ID, then create a matching ID for the resizer, eg: "#paneLeft" => "#paneLeft-toggler"
  4402. .attr("id", paneId ? paneId +"-toggler" : "" )
  4403. .data({
  4404. parentLayout: Instance
  4405. , layoutPane: Instance[pane] // NEW pointer to pane-alias-object
  4406. , layoutEdge: pane
  4407. , layoutRole: "toggler"
  4408. })
  4409. .css(_c.togglers.cssReq) // add base/required styles
  4410. .css(o.applyDemoStyles ? _c.togglers.cssDemo : {}) // add demo styles
  4411. .addClass(tClass +" "+ tClass+_pane)
  4412. .hover(addHover, removeHover) // ALWAYS add hover-classes, even if toggling is not enabled - handle with CSS instead
  4413. .bind("mouseenter", onResizerEnter) // NEED toggler.mouseenter because mouseenter MAY NOT fire on resizer
  4414. .appendTo($R) // append SPAN to resizer DIV
  4415. ;
  4416. // ADD INNER-SPANS TO TOGGLER
  4417. if (o.togglerContent_open) // ui-layout-open
  4418. $("<span>"+ o.togglerContent_open +"</span>")
  4419. .data({
  4420. layoutEdge: pane
  4421. , layoutRole: "togglerContent"
  4422. })
  4423. .data("layoutRole", "togglerContent")
  4424. .data("layoutEdge", pane)
  4425. .addClass("content content-open")
  4426. .css("display","none")
  4427. .appendTo( $T )
  4428. //.hover( addHover, removeHover ) // use ui-layout-toggler-west-hover .content-open instead!
  4429. ;
  4430. if (o.togglerContent_closed) // ui-layout-closed
  4431. $("<span>"+ o.togglerContent_closed +"</span>")
  4432. .data({
  4433. layoutEdge: pane
  4434. , layoutRole: "togglerContent"
  4435. })
  4436. .addClass("content content-closed")
  4437. .css("display","none")
  4438. .appendTo( $T )
  4439. //.hover( addHover, removeHover ) // use ui-layout-toggler-west-hover .content-closed instead!
  4440. ;
  4441. // ADD TOGGLER.click/.hover
  4442. enableClosable(pane);
  4443. }
  4444. // add Draggable events
  4445. initResizable(pane);
  4446. // ADD CLASSNAMES & SLIDE-BINDINGS - eg: class="resizer resizer-west resizer-open"
  4447. if (s.isVisible)
  4448. setAsOpen(pane); // onOpen will be called, but NOT onResize
  4449. else {
  4450. setAsClosed(pane); // onClose will be called
  4451. bindStartSlidingEvents(pane, true); // will enable events IF option is set
  4452. }
  4453. });
  4454. // SET ALL HANDLE DIMENSIONS
  4455. sizeHandles();
  4456. }
  4457. /**
  4458. * Initialize scrolling ui-layout-content div - if exists
  4459. *
  4460. * @see initPane() - or externally after an Ajax injection
  4461. * @param {string} pane The pane to process
  4462. * @param {boolean=} [resize=true] Size content after init
  4463. */
  4464. , initContent = function (pane, resize) {
  4465. if (!isInitialized()) return;
  4466. var
  4467. o = options[pane]
  4468. , sel = o.contentSelector
  4469. , I = Instance[pane]
  4470. , $P = $Ps[pane]
  4471. , $C
  4472. ;
  4473. if (sel) $C = I.content = $Cs[pane] = (o.findNestedContent)
  4474. ? $P.find(sel).eq(0) // match 1-element only
  4475. : $P.children(sel).eq(0)
  4476. ;
  4477. if ($C && $C.length) {
  4478. $C.data("layoutRole", "content");
  4479. // SAVE original Content CSS
  4480. if (!$C.data("layoutCSS"))
  4481. $C.data("layoutCSS", styles($C, "height"));
  4482. $C.css( _c.content.cssReq );
  4483. if (o.applyDemoStyles) {
  4484. $C.css( _c.content.cssDemo ); // add padding & overflow: auto to content-div
  4485. $P.css( _c.content.cssDemoPane ); // REMOVE padding/scrolling from pane
  4486. }
  4487. // ensure no vertical scrollbar on pane - will mess up measurements
  4488. if ($P.css("overflowX").match(/(scroll|auto)/)) {
  4489. $P.css("overflow", "hidden");
  4490. }
  4491. state[pane].content = {}; // init content state
  4492. if (resize !== false) sizeContent(pane);
  4493. // sizeContent() is called AFTER init of all elements
  4494. }
  4495. else
  4496. I.content = $Cs[pane] = false;
  4497. }
  4498. /**
  4499. * Add resize-bars to all panes that specify it in options
  4500. * -dependancy: $.fn.resizable - will skip if not found
  4501. *
  4502. * @see _create()
  4503. * @param {string=} [panes=""] The edge(s) to process
  4504. */
  4505. , initResizable = function (panes) {
  4506. var draggingAvailable = $.layout.plugins.draggable
  4507. , side // set in start()
  4508. ;
  4509. panes = panes ? panes.split(",") : _c.borderPanes;
  4510. $.each(panes, function (idx, pane) {
  4511. var o = options[pane];
  4512. if (!draggingAvailable || !$Ps[pane] || !o.resizable) {
  4513. o.resizable = false;
  4514. return true; // skip to next
  4515. }
  4516. var s = state[pane]
  4517. , z = options.zIndexes
  4518. , c = _c[pane]
  4519. , side = c.dir=="horz" ? "top" : "left"
  4520. , $P = $Ps[pane]
  4521. , $R = $Rs[pane]
  4522. , base = o.resizerClass
  4523. , lastPos = 0 // used when live-resizing
  4524. , r, live // set in start because may change
  4525. // 'drag' classes are applied to the ORIGINAL resizer-bar while dragging is in process
  4526. , resizerClass = base+"-drag" // resizer-drag
  4527. , resizerPaneClass = base+"-"+pane+"-drag" // resizer-north-drag
  4528. // 'helper' class is applied to the CLONED resizer-bar while it is being dragged
  4529. , helperClass = base+"-dragging" // resizer-dragging
  4530. , helperPaneClass = base+"-"+pane+"-dragging" // resizer-north-dragging
  4531. , helperLimitClass = base+"-dragging-limit" // resizer-drag
  4532. , helperPaneLimitClass = base+"-"+pane+"-dragging-limit" // resizer-north-drag
  4533. , helperClassesSet = false // logic var
  4534. ;
  4535. if (!s.isClosed)
  4536. $R.attr("title", o.tips.Resize)
  4537. .css("cursor", o.resizerCursor); // n-resize, s-resize, etc
  4538. $R.draggable({
  4539. containment: $N[0] // limit resizing to layout container
  4540. , axis: (c.dir=="horz" ? "y" : "x") // limit resizing to horz or vert axis
  4541. , delay: 0
  4542. , distance: 1
  4543. , grid: o.resizingGrid
  4544. // basic format for helper - style it using class: .ui-draggable-dragging
  4545. , helper: "clone"
  4546. , opacity: o.resizerDragOpacity
  4547. , addClasses: false // avoid ui-state-disabled class when disabled
  4548. //, iframeFix: o.draggableIframeFix // TODO: consider using when bug is fixed
  4549. , zIndex: z.resizer_drag
  4550. , start: function (e, ui) {
  4551. // REFRESH options & state pointers in case we used swapPanes
  4552. o = options[pane];
  4553. s = state[pane];
  4554. // re-read options
  4555. live = o.livePaneResizing;
  4556. // ondrag_start callback - will CANCEL hide if returns false
  4557. // TODO: dragging CANNOT be cancelled like this, so see if there is a way?
  4558. if (false === _runCallbacks("ondrag_start", pane)) return false;
  4559. s.isResizing = true; // prevent pane from closing while resizing
  4560. state.paneResizing = pane; // easy to see if ANY pane is resizing
  4561. timer.clear(pane+"_closeSlider"); // just in case already triggered
  4562. // SET RESIZER LIMITS - used in drag()
  4563. setSizeLimits(pane); // update pane/resizer state
  4564. r = s.resizerPosition;
  4565. lastPos = ui.position[ side ]
  4566. $R.addClass( resizerClass +" "+ resizerPaneClass ); // add drag classes
  4567. helperClassesSet = false; // reset logic var - see drag()
  4568. // DISABLE TEXT SELECTION (probably already done by resizer.mouseOver)
  4569. $('body').disableSelection();
  4570. // MASK PANES CONTAINING IFRAMES, APPLETS OR OTHER TROUBLESOME ELEMENTS
  4571. showMasks( pane, { resizing: true });
  4572. }
  4573. , drag: function (e, ui) {
  4574. if (!helperClassesSet) { // can only add classes after clone has been added to the DOM
  4575. //$(".ui-draggable-dragging")
  4576. ui.helper
  4577. .addClass( helperClass +" "+ helperPaneClass ) // add helper classes
  4578. .css({ right: "auto", bottom: "auto" }) // fix dir="rtl" issue
  4579. .children().css("visibility","hidden") // hide toggler inside dragged resizer-bar
  4580. ;
  4581. helperClassesSet = true;
  4582. // draggable bug!? RE-SET zIndex to prevent E/W resize-bar showing through N/S pane!
  4583. if (s.isSliding) $Ps[pane].css("zIndex", z.pane_sliding);
  4584. }
  4585. // CONTAIN RESIZER-BAR TO RESIZING LIMITS
  4586. var limit = 0;
  4587. if (ui.position[side] < r.min) {
  4588. ui.position[side] = r.min;
  4589. limit = -1;
  4590. }
  4591. else if (ui.position[side] > r.max) {
  4592. ui.position[side] = r.max;
  4593. limit = 1;
  4594. }
  4595. // ADD/REMOVE dragging-limit CLASS
  4596. if (limit) {
  4597. ui.helper.addClass( helperLimitClass +" "+ helperPaneLimitClass ); // at dragging-limit
  4598. window.defaultStatus = (limit>0 && pane.match(/(north|west)/)) || (limit<0 && pane.match(/(south|east)/)) ? o.tips.maxSizeWarning : o.tips.minSizeWarning;
  4599. }
  4600. else {
  4601. ui.helper.removeClass( helperLimitClass +" "+ helperPaneLimitClass ); // not at dragging-limit
  4602. window.defaultStatus = "";
  4603. }
  4604. // DYNAMICALLY RESIZE PANES IF OPTION ENABLED
  4605. // won't trigger unless resizer has actually moved!
  4606. if (live && Math.abs(ui.position[side] - lastPos) >= o.liveResizingTolerance) {
  4607. lastPos = ui.position[side];
  4608. resizePanes(e, ui, pane)
  4609. }
  4610. }
  4611. , stop: function (e, ui) {
  4612. $('body').enableSelection(); // RE-ENABLE TEXT SELECTION
  4613. window.defaultStatus = ""; // clear 'resizing limit' message from statusbar
  4614. $R.removeClass( resizerClass +" "+ resizerPaneClass ); // remove drag classes from Resizer
  4615. s.isResizing = false;
  4616. state.paneResizing = false; // easy to see if ANY pane is resizing
  4617. resizePanes(e, ui, pane, true); // true = resizingDone
  4618. }
  4619. });
  4620. });
  4621. /**
  4622. * resizePanes
  4623. *
  4624. * Sub-routine called from stop() - and drag() if livePaneResizing
  4625. *
  4626. * @param {!Object} evt
  4627. * @param {!Object} ui
  4628. * @param {string} pane
  4629. * @param {boolean=} [resizingDone=false]
  4630. */
  4631. var resizePanes = function (evt, ui, pane, resizingDone) {
  4632. var dragPos = ui.position
  4633. , c = _c[pane]
  4634. , o = options[pane]
  4635. , s = state[pane]
  4636. , resizerPos
  4637. ;
  4638. switch (pane) {
  4639. case "north": resizerPos = dragPos.top; break;
  4640. case "west": resizerPos = dragPos.left; break;
  4641. case "south": resizerPos = sC.layoutHeight - dragPos.top - o.spacing_open; break;
  4642. case "east": resizerPos = sC.layoutWidth - dragPos.left - o.spacing_open; break;
  4643. };
  4644. // remove container margin from resizer position to get the pane size
  4645. var newSize = resizerPos - sC.inset[c.side];
  4646. // Disable OR Resize Mask(s) created in drag.start
  4647. if (!resizingDone) {
  4648. // ensure we meet liveResizingTolerance criteria
  4649. if (Math.abs(newSize - s.size) < o.liveResizingTolerance)
  4650. return; // SKIP resize this time
  4651. // resize the pane
  4652. manualSizePane(pane, newSize, false, true); // true = noAnimation
  4653. sizeMasks(); // resize all visible masks
  4654. }
  4655. else { // resizingDone
  4656. // ondrag_end callback
  4657. if (false !== _runCallbacks("ondrag_end", pane))
  4658. manualSizePane(pane, newSize, false, true); // true = noAnimation
  4659. hideMasks(true); // true = force hiding all masks even if one is 'sliding'
  4660. if (s.isSliding) // RE-SHOW 'object-masks' so objects won't show through sliding pane
  4661. showMasks( pane, { resizing: true });
  4662. }
  4663. };
  4664. }
  4665. /**
  4666. * sizeMask
  4667. *
  4668. * Needed to overlay a DIV over an IFRAME-pane because mask CANNOT be *inside* the pane
  4669. * Called when mask created, and during livePaneResizing
  4670. */
  4671. , sizeMask = function () {
  4672. var $M = $(this)
  4673. , pane = $M.data("layoutMask") // eg: "west"
  4674. , s = state[pane]
  4675. ;
  4676. // only masks over an IFRAME-pane need manual resizing
  4677. if (s.tagName == "IFRAME" && s.isVisible) // no need to mask closed/hidden panes
  4678. $M.css({
  4679. top: s.offsetTop
  4680. , left: s.offsetLeft
  4681. , width: s.outerWidth
  4682. , height: s.outerHeight
  4683. });
  4684. /* ALT Method...
  4685. var $P = $Ps[pane];
  4686. $M.css( $P.position() ).css({ width: $P[0].offsetWidth, height: $P[0].offsetHeight });
  4687. */
  4688. }
  4689. , sizeMasks = function () {
  4690. $Ms.each( sizeMask ); // resize all 'visible' masks
  4691. }
  4692. /**
  4693. * @param {string} pane The pane being resized, animated or isSliding
  4694. * @param {Object=} [args] (optional) Options: which masks to apply, and to which panes
  4695. */
  4696. , showMasks = function (pane, args) {
  4697. var c = _c[pane]
  4698. , panes = ["center"]
  4699. , z = options.zIndexes
  4700. , a = $.extend({
  4701. objectsOnly: false
  4702. , animation: false
  4703. , resizing: true
  4704. , sliding: state[pane].isSliding
  4705. }, args )
  4706. , o, s
  4707. ;
  4708. if (a.resizing)
  4709. panes.push( pane );
  4710. if (a.sliding)
  4711. panes.push( _c.oppositeEdge[pane] ); // ADD the oppositeEdge-pane
  4712. if (c.dir === "horz") {
  4713. panes.push("west");
  4714. panes.push("east");
  4715. }
  4716. $.each(panes, function(i,p){
  4717. s = state[p];
  4718. o = options[p];
  4719. if (s.isVisible && ( o.maskObjects || (!a.objectsOnly && o.maskContents) )) {
  4720. getMasks(p).each(function(){
  4721. sizeMask.call(this);
  4722. this.style.zIndex = s.isSliding ? z.pane_sliding+1 : z.pane_normal+1
  4723. this.style.display = "block";
  4724. });
  4725. }
  4726. });
  4727. }
  4728. /**
  4729. * @param {boolean=} force Hide masks even if a pane is sliding
  4730. */
  4731. , hideMasks = function (force) {
  4732. // ensure no pane is resizing - could be a timing issue
  4733. if (force || !state.paneResizing) {
  4734. $Ms.hide(); // hide ALL masks
  4735. }
  4736. // if ANY pane is sliding, then DO NOT remove masks from panes with maskObjects enabled
  4737. else if (!force && !$.isEmptyObject( state.panesSliding )) {
  4738. var i = $Ms.length - 1
  4739. , p, $M;
  4740. for (; i >= 0; i--) {
  4741. $M = $Ms.eq(i);
  4742. p = $M.data("layoutMask");
  4743. if (!options[p].maskObjects) {
  4744. $M.hide();
  4745. }
  4746. }
  4747. }
  4748. }
  4749. /**
  4750. * @param {string} pane
  4751. */
  4752. , getMasks = function (pane) {
  4753. var $Masks = $([])
  4754. , $M, i = 0, c = $Ms.length
  4755. ;
  4756. for (; i<c; i++) {
  4757. $M = $Ms.eq(i);
  4758. if ($M.data("layoutMask") === pane)
  4759. $Masks = $Masks.add( $M );
  4760. }
  4761. if ($Masks.length)
  4762. return $Masks;
  4763. else
  4764. return createMasks(pane);
  4765. }
  4766. /**
  4767. * createMasks
  4768. *
  4769. * Generates both DIV (ALWAYS used) and IFRAME (optional) elements as masks
  4770. * An IFRAME mask is created *under* the DIV when maskObjects=true, because a DIV cannot mask an applet
  4771. *
  4772. * @param {string} pane
  4773. */
  4774. , createMasks = function (pane) {
  4775. var
  4776. $P = $Ps[pane]
  4777. , s = state[pane]
  4778. , o = options[pane]
  4779. , z = options.zIndexes
  4780. //, objMask = o.maskObjects && s.tagName != "IFRAME" // check for option
  4781. , $Masks = $([])
  4782. , isIframe, el, $M, css, i
  4783. ;
  4784. if (!o.maskContents && !o.maskObjects) return $Masks;
  4785. // if o.maskObjects=true, then loop TWICE to create BOTH kinds of mask, else only create a DIV
  4786. for (i=0; i < (o.maskObjects ? 2 : 1); i++) {
  4787. isIframe = o.maskObjects && i==0;
  4788. el = document.createElement( isIframe ? "iframe" : "div" );
  4789. $M = $(el).data("layoutMask", pane); // add data to relate mask to pane
  4790. el.className = "ui-layout-mask ui-layout-mask-"+ pane; // for user styling
  4791. css = el.style;
  4792. // styles common to both DIVs and IFRAMES
  4793. css.display = "block";
  4794. css.position = "absolute";
  4795. css.background = "#FFF";
  4796. if (isIframe) { // IFRAME-only props
  4797. el.frameborder = 0;
  4798. el.src = "about:blank";
  4799. //el.allowTransparency = true; - for IE, but breaks masking ability!
  4800. css.opacity = 0;
  4801. css.filter = "Alpha(Opacity='0')";
  4802. css.border = 0;
  4803. }
  4804. // if pane is an IFRAME, then must mask the pane itself
  4805. if (s.tagName == "IFRAME") {
  4806. // NOTE sizing done by a subroutine so can be called during live-resizing
  4807. css.zIndex = z.pane_normal+1; // 1-higher than pane
  4808. $N.append( el ); // append to LAYOUT CONTAINER
  4809. }
  4810. // otherwise put masks *inside the pane* to mask its contents
  4811. else {
  4812. $M.addClass("ui-layout-mask-inside-pane");
  4813. css.zIndex = o.maskZindex || z.content_mask; // usually 1, but customizable
  4814. css.top = 0;
  4815. css.left = 0;
  4816. css.width = "100%";
  4817. css.height = "100%";
  4818. $P.append( el ); // append INSIDE pane element
  4819. }
  4820. // add to return object
  4821. $Masks = $Masks.add( el );
  4822. // add Mask to cached array so can be resized & reused
  4823. $Ms = $Ms.add( el );
  4824. }
  4825. return $Masks;
  4826. }
  4827. /**
  4828. * Destroy this layout and reset all elements
  4829. *
  4830. * @param {boolean=} [destroyChildren=false] Destory Child-Layouts first?
  4831. */
  4832. , destroy = function (evt_or_destroyChildren, destroyChildren) {
  4833. // UNBIND layout events and remove global object
  4834. $(window).unbind("."+ sID); // resize & unload
  4835. $(document).unbind("."+ sID); // keyDown (hotkeys)
  4836. if (typeof evt_or_destroyChildren === "object")
  4837. // stopPropagation if called by trigger("layoutdestroy") - use evtPane utility
  4838. evtPane(evt_or_destroyChildren);
  4839. else // no event, so transfer 1st param to destroyChildren param
  4840. destroyChildren = evt_or_destroyChildren;
  4841. // need to look for parent layout BEFORE we remove the container data, else skips a level
  4842. //var parentPane = Instance.hasParentLayout ? $.layout.getParentPaneInstance( $N ) : null;
  4843. // reset layout-container
  4844. $N .clearQueue()
  4845. .removeData("layout")
  4846. .removeData("layoutContainer")
  4847. .removeClass(options.containerClass)
  4848. .unbind("."+ sID) // remove ALL Layout events
  4849. ;
  4850. // remove all mask elements that have been created
  4851. $Ms.remove();
  4852. // loop all panes to remove layout classes, attributes and bindings
  4853. $.each(_c.allPanes, function (i, pane) {
  4854. removePane( pane, false, true, destroyChildren ); // true = skipResize
  4855. });
  4856. // do NOT reset container CSS if is a 'pane' (or 'content') in an outer-layout - ie, THIS layout is 'nested'
  4857. var css = "layoutCSS";
  4858. if ($N.data(css) && !$N.data("layoutRole")) // RESET CSS
  4859. $N.css( $N.data(css) ).removeData(css);
  4860. // for full-page layouts, also reset the <HTML> CSS
  4861. if (sC.tagName === "BODY" && ($N = $("html")).data(css)) // RESET <HTML> CSS
  4862. $N.css( $N.data(css) ).removeData(css);
  4863. // trigger plugins for this layout, if there are any
  4864. runPluginCallbacks( Instance, $.layout.onDestroy );
  4865. // trigger state-management and onunload callback
  4866. unload();
  4867. // clear the Instance of everything except for container & options (so could recreate)
  4868. // RE-CREATE: myLayout = myLayout.container.layout( myLayout.options );
  4869. for (var n in Instance)
  4870. if (!n.match(/^(container|options)$/)) delete Instance[ n ];
  4871. // add a 'destroyed' flag to make it easy to check
  4872. Instance.destroyed = true;
  4873. // if this is a child layout, CLEAR the child-pointer in the parent
  4874. /* for now the pointer REMAINS, but with only container, options and destroyed keys
  4875. if (parentPane) {
  4876. var layout = parentPane.pane.data("parentLayout")
  4877. , key = layout.options.instanceKey || 'error';
  4878. // THIS SYNTAX MAY BE WRONG!
  4879. parentPane.children[key] = layout.children[ parentPane.name ].children[key] = null;
  4880. }
  4881. */
  4882. return Instance; // for coding convenience
  4883. }
  4884. /**
  4885. * Remove a pane from the layout - subroutine of destroy()
  4886. *
  4887. * @see destroy()
  4888. * @param {(string|Object)} evt_or_pane The pane to process
  4889. * @param {boolean=} [remove=false] Remove the DOM element?
  4890. * @param {boolean=} [skipResize=false] Skip calling resizeAll()?
  4891. * @param {boolean=} [destroyChild=true] Destroy Child-layouts? If not passed, obeys options setting
  4892. */
  4893. , removePane = function (evt_or_pane, remove, skipResize, destroyChild) {
  4894. if (!isInitialized()) return;
  4895. var pane = evtPane.call(this, evt_or_pane)
  4896. , $P = $Ps[pane]
  4897. , $C = $Cs[pane]
  4898. , $R = $Rs[pane]
  4899. , $T = $Ts[pane]
  4900. ;
  4901. // NOTE: elements can still exist even after remove()
  4902. // so check for missing data(), which is cleared by removed()
  4903. if ($P && $.isEmptyObject( $P.data() )) $P = false;
  4904. if ($C && $.isEmptyObject( $C.data() )) $C = false;
  4905. if ($R && $.isEmptyObject( $R.data() )) $R = false;
  4906. if ($T && $.isEmptyObject( $T.data() )) $T = false;
  4907. if ($P) $P.stop(true, true);
  4908. var o = options[pane]
  4909. , s = state[pane]
  4910. , d = "layout"
  4911. , css = "layoutCSS"
  4912. , pC = children[pane]
  4913. , hasChildren = $.isPlainObject( pC ) && !$.isEmptyObject( pC )
  4914. , destroy = destroyChild !== undefined ? destroyChild : o.destroyChildren
  4915. ;
  4916. // FIRST destroy the child-layout(s)
  4917. if (hasChildren && destroy) {
  4918. $.each( pC, function (key, child) {
  4919. if (!child.destroyed)
  4920. child.destroy(true);// tell child-layout to destroy ALL its child-layouts too
  4921. if (child.destroyed) // destroy was successful
  4922. delete pC[key];
  4923. });
  4924. // if no more children, remove the children hash
  4925. if ($.isEmptyObject( pC )) {
  4926. pC = children[pane] = null; // clear children hash
  4927. hasChildren = false;
  4928. }
  4929. }
  4930. // Note: can't 'remove' a pane element with non-destroyed children
  4931. if ($P && remove && !hasChildren)
  4932. $P.remove(); // remove the pane-element and everything inside it
  4933. else if ($P && $P[0]) {
  4934. // create list of ALL pane-classes that need to be removed
  4935. var root = o.paneClass // default="ui-layout-pane"
  4936. , pRoot = root +"-"+ pane // eg: "ui-layout-pane-west"
  4937. , _open = "-open"
  4938. , _sliding= "-sliding"
  4939. , _closed = "-closed"
  4940. , classes = [ root, root+_open, root+_closed, root+_sliding, // generic classes
  4941. pRoot, pRoot+_open, pRoot+_closed, pRoot+_sliding ] // pane-specific classes
  4942. ;
  4943. $.merge(classes, getHoverClasses($P, true)); // ADD hover-classes
  4944. // remove all Layout classes from pane-element
  4945. $P .removeClass( classes.join(" ") ) // remove ALL pane-classes
  4946. .removeData("parentLayout")
  4947. .removeData("layoutPane")
  4948. .removeData("layoutRole")
  4949. .removeData("layoutEdge")
  4950. .removeData("autoHidden") // in case set
  4951. .unbind("."+ sID) // remove ALL Layout events
  4952. // TODO: remove these extra unbind commands when jQuery is fixed
  4953. //.unbind("mouseenter"+ sID)
  4954. //.unbind("mouseleave"+ sID)
  4955. ;
  4956. // do NOT reset CSS if this pane/content is STILL the container of a nested layout!
  4957. // the nested layout will reset its 'container' CSS when/if it is destroyed
  4958. if (hasChildren && $C) {
  4959. // a content-div may not have a specific width, so give it one to contain the Layout
  4960. $C.width( $C.width() );
  4961. $.each( pC, function (key, child) {
  4962. child.resizeAll(); // resize the Layout
  4963. });
  4964. }
  4965. else if ($C)
  4966. $C.css( $C.data(css) ).removeData(css).removeData("layoutRole");
  4967. // remove pane AFTER content in case there was a nested layout
  4968. if (!$P.data(d))
  4969. $P.css( $P.data(css) ).removeData(css);
  4970. }
  4971. // REMOVE pane resizer and toggler elements
  4972. if ($T) $T.remove();
  4973. if ($R) $R.remove();
  4974. // CLEAR all pointers and state data
  4975. Instance[pane] = $Ps[pane] = $Cs[pane] = $Rs[pane] = $Ts[pane] = false;
  4976. s = { removed: true };
  4977. if (!skipResize)
  4978. resizeAll();
  4979. }
  4980. /*
  4981. * ###########################
  4982. * ACTION METHODS
  4983. * ###########################
  4984. */
  4985. /**
  4986. * @param {string} pane
  4987. */
  4988. , _hidePane = function (pane) {
  4989. var $P = $Ps[pane]
  4990. , o = options[pane]
  4991. , s = $P[0].style
  4992. ;
  4993. if (o.useOffscreenClose) {
  4994. if (!$P.data(_c.offscreenReset))
  4995. $P.data(_c.offscreenReset, { left: s.left, right: s.right });
  4996. $P.css( _c.offscreenCSS );
  4997. }
  4998. else
  4999. $P.hide().removeData(_c.offscreenReset);
  5000. }
  5001. /**
  5002. * @param {string} pane
  5003. */
  5004. , _showPane = function (pane) {
  5005. var $P = $Ps[pane]
  5006. , o = options[pane]
  5007. , off = _c.offscreenCSS
  5008. , old = $P.data(_c.offscreenReset)
  5009. , s = $P[0].style
  5010. ;
  5011. $P .show() // ALWAYS show, just in case
  5012. .removeData(_c.offscreenReset);
  5013. if (o.useOffscreenClose && old) {
  5014. if (s.left == off.left)
  5015. s.left = old.left;
  5016. if (s.right == off.right)
  5017. s.right = old.right;
  5018. }
  5019. }
  5020. /**
  5021. * Completely 'hides' a pane, including its spacing - as if it does not exist
  5022. * The pane is not actually 'removed' from the source, so can use 'show' to un-hide it
  5023. *
  5024. * @param {(string|Object)} evt_or_pane The pane being hidden, ie: north, south, east, or west
  5025. * @param {boolean=} [noAnimation=false]
  5026. */
  5027. , hide = function (evt_or_pane, noAnimation) {
  5028. if (!isInitialized()) return;
  5029. var pane = evtPane.call(this, evt_or_pane)
  5030. , o = options[pane]
  5031. , s = state[pane]
  5032. , $P = $Ps[pane]
  5033. , $R = $Rs[pane]
  5034. ;
  5035. if (!$P || s.isHidden) return; // pane does not exist OR is already hidden
  5036. // onhide_start callback - will CANCEL hide if returns false
  5037. if (state.initialized && false === _runCallbacks("onhide_start", pane)) return;
  5038. s.isSliding = false; // just in case
  5039. delete state.panesSliding[pane];
  5040. // now hide the elements
  5041. if ($R) $R.hide(); // hide resizer-bar
  5042. if (!state.initialized || s.isClosed) {
  5043. s.isClosed = true; // to trigger open-animation on show()
  5044. s.isHidden = true;
  5045. s.isVisible = false;
  5046. if (!state.initialized)
  5047. _hidePane(pane); // no animation when loading page
  5048. sizeMidPanes(_c[pane].dir === "horz" ? "" : "center");
  5049. if (state.initialized || o.triggerEventsOnLoad)
  5050. _runCallbacks("onhide_end", pane);
  5051. }
  5052. else {
  5053. s.isHiding = true; // used by onclose
  5054. close(pane, false, noAnimation); // adjust all panes to fit
  5055. }
  5056. }
  5057. /**
  5058. * Show a hidden pane - show as 'closed' by default unless openPane = true
  5059. *
  5060. * @param {(string|Object)} evt_or_pane The pane being opened, ie: north, south, east, or west
  5061. * @param {boolean=} [openPane=false]
  5062. * @param {boolean=} [noAnimation=false]
  5063. * @param {boolean=} [noAlert=false]
  5064. */
  5065. , show = function (evt_or_pane, openPane, noAnimation, noAlert) {
  5066. if (!isInitialized()) return;
  5067. var pane = evtPane.call(this, evt_or_pane)
  5068. , o = options[pane]
  5069. , s = state[pane]
  5070. , $P = $Ps[pane]
  5071. , $R = $Rs[pane]
  5072. ;
  5073. if (!$P || !s.isHidden) return; // pane does not exist OR is not hidden
  5074. // onshow_start callback - will CANCEL show if returns false
  5075. if (false === _runCallbacks("onshow_start", pane)) return;
  5076. s.isShowing = true; // used by onopen/onclose
  5077. //s.isHidden = false; - will be set by open/close - if not cancelled
  5078. s.isSliding = false; // just in case
  5079. delete state.panesSliding[pane];
  5080. // now show the elements
  5081. //if ($R) $R.show(); - will be shown by open/close
  5082. if (openPane === false)
  5083. close(pane, true); // true = force
  5084. else
  5085. open(pane, false, noAnimation, noAlert); // adjust all panes to fit
  5086. }
  5087. /**
  5088. * Toggles a pane open/closed by calling either open or close
  5089. *
  5090. * @param {(string|Object)} evt_or_pane The pane being toggled, ie: north, south, east, or west
  5091. * @param {boolean=} [slide=false]
  5092. */
  5093. , toggle = function (evt_or_pane, slide) {
  5094. if (!isInitialized()) return;
  5095. var evt = evtObj(evt_or_pane)
  5096. , pane = evtPane.call(this, evt_or_pane)
  5097. , s = state[pane]
  5098. ;
  5099. if (evt) // called from to $R.dblclick OR triggerPaneEvent
  5100. evt.stopImmediatePropagation();
  5101. if (s.isHidden)
  5102. show(pane); // will call 'open' after unhiding it
  5103. else if (s.isClosed)
  5104. open(pane, !!slide);
  5105. else
  5106. close(pane);
  5107. }
  5108. /**
  5109. * Utility method used during init or other auto-processes
  5110. *
  5111. * @param {string} pane The pane being closed
  5112. * @param {boolean=} [setHandles=false]
  5113. */
  5114. , _closePane = function (pane, setHandles) {
  5115. var
  5116. $P = $Ps[pane]
  5117. , s = state[pane]
  5118. ;
  5119. _hidePane(pane);
  5120. s.isClosed = true;
  5121. s.isVisible = false;
  5122. if (setHandles) setAsClosed(pane);
  5123. }
  5124. /**
  5125. * Close the specified pane (animation optional), and resize all other panes as needed
  5126. *
  5127. * @param {(string|Object)} evt_or_pane The pane being closed, ie: north, south, east, or west
  5128. * @param {boolean=} [force=false]
  5129. * @param {boolean=} [noAnimation=false]
  5130. * @param {boolean=} [skipCallback=false]
  5131. */
  5132. , close = function (evt_or_pane, force, noAnimation, skipCallback) {
  5133. var pane = evtPane.call(this, evt_or_pane);
  5134. // if pane has been initialized, but NOT the complete layout, close pane instantly
  5135. if (!state.initialized && $Ps[pane]) {
  5136. _closePane(pane, true); // INIT pane as closed
  5137. return;
  5138. }
  5139. if (!isInitialized()) return;
  5140. var
  5141. $P = $Ps[pane]
  5142. , $R = $Rs[pane]
  5143. , $T = $Ts[pane]
  5144. , o = options[pane]
  5145. , s = state[pane]
  5146. , c = _c[pane]
  5147. , doFX, isShowing, isHiding, wasSliding;
  5148. // QUEUE in case another action/animation is in progress
  5149. $N.queue(function( queueNext ){
  5150. if ( !$P
  5151. || (!o.closable && !s.isShowing && !s.isHiding) // invalid request // (!o.resizable && !o.closable) ???
  5152. || (!force && s.isClosed && !s.isShowing) // already closed
  5153. ) return queueNext();
  5154. // onclose_start callback - will CANCEL hide if returns false
  5155. // SKIP if just 'showing' a hidden pane as 'closed'
  5156. var abort = !s.isShowing && false === _runCallbacks("onclose_start", pane);
  5157. // transfer logic vars to temp vars
  5158. isShowing = s.isShowing;
  5159. isHiding = s.isHiding;
  5160. wasSliding = s.isSliding;
  5161. // now clear the logic vars (REQUIRED before aborting)
  5162. delete s.isShowing;
  5163. delete s.isHiding;
  5164. if (abort) return queueNext();
  5165. doFX = !noAnimation && !s.isClosed && (o.fxName_close != "none");
  5166. s.isMoving = true;
  5167. s.isClosed = true;
  5168. s.isVisible = false;
  5169. // update isHidden BEFORE sizing panes
  5170. if (isHiding) s.isHidden = true;
  5171. else if (isShowing) s.isHidden = false;
  5172. if (s.isSliding) // pane is being closed, so UNBIND trigger events
  5173. bindStopSlidingEvents(pane, false); // will set isSliding=false
  5174. else // resize panes adjacent to this one
  5175. sizeMidPanes(_c[pane].dir === "horz" ? "" : "center", false); // false = NOT skipCallback
  5176. // if this pane has a resizer bar, move it NOW - before animation
  5177. setAsClosed(pane);
  5178. // CLOSE THE PANE
  5179. if (doFX) { // animate the close
  5180. lockPaneForFX(pane, true); // need to set left/top so animation will work
  5181. $P.hide( o.fxName_close, o.fxSettings_close, o.fxSpeed_close, function () {
  5182. lockPaneForFX(pane, false); // undo
  5183. if (s.isClosed) close_2();
  5184. queueNext();
  5185. });
  5186. }
  5187. else { // hide the pane without animation
  5188. _hidePane(pane);
  5189. close_2();
  5190. queueNext();
  5191. };
  5192. });
  5193. // SUBROUTINE
  5194. function close_2 () {
  5195. s.isMoving = false;
  5196. bindStartSlidingEvents(pane, true); // will enable if o.slidable = true
  5197. // if opposite-pane was autoClosed, see if it can be autoOpened now
  5198. var altPane = _c.oppositeEdge[pane];
  5199. if (state[ altPane ].noRoom) {
  5200. setSizeLimits( altPane );
  5201. makePaneFit( altPane );
  5202. }
  5203. if (!skipCallback && (state.initialized || o.triggerEventsOnLoad)) {
  5204. // onclose callback - UNLESS just 'showing' a hidden pane as 'closed'
  5205. if (!isShowing) _runCallbacks("onclose_end", pane);
  5206. // onhide OR onshow callback
  5207. if (isShowing) _runCallbacks("onshow_end", pane);
  5208. if (isHiding) _runCallbacks("onhide_end", pane);
  5209. }
  5210. }
  5211. }
  5212. /**
  5213. * @param {string} pane The pane just closed, ie: north, south, east, or west
  5214. */
  5215. , setAsClosed = function (pane) {
  5216. if (!$Rs[pane]) return; // handles not initialized yet!
  5217. var
  5218. $P = $Ps[pane]
  5219. , $R = $Rs[pane]
  5220. , $T = $Ts[pane]
  5221. , o = options[pane]
  5222. , s = state[pane]
  5223. , side = _c[pane].side
  5224. , rClass = o.resizerClass
  5225. , tClass = o.togglerClass
  5226. , _pane = "-"+ pane // used for classNames
  5227. , _open = "-open"
  5228. , _sliding= "-sliding"
  5229. , _closed = "-closed"
  5230. ;
  5231. $R
  5232. .css(side, sC.inset[side]) // move the resizer
  5233. .removeClass( rClass+_open +" "+ rClass+_pane+_open )
  5234. .removeClass( rClass+_sliding +" "+ rClass+_pane+_sliding )
  5235. .addClass( rClass+_closed +" "+ rClass+_pane+_closed )
  5236. ;
  5237. // DISABLE 'resizing' when closed - do this BEFORE bindStartSlidingEvents?
  5238. if (o.resizable && $.layout.plugins.draggable)
  5239. $R
  5240. .draggable("disable")
  5241. .removeClass("ui-state-disabled") // do NOT apply disabled styling - not suitable here
  5242. .css("cursor", "default")
  5243. .attr("title","")
  5244. ;
  5245. // if pane has a toggler button, adjust that too
  5246. if ($T) {
  5247. $T
  5248. .removeClass( tClass+_open +" "+ tClass+_pane+_open )
  5249. .addClass( tClass+_closed +" "+ tClass+_pane+_closed )
  5250. .attr("title", o.tips.Open) // may be blank
  5251. ;
  5252. // toggler-content - if exists
  5253. $T.children(".content-open").hide();
  5254. $T.children(".content-closed").css("display","block");
  5255. }
  5256. // sync any 'pin buttons'
  5257. syncPinBtns(pane, false);
  5258. if (state.initialized) {
  5259. // resize 'length' and position togglers for adjacent panes
  5260. sizeHandles();
  5261. }
  5262. }
  5263. /**
  5264. * Open the specified pane (animation optional), and resize all other panes as needed
  5265. *
  5266. * @param {(string|Object)} evt_or_pane The pane being opened, ie: north, south, east, or west
  5267. * @param {boolean=} [slide=false]
  5268. * @param {boolean=} [noAnimation=false]
  5269. * @param {boolean=} [noAlert=false]
  5270. */
  5271. , open = function (evt_or_pane, slide, noAnimation, noAlert) {
  5272. if (!isInitialized()) return;
  5273. var pane = evtPane.call(this, evt_or_pane)
  5274. , $P = $Ps[pane]
  5275. , $R = $Rs[pane]
  5276. , $T = $Ts[pane]
  5277. , o = options[pane]
  5278. , s = state[pane]
  5279. , c = _c[pane]
  5280. , doFX, isShowing
  5281. ;
  5282. // QUEUE in case another action/animation is in progress
  5283. $N.queue(function( queueNext ){
  5284. if ( !$P
  5285. || (!o.resizable && !o.closable && !s.isShowing) // invalid request
  5286. || (s.isVisible && !s.isSliding) // already open
  5287. ) return queueNext();
  5288. // pane can ALSO be unhidden by just calling show(), so handle this scenario
  5289. if (s.isHidden && !s.isShowing) {
  5290. queueNext(); // call before show() because it needs the queue free
  5291. show(pane, true);
  5292. return;
  5293. }
  5294. if (s.autoResize && s.size != o.size) // resize pane to original size set in options
  5295. sizePane(pane, o.size, true, true, true); // true=skipCallback/noAnimation/forceResize
  5296. else
  5297. // make sure there is enough space available to open the pane
  5298. setSizeLimits(pane, slide);
  5299. // onopen_start callback - will CANCEL open if returns false
  5300. var cbReturn = _runCallbacks("onopen_start", pane);
  5301. if (cbReturn === "abort")
  5302. return queueNext();
  5303. // update pane-state again in case options were changed in onopen_start
  5304. if (cbReturn !== "NC") // NC = "No Callback"
  5305. setSizeLimits(pane, slide);
  5306. if (s.minSize > s.maxSize) { // INSUFFICIENT ROOM FOR PANE TO OPEN!
  5307. syncPinBtns(pane, false); // make sure pin-buttons are reset
  5308. if (!noAlert && o.tips.noRoomToOpen)
  5309. alert(o.tips.noRoomToOpen);
  5310. return queueNext(); // ABORT
  5311. }
  5312. if (slide) // START Sliding - will set isSliding=true
  5313. bindStopSlidingEvents(pane, true); // BIND trigger events to close sliding-pane
  5314. else if (s.isSliding) // PIN PANE (stop sliding) - open pane 'normally' instead
  5315. bindStopSlidingEvents(pane, false); // UNBIND trigger events - will set isSliding=false
  5316. else if (o.slidable)
  5317. bindStartSlidingEvents(pane, false); // UNBIND trigger events
  5318. s.noRoom = false; // will be reset by makePaneFit if 'noRoom'
  5319. makePaneFit(pane);
  5320. // transfer logic var to temp var
  5321. isShowing = s.isShowing;
  5322. // now clear the logic var
  5323. delete s.isShowing;
  5324. doFX = !noAnimation && s.isClosed && (o.fxName_open != "none");
  5325. s.isMoving = true;
  5326. s.isVisible = true;
  5327. s.isClosed = false;
  5328. // update isHidden BEFORE sizing panes - WHY??? Old?
  5329. if (isShowing) s.isHidden = false;
  5330. if (doFX) { // ANIMATE
  5331. // mask adjacent panes with objects
  5332. lockPaneForFX(pane, true); // need to set left/top so animation will work
  5333. $P.show( o.fxName_open, o.fxSettings_open, o.fxSpeed_open, function() {
  5334. lockPaneForFX(pane, false); // undo
  5335. if (s.isVisible) open_2(); // continue
  5336. queueNext();
  5337. });
  5338. }
  5339. else { // no animation
  5340. _showPane(pane);// just show pane and...
  5341. open_2(); // continue
  5342. queueNext();
  5343. };
  5344. });
  5345. // SUBROUTINE
  5346. function open_2 () {
  5347. s.isMoving = false;
  5348. // cure iframe display issues
  5349. _fixIframe(pane);
  5350. // NOTE: if isSliding, then other panes are NOT 'resized'
  5351. if (!s.isSliding) { // resize all panes adjacent to this one
  5352. sizeMidPanes(_c[pane].dir=="vert" ? "center" : "", false); // false = NOT skipCallback
  5353. }
  5354. // set classes, position handles and execute callbacks...
  5355. setAsOpen(pane);
  5356. };
  5357. }
  5358. /**
  5359. * @param {string} pane The pane just opened, ie: north, south, east, or west
  5360. * @param {boolean=} [skipCallback=false]
  5361. */
  5362. , setAsOpen = function (pane, skipCallback) {
  5363. var
  5364. $P = $Ps[pane]
  5365. , $R = $Rs[pane]
  5366. , $T = $Ts[pane]
  5367. , o = options[pane]
  5368. , s = state[pane]
  5369. , side = _c[pane].side
  5370. , rClass = o.resizerClass
  5371. , tClass = o.togglerClass
  5372. , _pane = "-"+ pane // used for classNames
  5373. , _open = "-open"
  5374. , _closed = "-closed"
  5375. , _sliding= "-sliding"
  5376. ;
  5377. $R
  5378. .css(side, sC.inset[side] + getPaneSize(pane)) // move the resizer
  5379. .removeClass( rClass+_closed +" "+ rClass+_pane+_closed )
  5380. .addClass( rClass+_open +" "+ rClass+_pane+_open )
  5381. ;
  5382. if (s.isSliding)
  5383. $R.addClass( rClass+_sliding +" "+ rClass+_pane+_sliding )
  5384. else // in case 'was sliding'
  5385. $R.removeClass( rClass+_sliding +" "+ rClass+_pane+_sliding )
  5386. removeHover( 0, $R ); // remove hover classes
  5387. if (o.resizable && $.layout.plugins.draggable)
  5388. $R .draggable("enable")
  5389. .css("cursor", o.resizerCursor)
  5390. .attr("title", o.tips.Resize);
  5391. else if (!s.isSliding)
  5392. $R.css("cursor", "default"); // n-resize, s-resize, etc
  5393. // if pane also has a toggler button, adjust that too
  5394. if ($T) {
  5395. $T .removeClass( tClass+_closed +" "+ tClass+_pane+_closed )
  5396. .addClass( tClass+_open +" "+ tClass+_pane+_open )
  5397. .attr("title", o.tips.Close); // may be blank
  5398. removeHover( 0, $T ); // remove hover classes
  5399. // toggler-content - if exists
  5400. $T.children(".content-closed").hide();
  5401. $T.children(".content-open").css("display","block");
  5402. }
  5403. // sync any 'pin buttons'
  5404. syncPinBtns(pane, !s.isSliding);
  5405. // update pane-state dimensions - BEFORE resizing content
  5406. $.extend(s, elDims($P));
  5407. if (state.initialized) {
  5408. // resize resizer & toggler sizes for all panes
  5409. sizeHandles();
  5410. // resize content every time pane opens - to be sure
  5411. sizeContent(pane, true); // true = remeasure headers/footers, even if 'pane.isMoving'
  5412. }
  5413. if (!skipCallback && (state.initialized || o.triggerEventsOnLoad) && $P.is(":visible")) {
  5414. // onopen callback
  5415. _runCallbacks("onopen_end", pane);
  5416. // onshow callback - TODO: should this be here?
  5417. if (s.isShowing) _runCallbacks("onshow_end", pane);
  5418. // ALSO call onresize because layout-size *may* have changed while pane was closed
  5419. if (state.initialized)
  5420. _runCallbacks("onresize_end", pane);
  5421. }
  5422. // TODO: Somehow sizePane("north") is being called after this point???
  5423. }
  5424. /**
  5425. * slideOpen / slideClose / slideToggle
  5426. *
  5427. * Pass-though methods for sliding
  5428. */
  5429. , slideOpen = function (evt_or_pane) {
  5430. if (!isInitialized()) return;
  5431. var evt = evtObj(evt_or_pane)
  5432. , pane = evtPane.call(this, evt_or_pane)
  5433. , s = state[pane]
  5434. , delay = options[pane].slideDelay_open
  5435. ;
  5436. // prevent event from triggering on NEW resizer binding created below
  5437. if (evt) evt.stopImmediatePropagation();
  5438. if (s.isClosed && evt && evt.type === "mouseenter" && delay > 0)
  5439. // trigger = mouseenter - use a delay
  5440. timer.set(pane+"_openSlider", open_NOW, delay);
  5441. else
  5442. open_NOW(); // will unbind events if is already open
  5443. /**
  5444. * SUBROUTINE for timed open
  5445. */
  5446. function open_NOW () {
  5447. if (!s.isClosed) // skip if no longer closed!
  5448. bindStopSlidingEvents(pane, true); // BIND trigger events to close sliding-pane
  5449. else if (!s.isMoving)
  5450. open(pane, true); // true = slide - open() will handle binding
  5451. };
  5452. }
  5453. , slideClose = function (evt_or_pane) {
  5454. if (!isInitialized()) return;
  5455. var evt = evtObj(evt_or_pane)
  5456. , pane = evtPane.call(this, evt_or_pane)
  5457. , o = options[pane]
  5458. , s = state[pane]
  5459. , delay = s.isMoving ? 1000 : 300 // MINIMUM delay - option may override
  5460. ;
  5461. if (s.isClosed || s.isResizing)
  5462. return; // skip if already closed OR in process of resizing
  5463. else if (o.slideTrigger_close === "click")
  5464. close_NOW(); // close immediately onClick
  5465. else if (o.preventQuickSlideClose && s.isMoving)
  5466. return; // handle Chrome quick-close on slide-open
  5467. else if (o.preventPrematureSlideClose && evt && $.layout.isMouseOverElem(evt, $Ps[pane]))
  5468. return; // handle incorrect mouseleave trigger, like when over a SELECT-list in IE
  5469. else if (evt) // trigger = mouseleave - use a delay
  5470. // 1 sec delay if 'opening', else .3 sec
  5471. timer.set(pane+"_closeSlider", close_NOW, max(o.slideDelay_close, delay));
  5472. else // called programically
  5473. close_NOW();
  5474. /**
  5475. * SUBROUTINE for timed close
  5476. */
  5477. function close_NOW () {
  5478. if (s.isClosed) // skip 'close' if already closed!
  5479. bindStopSlidingEvents(pane, false); // UNBIND trigger events - TODO: is this needed here?
  5480. else if (!s.isMoving)
  5481. close(pane); // close will handle unbinding
  5482. };
  5483. }
  5484. /**
  5485. * @param {(string|Object)} evt_or_pane The pane being opened, ie: north, south, east, or west
  5486. */
  5487. , slideToggle = function (evt_or_pane) {
  5488. var pane = evtPane.call(this, evt_or_pane);
  5489. toggle(pane, true);
  5490. }
  5491. /**
  5492. * Must set left/top on East/South panes so animation will work properly
  5493. *
  5494. * @param {string} pane The pane to lock, 'east' or 'south' - any other is ignored!
  5495. * @param {boolean} doLock true = set left/top, false = remove
  5496. */
  5497. , lockPaneForFX = function (pane, doLock) {
  5498. var $P = $Ps[pane]
  5499. , s = state[pane]
  5500. , o = options[pane]
  5501. , z = options.zIndexes
  5502. ;
  5503. if (doLock) {
  5504. showMasks( pane, { animation: true, objectsOnly: true });
  5505. $P.css({ zIndex: z.pane_animate }); // overlay all elements during animation
  5506. if (pane=="south")
  5507. $P.css({ top: sC.inset.top + sC.innerHeight - $P.outerHeight() });
  5508. else if (pane=="east")
  5509. $P.css({ left: sC.inset.left + sC.innerWidth - $P.outerWidth() });
  5510. }
  5511. else { // animation DONE - RESET CSS
  5512. hideMasks();
  5513. $P.css({ zIndex: (s.isSliding ? z.pane_sliding : z.pane_normal) });
  5514. if (pane=="south")
  5515. $P.css({ top: "auto" });
  5516. // if pane is positioned 'off-screen', then DO NOT screw with it!
  5517. else if (pane=="east" && !$P.css("left").match(/\-99999/))
  5518. $P.css({ left: "auto" });
  5519. // fix anti-aliasing in IE - only needed for animations that change opacity
  5520. if (browser.msie && o.fxOpacityFix && o.fxName_open != "slide" && $P.css("filter") && $P.css("opacity") == 1)
  5521. $P[0].style.removeAttribute('filter');
  5522. }
  5523. }
  5524. /**
  5525. * Toggle sliding functionality of a specific pane on/off by adding removing 'slide open' trigger
  5526. *
  5527. * @see open(), close()
  5528. * @param {string} pane The pane to enable/disable, 'north', 'south', etc.
  5529. * @param {boolean} enable Enable or Disable sliding?
  5530. */
  5531. , bindStartSlidingEvents = function (pane, enable) {
  5532. var o = options[pane]
  5533. , $P = $Ps[pane]
  5534. , $R = $Rs[pane]
  5535. , evtName = o.slideTrigger_open.toLowerCase()
  5536. ;
  5537. if (!$R || (enable && !o.slidable)) return;
  5538. // make sure we have a valid event
  5539. if (evtName.match(/mouseover/))
  5540. evtName = o.slideTrigger_open = "mouseenter";
  5541. else if (!evtName.match(/(click|dblclick|mouseenter)/))
  5542. evtName = o.slideTrigger_open = "click";
  5543. // must remove double-click-toggle when using dblclick-slide
  5544. if (o.resizerDblClickToggle && evtName.match(/click/)) {
  5545. $R[enable ? "unbind" : "bind"]('dblclick.'+ sID, toggle)
  5546. }
  5547. $R
  5548. // add or remove event
  5549. [enable ? "bind" : "unbind"](evtName +'.'+ sID, slideOpen)
  5550. // set the appropriate cursor & title/tip
  5551. .css("cursor", enable ? o.sliderCursor : "default")
  5552. .attr("title", enable ? o.tips.Slide : "")
  5553. ;
  5554. }
  5555. /**
  5556. * Add or remove 'mouseleave' events to 'slide close' when pane is 'sliding' open or closed
  5557. * Also increases zIndex when pane is sliding open
  5558. * See bindStartSlidingEvents for code to control 'slide open'
  5559. *
  5560. * @see slideOpen(), slideClose()
  5561. * @param {string} pane The pane to process, 'north', 'south', etc.
  5562. * @param {boolean} enable Enable or Disable events?
  5563. */
  5564. , bindStopSlidingEvents = function (pane, enable) {
  5565. var o = options[pane]
  5566. , s = state[pane]
  5567. , c = _c[pane]
  5568. , z = options.zIndexes
  5569. , evtName = o.slideTrigger_close.toLowerCase()
  5570. , action = (enable ? "bind" : "unbind")
  5571. , $P = $Ps[pane]
  5572. , $R = $Rs[pane]
  5573. ;
  5574. timer.clear(pane+"_closeSlider"); // just in case
  5575. if (enable) {
  5576. s.isSliding = true;
  5577. state.panesSliding[pane] = true;
  5578. // remove 'slideOpen' event from resizer
  5579. // ALSO will raise the zIndex of the pane & resizer
  5580. bindStartSlidingEvents(pane, false);
  5581. }
  5582. else {
  5583. s.isSliding = false;
  5584. delete state.panesSliding[pane];
  5585. }
  5586. // RE/SET zIndex - increases when pane is sliding-open, resets to normal when not
  5587. $P.css("zIndex", enable ? z.pane_sliding : z.pane_normal);
  5588. $R.css("zIndex", enable ? z.pane_sliding+2 : z.resizer_normal); // NOTE: mask = pane_sliding+1
  5589. // make sure we have a valid event
  5590. if (!evtName.match(/(click|mouseleave)/))
  5591. evtName = o.slideTrigger_close = "mouseleave"; // also catches 'mouseout'
  5592. // add/remove slide triggers
  5593. $R[action](evtName, slideClose); // base event on resize
  5594. // need extra events for mouseleave
  5595. if (evtName === "mouseleave") {
  5596. // also close on pane.mouseleave
  5597. $P[action]("mouseleave."+ sID, slideClose);
  5598. // cancel timer when mouse moves between 'pane' and 'resizer'
  5599. $R[action]("mouseenter."+ sID, cancelMouseOut);
  5600. $P[action]("mouseenter."+ sID, cancelMouseOut);
  5601. }
  5602. if (!enable)
  5603. timer.clear(pane+"_closeSlider");
  5604. else if (evtName === "click" && !o.resizable) {
  5605. // IF pane is not resizable (which already has a cursor and tip)
  5606. // then set the a cursor & title/tip on resizer when sliding
  5607. $R.css("cursor", enable ? o.sliderCursor : "default");
  5608. $R.attr("title", enable ? o.tips.Close : ""); // use Toggler-tip, eg: "Close Pane"
  5609. }
  5610. // SUBROUTINE for mouseleave timer clearing
  5611. function cancelMouseOut (evt) {
  5612. timer.clear(pane+"_closeSlider");
  5613. evt.stopPropagation();
  5614. }
  5615. }
  5616. /**
  5617. * Hides/closes a pane if there is insufficient room - reverses this when there is room again
  5618. * MUST have already called setSizeLimits() before calling this method
  5619. *
  5620. * @param {string} pane The pane being resized
  5621. * @param {boolean=} [isOpening=false] Called from onOpen?
  5622. * @param {boolean=} [skipCallback=false] Should the onresize callback be run?
  5623. * @param {boolean=} [force=false]
  5624. */
  5625. , makePaneFit = function (pane, isOpening, skipCallback, force) {
  5626. var o = options[pane]
  5627. , s = state[pane]
  5628. , c = _c[pane]
  5629. , $P = $Ps[pane]
  5630. , $R = $Rs[pane]
  5631. , isSidePane = c.dir==="vert"
  5632. , hasRoom = false
  5633. ;
  5634. // special handling for center & east/west panes
  5635. if (pane === "center" || (isSidePane && s.noVerticalRoom)) {
  5636. // see if there is enough room to display the pane
  5637. // ERROR: hasRoom = s.minHeight <= s.maxHeight && (isSidePane || s.minWidth <= s.maxWidth);
  5638. hasRoom = (s.maxHeight >= 0);
  5639. if (hasRoom && s.noRoom) { // previously hidden due to noRoom, so show now
  5640. _showPane(pane);
  5641. if ($R) $R.show();
  5642. s.isVisible = true;
  5643. s.noRoom = false;
  5644. if (isSidePane) s.noVerticalRoom = false;
  5645. _fixIframe(pane);
  5646. }
  5647. else if (!hasRoom && !s.noRoom) { // not currently hidden, so hide now
  5648. _hidePane(pane);
  5649. if ($R) $R.hide();
  5650. s.isVisible = false;
  5651. s.noRoom = true;
  5652. }
  5653. }
  5654. // see if there is enough room to fit the border-pane
  5655. if (pane === "center") {
  5656. // ignore center in this block
  5657. }
  5658. else if (s.minSize <= s.maxSize) { // pane CAN fit
  5659. hasRoom = true;
  5660. if (s.size > s.maxSize) // pane is too big - shrink it
  5661. sizePane(pane, s.maxSize, skipCallback, true, force); // true = noAnimation
  5662. else if (s.size < s.minSize) // pane is too small - enlarge it
  5663. sizePane(pane, s.minSize, skipCallback, true, force); // true = noAnimation
  5664. // need s.isVisible because new pseudoClose method keeps pane visible, but off-screen
  5665. else if ($R && s.isVisible && $P.is(":visible")) {
  5666. // make sure resizer-bar is positioned correctly
  5667. // handles situation where nested layout was 'hidden' when initialized
  5668. var pos = s.size + sC.inset[c.side];
  5669. if ($.layout.cssNum( $R, c.side ) != pos) $R.css( c.side, pos );
  5670. }
  5671. // if was previously hidden due to noRoom, then RESET because NOW there is room
  5672. if (s.noRoom) {
  5673. // s.noRoom state will be set by open or show
  5674. if (s.wasOpen && o.closable) {
  5675. if (o.autoReopen)
  5676. open(pane, false, true, true); // true = noAnimation, true = noAlert
  5677. else // leave the pane closed, so just update state
  5678. s.noRoom = false;
  5679. }
  5680. else
  5681. show(pane, s.wasOpen, true, true); // true = noAnimation, true = noAlert
  5682. }
  5683. }
  5684. else { // !hasRoom - pane CANNOT fit
  5685. if (!s.noRoom) { // pane not set as noRoom yet, so hide or close it now...
  5686. s.noRoom = true; // update state
  5687. s.wasOpen = !s.isClosed && !s.isSliding;
  5688. if (s.isClosed){} // SKIP
  5689. else if (o.closable) // 'close' if possible
  5690. close(pane, true, true); // true = force, true = noAnimation
  5691. else // 'hide' pane if cannot just be closed
  5692. hide(pane, true); // true = noAnimation
  5693. }
  5694. }
  5695. }
  5696. /**
  5697. * manualSizePane is an exposed flow-through method allowing extra code when pane is 'manually resized'
  5698. *
  5699. * @param {(string|Object)} evt_or_pane The pane being resized
  5700. * @param {number} size The *desired* new size for this pane - will be validated
  5701. * @param {boolean=} [skipCallback=false] Should the onresize callback be run?
  5702. * @param {boolean=} [noAnimation=false]
  5703. * @param {boolean=} [force=false] Force resizing even if does not seem necessary
  5704. */
  5705. , manualSizePane = function (evt_or_pane, size, skipCallback, noAnimation, force) {
  5706. if (!isInitialized()) return;
  5707. var pane = evtPane.call(this, evt_or_pane)
  5708. , o = options[pane]
  5709. , s = state[pane]
  5710. // if resizing callbacks have been delayed and resizing is now DONE, force resizing to complete...
  5711. , forceResize = force || (o.livePaneResizing && !s.isResizing)
  5712. ;
  5713. // ANY call to manualSizePane disables autoResize - ie, percentage sizing
  5714. s.autoResize = false;
  5715. // flow-through...
  5716. sizePane(pane, size, skipCallback, noAnimation, forceResize); // will animate resize if option enabled
  5717. }
  5718. /**
  5719. * sizePane is called only by internal methods whenever a pane needs to be resized
  5720. *
  5721. * @param {(string|Object)} evt_or_pane The pane being resized
  5722. * @param {number} size The *desired* new size for this pane - will be validated
  5723. * @param {boolean=} [skipCallback=false] Should the onresize callback be run?
  5724. * @param {boolean=} [noAnimation=false]
  5725. * @param {boolean=} [force=false] Force resizing even if does not seem necessary
  5726. */
  5727. , sizePane = function (evt_or_pane, size, skipCallback, noAnimation, force) {
  5728. if (!isInitialized()) return;
  5729. var pane = evtPane.call(this, evt_or_pane) // probably NEVER called from event?
  5730. , o = options[pane]
  5731. , s = state[pane]
  5732. , $P = $Ps[pane]
  5733. , $R = $Rs[pane]
  5734. , side = _c[pane].side
  5735. , dimName = _c[pane].sizeType.toLowerCase()
  5736. , skipResizeWhileDragging = s.isResizing && !o.triggerEventsDuringLiveResize
  5737. , doFX = noAnimation !== true && o.animatePaneSizing
  5738. , oldSize, newSize
  5739. ;
  5740. // QUEUE in case another action/animation is in progress
  5741. $N.queue(function( queueNext ){
  5742. // calculate 'current' min/max sizes
  5743. setSizeLimits(pane); // update pane-state
  5744. oldSize = s.size;
  5745. size = _parseSize(pane, size); // handle percentages & auto
  5746. size = max(size, _parseSize(pane, o.minSize));
  5747. size = min(size, s.maxSize);
  5748. if (size < s.minSize) { // not enough room for pane!
  5749. queueNext(); // call before makePaneFit() because it needs the queue free
  5750. makePaneFit(pane, false, skipCallback); // will hide or close pane
  5751. return;
  5752. }
  5753. // IF newSize is same as oldSize, then nothing to do - abort
  5754. if (!force && size === oldSize)
  5755. return queueNext();
  5756. s.newSize = size;
  5757. // onresize_start callback CANNOT cancel resizing because this would break the layout!
  5758. if (!skipCallback && state.initialized && s.isVisible)
  5759. _runCallbacks("onresize_start", pane);
  5760. // resize the pane, and make sure its visible
  5761. newSize = cssSize(pane, size);
  5762. if (doFX && $P.is(":visible")) { // ANIMATE
  5763. var fx = $.layout.effects.size[pane] || $.layout.effects.size.all
  5764. , easing = o.fxSettings_size.easing || fx.easing
  5765. , z = options.zIndexes
  5766. , props = {};
  5767. props[ dimName ] = newSize +'px';
  5768. s.isMoving = true;
  5769. // overlay all elements during animation
  5770. $P.css({ zIndex: z.pane_animate })
  5771. .show().animate( props, o.fxSpeed_size, easing, function(){
  5772. // reset zIndex after animation
  5773. $P.css({ zIndex: (s.isSliding ? z.pane_sliding : z.pane_normal) });
  5774. s.isMoving = false;
  5775. delete s.newSize;
  5776. sizePane_2(); // continue
  5777. queueNext();
  5778. });
  5779. }
  5780. else { // no animation
  5781. $P.css( dimName, newSize ); // resize pane
  5782. delete s.newSize;
  5783. // if pane is visible, then
  5784. if ($P.is(":visible"))
  5785. sizePane_2(); // continue
  5786. else {
  5787. // pane is NOT VISIBLE, so just update state data...
  5788. // when pane is *next opened*, it will have the new size
  5789. s.size = size; // update state.size
  5790. $.extend(s, elDims($P)); // update state dimensions
  5791. }
  5792. queueNext();
  5793. };
  5794. });
  5795. // SUBROUTINE
  5796. function sizePane_2 () {
  5797. /* Panes are sometimes not sized precisely in some browsers!?
  5798. * This code will resize the pane up to 3 times to nudge the pane to the correct size
  5799. */
  5800. var actual = dimName==='width' ? $P.outerWidth() : $P.outerHeight()
  5801. , tries = [{
  5802. pane: pane
  5803. , count: 1
  5804. , target: size
  5805. , actual: actual
  5806. , correct: (size === actual)
  5807. , attempt: size
  5808. , cssSize: newSize
  5809. }]
  5810. , lastTry = tries[0]
  5811. , thisTry = {}
  5812. , msg = 'Inaccurate size after resizing the '+ pane +'-pane.'
  5813. ;
  5814. while ( !lastTry.correct ) {
  5815. thisTry = { pane: pane, count: lastTry.count+1, target: size };
  5816. if (lastTry.actual > size)
  5817. thisTry.attempt = max(0, lastTry.attempt - (lastTry.actual - size));
  5818. else // lastTry.actual < size
  5819. thisTry.attempt = max(0, lastTry.attempt + (size - lastTry.actual));
  5820. thisTry.cssSize = cssSize(pane, thisTry.attempt);
  5821. $P.css( dimName, thisTry.cssSize );
  5822. thisTry.actual = dimName=='width' ? $P.outerWidth() : $P.outerHeight();
  5823. thisTry.correct = (size === thisTry.actual);
  5824. // log attempts and alert the user of this *non-fatal error* (if showDebugMessages)
  5825. if ( tries.length === 1) {
  5826. _log(msg, false, true);
  5827. _log(lastTry, false, true);
  5828. }
  5829. _log(thisTry, false, true);
  5830. // after 4 tries, is as close as its gonna get!
  5831. if (tries.length > 3) break;
  5832. tries.push( thisTry );
  5833. lastTry = tries[ tries.length - 1 ];
  5834. }
  5835. // END TESTING CODE
  5836. // update pane-state dimensions
  5837. s.size = size;
  5838. $.extend(s, elDims($P));
  5839. if (s.isVisible && $P.is(":visible")) {
  5840. // reposition the resizer-bar
  5841. if ($R) $R.css( side, size + sC.inset[side] );
  5842. // resize the content-div
  5843. sizeContent(pane);
  5844. }
  5845. if (!skipCallback && !skipResizeWhileDragging && state.initialized && s.isVisible)
  5846. _runCallbacks("onresize_end", pane);
  5847. // resize all the adjacent panes, and adjust their toggler buttons
  5848. // when skipCallback passed, it means the controlling method will handle 'other panes'
  5849. if (!skipCallback) {
  5850. // also no callback if live-resize is in progress and NOT triggerEventsDuringLiveResize
  5851. if (!s.isSliding) sizeMidPanes(_c[pane].dir=="horz" ? "" : "center", skipResizeWhileDragging, force);
  5852. sizeHandles();
  5853. }
  5854. // if opposite-pane was autoClosed, see if it can be autoOpened now
  5855. var altPane = _c.oppositeEdge[pane];
  5856. if (size < oldSize && state[ altPane ].noRoom) {
  5857. setSizeLimits( altPane );
  5858. makePaneFit( altPane, false, skipCallback );
  5859. }
  5860. // DEBUG - ALERT user/developer so they know there was a sizing problem
  5861. if (tries.length > 1)
  5862. _log(msg +'\nSee the Error Console for details.', true, true);
  5863. }
  5864. }
  5865. /**
  5866. * @see initPanes(), sizePane(), resizeAll(), open(), close(), hide()
  5867. * @param {(Array.<string>|string)} panes The pane(s) being resized, comma-delmited string
  5868. * @param {boolean=} [skipCallback=false] Should the onresize callback be run?
  5869. * @param {boolean=} [force=false]
  5870. */
  5871. , sizeMidPanes = function (panes, skipCallback, force) {
  5872. panes = (panes ? panes : "east,west,center").split(",");
  5873. $.each(panes, function (i, pane) {
  5874. if (!$Ps[pane]) return; // NO PANE - skip
  5875. var
  5876. o = options[pane]
  5877. , s = state[pane]
  5878. , $P = $Ps[pane]
  5879. , $R = $Rs[pane]
  5880. , isCenter= (pane=="center")
  5881. , hasRoom = true
  5882. , CSS = {}
  5883. // if pane is not visible, show it invisibly NOW rather than for *each call* in this script
  5884. , visCSS = $.layout.showInvisibly($P)
  5885. , newCenter = calcNewCenterPaneDims()
  5886. ;
  5887. // update pane-state dimensions
  5888. $.extend(s, elDims($P));
  5889. if (pane === "center") {
  5890. if (!force && s.isVisible && newCenter.width === s.outerWidth && newCenter.height === s.outerHeight) {
  5891. $P.css(visCSS);
  5892. return true; // SKIP - pane already the correct size
  5893. }
  5894. // set state for makePaneFit() logic
  5895. $.extend(s, cssMinDims(pane), {
  5896. maxWidth: newCenter.width
  5897. , maxHeight: newCenter.height
  5898. });
  5899. CSS = newCenter;
  5900. s.newWidth = CSS.width;
  5901. s.newHeight = CSS.height;
  5902. // convert OUTER width/height to CSS width/height
  5903. CSS.width = cssW($P, CSS.width);
  5904. // NEW - allow pane to extend 'below' visible area rather than hide it
  5905. CSS.height = cssH($P, CSS.height);
  5906. hasRoom = CSS.width >= 0 && CSS.height >= 0; // height >= 0 = ALWAYS TRUE NOW
  5907. // during layout init, try to shrink east/west panes to make room for center
  5908. if (!state.initialized && o.minWidth > newCenter.width) {
  5909. var
  5910. reqPx = o.minWidth - s.outerWidth
  5911. , minE = options.east.minSize || 0
  5912. , minW = options.west.minSize || 0
  5913. , sizeE = state.east.size
  5914. , sizeW = state.west.size
  5915. , newE = sizeE
  5916. , newW = sizeW
  5917. ;
  5918. if (reqPx > 0 && state.east.isVisible && sizeE > minE) {
  5919. newE = max( sizeE-minE, sizeE-reqPx );
  5920. reqPx -= sizeE-newE;
  5921. }
  5922. if (reqPx > 0 && state.west.isVisible && sizeW > minW) {
  5923. newW = max( sizeW-minW, sizeW-reqPx );
  5924. reqPx -= sizeW-newW;
  5925. }
  5926. // IF we found enough extra space, then resize the border panes as calculated
  5927. if (reqPx === 0) {
  5928. if (sizeE && sizeE != minE)
  5929. sizePane('east', newE, true, true, force); // true = skipCallback/noAnimation - initPanes will handle when done
  5930. if (sizeW && sizeW != minW)
  5931. sizePane('west', newW, true, true, force); // true = skipCallback/noAnimation
  5932. // now start over!
  5933. sizeMidPanes('center', skipCallback, force);
  5934. $P.css(visCSS);
  5935. return; // abort this loop
  5936. }
  5937. }
  5938. }
  5939. else { // for east and west, set only the height, which is same as center height
  5940. // set state.min/maxWidth/Height for makePaneFit() logic
  5941. if (s.isVisible && !s.noVerticalRoom)
  5942. $.extend(s, elDims($P), cssMinDims(pane))
  5943. if (!force && !s.noVerticalRoom && newCenter.height === s.outerHeight) {
  5944. $P.css(visCSS);
  5945. return true; // SKIP - pane already the correct size
  5946. }
  5947. // east/west have same top, bottom & height as center
  5948. CSS.top = newCenter.top;
  5949. CSS.bottom = newCenter.bottom;
  5950. s.newSize = newCenter.height
  5951. // NEW - allow pane to extend 'below' visible area rather than hide it
  5952. CSS.height = cssH($P, newCenter.height);
  5953. s.maxHeight = CSS.height;
  5954. hasRoom = (s.maxHeight >= 0); // ALWAYS TRUE NOW
  5955. if (!hasRoom) s.noVerticalRoom = true; // makePaneFit() logic
  5956. }
  5957. if (hasRoom) {
  5958. // resizeAll passes skipCallback because it triggers callbacks after ALL panes are resized
  5959. if (!skipCallback && state.initialized)
  5960. _runCallbacks("onresize_start", pane);
  5961. $P.css(CSS); // apply the CSS to pane
  5962. if (pane !== "center")
  5963. sizeHandles(pane); // also update resizer length
  5964. if (s.noRoom && !s.isClosed && !s.isHidden)
  5965. makePaneFit(pane); // will re-open/show auto-closed/hidden pane
  5966. if (s.isVisible) {
  5967. $.extend(s, elDims($P)); // update pane dimensions
  5968. if (state.initialized) sizeContent(pane); // also resize the contents, if exists
  5969. }
  5970. }
  5971. else if (!s.noRoom && s.isVisible) // no room for pane
  5972. makePaneFit(pane); // will hide or close pane
  5973. // reset visibility, if necessary
  5974. $P.css(visCSS);
  5975. delete s.newSize;
  5976. delete s.newWidth;
  5977. delete s.newHeight;
  5978. if (!s.isVisible)
  5979. return true; // DONE - next pane
  5980. /*
  5981. * Extra CSS for IE6 or IE7 in Quirks-mode - add 'width' to NORTH/SOUTH panes
  5982. * Normally these panes have only 'left' & 'right' positions so pane auto-sizes
  5983. * ALSO required when pane is an IFRAME because will NOT default to 'full width'
  5984. * TODO: Can I use width:100% for a north/south iframe?
  5985. * TODO: Sounds like a job for $P.outerWidth( sC.innerWidth ) SETTER METHOD
  5986. */
  5987. if (pane === "center") { // finished processing midPanes
  5988. var fix = browser.isIE6 || !browser.boxModel;
  5989. if ($Ps.north && (fix || state.north.tagName=="IFRAME"))
  5990. $Ps.north.css("width", cssW($Ps.north, sC.innerWidth));
  5991. if ($Ps.south && (fix || state.south.tagName=="IFRAME"))
  5992. $Ps.south.css("width", cssW($Ps.south, sC.innerWidth));
  5993. }
  5994. // resizeAll passes skipCallback because it triggers callbacks after ALL panes are resized
  5995. if (!skipCallback && state.initialized)
  5996. _runCallbacks("onresize_end", pane);
  5997. });
  5998. }
  5999. /**
  6000. * @see window.onresize(), callbacks or custom code
  6001. * @param {(Object|boolean)=} evt_or_refresh If 'true', then also reset pane-positioning
  6002. */
  6003. , resizeAll = function (evt_or_refresh) {
  6004. var oldW = sC.innerWidth
  6005. , oldH = sC.innerHeight
  6006. ;
  6007. // stopPropagation if called by trigger("layoutdestroy") - use evtPane utility
  6008. evtPane(evt_or_refresh);
  6009. // cannot size layout when 'container' is hidden or collapsed
  6010. if (!$N.is(":visible")) return;
  6011. if (!state.initialized) {
  6012. _initLayoutElements();
  6013. return; // no need to resize since we just initialized!
  6014. }
  6015. if (evt_or_refresh === true && $.isPlainObject(options.outset)) {
  6016. // update container CSS in case outset option has changed
  6017. $N.css( options.outset );
  6018. }
  6019. // UPDATE container dimensions
  6020. $.extend(sC, elDims( $N, options.inset ));
  6021. if (!sC.outerHeight) return;
  6022. // if 'true' passed, refresh pane & handle positioning too
  6023. if (evt_or_refresh === true) {
  6024. setPanePosition();
  6025. }
  6026. // onresizeall_start will CANCEL resizing if returns false
  6027. // state.container has already been set, so user can access this info for calcuations
  6028. if (false === _runCallbacks("onresizeall_start")) return false;
  6029. var // see if container is now 'smaller' than before
  6030. shrunkH = (sC.innerHeight < oldH)
  6031. , shrunkW = (sC.innerWidth < oldW)
  6032. , $P, o, s
  6033. ;
  6034. // NOTE special order for sizing: S-N-E-W
  6035. $.each(["south","north","east","west"], function (i, pane) {
  6036. if (!$Ps[pane]) return; // no pane - SKIP
  6037. o = options[pane];
  6038. s = state[pane];
  6039. if (s.autoResize && s.size != o.size) // resize pane to original size set in options
  6040. sizePane(pane, o.size, true, true, true); // true=skipCallback/noAnimation/forceResize
  6041. else {
  6042. setSizeLimits(pane);
  6043. makePaneFit(pane, false, true, true); // true=skipCallback/forceResize
  6044. }
  6045. });
  6046. sizeMidPanes("", true, true); // true=skipCallback/forceResize
  6047. sizeHandles(); // reposition the toggler elements
  6048. // trigger all individual pane callbacks AFTER layout has finished resizing
  6049. $.each(_c.allPanes, function (i, pane) {
  6050. $P = $Ps[pane];
  6051. if (!$P) return; // SKIP
  6052. if (state[pane].isVisible) // undefined for non-existent panes
  6053. _runCallbacks("onresize_end", pane); // callback - if exists
  6054. });
  6055. _runCallbacks("onresizeall_end");
  6056. //_triggerLayoutEvent(pane, 'resizeall');
  6057. }
  6058. /**
  6059. * Whenever a pane resizes or opens that has a nested layout, trigger resizeAll
  6060. *
  6061. * @param {(string|Object)} evt_or_pane The pane just resized or opened
  6062. */
  6063. , resizeChildren = function (evt_or_pane, skipRefresh) {
  6064. var pane = evtPane.call(this, evt_or_pane);
  6065. if (!options[pane].resizeChildren) return;
  6066. // ensure the pane-children are up-to-date
  6067. if (!skipRefresh) refreshChildren( pane );
  6068. var pC = children[pane];
  6069. if ($.isPlainObject( pC )) {
  6070. // resize one or more children
  6071. $.each( pC, function (key, child) {
  6072. if (!child.destroyed) child.resizeAll();
  6073. });
  6074. }
  6075. }
  6076. /**
  6077. * IF pane has a content-div, then resize all elements inside pane to fit pane-height
  6078. *
  6079. * @param {(string|Object)} evt_or_panes The pane(s) being resized
  6080. * @param {boolean=} [remeasure=false] Should the content (header/footer) be remeasured?
  6081. */
  6082. , sizeContent = function (evt_or_panes, remeasure) {
  6083. if (!isInitialized()) return;
  6084. var panes = evtPane.call(this, evt_or_panes);
  6085. panes = panes ? panes.split(",") : _c.allPanes;
  6086. $.each(panes, function (idx, pane) {
  6087. var
  6088. $P = $Ps[pane]
  6089. , $C = $Cs[pane]
  6090. , o = options[pane]
  6091. , s = state[pane]
  6092. , m = s.content // m = measurements
  6093. ;
  6094. if (!$P || !$C || !$P.is(":visible")) return true; // NOT VISIBLE - skip
  6095. // if content-element was REMOVED, update OR remove the pointer
  6096. if (!$C.length) {
  6097. initContent(pane, false); // false = do NOT sizeContent() - already there!
  6098. if (!$C) return; // no replacement element found - pointer have been removed
  6099. }
  6100. // onsizecontent_start will CANCEL resizing if returns false
  6101. if (false === _runCallbacks("onsizecontent_start", pane)) return;
  6102. // skip re-measuring offsets if live-resizing
  6103. if ((!s.isMoving && !s.isResizing) || o.liveContentResizing || remeasure || m.top == undefined) {
  6104. _measure();
  6105. // if any footers are below pane-bottom, they may not measure correctly,
  6106. // so allow pane overflow and re-measure
  6107. if (m.hiddenFooters > 0 && $P.css("overflow") === "hidden") {
  6108. $P.css("overflow", "visible");
  6109. _measure(); // remeasure while overflowing
  6110. $P.css("overflow", "hidden");
  6111. }
  6112. }
  6113. // NOTE: spaceAbove/Below *includes* the pane paddingTop/Bottom, but not pane.borders
  6114. var newH = s.innerHeight - (m.spaceAbove - s.css.paddingTop) - (m.spaceBelow - s.css.paddingBottom);
  6115. if (!$C.is(":visible") || m.height != newH) {
  6116. // size the Content element to fit new pane-size - will autoHide if not enough room
  6117. setOuterHeight($C, newH, true); // true=autoHide
  6118. m.height = newH; // save new height
  6119. };
  6120. if (state.initialized)
  6121. _runCallbacks("onsizecontent_end", pane);
  6122. function _below ($E) {
  6123. return max(s.css.paddingBottom, (parseInt($E.css("marginBottom"), 10) || 0));
  6124. };
  6125. function _measure () {
  6126. var
  6127. ignore = options[pane].contentIgnoreSelector
  6128. , $Fs = $C.nextAll().not(".ui-layout-mask").not(ignore || ":lt(0)") // not :lt(0) = ALL
  6129. , $Fs_vis = $Fs.filter(':visible')
  6130. , $F = $Fs_vis.filter(':last')
  6131. ;
  6132. m = {
  6133. top: $C[0].offsetTop
  6134. , height: $C.outerHeight()
  6135. , numFooters: $Fs.length
  6136. , hiddenFooters: $Fs.length - $Fs_vis.length
  6137. , spaceBelow: 0 // correct if no content footer ($E)
  6138. }
  6139. m.spaceAbove = m.top; // just for state - not used in calc
  6140. m.bottom = m.top + m.height;
  6141. if ($F.length)
  6142. //spaceBelow = (LastFooter.top + LastFooter.height) [footerBottom] - Content.bottom + max(LastFooter.marginBottom, pane.paddingBotom)
  6143. m.spaceBelow = ($F[0].offsetTop + $F.outerHeight()) - m.bottom + _below($F);
  6144. else // no footer - check marginBottom on Content element itself
  6145. m.spaceBelow = _below($C);
  6146. };
  6147. });
  6148. }
  6149. /**
  6150. * Called every time a pane is opened, closed, or resized to slide the togglers to 'center' and adjust their length if necessary
  6151. *
  6152. * @see initHandles(), open(), close(), resizeAll()
  6153. * @param {(string|Object)=} evt_or_panes The pane(s) being resized
  6154. */
  6155. , sizeHandles = function (evt_or_panes) {
  6156. var panes = evtPane.call(this, evt_or_panes)
  6157. panes = panes ? panes.split(",") : _c.borderPanes;
  6158. $.each(panes, function (i, pane) {
  6159. var
  6160. o = options[pane]
  6161. , s = state[pane]
  6162. , $P = $Ps[pane]
  6163. , $R = $Rs[pane]
  6164. , $T = $Ts[pane]
  6165. , $TC
  6166. ;
  6167. if (!$P || !$R) return;
  6168. var
  6169. dir = _c[pane].dir
  6170. , _state = (s.isClosed ? "_closed" : "_open")
  6171. , spacing = o["spacing"+ _state]
  6172. , togAlign = o["togglerAlign"+ _state]
  6173. , togLen = o["togglerLength"+ _state]
  6174. , paneLen
  6175. , left
  6176. , offset
  6177. , CSS = {}
  6178. ;
  6179. if (spacing === 0) {
  6180. $R.hide();
  6181. return;
  6182. }
  6183. else if (!s.noRoom && !s.isHidden) // skip if resizer was hidden for any reason
  6184. $R.show(); // in case was previously hidden
  6185. // Resizer Bar is ALWAYS same width/height of pane it is attached to
  6186. if (dir === "horz") { // north/south
  6187. //paneLen = $P.outerWidth(); // s.outerWidth ||
  6188. paneLen = sC.innerWidth; // handle offscreen-panes
  6189. s.resizerLength = paneLen;
  6190. left = $.layout.cssNum($P, "left")
  6191. $R.css({
  6192. width: cssW($R, paneLen) // account for borders & padding
  6193. , height: cssH($R, spacing) // ditto
  6194. , left: left > -9999 ? left : sC.inset.left // handle offscreen-panes
  6195. });
  6196. }
  6197. else { // east/west
  6198. paneLen = $P.outerHeight(); // s.outerHeight ||
  6199. s.resizerLength = paneLen;
  6200. $R.css({
  6201. height: cssH($R, paneLen) // account for borders & padding
  6202. , width: cssW($R, spacing) // ditto
  6203. , top: sC.inset.top + getPaneSize("north", true) // TODO: what if no North pane?
  6204. //, top: $.layout.cssNum($Ps["center"], "top")
  6205. });
  6206. }
  6207. // remove hover classes
  6208. removeHover( o, $R );
  6209. if ($T) {
  6210. if (togLen === 0 || (s.isSliding && o.hideTogglerOnSlide)) {
  6211. $T.hide(); // always HIDE the toggler when 'sliding'
  6212. return;
  6213. }
  6214. else
  6215. $T.show(); // in case was previously hidden
  6216. if (!(togLen > 0) || togLen === "100%" || togLen > paneLen) {
  6217. togLen = paneLen;
  6218. offset = 0;
  6219. }
  6220. else { // calculate 'offset' based on options.PANE.togglerAlign_open/closed
  6221. if (isStr(togAlign)) {
  6222. switch (togAlign) {
  6223. case "top":
  6224. case "left": offset = 0;
  6225. break;
  6226. case "bottom":
  6227. case "right": offset = paneLen - togLen;
  6228. break;
  6229. case "middle":
  6230. case "center":
  6231. default: offset = round((paneLen - togLen) / 2); // 'default' catches typos
  6232. }
  6233. }
  6234. else { // togAlign = number
  6235. var x = parseInt(togAlign, 10); //
  6236. if (togAlign >= 0) offset = x;
  6237. else offset = paneLen - togLen + x; // NOTE: x is negative!
  6238. }
  6239. }
  6240. if (dir === "horz") { // north/south
  6241. var width = cssW($T, togLen);
  6242. $T.css({
  6243. width: width // account for borders & padding
  6244. , height: cssH($T, spacing) // ditto
  6245. , left: offset // TODO: VERIFY that toggler positions correctly for ALL values
  6246. , top: 0
  6247. });
  6248. // CENTER the toggler content SPAN
  6249. $T.children(".content").each(function(){
  6250. $TC = $(this);
  6251. $TC.css("marginLeft", round((width-$TC.outerWidth())/2)); // could be negative
  6252. });
  6253. }
  6254. else { // east/west
  6255. var height = cssH($T, togLen);
  6256. $T.css({
  6257. height: height // account for borders & padding
  6258. , width: cssW($T, spacing) // ditto
  6259. , top: offset // POSITION the toggler
  6260. , left: 0
  6261. });
  6262. // CENTER the toggler content SPAN
  6263. $T.children(".content").each(function(){
  6264. $TC = $(this);
  6265. $TC.css("marginTop", round((height-$TC.outerHeight())/2)); // could be negative
  6266. });
  6267. }
  6268. // remove ALL hover classes
  6269. removeHover( 0, $T );
  6270. }
  6271. // DONE measuring and sizing this resizer/toggler, so can be 'hidden' now
  6272. if (!state.initialized && (o.initHidden || s.isHidden)) {
  6273. $R.hide();
  6274. if ($T) $T.hide();
  6275. }
  6276. });
  6277. }
  6278. /**
  6279. * @param {(string|Object)} evt_or_pane
  6280. */
  6281. , enableClosable = function (evt_or_pane) {
  6282. if (!isInitialized()) return;
  6283. var pane = evtPane.call(this, evt_or_pane)
  6284. , $T = $Ts[pane]
  6285. , o = options[pane]
  6286. ;
  6287. if (!$T) return;
  6288. o.closable = true;
  6289. $T .bind("click."+ sID, function(evt){ evt.stopPropagation(); toggle(pane); })
  6290. .css("visibility", "visible")
  6291. .css("cursor", "pointer")
  6292. .attr("title", state[pane].isClosed ? o.tips.Open : o.tips.Close) // may be blank
  6293. .show();
  6294. }
  6295. /**
  6296. * @param {(string|Object)} evt_or_pane
  6297. * @param {boolean=} [hide=false]
  6298. */
  6299. , disableClosable = function (evt_or_pane, hide) {
  6300. if (!isInitialized()) return;
  6301. var pane = evtPane.call(this, evt_or_pane)
  6302. , $T = $Ts[pane]
  6303. ;
  6304. if (!$T) return;
  6305. options[pane].closable = false;
  6306. // is closable is disable, then pane MUST be open!
  6307. if (state[pane].isClosed) open(pane, false, true);
  6308. $T .unbind("."+ sID)
  6309. .css("visibility", hide ? "hidden" : "visible") // instead of hide(), which creates logic issues
  6310. .css("cursor", "default")
  6311. .attr("title", "");
  6312. }
  6313. /**
  6314. * @param {(string|Object)} evt_or_pane
  6315. */
  6316. , enableSlidable = function (evt_or_pane) {
  6317. if (!isInitialized()) return;
  6318. var pane = evtPane.call(this, evt_or_pane)
  6319. , $R = $Rs[pane]
  6320. ;
  6321. if (!$R || !$R.data('draggable')) return;
  6322. options[pane].slidable = true;
  6323. if (state[pane].isClosed)
  6324. bindStartSlidingEvents(pane, true);
  6325. }
  6326. /**
  6327. * @param {(string|Object)} evt_or_pane
  6328. */
  6329. , disableSlidable = function (evt_or_pane) {
  6330. if (!isInitialized()) return;
  6331. var pane = evtPane.call(this, evt_or_pane)
  6332. , $R = $Rs[pane]
  6333. ;
  6334. if (!$R) return;
  6335. options[pane].slidable = false;
  6336. if (state[pane].isSliding)
  6337. close(pane, false, true);
  6338. else {
  6339. bindStartSlidingEvents(pane, false);
  6340. $R .css("cursor", "default")
  6341. .attr("title", "");
  6342. removeHover(null, $R[0]); // in case currently hovered
  6343. }
  6344. }
  6345. /**
  6346. * @param {(string|Object)} evt_or_pane
  6347. */
  6348. , enableResizable = function (evt_or_pane) {
  6349. if (!isInitialized()) return;
  6350. var pane = evtPane.call(this, evt_or_pane)
  6351. , $R = $Rs[pane]
  6352. , o = options[pane]
  6353. ;
  6354. if (!$R || !$R.data('draggable')) return;
  6355. o.resizable = true;
  6356. $R.draggable("enable");
  6357. if (!state[pane].isClosed)
  6358. $R .css("cursor", o.resizerCursor)
  6359. .attr("title", o.tips.Resize);
  6360. }
  6361. /**
  6362. * @param {(string|Object)} evt_or_pane
  6363. */
  6364. , disableResizable = function (evt_or_pane) {
  6365. if (!isInitialized()) return;
  6366. var pane = evtPane.call(this, evt_or_pane)
  6367. , $R = $Rs[pane]
  6368. ;
  6369. if (!$R || !$R.data('draggable')) return;
  6370. options[pane].resizable = false;
  6371. $R .draggable("disable")
  6372. .css("cursor", "default")
  6373. .attr("title", "");
  6374. removeHover(null, $R[0]); // in case currently hovered
  6375. }
  6376. /**
  6377. * Move a pane from source-side (eg, west) to target-side (eg, east)
  6378. * If pane exists on target-side, move that to source-side, ie, 'swap' the panes
  6379. *
  6380. * @param {(string|Object)} evt_or_pane1 The pane/edge being swapped
  6381. * @param {string} pane2 ditto
  6382. */
  6383. , swapPanes = function (evt_or_pane1, pane2) {
  6384. if (!isInitialized()) return;
  6385. var pane1 = evtPane.call(this, evt_or_pane1);
  6386. // change state.edge NOW so callbacks can know where pane is headed...
  6387. state[pane1].edge = pane2;
  6388. state[pane2].edge = pane1;
  6389. // run these even if NOT state.initialized
  6390. if (false === _runCallbacks("onswap_start", pane1)
  6391. || false === _runCallbacks("onswap_start", pane2)
  6392. ) {
  6393. state[pane1].edge = pane1; // reset
  6394. state[pane2].edge = pane2;
  6395. return;
  6396. }
  6397. var
  6398. oPane1 = copy( pane1 )
  6399. , oPane2 = copy( pane2 )
  6400. , sizes = {}
  6401. ;
  6402. sizes[pane1] = oPane1 ? oPane1.state.size : 0;
  6403. sizes[pane2] = oPane2 ? oPane2.state.size : 0;
  6404. // clear pointers & state
  6405. $Ps[pane1] = false;
  6406. $Ps[pane2] = false;
  6407. state[pane1] = {};
  6408. state[pane2] = {};
  6409. // ALWAYS remove the resizer & toggler elements
  6410. if ($Ts[pane1]) $Ts[pane1].remove();
  6411. if ($Ts[pane2]) $Ts[pane2].remove();
  6412. if ($Rs[pane1]) $Rs[pane1].remove();
  6413. if ($Rs[pane2]) $Rs[pane2].remove();
  6414. $Rs[pane1] = $Rs[pane2] = $Ts[pane1] = $Ts[pane2] = false;
  6415. // transfer element pointers and data to NEW Layout keys
  6416. move( oPane1, pane2 );
  6417. move( oPane2, pane1 );
  6418. // cleanup objects
  6419. oPane1 = oPane2 = sizes = null;
  6420. // make panes 'visible' again
  6421. if ($Ps[pane1]) $Ps[pane1].css(_c.visible);
  6422. if ($Ps[pane2]) $Ps[pane2].css(_c.visible);
  6423. // fix any size discrepancies caused by swap
  6424. resizeAll();
  6425. // run these even if NOT state.initialized
  6426. _runCallbacks("onswap_end", pane1);
  6427. _runCallbacks("onswap_end", pane2);
  6428. return;
  6429. function copy (n) { // n = pane
  6430. var
  6431. $P = $Ps[n]
  6432. , $C = $Cs[n]
  6433. ;
  6434. return !$P ? false : {
  6435. pane: n
  6436. , P: $P ? $P[0] : false
  6437. , C: $C ? $C[0] : false
  6438. , state: $.extend(true, {}, state[n])
  6439. , options: $.extend(true, {}, options[n])
  6440. }
  6441. };
  6442. function move (oPane, pane) {
  6443. if (!oPane) return;
  6444. var
  6445. P = oPane.P
  6446. , C = oPane.C
  6447. , oldPane = oPane.pane
  6448. , c = _c[pane]
  6449. // save pane-options that should be retained
  6450. , s = $.extend(true, {}, state[pane])
  6451. , o = options[pane]
  6452. // RETAIN side-specific FX Settings - more below
  6453. , fx = { resizerCursor: o.resizerCursor }
  6454. , re, size, pos
  6455. ;
  6456. $.each("fxName,fxSpeed,fxSettings".split(","), function (i, k) {
  6457. fx[k +"_open"] = o[k +"_open"];
  6458. fx[k +"_close"] = o[k +"_close"];
  6459. fx[k +"_size"] = o[k +"_size"];
  6460. });
  6461. // update object pointers and attributes
  6462. $Ps[pane] = $(P)
  6463. .data({
  6464. layoutPane: Instance[pane] // NEW pointer to pane-alias-object
  6465. , layoutEdge: pane
  6466. })
  6467. .css(_c.hidden)
  6468. .css(c.cssReq)
  6469. ;
  6470. $Cs[pane] = C ? $(C) : false;
  6471. // set options and state
  6472. options[pane] = $.extend(true, {}, oPane.options, fx);
  6473. state[pane] = $.extend(true, {}, oPane.state);
  6474. // change classNames on the pane, eg: ui-layout-pane-east ==> ui-layout-pane-west
  6475. re = new RegExp(o.paneClass +"-"+ oldPane, "g");
  6476. P.className = P.className.replace(re, o.paneClass +"-"+ pane);
  6477. // ALWAYS regenerate the resizer & toggler elements
  6478. initHandles(pane); // create the required resizer & toggler
  6479. // if moving to different orientation, then keep 'target' pane size
  6480. if (c.dir != _c[oldPane].dir) {
  6481. size = sizes[pane] || 0;
  6482. setSizeLimits(pane); // update pane-state
  6483. size = max(size, state[pane].minSize);
  6484. // use manualSizePane to disable autoResize - not useful after panes are swapped
  6485. manualSizePane(pane, size, true, true); // true/true = skipCallback/noAnimation
  6486. }
  6487. else // move the resizer here
  6488. $Rs[pane].css(c.side, sC.inset[c.side] + (state[pane].isVisible ? getPaneSize(pane) : 0));
  6489. // ADD CLASSNAMES & SLIDE-BINDINGS
  6490. if (oPane.state.isVisible && !s.isVisible)
  6491. setAsOpen(pane, true); // true = skipCallback
  6492. else {
  6493. setAsClosed(pane);
  6494. bindStartSlidingEvents(pane, true); // will enable events IF option is set
  6495. }
  6496. // DESTROY the object
  6497. oPane = null;
  6498. };
  6499. }
  6500. /**
  6501. * INTERNAL method to sync pin-buttons when pane is opened or closed
  6502. * Unpinned means the pane is 'sliding' - ie, over-top of the adjacent panes
  6503. *
  6504. * @see open(), setAsOpen(), setAsClosed()
  6505. * @param {string} pane These are the params returned to callbacks by layout()
  6506. * @param {boolean} doPin True means set the pin 'down', False means 'up'
  6507. */
  6508. , syncPinBtns = function (pane, doPin) {
  6509. if ($.layout.plugins.buttons)
  6510. $.each(state[pane].pins, function (i, selector) {
  6511. $.layout.buttons.setPinState(Instance, $(selector), pane, doPin);
  6512. });
  6513. }
  6514. ; // END var DECLARATIONS
  6515. /**
  6516. * Capture keys when enableCursorHotkey - toggle pane if hotkey pressed
  6517. *
  6518. * @see document.keydown()
  6519. */
  6520. function keyDown (evt) {
  6521. if (!evt) return true;
  6522. var code = evt.keyCode;
  6523. if (code < 33) return true; // ignore special keys: ENTER, TAB, etc
  6524. var
  6525. PANE = {
  6526. 38: "north" // Up Cursor - $.ui.keyCode.UP
  6527. , 40: "south" // Down Cursor - $.ui.keyCode.DOWN
  6528. , 37: "west" // Left Cursor - $.ui.keyCode.LEFT
  6529. , 39: "east" // Right Cursor - $.ui.keyCode.RIGHT
  6530. }
  6531. , ALT = evt.altKey // no worky!
  6532. , SHIFT = evt.shiftKey
  6533. , CTRL = evt.ctrlKey
  6534. , CURSOR = (CTRL && code >= 37 && code <= 40)
  6535. , o, k, m, pane
  6536. ;
  6537. if (CURSOR && options[PANE[code]].enableCursorHotkey) // valid cursor-hotkey
  6538. pane = PANE[code];
  6539. else if (CTRL || SHIFT) // check to see if this matches a custom-hotkey
  6540. $.each(_c.borderPanes, function (i, p) { // loop each pane to check its hotkey
  6541. o = options[p];
  6542. k = o.customHotkey;
  6543. m = o.customHotkeyModifier; // if missing or invalid, treated as "CTRL+SHIFT"
  6544. if ((SHIFT && m=="SHIFT") || (CTRL && m=="CTRL") || (CTRL && SHIFT)) { // Modifier matches
  6545. if (k && code === (isNaN(k) || k <= 9 ? k.toUpperCase().charCodeAt(0) : k)) { // Key matches
  6546. pane = p;
  6547. return false; // BREAK
  6548. }
  6549. }
  6550. });
  6551. // validate pane
  6552. if (!pane || !$Ps[pane] || !options[pane].closable || state[pane].isHidden)
  6553. return true;
  6554. toggle(pane);
  6555. evt.stopPropagation();
  6556. evt.returnValue = false; // CANCEL key
  6557. return false;
  6558. };
  6559. /*
  6560. * ######################################
  6561. * UTILITY METHODS
  6562. * called externally or by initButtons
  6563. * ######################################
  6564. */
  6565. /**
  6566. * Change/reset a pane overflow setting & zIndex to allow popups/drop-downs to work
  6567. *
  6568. * @param {Object=} [el] (optional) Can also be 'bound' to a click, mouseOver, or other event
  6569. */
  6570. function allowOverflow (el) {
  6571. if (!isInitialized()) return;
  6572. if (this && this.tagName) el = this; // BOUND to element
  6573. var $P;
  6574. if (isStr(el))
  6575. $P = $Ps[el];
  6576. else if ($(el).data("layoutRole"))
  6577. $P = $(el);
  6578. else
  6579. $(el).parents().each(function(){
  6580. if ($(this).data("layoutRole")) {
  6581. $P = $(this);
  6582. return false; // BREAK
  6583. }
  6584. });
  6585. if (!$P || !$P.length) return; // INVALID
  6586. var
  6587. pane = $P.data("layoutEdge")
  6588. , s = state[pane]
  6589. ;
  6590. // if pane is already raised, then reset it before doing it again!
  6591. // this would happen if allowOverflow is attached to BOTH the pane and an element
  6592. if (s.cssSaved)
  6593. resetOverflow(pane); // reset previous CSS before continuing
  6594. // if pane is raised by sliding or resizing, or its closed, then abort
  6595. if (s.isSliding || s.isResizing || s.isClosed) {
  6596. s.cssSaved = false;
  6597. return;
  6598. }
  6599. var
  6600. newCSS = { zIndex: (options.zIndexes.resizer_normal + 1) }
  6601. , curCSS = {}
  6602. , of = $P.css("overflow")
  6603. , ofX = $P.css("overflowX")
  6604. , ofY = $P.css("overflowY")
  6605. ;
  6606. // determine which, if any, overflow settings need to be changed
  6607. if (of != "visible") {
  6608. curCSS.overflow = of;
  6609. newCSS.overflow = "visible";
  6610. }
  6611. if (ofX && !ofX.match(/(visible|auto)/)) {
  6612. curCSS.overflowX = ofX;
  6613. newCSS.overflowX = "visible";
  6614. }
  6615. if (ofY && !ofY.match(/(visible|auto)/)) {
  6616. curCSS.overflowY = ofX;
  6617. newCSS.overflowY = "visible";
  6618. }
  6619. // save the current overflow settings - even if blank!
  6620. s.cssSaved = curCSS;
  6621. // apply new CSS to raise zIndex and, if necessary, make overflow 'visible'
  6622. $P.css( newCSS );
  6623. // make sure the zIndex of all other panes is normal
  6624. $.each(_c.allPanes, function(i, p) {
  6625. if (p != pane) resetOverflow(p);
  6626. });
  6627. };
  6628. /**
  6629. * @param {Object=} [el] (optional) Can also be 'bound' to a click, mouseOver, or other event
  6630. */
  6631. function resetOverflow (el) {
  6632. if (!isInitialized()) return;
  6633. if (this && this.tagName) el = this; // BOUND to element
  6634. var $P;
  6635. if (isStr(el))
  6636. $P = $Ps[el];
  6637. else if ($(el).data("layoutRole"))
  6638. $P = $(el);
  6639. else
  6640. $(el).parents().each(function(){
  6641. if ($(this).data("layoutRole")) {
  6642. $P = $(this);
  6643. return false; // BREAK
  6644. }
  6645. });
  6646. if (!$P || !$P.length) return; // INVALID
  6647. var
  6648. pane = $P.data("layoutEdge")
  6649. , s = state[pane]
  6650. , CSS = s.cssSaved || {}
  6651. ;
  6652. // reset the zIndex
  6653. if (!s.isSliding && !s.isResizing)
  6654. $P.css("zIndex", options.zIndexes.pane_normal);
  6655. // reset Overflow - if necessary
  6656. $P.css( CSS );
  6657. // clear var
  6658. s.cssSaved = false;
  6659. };
  6660. /*
  6661. * #####################
  6662. * CREATE/RETURN LAYOUT
  6663. * #####################
  6664. */
  6665. try {
  6666. // validate that container exists
  6667. var $N = $(this).eq(0); // FIRST matching Container element
  6668. if (!$N.length) {
  6669. return _log( options.errors.containerMissing );
  6670. };
  6671. // Users retrieve Instance of a layout with: $N.layout() OR $N.data("layout")
  6672. // return the Instance-pointer if layout has already been initialized
  6673. if ($N.data("layoutContainer") && $N.data("layout"))
  6674. return $N.data("layout"); // cached pointer
  6675. } catch(e){
  6676. console.log("eeeee",e)
  6677. }
  6678. // init global vars
  6679. var
  6680. $Ps = {} // Panes x5 - set in initPanes()
  6681. , $Cs = {} // Content x5 - set in initPanes()
  6682. , $Rs = {} // Resizers x4 - set in initHandles()
  6683. , $Ts = {} // Togglers x4 - set in initHandles()
  6684. , $Ms = $([]) // Masks - up to 2 masks per pane (IFRAME + DIV)
  6685. // aliases for code brevity
  6686. , sC = state.container // alias for easy access to 'container dimensions'
  6687. , sID = state.id // alias for unique layout ID/namespace - eg: "layout435"
  6688. ;
  6689. // create Instance object to expose data & option Properties, and primary action Methods
  6690. var Instance = {
  6691. // layout data
  6692. options: options // property - options hash
  6693. , state: state // property - dimensions hash
  6694. // object pointers
  6695. , container: $N // property - object pointers for layout container
  6696. , panes: $Ps // property - object pointers for ALL Panes: panes.north, panes.center
  6697. , contents: $Cs // property - object pointers for ALL Content: contents.north, contents.center
  6698. , resizers: $Rs // property - object pointers for ALL Resizers, eg: resizers.north
  6699. , togglers: $Ts // property - object pointers for ALL Togglers, eg: togglers.north
  6700. // border-pane open/close
  6701. , hide: hide // method - ditto
  6702. , show: show // method - ditto
  6703. , toggle: toggle // method - pass a 'pane' ("north", "west", etc)
  6704. , open: open // method - ditto
  6705. , close: close // method - ditto
  6706. , slideOpen: slideOpen // method - ditto
  6707. , slideClose: slideClose // method - ditto
  6708. , slideToggle: slideToggle // method - ditto
  6709. // pane actions
  6710. , setSizeLimits: setSizeLimits // method - pass a 'pane' - update state min/max data
  6711. , _sizePane: sizePane // method -intended for user by plugins only!
  6712. , sizePane: manualSizePane // method - pass a 'pane' AND an 'outer-size' in pixels or percent, or 'auto'
  6713. , sizeContent: sizeContent // method - pass a 'pane'
  6714. , swapPanes: swapPanes // method - pass TWO 'panes' - will swap them
  6715. , showMasks: showMasks // method - pass a 'pane' OR list of panes - default = all panes with mask option set
  6716. , hideMasks: hideMasks // method - ditto'
  6717. // pane element methods
  6718. , initContent: initContent // method - ditto
  6719. , addPane: addPane // method - pass a 'pane'
  6720. , removePane: removePane // method - pass a 'pane' to remove from layout, add 'true' to delete the pane-elem
  6721. , createChildren: createChildren // method - pass a 'pane' and (optional) layout-options (OVERRIDES options[pane].children
  6722. , refreshChildren: refreshChildren // method - pass a 'pane' and a layout-instance
  6723. // special pane option setting
  6724. , enableClosable: enableClosable // method - pass a 'pane'
  6725. , disableClosable: disableClosable // method - ditto
  6726. , enableSlidable: enableSlidable // method - ditto
  6727. , disableSlidable: disableSlidable // method - ditto
  6728. , enableResizable: enableResizable // method - ditto
  6729. , disableResizable: disableResizable// method - ditto
  6730. // utility methods for panes
  6731. , allowOverflow: allowOverflow // utility - pass calling element (this)
  6732. , resetOverflow: resetOverflow // utility - ditto
  6733. // layout control
  6734. , destroy: destroy // method - no parameters
  6735. , initPanes: isInitialized // method - no parameters
  6736. , resizeAll: resizeAll // method - no parameters
  6737. // callback triggering
  6738. , runCallbacks: _runCallbacks // method - pass evtName & pane (if a pane-event), eg: trigger("onopen", "west")
  6739. // alias collections of options, state and children - created in addPane and extended elsewhere
  6740. , hasParentLayout: false // set by initContainer()
  6741. , children: children // pointers to child-layouts, eg: Instance.children.west.layoutName
  6742. , north: false // alias group: { name: pane, pane: $Ps[pane], options: options[pane], state: state[pane], children: children[pane] }
  6743. , south: false // ditto
  6744. , west: false // ditto
  6745. , east: false // ditto
  6746. , center: false // ditto
  6747. };
  6748. // create the border layout NOW
  6749. if (_create() === 'cancel') // onload_start callback returned false to CANCEL layout creation
  6750. return null;
  6751. else // true OR false -- if layout-elements did NOT init (hidden or do not exist), can auto-init later
  6752. return Instance; // return the Instance object
  6753. }
  6754. })( jQuery );
  6755. // END Layout - keep internal vars internal!
  6756. // START Plugins - shared wrapper, no global vars
  6757. (function ($) {
  6758. /**
  6759. * jquery.layout.state 1.0
  6760. * $Date: 2011-07-16 08:00:00 (Sat, 16 July 2011) $
  6761. *
  6762. * Copyright (c) 2012
  6763. * Kevin Dalman (http://allpro.net)
  6764. *
  6765. * Dual licensed under the GPL (http://www.gnu.org/licenses/gpl.html)
  6766. * and MIT (http://www.opensource.org/licenses/mit-license.php) licenses.
  6767. *
  6768. * @requires: UI Layout 1.3.0.rc30.1 or higher
  6769. * @requires: $.ui.cookie (above)
  6770. *
  6771. * @see: http://groups.google.com/group/jquery-ui-layout
  6772. */
  6773. /*
  6774. * State-management options stored in options.stateManagement, which includes a .cookie hash
  6775. * Default options saves ALL KEYS for ALL PANES, ie: pane.size, pane.isClosed, pane.isHidden
  6776. *
  6777. * // STATE/COOKIE OPTIONS
  6778. * @example $(el).layout({
  6779. stateManagement: {
  6780. enabled: true
  6781. , stateKeys: "east.size,west.size,east.isClosed,west.isClosed"
  6782. , cookie: { name: "appLayout", path: "/" }
  6783. }
  6784. })
  6785. * @example $(el).layout({ stateManagement__enabled: true }) // enable auto-state-management using cookies
  6786. * @example $(el).layout({ stateManagement__cookie: { name: "appLayout", path: "/" } })
  6787. * @example $(el).layout({ stateManagement__cookie__name: "appLayout", stateManagement__cookie__path: "/" })
  6788. *
  6789. * // STATE/COOKIE METHODS
  6790. * @example myLayout.saveCookie( "west.isClosed,north.size,south.isHidden", {expires: 7} );
  6791. * @example myLayout.loadCookie();
  6792. * @example myLayout.deleteCookie();
  6793. * @example var JSON = myLayout.readState(); // CURRENT Layout State
  6794. * @example var JSON = myLayout.readCookie(); // SAVED Layout State (from cookie)
  6795. * @example var JSON = myLayout.state.stateData; // LAST LOADED Layout State (cookie saved in layout.state hash)
  6796. *
  6797. * CUSTOM STATE-MANAGEMENT (eg, saved in a database)
  6798. * @example var JSON = myLayout.readState( "west.isClosed,north.size,south.isHidden" );
  6799. * @example myLayout.loadState( JSON );
  6800. */
  6801. /**
  6802. * UI COOKIE UTILITY
  6803. *
  6804. * A $.cookie OR $.ui.cookie namespace *should be standard*, but until then...
  6805. * This creates $.ui.cookie so Layout does not need the cookie.jquery.js plugin
  6806. * NOTE: This utility is REQUIRED by the layout.state plugin
  6807. *
  6808. * Cookie methods in Layout are created as part of State Management
  6809. */
  6810. if (!$.ui) $.ui = {};
  6811. $.ui.cookie = {
  6812. // cookieEnabled is not in DOM specs, but DOES works in all browsers,including IE6
  6813. acceptsCookies: !!navigator.cookieEnabled
  6814. , read: function (name) {
  6815. var c = document.cookie
  6816. , cs = c ? c.split(';') : []
  6817. , pair // loop var
  6818. ;
  6819. for (var i=0, n=cs.length; i < n; i++) {
  6820. pair = $.trim(cs[i]).split('='); // name=value pair
  6821. if (pair[0] == name) // found the layout cookie
  6822. return decodeURIComponent(pair[1]);
  6823. }
  6824. return null;
  6825. }
  6826. , write: function (name, val, cookieOpts) {
  6827. var params = ""
  6828. , date = ""
  6829. , clear = false
  6830. , o = cookieOpts || {}
  6831. , x = o.expires || null
  6832. , t = $.type(x)
  6833. ;
  6834. if (t === "date")
  6835. date = x;
  6836. else if (t === "string" && x > 0) {
  6837. x = parseInt(x,10);
  6838. t = "number";
  6839. }
  6840. if (t === "number") {
  6841. date = new Date();
  6842. if (x > 0)
  6843. date.setDate(date.getDate() + x);
  6844. else {
  6845. date.setFullYear(1970);
  6846. clear = true;
  6847. }
  6848. }
  6849. if (date) params += ";expires="+ date.toUTCString();
  6850. if (o.path) params += ";path="+ o.path;
  6851. if (o.domain) params += ";domain="+ o.domain;
  6852. if (o.secure) params += ";secure";
  6853. document.cookie = name +"="+ (clear ? "" : encodeURIComponent( val )) + params; // write or clear cookie
  6854. }
  6855. , clear: function (name) {
  6856. $.ui.cookie.write(name, "", {expires: -1});
  6857. }
  6858. };
  6859. // if cookie.jquery.js is not loaded, create an alias to replicate it
  6860. // this may be useful to other plugins or code dependent on that plugin
  6861. if (!$.cookie) $.cookie = function (k, v, o) {
  6862. var C = $.ui.cookie;
  6863. if (v === null)
  6864. C.clear(k);
  6865. else if (v === undefined)
  6866. return C.read(k);
  6867. else
  6868. C.write(k, v, o);
  6869. };
  6870. // tell Layout that the state plugin is available
  6871. $.layout.plugins.stateManagement = true;
  6872. // Add State-Management options to layout.defaults
  6873. $.layout.config.optionRootKeys.push("stateManagement");
  6874. $.layout.defaults.stateManagement = {
  6875. enabled: false // true = enable state-management, even if not using cookies
  6876. , autoSave: true // Save a state-cookie when page exits?
  6877. , autoLoad: true // Load the state-cookie when Layout inits?
  6878. , animateLoad: true // animate panes when loading state into an active layout
  6879. , includeChildren: true // recurse into child layouts to include their state as well
  6880. // List state-data to save - must be pane-specific
  6881. , stateKeys: "north.size,south.size,east.size,west.size,"+
  6882. "north.isClosed,south.isClosed,east.isClosed,west.isClosed,"+
  6883. "north.isHidden,south.isHidden,east.isHidden,west.isHidden"
  6884. , cookie: {
  6885. name: "" // If not specified, will use Layout.name, else just "Layout"
  6886. , domain: "" // blank = current domain
  6887. , path: "" // blank = current page, "/" = entire website
  6888. , expires: "" // 'days' to keep cookie - leave blank for 'session cookie'
  6889. , secure: false
  6890. }
  6891. };
  6892. // Set stateManagement as a layout-option, NOT a pane-option
  6893. $.layout.optionsMap.layout.push("stateManagement");
  6894. /*
  6895. * State Management methods
  6896. */
  6897. $.layout.state = {
  6898. /**
  6899. * Get the current layout state and save it to a cookie
  6900. *
  6901. * myLayout.saveCookie( keys, cookieOpts )
  6902. *
  6903. * @param {Object} inst
  6904. * @param {(string|Array)=} keys
  6905. * @param {Object=} cookieOpts
  6906. */
  6907. saveCookie: function (inst, keys, cookieOpts) {
  6908. var o = inst.options
  6909. , sm = o.stateManagement
  6910. , oC = $.extend(true, {}, sm.cookie, cookieOpts || null)
  6911. , data = inst.state.stateData = inst.readState( keys || sm.stateKeys ) // read current panes-state
  6912. ;
  6913. $.ui.cookie.write( oC.name || o.name || "Layout", $.layout.state.encodeJSON(data), oC );
  6914. return $.extend(true, {}, data); // return COPY of state.stateData data
  6915. }
  6916. /**
  6917. * Remove the state cookie
  6918. *
  6919. * @param {Object} inst
  6920. */
  6921. , deleteCookie: function (inst) {
  6922. var o = inst.options;
  6923. $.ui.cookie.clear( o.stateManagement.cookie.name || o.name || "Layout" );
  6924. }
  6925. /**
  6926. * Read & return data from the cookie - as JSON
  6927. *
  6928. * @param {Object} inst
  6929. */
  6930. , readCookie: function (inst) {
  6931. var o = inst.options;
  6932. var c = $.ui.cookie.read( o.stateManagement.cookie.name || o.name || "Layout" );
  6933. // convert cookie string back to a hash and return it
  6934. return c ? $.layout.state.decodeJSON(c) : {};
  6935. }
  6936. /**
  6937. * Get data from the cookie and USE IT to loadState
  6938. *
  6939. * @param {Object} inst
  6940. */
  6941. , loadCookie: function (inst) {
  6942. var c = $.layout.state.readCookie(inst); // READ the cookie
  6943. if (c) {
  6944. inst.state.stateData = $.extend(true, {}, c); // SET state.stateData
  6945. inst.loadState(c); // LOAD the retrieved state
  6946. }
  6947. return c;
  6948. }
  6949. /**
  6950. * Update layout options from the cookie, if one exists
  6951. *
  6952. * @param {Object} inst
  6953. * @param {Object=} stateData
  6954. * @param {boolean=} animate
  6955. */
  6956. , loadState: function (inst, data, opts) {
  6957. if (!$.isPlainObject( data ) || $.isEmptyObject( data )) return;
  6958. // normalize data & cache in the state object
  6959. data = inst.state.stateData = $.layout.transformData( data ); // panes = default subkey
  6960. // add missing/default state-restore options
  6961. var smo = inst.options.stateManagement;
  6962. opts = $.extend({
  6963. animateLoad: false //smo.animateLoad
  6964. , includeChildren: smo.includeChildren
  6965. }, opts );
  6966. if (!inst.state.initialized) {
  6967. /*
  6968. * layout NOT initialized, so just update its options
  6969. */
  6970. // MUST remove pane.children keys before applying to options
  6971. // use a copy so we don't remove keys from original data
  6972. var o = $.extend(true, {}, data);
  6973. //delete o.center; // center has no state-data - only children
  6974. $.each($.layout.config.allPanes, function (idx, pane) {
  6975. if (o[pane]) delete o[pane].children;
  6976. });
  6977. // update CURRENT layout-options with saved state data
  6978. $.extend(true, inst.options, o);
  6979. }
  6980. else {
  6981. /*
  6982. * layout already initialized, so modify layout's configuration
  6983. */
  6984. var noAnimate = !opts.animateLoad
  6985. , o, c, h, state, open
  6986. ;
  6987. $.each($.layout.config.borderPanes, function (idx, pane) {
  6988. o = data[ pane ];
  6989. if (!$.isPlainObject( o )) return; // no key, skip pane
  6990. s = o.size;
  6991. c = o.initClosed;
  6992. h = o.initHidden;
  6993. ar = o.autoResize
  6994. state = inst.state[pane];
  6995. open = state.isVisible;
  6996. // reset autoResize
  6997. if (ar)
  6998. state.autoResize = ar;
  6999. // resize BEFORE opening
  7000. if (!open)
  7001. inst._sizePane(pane, s, false, false, false); // false=skipCallback/noAnimation/forceResize
  7002. // open/close as necessary - DO NOT CHANGE THIS ORDER!
  7003. if (h === true) inst.hide(pane, noAnimate);
  7004. else if (c === true) inst.close(pane, false, noAnimate);
  7005. else if (c === false) inst.open (pane, false, noAnimate);
  7006. else if (h === false) inst.show (pane, false, noAnimate);
  7007. // resize AFTER any other actions
  7008. if (open)
  7009. inst._sizePane(pane, s, false, false, noAnimate); // animate resize if option passed
  7010. });
  7011. /*
  7012. * RECURSE INTO CHILD-LAYOUTS
  7013. */
  7014. if (opts.includeChildren) {
  7015. var paneStateChildren, childState;
  7016. $.each(inst.children, function (pane, paneChildren) {
  7017. paneStateChildren = data[pane] ? data[pane].children : 0;
  7018. if (paneStateChildren && paneChildren) {
  7019. $.each(paneChildren, function (stateKey, child) {
  7020. childState = paneStateChildren[stateKey];
  7021. if (child && childState)
  7022. child.loadState( childState );
  7023. });
  7024. }
  7025. });
  7026. }
  7027. }
  7028. }
  7029. /**
  7030. * Get the *current layout state* and return it as a hash
  7031. *
  7032. * @param {Object=} inst // Layout instance to get state for
  7033. * @param {object=} [opts] // State-Managements override options
  7034. */
  7035. , readState: function (inst, opts) {
  7036. // backward compatility
  7037. if ($.type(opts) === 'string') opts = { keys: opts };
  7038. if (!opts) opts = {};
  7039. var sm = inst.options.stateManagement
  7040. , ic = opts.includeChildren
  7041. , recurse = ic !== undefined ? ic : sm.includeChildren
  7042. , keys = opts.stateKeys || sm.stateKeys
  7043. , alt = { isClosed: 'initClosed', isHidden: 'initHidden' }
  7044. , state = inst.state
  7045. , panes = $.layout.config.allPanes
  7046. , data = {}
  7047. , pair, pane, key, val
  7048. , ps, pC, child, array, count, branch
  7049. ;
  7050. if ($.isArray(keys)) keys = keys.join(",");
  7051. // convert keys to an array and change delimiters from '__' to '.'
  7052. keys = keys.replace(/__/g, ".").split(',');
  7053. // loop keys and create a data hash
  7054. for (var i=0, n=keys.length; i < n; i++) {
  7055. pair = keys[i].split(".");
  7056. pane = pair[0];
  7057. key = pair[1];
  7058. if ($.inArray(pane, panes) < 0) continue; // bad pane!
  7059. val = state[ pane ][ key ];
  7060. if (val == undefined) continue;
  7061. if (key=="isClosed" && state[pane]["isSliding"])
  7062. val = true; // if sliding, then *really* isClosed
  7063. ( data[pane] || (data[pane]={}) )[ alt[key] ? alt[key] : key ] = val;
  7064. }
  7065. // recurse into the child-layouts for each pane
  7066. if (recurse) {
  7067. $.each(panes, function (idx, pane) {
  7068. pC = inst.children[pane];
  7069. ps = state.stateData[pane];
  7070. if ($.isPlainObject( pC ) && !$.isEmptyObject( pC )) {
  7071. // ensure a key exists for this 'pane', eg: branch = data.center
  7072. branch = data[pane] || (data[pane] = {});
  7073. if (!branch.children) branch.children = {};
  7074. $.each( pC, function (key, child) {
  7075. // ONLY read state from an initialize layout
  7076. if ( child.state.initialized )
  7077. branch.children[ key ] = $.layout.state.readState( child );
  7078. // if we have PREVIOUS (onLoad) state for this child-layout, KEEP IT!
  7079. else if ( ps && ps.children && ps.children[ key ] ) {
  7080. branch.children[ key ] = $.extend(true, {}, ps.children[ key ] );
  7081. }
  7082. });
  7083. }
  7084. });
  7085. }
  7086. return data;
  7087. }
  7088. /**
  7089. * Stringify a JSON hash so can save in a cookie or db-field
  7090. */
  7091. , encodeJSON: function (JSON) {
  7092. return parse(JSON);
  7093. function parse (h) {
  7094. var D=[], i=0, k, v, t // k = key, v = value
  7095. , a = $.isArray(h)
  7096. ;
  7097. for (k in h) {
  7098. v = h[k];
  7099. t = typeof v;
  7100. if (t == 'string') // STRING - add quotes
  7101. v = '"'+ v +'"';
  7102. else if (t == 'object') // SUB-KEY - recurse into it
  7103. v = parse(v);
  7104. D[i++] = (!a ? '"'+ k +'":' : '') + v;
  7105. }
  7106. return (a ? '[' : '{') + D.join(',') + (a ? ']' : '}');
  7107. };
  7108. }
  7109. /**
  7110. * Convert stringified JSON back to a hash object
  7111. * @see $.parseJSON(), adding in jQuery 1.4.1
  7112. */
  7113. , decodeJSON: function (str) {
  7114. try { return $.parseJSON ? $.parseJSON(str) : window["eval"]("("+ str +")") || {}; }
  7115. catch (e) { return {}; }
  7116. }
  7117. , _create: function (inst) {
  7118. var _ = $.layout.state
  7119. , o = inst.options
  7120. , sm = o.stateManagement
  7121. ;
  7122. // ADD State-Management plugin methods to inst
  7123. $.extend( inst, {
  7124. // readCookie - update options from cookie - returns hash of cookie data
  7125. readCookie: function () { return _.readCookie(inst); }
  7126. // deleteCookie
  7127. , deleteCookie: function () { _.deleteCookie(inst); }
  7128. // saveCookie - optionally pass keys-list and cookie-options (hash)
  7129. , saveCookie: function (keys, cookieOpts) { return _.saveCookie(inst, keys, cookieOpts); }
  7130. // loadCookie - readCookie and use to loadState() - returns hash of cookie data
  7131. , loadCookie: function () { return _.loadCookie(inst); }
  7132. // loadState - pass a hash of state to use to update options
  7133. , loadState: function (stateData, opts) { _.loadState(inst, stateData, opts); }
  7134. // readState - returns hash of current layout-state
  7135. , readState: function (keys) { return _.readState(inst, keys); }
  7136. // add JSON utility methods too...
  7137. , encodeJSON: _.encodeJSON
  7138. , decodeJSON: _.decodeJSON
  7139. });
  7140. // init state.stateData key, even if plugin is initially disabled
  7141. inst.state.stateData = {};
  7142. // autoLoad MUST BE one of: data-array, data-hash, callback-function, or TRUE
  7143. if ( !sm.autoLoad ) return;
  7144. // When state-data exists in the autoLoad key USE IT,
  7145. // even if stateManagement.enabled == false
  7146. if ($.isPlainObject( sm.autoLoad )) {
  7147. if (!$.isEmptyObject( sm.autoLoad )) {
  7148. inst.loadState( sm.autoLoad );
  7149. }
  7150. }
  7151. else if ( sm.enabled ) {
  7152. // update the options from cookie or callback
  7153. // if options is a function, call it to get stateData
  7154. if ($.isFunction( sm.autoLoad )) {
  7155. var d = {};
  7156. try {
  7157. d = sm.autoLoad( inst, inst.state, inst.options, inst.options.name || '' ); // try to get data from fn
  7158. } catch (e) {}
  7159. if (d && $.isPlainObject( d ) && !$.isEmptyObject( d ))
  7160. inst.loadState(d);
  7161. }
  7162. else // any other truthy value will trigger loadCookie
  7163. inst.loadCookie();
  7164. }
  7165. }
  7166. , _unload: function (inst) {
  7167. var sm = inst.options.stateManagement;
  7168. if (sm.enabled && sm.autoSave) {
  7169. // if options is a function, call it to save the stateData
  7170. if ($.isFunction( sm.autoSave )) {
  7171. try {
  7172. sm.autoSave( inst, inst.state, inst.options, inst.options.name || '' ); // try to get data from fn
  7173. } catch (e) {}
  7174. }
  7175. else // any truthy value will trigger saveCookie
  7176. inst.saveCookie();
  7177. }
  7178. }
  7179. };
  7180. // add state initialization method to Layout's onCreate array of functions
  7181. $.layout.onCreate.push( $.layout.state._create );
  7182. $.layout.onUnload.push( $.layout.state._unload );
  7183. /**
  7184. * jquery.layout.buttons 1.0
  7185. * $Date: 2011-07-16 08:00:00 (Sat, 16 July 2011) $
  7186. *
  7187. * Copyright (c) 2012
  7188. * Kevin Dalman (http://allpro.net)
  7189. *
  7190. * Dual licensed under the GPL (http://www.gnu.org/licenses/gpl.html)
  7191. * and MIT (http://www.opensource.org/licenses/mit-license.php) licenses.
  7192. *
  7193. * @requires: UI Layout 1.3.0.rc30.1 or higher
  7194. *
  7195. * @see: http://groups.google.com/group/jquery-ui-layout
  7196. *
  7197. * Docs: [ to come ]
  7198. * Tips: [ to come ]
  7199. */
  7200. // tell Layout that the state plugin is available
  7201. $.layout.plugins.buttons = true;
  7202. // Add buttons options to layout.defaults
  7203. $.layout.defaults.autoBindCustomButtons = false;
  7204. // Specify autoBindCustomButtons as a layout-option, NOT a pane-option
  7205. $.layout.optionsMap.layout.push("autoBindCustomButtons");
  7206. /*
  7207. * Button methods
  7208. */
  7209. $.layout.buttons = {
  7210. /**
  7211. * Searches for .ui-layout-button-xxx elements and auto-binds them as layout-buttons
  7212. *
  7213. * @see _create()
  7214. *
  7215. * @param {Object} inst Layout Instance object
  7216. */
  7217. init: function (inst) {
  7218. var pre = "ui-layout-button-"
  7219. , layout = inst.options.name || ""
  7220. , name;
  7221. $.each("toggle,open,close,pin,toggle-slide,open-slide".split(","), function (i, action) {
  7222. $.each($.layout.config.borderPanes, function (ii, pane) {
  7223. $("."+pre+action+"-"+pane).each(function(){
  7224. // if button was previously 'bound', data.layoutName was set, but is blank if layout has no 'name'
  7225. name = $(this).data("layoutName") || $(this).attr("layoutName");
  7226. if (name == undefined || name === layout)
  7227. inst.bindButton(this, action, pane);
  7228. });
  7229. });
  7230. });
  7231. }
  7232. /**
  7233. * Helper function to validate params received by addButton utilities
  7234. *
  7235. * Two classes are added to the element, based on the buttonClass...
  7236. * The type of button is appended to create the 2nd className:
  7237. * - ui-layout-button-pin // action btnClass
  7238. * - ui-layout-button-pin-west // action btnClass + pane
  7239. * - ui-layout-button-toggle
  7240. * - ui-layout-button-open
  7241. * - ui-layout-button-close
  7242. *
  7243. * @param {Object} inst Layout Instance object
  7244. * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button"
  7245. * @param {string} pane Name of the pane the button is for: 'north', 'south', etc.
  7246. *
  7247. * @return {Array.<Object>} If both params valid, the element matching 'selector' in a jQuery wrapper - otherwise returns null
  7248. */
  7249. , get: function (inst, selector, pane, action) {
  7250. var $E = $(selector)
  7251. , o = inst.options
  7252. , err = o.errors.addButtonError
  7253. ;
  7254. if (!$E.length) { // element not found
  7255. $.layout.msg(err +" "+ o.errors.selector +": "+ selector, true);
  7256. }
  7257. else if ($.inArray(pane, $.layout.config.borderPanes) < 0) { // invalid 'pane' sepecified
  7258. $.layout.msg(err +" "+ o.errors.pane +": "+ pane, true);
  7259. $E = $(""); // NO BUTTON
  7260. }
  7261. else { // VALID
  7262. var btn = o[pane].buttonClass +"-"+ action;
  7263. $E .addClass( btn +" "+ btn +"-"+ pane )
  7264. .data("layoutName", o.name); // add layout identifier - even if blank!
  7265. }
  7266. return $E;
  7267. }
  7268. /**
  7269. * NEW syntax for binding layout-buttons - will eventually replace addToggle, addOpen, etc.
  7270. *
  7271. * @param {Object} inst Layout Instance object
  7272. * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button"
  7273. * @param {string} action
  7274. * @param {string} pane
  7275. */
  7276. , bind: function (inst, selector, action, pane) {
  7277. var _ = $.layout.buttons;
  7278. switch (action.toLowerCase()) {
  7279. case "toggle": _.addToggle (inst, selector, pane); break;
  7280. case "open": _.addOpen (inst, selector, pane); break;
  7281. case "close": _.addClose (inst, selector, pane); break;
  7282. case "pin": _.addPin (inst, selector, pane); break;
  7283. case "toggle-slide": _.addToggle (inst, selector, pane, true); break;
  7284. case "open-slide": _.addOpen (inst, selector, pane, true); break;
  7285. }
  7286. return inst;
  7287. }
  7288. /**
  7289. * Add a custom Toggler button for a pane
  7290. *
  7291. * @param {Object} inst Layout Instance object
  7292. * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button"
  7293. * @param {string} pane Name of the pane the button is for: 'north', 'south', etc.
  7294. * @param {boolean=} slide true = slide-open, false = pin-open
  7295. */
  7296. , addToggle: function (inst, selector, pane, slide) {
  7297. $.layout.buttons.get(inst, selector, pane, "toggle")
  7298. .click(function(evt){
  7299. inst.toggle(pane, !!slide);
  7300. evt.stopPropagation();
  7301. });
  7302. return inst;
  7303. }
  7304. /**
  7305. * Add a custom Open button for a pane
  7306. *
  7307. * @param {Object} inst Layout Instance object
  7308. * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button"
  7309. * @param {string} pane Name of the pane the button is for: 'north', 'south', etc.
  7310. * @param {boolean=} slide true = slide-open, false = pin-open
  7311. */
  7312. , addOpen: function (inst, selector, pane, slide) {
  7313. $.layout.buttons.get(inst, selector, pane, "open")
  7314. .attr("title", inst.options[pane].tips.Open)
  7315. .click(function (evt) {
  7316. inst.open(pane, !!slide);
  7317. evt.stopPropagation();
  7318. });
  7319. return inst;
  7320. }
  7321. /**
  7322. * Add a custom Close button for a pane
  7323. *
  7324. * @param {Object} inst Layout Instance object
  7325. * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button"
  7326. * @param {string} pane Name of the pane the button is for: 'north', 'south', etc.
  7327. */
  7328. , addClose: function (inst, selector, pane) {
  7329. $.layout.buttons.get(inst, selector, pane, "close")
  7330. .attr("title", inst.options[pane].tips.Close)
  7331. .click(function (evt) {
  7332. inst.close(pane);
  7333. evt.stopPropagation();
  7334. });
  7335. return inst;
  7336. }
  7337. /**
  7338. * Add a custom Pin button for a pane
  7339. *
  7340. * Four classes are added to the element, based on the paneClass for the associated pane...
  7341. * Assuming the default paneClass and the pin is 'up', these classes are added for a west-pane pin:
  7342. * - ui-layout-pane-pin
  7343. * - ui-layout-pane-west-pin
  7344. * - ui-layout-pane-pin-up
  7345. * - ui-layout-pane-west-pin-up
  7346. *
  7347. * @param {Object} inst Layout Instance object
  7348. * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button"
  7349. * @param {string} pane Name of the pane the pin is for: 'north', 'south', etc.
  7350. */
  7351. , addPin: function (inst, selector, pane) {
  7352. var _ = $.layout.buttons
  7353. , $E = _.get(inst, selector, pane, "pin");
  7354. if ($E.length) {
  7355. var s = inst.state[pane];
  7356. $E.click(function (evt) {
  7357. _.setPinState(inst, $(this), pane, (s.isSliding || s.isClosed));
  7358. if (s.isSliding || s.isClosed) inst.open( pane ); // change from sliding to open
  7359. else inst.close( pane ); // slide-closed
  7360. evt.stopPropagation();
  7361. });
  7362. // add up/down pin attributes and classes
  7363. _.setPinState(inst, $E, pane, (!s.isClosed && !s.isSliding));
  7364. // add this pin to the pane data so we can 'sync it' automatically
  7365. // PANE.pins key is an array so we can store multiple pins for each pane
  7366. s.pins.push( selector ); // just save the selector string
  7367. }
  7368. return inst;
  7369. }
  7370. /**
  7371. * Change the class of the pin button to make it look 'up' or 'down'
  7372. *
  7373. * @see addPin(), syncPins()
  7374. *
  7375. * @param {Object} inst Layout Instance object
  7376. * @param {Array.<Object>} $Pin The pin-span element in a jQuery wrapper
  7377. * @param {string} pane These are the params returned to callbacks by layout()
  7378. * @param {boolean} doPin true = set the pin 'down', false = set it 'up'
  7379. */
  7380. , setPinState: function (inst, $Pin, pane, doPin) {
  7381. var updown = $Pin.attr("pin");
  7382. if (updown && doPin === (updown=="down")) return; // already in correct state
  7383. var
  7384. o = inst.options[pane]
  7385. , pin = o.buttonClass +"-pin"
  7386. , side = pin +"-"+ pane
  7387. , UP = pin +"-up "+ side +"-up"
  7388. , DN = pin +"-down "+side +"-down"
  7389. ;
  7390. $Pin
  7391. .attr("pin", doPin ? "down" : "up") // logic
  7392. .attr("title", doPin ? o.tips.Unpin : o.tips.Pin)
  7393. .removeClass( doPin ? UP : DN )
  7394. .addClass( doPin ? DN : UP )
  7395. ;
  7396. }
  7397. /**
  7398. * INTERNAL function to sync 'pin buttons' when pane is opened or closed
  7399. * Unpinned means the pane is 'sliding' - ie, over-top of the adjacent panes
  7400. *
  7401. * @see open(), close()
  7402. *
  7403. * @param {Object} inst Layout Instance object
  7404. * @param {string} pane These are the params returned to callbacks by layout()
  7405. * @param {boolean} doPin True means set the pin 'down', False means 'up'
  7406. */
  7407. , syncPinBtns: function (inst, pane, doPin) {
  7408. // REAL METHOD IS _INSIDE_ LAYOUT - THIS IS HERE JUST FOR REFERENCE
  7409. $.each(inst.state[pane].pins, function (i, selector) {
  7410. $.layout.buttons.setPinState(inst, $(selector), pane, doPin);
  7411. });
  7412. }
  7413. , _load: function (inst) {
  7414. var _ = $.layout.buttons;
  7415. // ADD Button methods to Layout Instance
  7416. // Note: sel = jQuery Selector string
  7417. $.extend( inst, {
  7418. bindButton: function (sel, action, pane) { return _.bind(inst, sel, action, pane); }
  7419. // DEPRECATED METHODS
  7420. , addToggleBtn: function (sel, pane, slide) { return _.addToggle(inst, sel, pane, slide); }
  7421. , addOpenBtn: function (sel, pane, slide) { return _.addOpen(inst, sel, pane, slide); }
  7422. , addCloseBtn: function (sel, pane) { return _.addClose(inst, sel, pane); }
  7423. , addPinBtn: function (sel, pane) { return _.addPin(inst, sel, pane); }
  7424. });
  7425. // init state array to hold pin-buttons
  7426. for (var i=0; i<4; i++) {
  7427. var pane = $.layout.config.borderPanes[i];
  7428. inst.state[pane].pins = [];
  7429. }
  7430. // auto-init buttons onLoad if option is enabled
  7431. if ( inst.options.autoBindCustomButtons )
  7432. _.init(inst);
  7433. }
  7434. , _unload: function (inst) {
  7435. // TODO: unbind all buttons???
  7436. }
  7437. };
  7438. // add initialization method to Layout's onLoad array of functions
  7439. $.layout.onLoad.push( $.layout.buttons._load );
  7440. //$.layout.onUnload.push( $.layout.buttons._unload );
  7441. /**
  7442. * jquery.layout.browserZoom 1.0
  7443. * $Date: 2011-12-29 08:00:00 (Thu, 29 Dec 2011) $
  7444. *
  7445. * Copyright (c) 2012
  7446. * Kevin Dalman (http://allpro.net)
  7447. *
  7448. * Dual licensed under the GPL (http://www.gnu.org/licenses/gpl.html)
  7449. * and MIT (http://www.opensource.org/licenses/mit-license.php) licenses.
  7450. *
  7451. * @requires: UI Layout 1.3.0.rc30.1 or higher
  7452. *
  7453. * @see: http://groups.google.com/group/jquery-ui-layout
  7454. *
  7455. * TODO: Extend logic to handle other problematic zooming in browsers
  7456. * TODO: Add hotkey/mousewheel bindings to _instantly_ respond to these zoom event
  7457. */
  7458. // tell Layout that the plugin is available
  7459. $.layout.plugins.browserZoom = true;
  7460. $.layout.defaults.browserZoomCheckInterval = 1000;
  7461. $.layout.optionsMap.layout.push("browserZoomCheckInterval");
  7462. /*
  7463. * browserZoom methods
  7464. */
  7465. $.layout.browserZoom = {
  7466. _init: function (inst) {
  7467. // abort if browser does not need this check
  7468. if ($.layout.browserZoom.ratio() !== false)
  7469. $.layout.browserZoom._setTimer(inst);
  7470. }
  7471. , _setTimer: function (inst) {
  7472. // abort if layout destroyed or browser does not need this check
  7473. if (inst.destroyed) return;
  7474. var o = inst.options
  7475. , s = inst.state
  7476. // don't need check if inst has parentLayout, but check occassionally in case parent destroyed!
  7477. // MINIMUM 100ms interval, for performance
  7478. , ms = inst.hasParentLayout ? 5000 : Math.max( o.browserZoomCheckInterval, 100 )
  7479. ;
  7480. // set the timer
  7481. setTimeout(function(){
  7482. if (inst.destroyed || !o.resizeWithWindow) return;
  7483. var d = $.layout.browserZoom.ratio();
  7484. if (d !== s.browserZoom) {
  7485. s.browserZoom = d;
  7486. inst.resizeAll();
  7487. }
  7488. // set a NEW timeout
  7489. $.layout.browserZoom._setTimer(inst);
  7490. }
  7491. , ms );
  7492. }
  7493. , ratio: function () {
  7494. var w = window
  7495. , s = screen
  7496. , d = document
  7497. , dE = d.documentElement || d.body
  7498. , b = $.layout.browser
  7499. , v = b.version
  7500. , r, sW, cW
  7501. ;
  7502. // we can ignore all browsers that fire window.resize event onZoom
  7503. if ((b.msie && v > 8)
  7504. || !b.msie
  7505. ) return false; // don't need to track zoom
  7506. if (s.deviceXDPI && s.systemXDPI) // syntax compiler hack
  7507. return calc(s.deviceXDPI, s.systemXDPI);
  7508. // everything below is just for future reference!
  7509. if (b.webkit && (r = d.body.getBoundingClientRect))
  7510. return calc((r.left - r.right), d.body.offsetWidth);
  7511. if (b.webkit && (sW = w.outerWidth))
  7512. return calc(sW, w.innerWidth);
  7513. if ((sW = s.width) && (cW = dE.clientWidth))
  7514. return calc(sW, cW);
  7515. return false; // no match, so cannot - or don't need to - track zoom
  7516. function calc (x,y) { return (parseInt(x,10) / parseInt(y,10) * 100).toFixed(); }
  7517. }
  7518. };
  7519. // add initialization method to Layout's onLoad array of functions
  7520. $.layout.onReady.push( $.layout.browserZoom._init );
  7521. })( jQuery );