jquery-layout.js 271 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503
  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. // console.log("_over", this.element[0]);
  1917. var draggable = $.ui.ddmanager.current;
  1918. // Bail if draggable and droppable are same element
  1919. if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
  1920. return;
  1921. }
  1922. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  1923. if ( this.options.hoverClass ) {
  1924. this.element.addClass( this.options.hoverClass );
  1925. }
  1926. this._trigger( "over", event, this.ui( draggable ) );
  1927. }
  1928. },
  1929. _out: function( event ) {
  1930. var draggable = $.ui.ddmanager.current;
  1931. // Bail if draggable and droppable are same element
  1932. if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
  1933. return;
  1934. }
  1935. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  1936. if ( this.options.hoverClass ) {
  1937. this.element.removeClass( this.options.hoverClass );
  1938. }
  1939. this._trigger( "out", event, this.ui( draggable ) );
  1940. }
  1941. },
  1942. _drop: function( event, custom ) {
  1943. var draggable = custom || $.ui.ddmanager.current,
  1944. childrenIntersection = false;
  1945. // Bail if draggable and droppable are same element
  1946. if ( !draggable || ( draggable.currentItem || draggable.element )[ 0 ] === this.element[ 0 ] ) {
  1947. return false;
  1948. }
  1949. this.element.find( ":data(ui-droppable)" ).not( ".ui-draggable-dragging" ).each(function() {
  1950. var inst = $( this ).droppable( "instance" );
  1951. if (
  1952. inst.options.greedy &&
  1953. !inst.options.disabled &&
  1954. inst.options.scope === draggable.options.scope &&
  1955. inst.accept.call( inst.element[ 0 ], ( draggable.currentItem || draggable.element ) ) &&
  1956. $.ui.intersect( draggable, $.extend( inst, { offset: inst.element.offset() } ), inst.options.tolerance, event )
  1957. ) { childrenIntersection = true; return false; }
  1958. });
  1959. if ( childrenIntersection ) {
  1960. return false;
  1961. }
  1962. if ( this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  1963. if ( this.options.activeClass ) {
  1964. this.element.removeClass( this.options.activeClass );
  1965. }
  1966. if ( this.options.hoverClass ) {
  1967. this.element.removeClass( this.options.hoverClass );
  1968. }
  1969. this._trigger( "drop", event, this.ui( draggable ) );
  1970. return this.element;
  1971. }
  1972. return false;
  1973. },
  1974. ui: function( c ) {
  1975. return {
  1976. draggable: ( c.currentItem || c.element ),
  1977. helper: c.helper,
  1978. position: c.position,
  1979. offset: c.positionAbs
  1980. };
  1981. }
  1982. });
  1983. $.ui.intersect = (function() {
  1984. function isOverAxis( x, reference, size ) {
  1985. return ( x >= reference ) && ( x < ( reference + size ) );
  1986. }
  1987. return function( draggable, droppable, toleranceMode, event ) {
  1988. if ( !droppable.offset ) {
  1989. return false;
  1990. }
  1991. var x1 = ( draggable.positionAbs || draggable.position.absolute ).left + draggable.margins.left,
  1992. y1 = ( draggable.positionAbs || draggable.position.absolute ).top + draggable.margins.top,
  1993. x2 = x1 + draggable.helperProportions.width,
  1994. y2 = y1 + draggable.helperProportions.height,
  1995. l = droppable.offset.left,
  1996. t = droppable.offset.top,
  1997. r = l + droppable.proportions().width,
  1998. b = t + droppable.proportions().height;
  1999. switch ( toleranceMode ) {
  2000. case "fit":
  2001. return ( l <= x1 && x2 <= r && t <= y1 && y2 <= b );
  2002. case "intersect":
  2003. return ( l < x1 + ( draggable.helperProportions.width / 2 ) && // Right Half
  2004. x2 - ( draggable.helperProportions.width / 2 ) < r && // Left Half
  2005. t < y1 + ( draggable.helperProportions.height / 2 ) && // Bottom Half
  2006. y2 - ( draggable.helperProportions.height / 2 ) < b ); // Top Half
  2007. case "pointer":
  2008. return isOverAxis( event.pageY, t, droppable.proportions().height ) && isOverAxis( event.pageX, l, droppable.proportions().width );
  2009. case "touch":
  2010. return (
  2011. ( y1 >= t && y1 <= b ) || // Top edge touching
  2012. ( y2 >= t && y2 <= b ) || // Bottom edge touching
  2013. ( y1 < t && y2 > b ) // Surrounded vertically
  2014. ) && (
  2015. ( x1 >= l && x1 <= r ) || // Left edge touching
  2016. ( x2 >= l && x2 <= r ) || // Right edge touching
  2017. ( x1 < l && x2 > r ) // Surrounded horizontally
  2018. );
  2019. default:
  2020. return false;
  2021. }
  2022. };
  2023. })();
  2024. /*
  2025. This manager tracks offsets of draggables and droppables
  2026. */
  2027. $.ui.ddmanager = {
  2028. current: null,
  2029. droppables: { "default": [] },
  2030. prepareOffsets: function( t, event ) {
  2031. var i, j,
  2032. m = $.ui.ddmanager.droppables[ t.options.scope ] || [],
  2033. type = event ? event.type : null, // workaround for #2317
  2034. list = ( t.currentItem || t.element ).find( ":data(ui-droppable)" ).addBack();
  2035. droppablesLoop: for ( i = 0; i < m.length; i++ ) {
  2036. // No disabled and non-accepted
  2037. if ( m[ i ].options.disabled || ( t && !m[ i ].accept.call( m[ i ].element[ 0 ], ( t.currentItem || t.element ) ) ) ) {
  2038. continue;
  2039. }
  2040. // Filter out elements in the current dragged item
  2041. for ( j = 0; j < list.length; j++ ) {
  2042. if ( list[ j ] === m[ i ].element[ 0 ] ) {
  2043. m[ i ].proportions().height = 0;
  2044. continue droppablesLoop;
  2045. }
  2046. }
  2047. m[ i ].visible = m[ i ].element.css( "display" ) !== "none";
  2048. if ( !m[ i ].visible ) {
  2049. continue;
  2050. }
  2051. // Activate the droppable if used directly from draggables
  2052. if ( type === "mousedown" ) {
  2053. m[ i ]._activate.call( m[ i ], event );
  2054. }
  2055. m[ i ].offset = m[ i ].element.offset();
  2056. m[ i ].proportions({ width: m[ i ].element[ 0 ].offsetWidth, height: m[ i ].element[ 0 ].offsetHeight });
  2057. }
  2058. },
  2059. drop: function( draggable, event ) {
  2060. var dropped = false;
  2061. // Create a copy of the droppables in case the list changes during the drop (#9116)
  2062. $.each( ( $.ui.ddmanager.droppables[ draggable.options.scope ] || [] ).slice(), function() {
  2063. if ( !this.options ) {
  2064. return;
  2065. }
  2066. if ( !this.options.disabled && this.visible && $.ui.intersect( draggable, this, this.options.tolerance, event ) ) {
  2067. dropped = this._drop.call( this, event ) || dropped;
  2068. }
  2069. if ( !this.options.disabled && this.visible && this.accept.call( this.element[ 0 ], ( draggable.currentItem || draggable.element ) ) ) {
  2070. this.isout = true;
  2071. this.isover = false;
  2072. this._deactivate.call( this, event );
  2073. }
  2074. });
  2075. return dropped;
  2076. },
  2077. dragStart: function( draggable, event ) {
  2078. // Listen for scrolling so that if the dragging causes scrolling the position of the droppables can be recalculated (see #5003)
  2079. draggable.element.parentsUntil( "body" ).bind( "scroll.droppable", function() {
  2080. if ( !draggable.options.refreshPositions ) {
  2081. $.ui.ddmanager.prepareOffsets( draggable, event );
  2082. }
  2083. });
  2084. },
  2085. drag: function( draggable, event ) {
  2086. // If you have a highly dynamic page, you might try this option. It renders positions every time you move the mouse.
  2087. if ( draggable.options.refreshPositions ) {
  2088. $.ui.ddmanager.prepareOffsets( draggable, event );
  2089. }
  2090. var droppables = $.ui.ddmanager.droppables[ draggable.options.scope ] || [];
  2091. // Run through all droppables and check their positions based on specific tolerance options
  2092. $.each( droppables, function() {
  2093. if ( this.options.disabled || this.greedyChild || !this.visible ) {
  2094. return;
  2095. }
  2096. var parentInstance, scope, parent,
  2097. intersects = $.ui.intersect( draggable, this, this.options.tolerance, event ),
  2098. c = !intersects && this.isover ? "isout" : ( intersects && !this.isover ? "isover" : null );
  2099. if ( !c ) {
  2100. return;
  2101. }
  2102. if ( this.options.greedy ) {
  2103. // find droppable parents with same scope
  2104. scope = this.options.scope;
  2105. parent = this.element.parents( ":data(ui-droppable)" ).filter( function() {
  2106. return $( this ).droppable( "instance" ).options.scope === scope;
  2107. } );
  2108. if ( parent.length ) {
  2109. parentInstance = $( parent[ 0 ] ).droppable( "instance" );
  2110. parentInstance.enteredGreedyChild = parentInstance.enteredGreedyChild || ( c === "isover" );
  2111. parentInstance.leftGreedyChild = parentInstance.leftGreedyChild || ( c === "isout" );
  2112. }
  2113. }
  2114. this[ c ] = true;
  2115. this[ c === "isout" ? "isover" : "isout" ] = false;
  2116. this.c = c;
  2117. } );
  2118. $.each( droppables, function() {
  2119. if ( this.enteredGreedyChild ) {
  2120. this.greedyChild = true
  2121. this.isover = false
  2122. this.isout = true
  2123. this.c = "isout"
  2124. }
  2125. // Only move into the parent if we haven't moved into another greedy child
  2126. if ( this.leftGreedyChild && !this.enteredGreedyChild ) {
  2127. this.greedyChild = false
  2128. this.isover = true
  2129. this.isout = false
  2130. this.c = "isover"
  2131. }
  2132. if ( !this.c ) {
  2133. return;
  2134. }
  2135. this[this.c === "isover" ? "_over" : "_out"].call( this, event );
  2136. this.leftGreedyChild = false;
  2137. this.enteredGreedyChild = false;
  2138. this.c = null;
  2139. } );
  2140. },
  2141. dragStop: function( draggable, event ) {
  2142. draggable.element.parentsUntil( "body" ).unbind( "scroll.droppable" );
  2143. // Call prepareOffsets one final time since IE does not fire return scroll events when overflow was caused by drag (see #5003)
  2144. if ( !draggable.options.refreshPositions ) {
  2145. $.ui.ddmanager.prepareOffsets( draggable, event );
  2146. }
  2147. }
  2148. };
  2149. var droppable = $.ui.droppable;
  2150. /**
  2151. * @preserve
  2152. * jquery.layout 1.3.0 - Release Candidate 30.79
  2153. * $Date: 2013-01-12 08:00:00 (Sat, 12 Jan 2013) $
  2154. * $Rev: 303007 $
  2155. *
  2156. * Copyright (c) 2013 Kevin Dalman (http://allpro.net)
  2157. * Based on work by Fabrizio Balliano (http://www.fabrizioballiano.net)
  2158. *
  2159. * Dual licensed under the GPL (http://www.gnu.org/licenses/gpl.html)
  2160. * and MIT (http://www.opensource.org/licenses/mit-license.php) licenses.
  2161. *
  2162. * SEE: http://layout.jquery-dev.net/LICENSE.txt
  2163. *
  2164. * Changelog: http://layout.jquery-dev.net/changelog.cfm#1.3.0.rc30.79
  2165. *
  2166. * Docs: http://layout.jquery-dev.net/documentation.html
  2167. * Tips: http://layout.jquery-dev.net/tips.html
  2168. * Help: http://groups.google.com/group/jquery-ui-layout
  2169. */
  2170. /* JavaDoc Info: http://code.google.com/closure/compiler/docs/js-for-compiler.html
  2171. * {!Object} non-nullable type (never NULL)
  2172. * {?string} nullable type (sometimes NULL) - default for {Object}
  2173. * {number=} optional parameter
  2174. * {*} ALL types
  2175. */
  2176. /* TODO for jQ 2.0
  2177. * change .andSelf() to .addBack()
  2178. * $.fn.disableSelection won't work
  2179. */
  2180. // NOTE: For best readability, view with a fixed-width font and tabs equal to 4-chars
  2181. ;(function ($) {
  2182. // alias Math methods - used a lot!
  2183. var min = Math.min
  2184. , max = Math.max
  2185. , round = Math.floor
  2186. , isStr = function (v) { return $.type(v) === "string"; }
  2187. /**
  2188. * @param {!Object} Instance
  2189. * @param {Array.<string>} a_fn
  2190. */
  2191. , runPluginCallbacks = function (Instance, a_fn) {
  2192. if ($.isArray(a_fn))
  2193. for (var i=0, c=a_fn.length; i<c; i++) {
  2194. var fn = a_fn[i];
  2195. try {
  2196. if (isStr(fn)) // 'name' of a function
  2197. fn = eval(fn);
  2198. if ($.isFunction(fn))
  2199. g(fn)( Instance );
  2200. } catch (ex) {}
  2201. }
  2202. function g (f) { return f; }; // compiler hack
  2203. }
  2204. ;
  2205. /*
  2206. * GENERIC $.layout METHODS - used by all layouts
  2207. */
  2208. $.layout = {
  2209. version: "1.3.rc30.79"
  2210. , revision: 0.033007 // 1.3.0 final = 1.0300 - major(n+).minor(nn)+patch(nn+)
  2211. // $.layout.browser REPLACES $.browser
  2212. , browser: {} // set below
  2213. // *PREDEFINED* EFFECTS & DEFAULTS
  2214. // MUST list effect here - OR MUST set an fxSettings option (can be an empty hash: {})
  2215. , effects: {
  2216. // Pane Open/Close Animations
  2217. slide: {
  2218. all: { duration: "fast" } // eg: duration: 1000, easing: "easeOutBounce"
  2219. , north: { direction: "up" }
  2220. , south: { direction: "down" }
  2221. , east: { direction: "right"}
  2222. , west: { direction: "left" }
  2223. }
  2224. , drop: {
  2225. all: { duration: "slow" }
  2226. , north: { direction: "up" }
  2227. , south: { direction: "down" }
  2228. , east: { direction: "right"}
  2229. , west: { direction: "left" }
  2230. }
  2231. , scale: {
  2232. all: { duration: "fast" }
  2233. }
  2234. // these are not recommended, but can be used
  2235. , blind: {}
  2236. , clip: {}
  2237. , explode: {}
  2238. , fade: {}
  2239. , fold: {}
  2240. , puff: {}
  2241. // Pane Resize Animations
  2242. , size: {
  2243. all: { easing: "swing" }
  2244. }
  2245. }
  2246. // INTERNAL CONFIG DATA - DO NOT CHANGE THIS!
  2247. , config: {
  2248. optionRootKeys: "effects,panes,north,south,west,east,center".split(",")
  2249. , allPanes: "north,south,west,east,center".split(",")
  2250. , borderPanes: "north,south,west,east".split(",")
  2251. , oppositeEdge: {
  2252. north: "south"
  2253. , south: "north"
  2254. , east: "west"
  2255. , west: "east"
  2256. }
  2257. // offscreen data
  2258. , offscreenCSS: { left: "-99999px", right: "auto" } // used by hide/close if useOffscreenClose=true
  2259. , offscreenReset: "offscreenReset" // key used for data
  2260. // CSS used in multiple places
  2261. , hidden: { visibility: "hidden" }
  2262. , visible: { visibility: "visible" }
  2263. // layout element settings
  2264. , resizers: {
  2265. cssReq: {
  2266. position: "absolute"
  2267. , padding: 0
  2268. , margin: 0
  2269. , fontSize: "1px"
  2270. , textAlign: "left" // to counter-act "center" alignment!
  2271. , overflow: "hidden" // prevent toggler-button from overflowing
  2272. // SEE $.layout.defaults.zIndexes.resizer_normal
  2273. }
  2274. , cssDemo: { // DEMO CSS - applied if: options.PANE.applyDemoStyles=true
  2275. background: "#DDD"
  2276. , border: "none"
  2277. }
  2278. }
  2279. , togglers: {
  2280. cssReq: {
  2281. position: "absolute"
  2282. , display: "block"
  2283. , padding: 0
  2284. , margin: 0
  2285. , overflow: "hidden"
  2286. , textAlign: "center"
  2287. , fontSize: "1px"
  2288. , cursor: "pointer"
  2289. , zIndex: 1
  2290. }
  2291. , cssDemo: { // DEMO CSS - applied if: options.PANE.applyDemoStyles=true
  2292. background: "#AAA"
  2293. }
  2294. }
  2295. , content: {
  2296. cssReq: {
  2297. position: "relative" /* contain floated or positioned elements */
  2298. }
  2299. , cssDemo: { // DEMO CSS - applied if: options.PANE.applyDemoStyles=true
  2300. overflow: "auto"
  2301. , padding: "10px"
  2302. }
  2303. , cssDemoPane: { // DEMO CSS - REMOVE scrolling from 'pane' when it has a content-div
  2304. overflow: "hidden"
  2305. , padding: 0
  2306. }
  2307. }
  2308. , panes: { // defaults for ALL panes - overridden by 'per-pane settings' below
  2309. cssReq: {
  2310. position: "absolute"
  2311. , margin: 0
  2312. // $.layout.defaults.zIndexes.pane_normal
  2313. }
  2314. , cssDemo: { // DEMO CSS - applied if: options.PANE.applyDemoStyles=true
  2315. padding: "10px"
  2316. , background: "#FFF"
  2317. , border: "1px solid #BBB"
  2318. , overflow: "auto"
  2319. }
  2320. }
  2321. , north: {
  2322. side: "top"
  2323. , sizeType: "Height"
  2324. , dir: "horz"
  2325. , cssReq: {
  2326. top: 0
  2327. , bottom: "auto"
  2328. , left: 0
  2329. , right: 0
  2330. , width: "auto"
  2331. // height: DYNAMIC
  2332. }
  2333. }
  2334. , south: {
  2335. side: "bottom"
  2336. , sizeType: "Height"
  2337. , dir: "horz"
  2338. , cssReq: {
  2339. top: "auto"
  2340. , bottom: 0
  2341. , left: 0
  2342. , right: 0
  2343. , width: "auto"
  2344. // height: DYNAMIC
  2345. }
  2346. }
  2347. , east: {
  2348. side: "right"
  2349. , sizeType: "Width"
  2350. , dir: "vert"
  2351. , cssReq: {
  2352. left: "auto"
  2353. , right: 0
  2354. , top: "auto" // DYNAMIC
  2355. , bottom: "auto" // DYNAMIC
  2356. , height: "auto"
  2357. // width: DYNAMIC
  2358. }
  2359. }
  2360. , west: {
  2361. side: "left"
  2362. , sizeType: "Width"
  2363. , dir: "vert"
  2364. , cssReq: {
  2365. left: 0
  2366. , right: "auto"
  2367. , top: "auto" // DYNAMIC
  2368. , bottom: "auto" // DYNAMIC
  2369. , height: "auto"
  2370. // width: DYNAMIC
  2371. }
  2372. }
  2373. , center: {
  2374. dir: "center"
  2375. , cssReq: {
  2376. left: "auto" // DYNAMIC
  2377. , right: "auto" // DYNAMIC
  2378. , top: "auto" // DYNAMIC
  2379. , bottom: "auto" // DYNAMIC
  2380. , height: "auto"
  2381. , width: "auto"
  2382. }
  2383. }
  2384. }
  2385. // CALLBACK FUNCTION NAMESPACE - used to store reusable callback functions
  2386. , callbacks: {}
  2387. , getParentPaneElem: function (el) {
  2388. // must pass either a container or pane element
  2389. var $el = $(el)
  2390. , layout = $el.data("layout") || $el.data("parentLayout");
  2391. if (layout) {
  2392. var $cont = layout.container;
  2393. // see if this container is directly-nested inside an outer-pane
  2394. if ($cont.data("layoutPane")) return $cont;
  2395. var $pane = $cont.closest("."+ $.layout.defaults.panes.paneClass);
  2396. // if a pane was found, return it
  2397. if ($pane.data("layoutPane")) return $pane;
  2398. }
  2399. return null;
  2400. }
  2401. , getParentPaneInstance: function (el) {
  2402. // must pass either a container or pane element
  2403. var $pane = $.layout.getParentPaneElem(el);
  2404. return $pane ? $pane.data("layoutPane") : null;
  2405. }
  2406. , getParentLayoutInstance: function (el) {
  2407. // must pass either a container or pane element
  2408. var $pane = $.layout.getParentPaneElem(el);
  2409. return $pane ? $pane.data("parentLayout") : null;
  2410. }
  2411. , getEventObject: function (evt) {
  2412. return typeof evt === "object" && evt.stopPropagation ? evt : null;
  2413. }
  2414. , parsePaneName: function (evt_or_pane) {
  2415. var evt = $.layout.getEventObject( evt_or_pane )
  2416. , pane = evt_or_pane;
  2417. if (evt) {
  2418. // ALWAYS stop propagation of events triggered in Layout!
  2419. evt.stopPropagation();
  2420. pane = $(this).data("layoutEdge");
  2421. }
  2422. if (pane && !/^(west|east|north|south|center)$/.test(pane)) {
  2423. $.layout.msg('LAYOUT ERROR - Invalid pane-name: "'+ pane +'"');
  2424. pane = "error";
  2425. }
  2426. return pane;
  2427. }
  2428. // LAYOUT-PLUGIN REGISTRATION
  2429. // more plugins can added beyond this default list
  2430. , plugins: {
  2431. draggable: !!$.fn.draggable // resizing
  2432. , effects: {
  2433. core: !!$.effects // animimations (specific effects tested by initOptions)
  2434. , slide: $.effects && ($.effects.slide || ($.effects.effect && $.effects.effect.slide)) // default effect
  2435. }
  2436. }
  2437. // arrays of plugin or other methods to be triggered for events in *each layout* - will be passed 'Instance'
  2438. , onCreate: [] // runs when layout is just starting to be created - right after options are set
  2439. , onLoad: [] // runs after layout container and global events init, but before initPanes is called
  2440. , onReady: [] // runs after initialization *completes* - ie, after initPanes completes successfully
  2441. , onDestroy: [] // runs after layout is destroyed
  2442. , onUnload: [] // runs after layout is destroyed OR when page unloads
  2443. , afterOpen: [] // runs after setAsOpen() completes
  2444. , afterClose: [] // runs after setAsClosed() completes
  2445. /*
  2446. * GENERIC UTILITY METHODS
  2447. */
  2448. // calculate and return the scrollbar width, as an integer
  2449. , scrollbarWidth: function () { return window.scrollbarWidth || $.layout.getScrollbarSize('width'); }
  2450. , scrollbarHeight: function () { return window.scrollbarHeight || $.layout.getScrollbarSize('height'); }
  2451. , getScrollbarSize: function (dim) {
  2452. var $c = $('<div style="position: absolute; top: -10000px; left: -10000px; width: 100px; height: 100px; overflow: scroll;"></div>').appendTo("body");
  2453. var d = { width: $c.css("width") - $c[0].clientWidth, height: $c.height() - $c[0].clientHeight };
  2454. $c.remove();
  2455. window.scrollbarWidth = d.width;
  2456. window.scrollbarHeight = d.height;
  2457. return dim.match(/^(width|height)$/) ? d[dim] : d;
  2458. }
  2459. /**
  2460. * Returns hash container 'display' and 'visibility'
  2461. *
  2462. * @see $.swap() - swaps CSS, runs callback, resets CSS
  2463. * @param {!Object} $E jQuery element
  2464. * @param {boolean=} [force=false] Run even if display != none
  2465. * @return {!Object} Returns current style props, if applicable
  2466. */
  2467. , showInvisibly: function ($E, force) {
  2468. if ($E && $E.length && (force || $E.css("display") === "none")) { // only if not *already hidden*
  2469. var s = $E[0].style
  2470. // save ONLY the 'style' props because that is what we must restore
  2471. , CSS = { display: s.display || '', visibility: s.visibility || '' };
  2472. // show element 'invisibly' so can be measured
  2473. $E.css({ display: "block", visibility: "hidden" });
  2474. return CSS;
  2475. }
  2476. return {};
  2477. }
  2478. /**
  2479. * Returns data for setting size of an element (container or a pane).
  2480. *
  2481. * @see _create(), onWindowResize() for container, plus others for pane
  2482. * @return JSON Returns a hash of all dimensions: top, bottom, left, right, outerWidth, innerHeight, etc
  2483. */
  2484. , getElementDimensions: function ($E, inset) {
  2485. var
  2486. // dimensions hash - start with current data IF passed
  2487. d = { css: {}, inset: {} }
  2488. , x = d.css // CSS hash
  2489. , i = { bottom: 0 } // TEMP insets (bottom = complier hack)
  2490. , N = $.layout.cssNum
  2491. , off = $E.offset()
  2492. , b, p, ei // TEMP border, padding
  2493. ;
  2494. d.offsetLeft = off.left;
  2495. d.offsetTop = off.top;
  2496. if (!inset) inset = {}; // simplify logic below
  2497. $.each("Left,Right,Top,Bottom".split(","), function (idx, e) { // e = edge
  2498. b = x["border" + e] = $.layout.borderWidth($E, e);
  2499. p = x["padding"+ e] = $.layout.cssNum($E, "padding"+e);
  2500. ei = e.toLowerCase();
  2501. d.inset[ei] = inset[ei] >= 0 ? inset[ei] : p; // any missing insetX value = paddingX
  2502. i[ei] = d.inset[ei] + b; // total offset of content from outer side
  2503. });
  2504. x.width = $E.width();
  2505. x.height = $E.height();
  2506. x.top = N($E,"top",true);
  2507. x.bottom = N($E,"bottom",true);
  2508. x.left = N($E,"left",true);
  2509. x.right = N($E,"right",true);
  2510. d.outerWidth = $E.outerWidth();
  2511. d.outerHeight = $E.outerHeight();
  2512. // calc the TRUE inner-dimensions, even in quirks-mode!
  2513. d.innerWidth = max(0, d.outerWidth - i.left - i.right);
  2514. d.innerHeight = max(0, d.outerHeight - i.top - i.bottom);
  2515. // layoutWidth/Height is used in calcs for manual resizing
  2516. // layoutW/H only differs from innerW/H when in quirks-mode - then is like outerW/H
  2517. d.layoutWidth = $E.innerWidth();
  2518. d.layoutHeight = $E.innerHeight();
  2519. //if ($E.prop('tagName') === 'BODY') { debugData( d, $E.prop('tagName') ); } // DEBUG
  2520. //d.visible = $E.is(":visible");// && x.width > 0 && x.height > 0;
  2521. return d;
  2522. }
  2523. , getElementStyles: function ($E, list) {
  2524. var
  2525. CSS = {}
  2526. , style = $E[0].style
  2527. , props = list.split(",")
  2528. , sides = "Top,Bottom,Left,Right".split(",")
  2529. , attrs = "Color,Style,Width".split(",")
  2530. , p, s, a, i, j, k
  2531. ;
  2532. for (i=0; i < props.length; i++) {
  2533. p = props[i];
  2534. if (p.match(/(border|padding|margin)$/))
  2535. for (j=0; j < 4; j++) {
  2536. s = sides[j];
  2537. if (p === "border")
  2538. for (k=0; k < 3; k++) {
  2539. a = attrs[k];
  2540. CSS[p+s+a] = style[p+s+a];
  2541. }
  2542. else
  2543. CSS[p+s] = style[p+s];
  2544. }
  2545. else
  2546. CSS[p] = style[p];
  2547. };
  2548. return CSS
  2549. }
  2550. /**
  2551. * Return the innerWidth for the current browser/doctype
  2552. *
  2553. * @see initPanes(), sizeMidPanes(), initHandles(), sizeHandles()
  2554. * @param {Array.<Object>} $E Must pass a jQuery object - first element is processed
  2555. * @param {number=} outerWidth (optional) Can pass a width, allowing calculations BEFORE element is resized
  2556. * @return {number} Returns the innerWidth of the elem by subtracting padding and borders
  2557. */
  2558. , cssWidth: function ($E, outerWidth) {
  2559. // a 'calculated' outerHeight can be passed so borders and/or padding are removed if needed
  2560. if (outerWidth <= 0) return 0;
  2561. var bs = !$.layout.browser.boxModel ? "border-box" : $.support.boxSizing ? $E.css("boxSizing") : "content-box"
  2562. , b = $.layout.borderWidth
  2563. , n = $.layout.cssNum
  2564. , W = outerWidth
  2565. ;
  2566. // strip border and/or padding from outerWidth to get CSS Width
  2567. if (bs !== "border-box")
  2568. W -= (b($E, "Left") + b($E, "Right"));
  2569. if (bs === "content-box")
  2570. W -= (n($E, "paddingLeft") + n($E, "paddingRight"));
  2571. return max(0,W);
  2572. }
  2573. /**
  2574. * Return the innerHeight for the current browser/doctype
  2575. *
  2576. * @see initPanes(), sizeMidPanes(), initHandles(), sizeHandles()
  2577. * @param {Array.<Object>} $E Must pass a jQuery object - first element is processed
  2578. * @param {number=} outerHeight (optional) Can pass a width, allowing calculations BEFORE element is resized
  2579. * @return {number} Returns the innerHeight of the elem by subtracting padding and borders
  2580. */
  2581. , cssHeight: function ($E, outerHeight) {
  2582. // a 'calculated' outerHeight can be passed so borders and/or padding are removed if needed
  2583. if (outerHeight <= 0) return 0;
  2584. var bs = !$.layout.browser.boxModel ? "border-box" : $.support.boxSizing ? $E.css("boxSizing") : "content-box"
  2585. , b = $.layout.borderWidth
  2586. , n = $.layout.cssNum
  2587. , H = outerHeight
  2588. ;
  2589. // strip border and/or padding from outerHeight to get CSS Height
  2590. if (bs !== "border-box")
  2591. H -= (b($E, "Top") + b($E, "Bottom"));
  2592. if (bs === "content-box")
  2593. H -= (n($E, "paddingTop") + n($E, "paddingBottom"));
  2594. return max(0,H);
  2595. }
  2596. /**
  2597. * Returns the 'current CSS numeric value' for a CSS property - 0 if property does not exist
  2598. *
  2599. * @see Called by many methods
  2600. * @param {Array.<Object>} $E Must pass a jQuery object - first element is processed
  2601. * @param {string} prop The name of the CSS property, eg: top, width, etc.
  2602. * @param {boolean=} [allowAuto=false] true = return 'auto' if that is value; false = return 0
  2603. * @return {(string|number)} Usually used to get an integer value for position (top, left) or size (height, width)
  2604. */
  2605. , cssNum: function ($E, prop, allowAuto) {
  2606. if (!$E.jquery) $E = $($E);
  2607. var CSS = $.layout.showInvisibly($E)
  2608. , p = $.css($E[0], prop, true)
  2609. , v = allowAuto && p=="auto" ? p : Math.round(parseFloat(p) || 0);
  2610. $E.css( CSS ); // RESET
  2611. return v;
  2612. }
  2613. , borderWidth: function (el, side) {
  2614. if (el.jquery) el = el[0];
  2615. var b = "border"+ side.substr(0,1).toUpperCase() + side.substr(1); // left => Left
  2616. return $.css(el, b+"Style", true) === "none" ? 0 : Math.round(parseFloat($.css(el, b+"Width", true)) || 0);
  2617. }
  2618. /**
  2619. * Mouse-tracking utility - FUTURE REFERENCE
  2620. *
  2621. * init: if (!window.mouse) {
  2622. * window.mouse = { x: 0, y: 0 };
  2623. * $(document).mousemove( $.layout.trackMouse );
  2624. * }
  2625. *
  2626. * @param {Object} evt
  2627. *
  2628. , trackMouse: function (evt) {
  2629. window.mouse = { x: evt.clientX, y: evt.clientY };
  2630. }
  2631. */
  2632. /**
  2633. * SUBROUTINE for preventPrematureSlideClose option
  2634. *
  2635. * @param {Object} evt
  2636. * @param {Object=} el
  2637. */
  2638. , isMouseOverElem: function (evt, el) {
  2639. var
  2640. $E = $(el || this)
  2641. , d = $E.offset()
  2642. , T = d.top
  2643. , L = d.left
  2644. , R = L + $E.outerWidth()
  2645. , B = T + $E.outerHeight()
  2646. , x = evt.pageX // evt.clientX ?
  2647. , y = evt.pageY // evt.clientY ?
  2648. ;
  2649. // if X & Y are < 0, probably means is over an open SELECT
  2650. return ($.layout.browser.msie && x < 0 && y < 0) || ((x >= L && x <= R) && (y >= T && y <= B));
  2651. }
  2652. /**
  2653. * Message/Logging Utility
  2654. *
  2655. * @example $.layout.msg("My message"); // log text
  2656. * @example $.layout.msg("My message", true); // alert text
  2657. * @example $.layout.msg({ foo: "bar" }, "Title"); // log hash-data, with custom title
  2658. * @example $.layout.msg({ foo: "bar" }, true, "Title", { sort: false }); -OR-
  2659. * @example $.layout.msg({ foo: "bar" }, "Title", { sort: false, display: true }); // alert hash-data
  2660. *
  2661. * @param {(Object|string)} info String message OR Hash/Array
  2662. * @param {(Boolean|string|Object)=} [popup=false] True means alert-box - can be skipped
  2663. * @param {(Object|string)=} [debugTitle=""] Title for Hash data - can be skipped
  2664. * @param {Object=} [debugOpts] Extra options for debug output
  2665. */
  2666. , msg: function (info, popup, debugTitle, debugOpts) {
  2667. if ($.isPlainObject(info) && window.debugData) {
  2668. if (typeof popup === "string") {
  2669. debugOpts = debugTitle;
  2670. debugTitle = popup;
  2671. }
  2672. else if (typeof debugTitle === "object") {
  2673. debugOpts = debugTitle;
  2674. debugTitle = null;
  2675. }
  2676. var t = debugTitle || "log( <object> )"
  2677. , o = $.extend({ sort: false, returnHTML: false, display: false }, debugOpts);
  2678. if (popup === true || o.display)
  2679. debugData( info, t, o );
  2680. else if (window.console)
  2681. console.log(debugData( info, t, o ));
  2682. }
  2683. else if (popup)
  2684. alert(info);
  2685. else if (window.console)
  2686. console.log(info);
  2687. else {
  2688. var id = "#layoutLogger"
  2689. , $l = $(id);
  2690. if (!$l.length)
  2691. $l = createLog();
  2692. $l.children("ul").append('<li style="padding: 4px 10px; margin: 0; border-top: 1px solid #CCC;">'+ info.replace(/\</g,"&lt;").replace(/\>/g,"&gt;") +'</li>');
  2693. }
  2694. function createLog () {
  2695. var pos = $.support.fixedPosition ? 'fixed' : 'absolute'
  2696. , $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);">'
  2697. + '<div style="font-size: 13px; font-weight: bold; padding: 5px 10px; background: #F6F6F6; border-radius: 5px 5px 0 0; cursor: move;">'
  2698. + '<span style="float: right; padding-left: 7px; cursor: pointer;" title="Remove Console" onclick="$(this).closest(\'#layoutLogger\').remove()">X</span>Layout console.log</div>'
  2699. + '<ul style="font-size: 13px; font-weight: none; list-style: none; margin: 0; padding: 0 0 2px;"></ul>'
  2700. + '</div>'
  2701. ).appendTo("body");
  2702. $e.css('left', $(window).width() - $e.outerWidth() - 5)
  2703. if ($.ui.draggable) $e.draggable({ handle: ':first-child' });
  2704. return $e;
  2705. };
  2706. }
  2707. };
  2708. /*
  2709. * $.layout.browser REPLACES removed $.browser, with extra data
  2710. * Parsing code here adapted from jQuery 1.8 $.browse
  2711. */
  2712. var u = navigator.userAgent.toLowerCase()
  2713. , m = /(chrome)[ \/]([\w.]+)/.exec( u )
  2714. || /(webkit)[ \/]([\w.]+)/.exec( u )
  2715. || /(opera)(?:.*version|)[ \/]([\w.]+)/.exec( u )
  2716. || /(msie) ([\w.]+)/.exec( u )
  2717. || u.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec( u )
  2718. || []
  2719. , b = m[1] || ""
  2720. , v = m[2] || 0
  2721. , ie = b === "msie"
  2722. ;
  2723. $.layout.browser = {
  2724. version: v
  2725. , safari: b === "webkit" // webkit (NOT chrome) = safari
  2726. , webkit: b === "chrome" // chrome = webkit
  2727. , msie: ie
  2728. , isIE6: ie && v == 6
  2729. // ONLY IE reverts to old box-model - update for older jQ onReady
  2730. , boxModel: !ie || $.support.boxModel !== false
  2731. };
  2732. if (b) $.layout.browser[b] = true; // set CURRENT browser
  2733. /* OLD versions of jQuery only set $.support.boxModel after page is loaded
  2734. * so if this is IE, use support.boxModel to test for quirks-mode (ONLY IE changes boxModel) */
  2735. if (ie) $(function(){ $.layout.browser.boxModel = $.support.boxModel; });
  2736. // DEFAULT OPTIONS
  2737. $.layout.defaults = {
  2738. /*
  2739. * LAYOUT & LAYOUT-CONTAINER OPTIONS
  2740. * - none of these options are applicable to individual panes
  2741. */
  2742. name: "" // Not required, but useful for buttons and used for the state-cookie
  2743. , containerClass: "ui-layout-container" // layout-container element
  2744. , inset: null // custom container-inset values (override padding)
  2745. , scrollToBookmarkOnLoad: true // after creating a layout, scroll to bookmark in URL (.../page.htm#myBookmark)
  2746. , resizeWithWindow: true // bind thisLayout.resizeAll() to the window.resize event
  2747. , resizeWithWindowDelay: 200 // delay calling resizeAll because makes window resizing very jerky
  2748. , resizeWithWindowMaxDelay: 0 // 0 = none - force resize every XX ms while window is being resized
  2749. , maskPanesEarly: false // true = create pane-masks on resizer.mouseDown instead of waiting for resizer.dragstart
  2750. , onresizeall_start: null // CALLBACK when resizeAll() STARTS - NOT pane-specific
  2751. , onresizeall_end: null // CALLBACK when resizeAll() ENDS - NOT pane-specific
  2752. , onload_start: null // CALLBACK when Layout inits - after options initialized, but before elements
  2753. , onload_end: null // CALLBACK when Layout inits - after EVERYTHING has been initialized
  2754. , onunload_start: null // CALLBACK when Layout is destroyed OR onWindowUnload
  2755. , onunload_end: null // CALLBACK when Layout is destroyed OR onWindowUnload
  2756. , initPanes: true // false = DO NOT initialize the panes onLoad - will init later
  2757. , showErrorMessages: true // enables fatal error messages to warn developers of common errors
  2758. , showDebugMessages: false // display console-and-alert debug msgs - IF this Layout version _has_ debugging code!
  2759. // Changing this zIndex value will cause other zIndex values to automatically change
  2760. , zIndex: null // the PANE zIndex - resizers and masks will be +1
  2761. // DO NOT CHANGE the zIndex values below unless you clearly understand their relationships
  2762. , zIndexes: { // set _default_ z-index values here...
  2763. pane_normal: 0 // normal z-index for panes
  2764. , content_mask: 1 // applied to overlays used to mask content INSIDE panes during resizing
  2765. , resizer_normal: 2 // normal z-index for resizer-bars
  2766. , pane_sliding: 100 // applied to *BOTH* the pane and its resizer when a pane is 'slid open'
  2767. , pane_animate: 1000 // applied to the pane when being animated - not applied to the resizer
  2768. , resizer_drag: 10000 // applied to the CLONED resizer-bar when being 'dragged'
  2769. }
  2770. , errors: {
  2771. pane: "pane" // description of "layout pane element" - used only in error messages
  2772. , selector: "selector" // description of "jQuery-selector" - used only in error messages
  2773. , addButtonError: "Error Adding Button\nInvalid "
  2774. , containerMissing: "UI Layout Initialization Error\nThe specified layout-container does not exist."
  2775. , centerPaneMissing: "UI Layout Initialization Error\nThe center-pane element does not exist.\nThe center-pane is a required element."
  2776. , noContainerHeight: "UI Layout Initialization Warning\nThe layout-container \"CONTAINER\" has no height.\nTherefore the layout is 0-height and hence 'invisible'!"
  2777. , callbackError: "UI Layout Callback Error\nThe EVENT callback is not a valid function."
  2778. }
  2779. /*
  2780. * PANE DEFAULT SETTINGS
  2781. * - settings under the 'panes' key become the default settings for *all panes*
  2782. * - ALL pane-options can also be set specifically for each panes, which will override these 'default values'
  2783. */
  2784. , panes: { // default options for 'all panes' - will be overridden by 'per-pane settings'
  2785. applyDemoStyles: false // NOTE: renamed from applyDefaultStyles for clarity
  2786. , closable: true // pane can open & close
  2787. , resizable: true // when open, pane can be resized
  2788. , slidable: true // when closed, pane can 'slide open' over other panes - closes on mouse-out
  2789. , initClosed: false // true = init pane as 'closed'
  2790. , initHidden: false // true = init pane as 'hidden' - no resizer-bar/spacing
  2791. // SELECTORS
  2792. //, paneSelector: "" // MUST be pane-specific - jQuery selector for pane
  2793. , contentSelector: ".ui-layout-content" // INNER div/element to auto-size so only it scrolls, not the entire pane!
  2794. , contentIgnoreSelector: ".ui-layout-ignore" // element(s) to 'ignore' when measuring 'content'
  2795. , findNestedContent: false // true = $P.find(contentSelector), false = $P.children(contentSelector)
  2796. // GENERIC ROOT-CLASSES - for auto-generated classNames
  2797. , paneClass: "ui-layout-pane" // Layout Pane
  2798. , resizerClass: "ui-layout-resizer" // Resizer Bar
  2799. , togglerClass: "ui-layout-toggler" // Toggler Button
  2800. , buttonClass: "ui-layout-button" // CUSTOM Buttons - eg: '[ui-layout-button]-toggle/-open/-close/-pin'
  2801. // ELEMENT SIZE & SPACING
  2802. //, size: 100 // MUST be pane-specific -initial size of pane
  2803. , minSize: 0 // when manually resizing a pane
  2804. , maxSize: 0 // ditto, 0 = no limit
  2805. , spacing_open: 6 // space between pane and adjacent panes - when pane is 'open'
  2806. , spacing_closed: 6 // ditto - when pane is 'closed'
  2807. , togglerLength_open: 50 // Length = WIDTH of toggler button on north/south sides - HEIGHT on east/west sides
  2808. , togglerLength_closed: 50 // 100% OR -1 means 'full height/width of resizer bar' - 0 means 'hidden'
  2809. , togglerAlign_open: "center" // top/left, bottom/right, center, OR...
  2810. , togglerAlign_closed: "center" // 1 => nn = offset from top/left, -1 => -nn == offset from bottom/right
  2811. , togglerContent_open: "" // text or HTML to put INSIDE the toggler
  2812. , togglerContent_closed: "" // ditto
  2813. // RESIZING OPTIONS
  2814. , resizerDblClickToggle: true //
  2815. , autoResize: true // IF size is 'auto' or a percentage, then recalc 'pixel size' whenever the layout resizes
  2816. , autoReopen: true // IF a pane was auto-closed due to noRoom, reopen it when there is room? False = leave it closed
  2817. , resizerDragOpacity: 1 // option for ui.draggable
  2818. //, resizerCursor: "" // MUST be pane-specific - cursor when over resizer-bar
  2819. , maskContents: false // true = add DIV-mask over-or-inside this pane so can 'drag' over IFRAMES
  2820. , maskObjects: false // true = add IFRAME-mask over-or-inside this pane to cover objects/applets - content-mask will overlay this mask
  2821. , maskZindex: null // will override zIndexes.content_mask if specified - not applicable to iframe-panes
  2822. , resizingGrid: false // grid size that the resizers will snap-to during resizing, eg: [20,20]
  2823. , livePaneResizing: false // true = LIVE Resizing as resizer is dragged
  2824. , liveContentResizing: false // true = re-measure header/footer heights as resizer is dragged
  2825. , liveResizingTolerance: 1 // how many px change before pane resizes, to control performance
  2826. // SLIDING OPTIONS
  2827. , sliderCursor: "pointer" // cursor when resizer-bar will trigger 'sliding'
  2828. , slideTrigger_open: "click" // click, dblclick, mouseenter
  2829. , slideTrigger_close: "mouseleave"// click, mouseleave
  2830. , slideDelay_open: 300 // applies only for mouseenter event - 0 = instant open
  2831. , slideDelay_close: 300 // applies only for mouseleave event (300ms is the minimum!)
  2832. , hideTogglerOnSlide: false // when pane is slid-open, should the toggler show?
  2833. , preventQuickSlideClose: $.layout.browser.webkit // Chrome triggers slideClosed as it is opening
  2834. , preventPrematureSlideClose: false // handle incorrect mouseleave trigger, like when over a SELECT-list in IE
  2835. // PANE-SPECIFIC TIPS & MESSAGES
  2836. , tips: {
  2837. Open: "Open" // eg: "Open Pane"
  2838. , Close: "Close"
  2839. , Resize: "Resize"
  2840. , Slide: "Slide Open"
  2841. , Pin: "Pin"
  2842. , Unpin: "Un-Pin"
  2843. , noRoomToOpen: "Not enough room to show this panel." // alert if user tries to open a pane that cannot
  2844. , minSizeWarning: "Panel has reached its minimum size" // displays in browser statusbar
  2845. , maxSizeWarning: "Panel has reached its maximum size" // ditto
  2846. }
  2847. // HOT-KEYS & MISC
  2848. , showOverflowOnHover: false // will bind allowOverflow() utility to pane.onMouseOver
  2849. , enableCursorHotkey: true // enabled 'cursor' hotkeys
  2850. //, customHotkey: "" // MUST be pane-specific - EITHER a charCode OR a character
  2851. , customHotkeyModifier: "SHIFT" // either 'SHIFT', 'CTRL' or 'CTRL+SHIFT' - NOT 'ALT'
  2852. // PANE ANIMATION
  2853. // NOTE: fxSss_open, fxSss_close & fxSss_size options (eg: fxName_open) are auto-generated if not passed
  2854. , fxName: "slide" // ('none' or blank), slide, drop, scale -- only relevant to 'open' & 'close', NOT 'size'
  2855. , fxSpeed: null // slow, normal, fast, 200, nnn - if passed, will OVERRIDE fxSettings.duration
  2856. , fxSettings: {} // can be passed, eg: { easing: "easeOutBounce", duration: 1500 }
  2857. , fxOpacityFix: true // tries to fix opacity in IE to restore anti-aliasing after animation
  2858. , animatePaneSizing: false // true = animate resizing after dragging resizer-bar OR sizePane() is called
  2859. /* NOTE: Action-specific FX options are auto-generated from the options above if not specifically set:
  2860. fxName_open: "slide" // 'Open' pane animation
  2861. fnName_close: "slide" // 'Close' pane animation
  2862. fxName_size: "slide" // 'Size' pane animation - when animatePaneSizing = true
  2863. fxSpeed_open: null
  2864. fxSpeed_close: null
  2865. fxSpeed_size: null
  2866. fxSettings_open: {}
  2867. fxSettings_close: {}
  2868. fxSettings_size: {}
  2869. */
  2870. // CHILD/NESTED LAYOUTS
  2871. , children: null // Layout-options for nested/child layout - even {} is valid as options
  2872. , containerSelector: '' // if child is NOT 'directly nested', a selector to find it/them (can have more than one child layout!)
  2873. , initChildren: true // true = child layout will be created as soon as _this_ layout completes initialization
  2874. , destroyChildren: true // true = destroy child-layout if this pane is destroyed
  2875. , resizeChildren: true // true = trigger child-layout.resizeAll() when this pane is resized
  2876. // EVENT TRIGGERING
  2877. , triggerEventsOnLoad: false // true = trigger onopen OR onclose callbacks when layout initializes
  2878. , triggerEventsDuringLiveResize: true // true = trigger onresize callback REPEATEDLY if livePaneResizing==true
  2879. // PANE CALLBACKS
  2880. , onshow_start: null // CALLBACK when pane STARTS to Show - BEFORE onopen/onhide_start
  2881. , onshow_end: null // CALLBACK when pane ENDS being Shown - AFTER onopen/onhide_end
  2882. , onhide_start: null // CALLBACK when pane STARTS to Close - BEFORE onclose_start
  2883. , onhide_end: null // CALLBACK when pane ENDS being Closed - AFTER onclose_end
  2884. , onopen_start: null // CALLBACK when pane STARTS to Open
  2885. , onopen_end: null // CALLBACK when pane ENDS being Opened
  2886. , onclose_start: null // CALLBACK when pane STARTS to Close
  2887. , onclose_end: null // CALLBACK when pane ENDS being Closed
  2888. , onresize_start: null // CALLBACK when pane STARTS being Resized ***FOR ANY REASON***
  2889. , onresize_end: null // CALLBACK when pane ENDS being Resized ***FOR ANY REASON***
  2890. , onsizecontent_start: null // CALLBACK when sizing of content-element STARTS
  2891. , onsizecontent_end: null // CALLBACK when sizing of content-element ENDS
  2892. , onswap_start: null // CALLBACK when pane STARTS to Swap
  2893. , onswap_end: null // CALLBACK when pane ENDS being Swapped
  2894. , ondrag_start: null // CALLBACK when pane STARTS being ***MANUALLY*** Resized
  2895. , ondrag_end: null // CALLBACK when pane ENDS being ***MANUALLY*** Resized
  2896. }
  2897. /*
  2898. * PANE-SPECIFIC SETTINGS
  2899. * - options listed below MUST be specified per-pane - they CANNOT be set under 'panes'
  2900. * - all options under the 'panes' key can also be set specifically for any pane
  2901. * - most options under the 'panes' key apply only to 'border-panes' - NOT the the center-pane
  2902. */
  2903. , north: {
  2904. paneSelector: ".ui-layout-north"
  2905. , size: "auto" // eg: "auto", "30%", .30, 200
  2906. , resizerCursor: "n-resize" // custom = url(myCursor.cur)
  2907. , customHotkey: "" // EITHER a charCode (43) OR a character ("o")
  2908. }
  2909. , south: {
  2910. paneSelector: ".ui-layout-south"
  2911. , size: "auto"
  2912. , resizerCursor: "s-resize"
  2913. , customHotkey: ""
  2914. }
  2915. , east: {
  2916. paneSelector: ".ui-layout-east"
  2917. , size: 200
  2918. , resizerCursor: "e-resize"
  2919. , customHotkey: ""
  2920. }
  2921. , west: {
  2922. paneSelector: ".ui-layout-west"
  2923. , size: 200
  2924. , resizerCursor: "w-resize"
  2925. , customHotkey: ""
  2926. }
  2927. , center: {
  2928. paneSelector: ".ui-layout-center"
  2929. , minWidth: 0
  2930. , minHeight: 0
  2931. }
  2932. };
  2933. $.layout.optionsMap = {
  2934. // layout/global options - NOT pane-options
  2935. layout: ("name,instanceKey,stateManagement,effects,inset,zIndexes,errors,"
  2936. + "zIndex,scrollToBookmarkOnLoad,showErrorMessages,maskPanesEarly,"
  2937. + "outset,resizeWithWindow,resizeWithWindowDelay,resizeWithWindowMaxDelay,"
  2938. + "onresizeall,onresizeall_start,onresizeall_end,onload,onload_start,onload_end,onunload,onunload_start,onunload_end").split(",")
  2939. // borderPanes: [ ALL options that are NOT specified as 'layout' ]
  2940. // default.panes options that apply to the center-pane (most options apply _only_ to border-panes)
  2941. , center: ("paneClass,contentSelector,contentIgnoreSelector,findNestedContent,applyDemoStyles,triggerEventsOnLoad,"
  2942. + "showOverflowOnHover,maskContents,maskObjects,liveContentResizing,"
  2943. + "containerSelector,children,initChildren,resizeChildren,destroyChildren,"
  2944. + "onresize,onresize_start,onresize_end,onsizecontent,onsizecontent_start,onsizecontent_end").split(",")
  2945. // options that MUST be specifically set 'per-pane' - CANNOT set in the panes (defaults) key
  2946. , noDefault: ("paneSelector,resizerCursor,customHotkey").split(",")
  2947. };
  2948. /**
  2949. * Processes options passed in converts flat-format data into subkey (JSON) format
  2950. * In flat-format, subkeys are _currently_ separated with 2 underscores, like north__optName
  2951. * Plugins may also call this method so they can transform their own data
  2952. *
  2953. * @param {!Object} hash Data/options passed by user - may be a single level or nested levels
  2954. * @param {boolean=} [addKeys=false] Should the primary layout.options keys be added if they do not exist?
  2955. * @return {Object} Returns hash of minWidth & minHeight
  2956. */
  2957. $.layout.transformData = function (hash, addKeys) {
  2958. var json = addKeys ? { panes: {}, center: {} } : {} // init return object
  2959. , branch, optKey, keys, key, val, i, c;
  2960. if (typeof hash !== "object") return json; // no options passed
  2961. // convert all 'flat-keys' to 'sub-key' format
  2962. for (optKey in hash) {
  2963. branch = json;
  2964. val = hash[ optKey ];
  2965. keys = optKey.split("__"); // eg: west__size or north__fxSettings__duration
  2966. c = keys.length - 1;
  2967. // convert underscore-delimited to subkeys
  2968. for (i=0; i <= c; i++) {
  2969. key = keys[i];
  2970. if (i === c) { // last key = value
  2971. if ($.isPlainObject( val ))
  2972. branch[key] = $.layout.transformData( val ); // RECURSE
  2973. else
  2974. branch[key] = val;
  2975. }
  2976. else {
  2977. if (!branch[key])
  2978. branch[key] = {}; // create the subkey
  2979. // recurse to sub-key for next loop - if not done
  2980. branch = branch[key];
  2981. }
  2982. }
  2983. }
  2984. return json;
  2985. };
  2986. // INTERNAL CONFIG DATA - DO NOT CHANGE THIS!
  2987. $.layout.backwardCompatibility = {
  2988. // data used by renameOldOptions()
  2989. map: {
  2990. // OLD Option Name: NEW Option Name
  2991. applyDefaultStyles: "applyDemoStyles"
  2992. // CHILD/NESTED LAYOUTS
  2993. , childOptions: "children"
  2994. , initChildLayout: "initChildren"
  2995. , destroyChildLayout: "destroyChildren"
  2996. , resizeChildLayout: "resizeChildren"
  2997. , resizeNestedLayout: "resizeChildren"
  2998. // MISC Options
  2999. , resizeWhileDragging: "livePaneResizing"
  3000. , resizeContentWhileDragging: "liveContentResizing"
  3001. , triggerEventsWhileDragging: "triggerEventsDuringLiveResize"
  3002. , maskIframesOnResize: "maskContents"
  3003. // STATE MANAGEMENT
  3004. , useStateCookie: "stateManagement.enabled"
  3005. , "cookie.autoLoad": "stateManagement.autoLoad"
  3006. , "cookie.autoSave": "stateManagement.autoSave"
  3007. , "cookie.keys": "stateManagement.stateKeys"
  3008. , "cookie.name": "stateManagement.cookie.name"
  3009. , "cookie.domain": "stateManagement.cookie.domain"
  3010. , "cookie.path": "stateManagement.cookie.path"
  3011. , "cookie.expires": "stateManagement.cookie.expires"
  3012. , "cookie.secure": "stateManagement.cookie.secure"
  3013. // OLD Language options
  3014. , noRoomToOpenTip: "tips.noRoomToOpen"
  3015. , togglerTip_open: "tips.Close" // open = Close
  3016. , togglerTip_closed: "tips.Open" // closed = Open
  3017. , resizerTip: "tips.Resize"
  3018. , sliderTip: "tips.Slide"
  3019. }
  3020. /**
  3021. * @param {Object} opts
  3022. */
  3023. , renameOptions: function (opts) {
  3024. var map = $.layout.backwardCompatibility.map
  3025. , oldData, newData, value
  3026. ;
  3027. for (var itemPath in map) {
  3028. oldData = getBranch( itemPath );
  3029. value = oldData.branch[ oldData.key ];
  3030. if (value !== undefined) {
  3031. newData = getBranch( map[itemPath], true );
  3032. newData.branch[ newData.key ] = value;
  3033. delete oldData.branch[ oldData.key ];
  3034. }
  3035. }
  3036. /**
  3037. * @param {string} path
  3038. * @param {boolean=} [create=false] Create path if does not exist
  3039. */
  3040. function getBranch (path, create) {
  3041. var a = path.split(".") // split keys into array
  3042. , c = a.length - 1
  3043. , D = { branch: opts, key: a[c] } // init branch at top & set key (last item)
  3044. , i = 0, k, undef;
  3045. for (; i<c; i++) { // skip the last key (data)
  3046. k = a[i];
  3047. if (D.branch[ k ] == undefined) { // child-key does not exist
  3048. if (create) {
  3049. D.branch = D.branch[ k ] = {}; // create child-branch
  3050. }
  3051. else // can't go any farther
  3052. D.branch = {}; // branch is undefined
  3053. }
  3054. else
  3055. D.branch = D.branch[ k ]; // get child-branch
  3056. }
  3057. return D;
  3058. };
  3059. }
  3060. /**
  3061. * @param {Object} opts
  3062. */
  3063. , renameAllOptions: function (opts) {
  3064. var ren = $.layout.backwardCompatibility.renameOptions;
  3065. // rename root (layout) options
  3066. ren( opts );
  3067. // rename 'defaults' to 'panes'
  3068. if (opts.defaults) {
  3069. if (typeof opts.panes !== "object")
  3070. opts.panes = {};
  3071. $.extend(true, opts.panes, opts.defaults);
  3072. delete opts.defaults;
  3073. }
  3074. // rename options in the the options.panes key
  3075. if (opts.panes) ren( opts.panes );
  3076. // rename options inside *each pane key*, eg: options.west
  3077. $.each($.layout.config.allPanes, function (i, pane) {
  3078. if (opts[pane]) ren( opts[pane] );
  3079. });
  3080. return opts;
  3081. }
  3082. };
  3083. /* ============================================================
  3084. * BEGIN WIDGET: $( selector ).layout( {options} );
  3085. * ============================================================
  3086. */
  3087. $.fn.layout = function (opts) {
  3088. var
  3089. // local aliases to global data
  3090. browser = $.layout.browser
  3091. , _c = $.layout.config
  3092. // local aliases to utlity methods
  3093. , cssW = $.layout.cssWidth
  3094. , cssH = $.layout.cssHeight
  3095. , elDims = $.layout.getElementDimensions
  3096. , styles = $.layout.getElementStyles
  3097. , evtObj = $.layout.getEventObject
  3098. , evtPane = $.layout.parsePaneName
  3099. /**
  3100. * options - populated by initOptions()
  3101. */
  3102. , options = $.extend(true, {}, $.layout.defaults)
  3103. , effects = options.effects = $.extend(true, {}, $.layout.effects)
  3104. /**
  3105. * layout-state object
  3106. */
  3107. , state = {
  3108. // generate unique ID to use for event.namespace so can unbind only events added by 'this layout'
  3109. id: "layout"+ $.now() // code uses alias: sID
  3110. , initialized: false
  3111. , paneResizing: false
  3112. , panesSliding: {}
  3113. , container: { // list all keys referenced in code to avoid compiler error msgs
  3114. innerWidth: 0
  3115. , innerHeight: 0
  3116. , outerWidth: 0
  3117. , outerHeight: 0
  3118. , layoutWidth: 0
  3119. , layoutHeight: 0
  3120. }
  3121. , north: { childIdx: 0 }
  3122. , south: { childIdx: 0 }
  3123. , east: { childIdx: 0 }
  3124. , west: { childIdx: 0 }
  3125. , center: { childIdx: 0 }
  3126. }
  3127. /**
  3128. * parent/child-layout pointers
  3129. */
  3130. //, hasParentLayout = false - exists ONLY inside Instance so can be set externally
  3131. , children = {
  3132. north: null
  3133. , south: null
  3134. , east: null
  3135. , west: null
  3136. , center: null
  3137. }
  3138. /*
  3139. * ###########################
  3140. * INTERNAL HELPER FUNCTIONS
  3141. * ###########################
  3142. */
  3143. /**
  3144. * Manages all internal timers
  3145. */
  3146. , timer = {
  3147. data: {}
  3148. , set: function (s, fn, ms) { timer.clear(s); timer.data[s] = setTimeout(fn, ms); }
  3149. , clear: function (s) { var t=timer.data; if (t[s]) {clearTimeout(t[s]); delete t[s];} }
  3150. }
  3151. /**
  3152. * Alert or console.log a message - IF option is enabled.
  3153. *
  3154. * @param {(string|!Object)} msg Message (or debug-data) to display
  3155. * @param {boolean=} [popup=false] True by default, means 'alert', false means use console.log
  3156. * @param {boolean=} [debug=false] True means is a widget debugging message
  3157. */
  3158. , _log = function (msg, popup, debug) {
  3159. var o = options;
  3160. if ((o.showErrorMessages && !debug) || (debug && o.showDebugMessages))
  3161. $.layout.msg( o.name +' / '+ msg, (popup !== false) );
  3162. return false;
  3163. }
  3164. /**
  3165. * Executes a Callback function after a trigger event, like resize, open or close
  3166. *
  3167. * @param {string} evtName Name of the layout callback, eg "onresize_start"
  3168. * @param {(string|boolean)=} [pane=""] This is passed only so we can pass the 'pane object' to the callback
  3169. * @param {(string|boolean)=} [skipBoundEvents=false] True = do not run events bound to the elements - only the callbacks set in options
  3170. */
  3171. , _runCallbacks = function (evtName, pane, skipBoundEvents) {
  3172. var hasPane = pane && isStr(pane)
  3173. , s = hasPane ? state[pane] : state
  3174. , o = hasPane ? options[pane] : options
  3175. , lName = options.name
  3176. // names like onopen and onopen_end separate are interchangeable in options...
  3177. , lng = evtName + (evtName.match(/_/) ? "" : "_end")
  3178. , shrt = lng.match(/_end$/) ? lng.substr(0, lng.length - 4) : ""
  3179. , fn = o[lng] || o[shrt]
  3180. , retVal = "NC" // NC = No Callback
  3181. , args = []
  3182. , $P
  3183. ;
  3184. if ( !hasPane && $.type(pane) === 'boolean' ) {
  3185. skipBoundEvents = pane; // allow pane param to be skipped for Layout callback
  3186. pane = "";
  3187. }
  3188. // first trigger the callback set in the options
  3189. if (fn) {
  3190. // convert function name (string) to function object
  3191. if (isStr( fn )) {
  3192. if (fn.match(/,/)) {
  3193. // function name cannot contain a comma,
  3194. // so must be a function name AND a parameter to pass
  3195. args = fn.split(",")
  3196. , fn = eval(args[0]);
  3197. }
  3198. else // just the name of an external function?
  3199. fn = eval(fn);
  3200. }
  3201. // execute the callback, if exists
  3202. if ($.isFunction( fn )) {
  3203. if (args.length)
  3204. retVal = g(fn)(args[1]); // pass the argument parsed from 'list'
  3205. else if ( hasPane )
  3206. // pass data: pane-name, pane-element, pane-state, pane-options, and layout-name
  3207. retVal = g(fn)( pane, $Ps[pane], s, o, lName );
  3208. else // must be a layout/container callback - pass suitable info
  3209. retVal = g(fn)( Instance, s, o, lName );
  3210. }
  3211. // _log( options.errors.callbackError.replace(/EVENT/, $.trim((pane || "") +" "+ lng)), false );
  3212. // if ($.type(ex) === 'string' && string.length)
  3213. // _log('Exception: '+ ex, false );
  3214. }
  3215. // trigger additional events bound directly to the pane
  3216. if (!skipBoundEvents && retVal !== false) {
  3217. if ( hasPane ) { // PANE events can be bound to each pane-elements
  3218. $P = $Ps[pane];
  3219. o = options[pane];
  3220. s = state[pane];
  3221. $P.triggerHandler('layoutpane'+ lng, [ pane, $P, s, o, lName ]);
  3222. if (shrt)
  3223. $P.triggerHandler('layoutpane'+ shrt, [ pane, $P, s, o, lName ]);
  3224. }
  3225. else { // LAYOUT events can be bound to the container-element
  3226. $N.triggerHandler('layout'+ lng, [ Instance, s, o, lName ]);
  3227. if (shrt)
  3228. $N.triggerHandler('layout'+ shrt, [ Instance, s, o, lName ]);
  3229. }
  3230. }
  3231. // ALWAYS resizeChildren after an onresize_end event - even during initialization
  3232. // IGNORE onsizecontent_end event because causes child-layouts to resize TWICE
  3233. if (hasPane && evtName === "onresize_end") // BAD: || evtName === "onsizecontent_end"
  3234. resizeChildren(pane+"", true); // compiler hack -force string
  3235. return retVal;
  3236. function g (f) { return f; }; // compiler hack
  3237. }
  3238. /**
  3239. * cure iframe display issues in IE & other browsers
  3240. */
  3241. , _fixIframe = function (pane) {
  3242. if (browser.mozilla) return; // skip FireFox - it auto-refreshes iframes onShow
  3243. var $P = $Ps[pane];
  3244. // if the 'pane' is an iframe, do it
  3245. if (state[pane].tagName === "IFRAME")
  3246. $P.css(_c.hidden).css(_c.visible);
  3247. else // ditto for any iframes INSIDE the pane
  3248. $P.find('IFRAME').css(_c.hidden).css(_c.visible);
  3249. }
  3250. /**
  3251. * @param {string} pane Can accept ONLY a 'pane' (east, west, etc)
  3252. * @param {number=} outerSize (optional) Can pass a width, allowing calculations BEFORE element is resized
  3253. * @return {number} Returns the innerHeight/Width of el by subtracting padding and borders
  3254. */
  3255. , cssSize = function (pane, outerSize) {
  3256. var fn = _c[pane].dir=="horz" ? cssH : cssW;
  3257. return fn($Ps[pane], outerSize);
  3258. }
  3259. /**
  3260. * @param {string} pane Can accept ONLY a 'pane' (east, west, etc)
  3261. * @return {Object} Returns hash of minWidth & minHeight
  3262. */
  3263. , cssMinDims = function (pane) {
  3264. // minWidth/Height means CSS width/height = 1px
  3265. var $P = $Ps[pane]
  3266. , dir = _c[pane].dir
  3267. , d = {
  3268. minWidth: 1001 - cssW($P, 1000)
  3269. , minHeight: 1001 - cssH($P, 1000)
  3270. }
  3271. ;
  3272. if (dir === "horz") d.minSize = d.minHeight;
  3273. if (dir === "vert") d.minSize = d.minWidth;
  3274. return d;
  3275. }
  3276. // TODO: see if these methods can be made more useful...
  3277. // TODO: *maybe* return cssW/H from these so caller can use this info
  3278. /**
  3279. * @param {(string|!Object)} el
  3280. * @param {number=} outerWidth
  3281. * @param {boolean=} [autoHide=false]
  3282. */
  3283. , setOuterWidth = function (el, outerWidth, autoHide) {
  3284. var $E = el, w;
  3285. if (isStr(el)) $E = $Ps[el]; // west
  3286. else if (!el.jquery) $E = $(el);
  3287. w = cssW($E, outerWidth);
  3288. $E.css({ width: w });
  3289. if (w > 0) {
  3290. if (autoHide && $E.data('autoHidden') && $E.innerHeight() > 0) {
  3291. $E.show().data('autoHidden', false);
  3292. if (!browser.mozilla) // FireFox refreshes iframes - IE does not
  3293. // make hidden, then visible to 'refresh' display after animation
  3294. $E.css(_c.hidden).css(_c.visible);
  3295. }
  3296. }
  3297. else if (autoHide && !$E.data('autoHidden'))
  3298. $E.hide().data('autoHidden', true);
  3299. }
  3300. /**
  3301. * @param {(string|!Object)} el
  3302. * @param {number=} outerHeight
  3303. * @param {boolean=} [autoHide=false]
  3304. */
  3305. , setOuterHeight = function (el, outerHeight, autoHide) {
  3306. var $E = el, h;
  3307. if (isStr(el)) $E = $Ps[el]; // west
  3308. else if (!el.jquery) $E = $(el);
  3309. h = cssH($E, outerHeight);
  3310. $E.css({ height: h, visibility: "visible" }); // may have been 'hidden' by sizeContent
  3311. if (h > 0 && $E.innerWidth() > 0) {
  3312. if (autoHide && $E.data('autoHidden')) {
  3313. $E.show().data('autoHidden', false);
  3314. if (!browser.mozilla) // FireFox refreshes iframes - IE does not
  3315. $E.css(_c.hidden).css(_c.visible);
  3316. }
  3317. }
  3318. else if (autoHide && !$E.data('autoHidden'))
  3319. $E.hide().data('autoHidden', true);
  3320. }
  3321. /**
  3322. * Converts any 'size' params to a pixel/integer size, if not already
  3323. * If 'auto' or a decimal/percentage is passed as 'size', a pixel-size is calculated
  3324. *
  3325. /**
  3326. * @param {string} pane
  3327. * @param {(string|number)=} size
  3328. * @param {string=} [dir]
  3329. * @return {number}
  3330. */
  3331. , _parseSize = function (pane, size, dir) {
  3332. if (!dir) dir = _c[pane].dir;
  3333. if (isStr(size) && size.match(/%/))
  3334. size = (size === '100%') ? -1 : parseInt(size, 10) / 100; // convert % to decimal
  3335. if (size === 0)
  3336. return 0;
  3337. else if (size >= 1)
  3338. return parseInt(size, 10);
  3339. var o = options, avail = 0;
  3340. if (dir=="horz") // north or south or center.minHeight
  3341. avail = sC.innerHeight - ($Ps.north ? o.north.spacing_open : 0) - ($Ps.south ? o.south.spacing_open : 0);
  3342. else if (dir=="vert") // east or west or center.minWidth
  3343. avail = sC.innerWidth - ($Ps.west ? o.west.spacing_open : 0) - ($Ps.east ? o.east.spacing_open : 0);
  3344. if (size === -1) // -1 == 100%
  3345. return avail;
  3346. else if (size > 0) // percentage, eg: .25
  3347. return round(avail * size);
  3348. else if (pane=="center")
  3349. return 0;
  3350. else { // size < 0 || size=='auto' || size==Missing || size==Invalid
  3351. // auto-size the pane
  3352. var dim = (dir === "horz" ? "height" : "width")
  3353. , $P = $Ps[pane]
  3354. , $C = dim === 'height' ? $Cs[pane] : false
  3355. , vis = $.layout.showInvisibly($P) // show pane invisibly if hidden
  3356. , szP = $P.css(dim) // SAVE current pane size
  3357. , szC = $C ? $C.css(dim) : 0 // SAVE current content size
  3358. ;
  3359. $P.css(dim, "auto");
  3360. if ($C) $C.css(dim, "auto");
  3361. size = (dim === "height") ? $P.outerHeight() : $P.outerWidth(); // MEASURE
  3362. $P.css(dim, szP).css(vis); // RESET size & visibility
  3363. if ($C) $C.css(dim, szC);
  3364. return size;
  3365. }
  3366. }
  3367. /**
  3368. * Calculates current 'size' (outer-width or outer-height) of a border-pane - optionally with 'pane-spacing' added
  3369. *
  3370. * @param {(string|!Object)} pane
  3371. * @param {boolean=} [inclSpace=false]
  3372. * @return {number} Returns EITHER Width for east/west panes OR Height for north/south panes
  3373. */
  3374. , getPaneSize = function (pane, inclSpace) {
  3375. var
  3376. $P = $Ps[pane]
  3377. , o = options[pane]
  3378. , s = state[pane]
  3379. , oSp = (inclSpace ? o.spacing_open : 0)
  3380. , cSp = (inclSpace ? o.spacing_closed : 0)
  3381. ;
  3382. if (!$P || s.isHidden)
  3383. return 0;
  3384. else if (s.isClosed || (s.isSliding && inclSpace))
  3385. return cSp;
  3386. else if (_c[pane].dir === "horz")
  3387. return $P.outerHeight() + oSp;
  3388. else // dir === "vert"
  3389. return $P.outerWidth() + oSp;
  3390. }
  3391. /**
  3392. * Calculate min/max pane dimensions and limits for resizing
  3393. *
  3394. * @param {string} pane
  3395. * @param {boolean=} [slide=false]
  3396. */
  3397. , setSizeLimits = function (pane, slide) {
  3398. if (!isInitialized()) return;
  3399. var
  3400. o = options[pane]
  3401. , s = state[pane]
  3402. , c = _c[pane]
  3403. , dir = c.dir
  3404. , type = c.sizeType.toLowerCase()
  3405. , isSliding = (slide != undefined ? slide : s.isSliding) // only open() passes 'slide' param
  3406. , $P = $Ps[pane]
  3407. , paneSpacing = o.spacing_open
  3408. // measure the pane on the *opposite side* from this pane
  3409. , altPane = _c.oppositeEdge[pane]
  3410. , altS = state[altPane]
  3411. , $altP = $Ps[altPane]
  3412. , altPaneSize = (!$altP || altS.isVisible===false || altS.isSliding ? 0 : (dir=="horz" ? $altP.outerHeight() : $altP.outerWidth()))
  3413. , altPaneSpacing = ((!$altP || altS.isHidden ? 0 : options[altPane][ altS.isClosed !== false ? "spacing_closed" : "spacing_open" ]) || 0)
  3414. // limitSize prevents this pane from 'overlapping' opposite pane
  3415. , containerSize = (dir=="horz" ? sC.innerHeight : sC.innerWidth)
  3416. , minCenterDims = cssMinDims("center")
  3417. , minCenterSize = dir=="horz" ? max(options.center.minHeight, minCenterDims.minHeight) : max(options.center.minWidth, minCenterDims.minWidth)
  3418. // if pane is 'sliding', then ignore center and alt-pane sizes - because 'overlays' them
  3419. , limitSize = (containerSize - paneSpacing - (isSliding ? 0 : (_parseSize("center", minCenterSize, dir) + altPaneSize + altPaneSpacing)))
  3420. , minSize = s.minSize = max( _parseSize(pane, o.minSize), cssMinDims(pane).minSize )
  3421. , maxSize = s.maxSize = min( (o.maxSize ? _parseSize(pane, o.maxSize) : 100000), limitSize )
  3422. , r = s.resizerPosition = {} // used to set resizing limits
  3423. , top = sC.inset.top
  3424. , left = sC.inset.left
  3425. , W = sC.innerWidth
  3426. , H = sC.innerHeight
  3427. , rW = o.spacing_open // subtract resizer-width to get top/left position for south/east
  3428. ;
  3429. switch (pane) {
  3430. case "north": r.min = top + minSize;
  3431. r.max = top + maxSize;
  3432. break;
  3433. case "west": r.min = left + minSize;
  3434. r.max = left + maxSize;
  3435. break;
  3436. case "south": r.min = top + H - maxSize - rW;
  3437. r.max = top + H - minSize - rW;
  3438. break;
  3439. case "east": r.min = left + W - maxSize - rW;
  3440. r.max = left + W - minSize - rW;
  3441. break;
  3442. };
  3443. }
  3444. /**
  3445. * Returns data for setting the size/position of center pane. Also used to set Height for east/west panes
  3446. *
  3447. * @return JSON Returns a hash of all dimensions: top, bottom, left, right, (outer) width and (outer) height
  3448. */
  3449. , calcNewCenterPaneDims = function () {
  3450. var d = {
  3451. top: getPaneSize("north", true) // true = include 'spacing' value for pane
  3452. , bottom: getPaneSize("south", true)
  3453. , left: getPaneSize("west", true)
  3454. , right: getPaneSize("east", true)
  3455. , width: 0
  3456. , height: 0
  3457. };
  3458. // NOTE: sC = state.container
  3459. // calc center-pane outer dimensions
  3460. d.width = sC.innerWidth - d.left - d.right; // outerWidth
  3461. d.height = sC.innerHeight - d.bottom - d.top; // outerHeight
  3462. // add the 'container border/padding' to get final positions relative to the container
  3463. d.top += sC.inset.top;
  3464. d.bottom += sC.inset.bottom;
  3465. d.left += sC.inset.left;
  3466. d.right += sC.inset.right;
  3467. return d;
  3468. }
  3469. /**
  3470. * @param {!Object} el
  3471. * @param {boolean=} [allStates=false]
  3472. */
  3473. , getHoverClasses = function (el, allStates) {
  3474. var
  3475. $El = $(el)
  3476. , type = $El.data("layoutRole")
  3477. , pane = $El.data("layoutEdge")
  3478. , o = options[pane]
  3479. , root = o[type +"Class"]
  3480. , _pane = "-"+ pane // eg: "-west"
  3481. , _open = "-open"
  3482. , _closed = "-closed"
  3483. , _slide = "-sliding"
  3484. , _hover = "-hover " // NOTE the trailing space
  3485. , _state = $El.hasClass(root+_closed) ? _closed : _open
  3486. , _alt = _state === _closed ? _open : _closed
  3487. , classes = (root+_hover) + (root+_pane+_hover) + (root+_state+_hover) + (root+_pane+_state+_hover)
  3488. ;
  3489. if (allStates) // when 'removing' classes, also remove alternate-state classes
  3490. classes += (root+_alt+_hover) + (root+_pane+_alt+_hover);
  3491. if (type=="resizer" && $El.hasClass(root+_slide))
  3492. classes += (root+_slide+_hover) + (root+_pane+_slide+_hover);
  3493. return $.trim(classes);
  3494. }
  3495. , addHover = function (evt, el) {
  3496. var $E = $(el || this);
  3497. if (evt && $E.data("layoutRole") === "toggler")
  3498. evt.stopPropagation(); // prevent triggering 'slide' on Resizer-bar
  3499. $E.addClass( getHoverClasses($E) );
  3500. }
  3501. , removeHover = function (evt, el) {
  3502. var $E = $(el || this);
  3503. $E.removeClass( getHoverClasses($E, true) );
  3504. }
  3505. , onResizerEnter = function (evt) { // ALSO called by toggler.mouseenter
  3506. var pane = $(this).data("layoutEdge")
  3507. , s = state[pane]
  3508. ;
  3509. // ignore closed-panes and mouse moving back & forth over resizer!
  3510. // also ignore if ANY pane is currently resizing
  3511. if ( s.isClosed || s.isResizing || state.paneResizing ) return;
  3512. if ($.fn.disableSelection)
  3513. $("body").disableSelection();
  3514. if (options.maskPanesEarly)
  3515. showMasks( pane, { resizing: true });
  3516. }
  3517. , onResizerLeave = function (evt, el) {
  3518. var e = el || this // el is only passed when called by the timer
  3519. , pane = $(e).data("layoutEdge")
  3520. , name = pane +"ResizerLeave"
  3521. ;
  3522. timer.clear(pane+"_openSlider"); // cancel slideOpen timer, if set
  3523. timer.clear(name); // cancel enableSelection timer - may re/set below
  3524. // this method calls itself on a timer because it needs to allow
  3525. // enough time for dragging to kick-in and set the isResizing flag
  3526. // dragging has a 100ms delay set, so this delay must be >100
  3527. if (!el) // 1st call - mouseleave event
  3528. timer.set(name, function(){ onResizerLeave(evt, e); }, 200);
  3529. // if user is resizing, then dragStop will enableSelection(), so can skip it here
  3530. else if ( !state.paneResizing ) { // 2nd call - by timer
  3531. if ($.fn.enableSelection)
  3532. $("body").enableSelection();
  3533. if (options.maskPanesEarly)
  3534. hideMasks();
  3535. }
  3536. }
  3537. /*
  3538. * ###########################
  3539. * INITIALIZATION METHODS
  3540. * ###########################
  3541. */
  3542. /**
  3543. * Initialize the layout - called automatically whenever an instance of layout is created
  3544. *
  3545. * @see none - triggered onInit
  3546. * @return mixed true = fully initialized | false = panes not initialized (yet) | 'cancel' = abort
  3547. */
  3548. , _create = function () {
  3549. // initialize config/options
  3550. initOptions();
  3551. var o = options
  3552. , s = state;
  3553. // TEMP state so isInitialized returns true during init process
  3554. s.creatingLayout = true;
  3555. // init plugins for this layout, if there are any (eg: stateManagement)
  3556. runPluginCallbacks( Instance, $.layout.onCreate );
  3557. // options & state have been initialized, so now run beforeLoad callback
  3558. // onload will CANCEL layout creation if it returns false
  3559. if (false === _runCallbacks("onload_start"))
  3560. return 'cancel';
  3561. // initialize the container element
  3562. _initContainer();
  3563. // bind hotkey function - keyDown - if required
  3564. initHotkeys();
  3565. // bind window.onunload
  3566. $(window).bind("unload."+ sID, unload);
  3567. // init plugins for this layout, if there are any (eg: customButtons)
  3568. runPluginCallbacks( Instance, $.layout.onLoad );
  3569. // if layout elements are hidden, then layout WILL NOT complete initialization!
  3570. // initLayoutElements will set initialized=true and run the onload callback IF successful
  3571. if (o.initPanes) _initLayoutElements();
  3572. delete s.creatingLayout;
  3573. return state.initialized;
  3574. }
  3575. /**
  3576. * Initialize the layout IF not already
  3577. *
  3578. * @see All methods in Instance run this test
  3579. * @return boolean true = layoutElements have been initialized | false = panes are not initialized (yet)
  3580. */
  3581. , isInitialized = function () {
  3582. if (state.initialized || state.creatingLayout) return true; // already initialized
  3583. else return _initLayoutElements(); // try to init panes NOW
  3584. }
  3585. /**
  3586. * Initialize the layout - called automatically whenever an instance of layout is created
  3587. *
  3588. * @see _create() & isInitialized
  3589. * @param {boolean=} [retry=false] // indicates this is a 2nd try
  3590. * @return An object pointer to the instance created
  3591. */
  3592. , _initLayoutElements = function (retry) {
  3593. // initialize config/options
  3594. var o = options;
  3595. // CANNOT init panes inside a hidden container!
  3596. if (!$N.is(":visible")) {
  3597. // handle Chrome bug where popup window 'has no height'
  3598. // if layout is BODY element, try again in 50ms
  3599. // SEE: http://layout.jquery-dev.net/samples/test_popup_window.html
  3600. if ( !retry && browser.webkit && $N[0].tagName === "BODY" )
  3601. setTimeout(function(){ _initLayoutElements(true); }, 50);
  3602. return false;
  3603. }
  3604. // a center pane is required, so make sure it exists
  3605. if (!getPane("center").length) {
  3606. return _log( o.errors.centerPaneMissing );
  3607. }
  3608. // TEMP state so isInitialized returns true during init process
  3609. state.creatingLayout = true;
  3610. // update Container dims
  3611. $.extend(sC, elDims( $N, o.inset )); // passing inset means DO NOT include insetX values
  3612. // initialize all layout elements
  3613. initPanes(); // size & position panes - calls initHandles() - which calls initResizable()
  3614. if (o.scrollToBookmarkOnLoad) {
  3615. var l = self.location;
  3616. if (l.hash) l.replace( l.hash ); // scrollTo Bookmark
  3617. }
  3618. // check to see if this layout 'nested' inside a pane
  3619. if (Instance.hasParentLayout)
  3620. o.resizeWithWindow = false;
  3621. // bind resizeAll() for 'this layout instance' to window.resize event
  3622. else if (o.resizeWithWindow)
  3623. $(window).bind("resize."+ sID, windowResize);
  3624. delete state.creatingLayout;
  3625. state.initialized = true;
  3626. // init plugins for this layout, if there are any
  3627. runPluginCallbacks( Instance, $.layout.onReady );
  3628. // now run the onload callback, if exists
  3629. _runCallbacks("onload_end");
  3630. return true; // elements initialized successfully
  3631. }
  3632. /**
  3633. * Initialize nested layouts for a specific pane - can optionally pass layout-options
  3634. *
  3635. * @param {(string|Object)} evt_or_pane The pane being opened, ie: north, south, east, or west
  3636. * @param {Object=} [opts] Layout-options - if passed, will OVERRRIDE options[pane].children
  3637. * @return An object pointer to the layout instance created - or null
  3638. */
  3639. , createChildren = function (evt_or_pane, opts) {
  3640. var pane = evtPane.call(this, evt_or_pane)
  3641. , $P = $Ps[pane]
  3642. ;
  3643. if (!$P) return;
  3644. var $C = $Cs[pane]
  3645. , s = state[pane]
  3646. , o = options[pane]
  3647. , sm = options.stateManagement || {}
  3648. , cos = opts ? (o.children = opts) : o.children
  3649. ;
  3650. if ( $.isPlainObject( cos ) )
  3651. cos = [ cos ]; // convert a hash to a 1-elem array
  3652. else if (!cos || !$.isArray( cos ))
  3653. return;
  3654. $.each( cos, function (idx, co) {
  3655. if ( !$.isPlainObject( co ) ) return;
  3656. // determine which element is supposed to be the 'child container'
  3657. // if pane has a 'containerSelector' OR a 'content-div', use those instead of the pane
  3658. var $containers = co.containerSelector ? $P.find( co.containerSelector ) : ($C || $P);
  3659. $containers.each(function(){
  3660. var $cont = $(this)
  3661. , child = $cont.data("layout") // see if a child-layout ALREADY exists on this element
  3662. ;
  3663. // if no layout exists, but children are set, try to create the layout now
  3664. if (!child) {
  3665. // TODO: see about moving this to the stateManagement plugin, as a method
  3666. // set a unique child-instance key for this layout, if not already set
  3667. setInstanceKey({ container: $cont, options: co }, s );
  3668. // If THIS layout has a hash in stateManagement.autoLoad,
  3669. // then see if it also contains state-data for this child-layout
  3670. // If so, copy the stateData to child.options.stateManagement.autoLoad
  3671. if ( sm.includeChildren && state.stateData[pane] ) {
  3672. // THIS layout's state was cached when its state was loaded
  3673. var paneChildren = state.stateData[pane].children || {}
  3674. , childState = paneChildren[ co.instanceKey ]
  3675. , co_sm = co.stateManagement || (co.stateManagement = { autoLoad: true })
  3676. ;
  3677. // COPY the stateData into the autoLoad key
  3678. if ( co_sm.autoLoad === true && childState ) {
  3679. co_sm.autoSave = false; // disable autoSave because saving handled by parent-layout
  3680. co_sm.includeChildren = true; // cascade option - FOR NOW
  3681. co_sm.autoLoad = $.extend(true, {}, childState); // COPY the state-hash
  3682. }
  3683. }
  3684. // create the layout
  3685. child = $cont.layout( co );
  3686. // if successful, update data
  3687. if (child) {
  3688. // add the child and update all layout-pointers
  3689. // MAY have already been done by child-layout calling parent.refreshChildren()
  3690. refreshChildren( pane, child );
  3691. }
  3692. }
  3693. });
  3694. });
  3695. }
  3696. , setInstanceKey = function (child, parentPaneState) {
  3697. // create a named key for use in state and instance branches
  3698. var $c = child.container
  3699. , o = child.options
  3700. , sm = o.stateManagement
  3701. , key = o.instanceKey || $c.data("layoutInstanceKey")
  3702. ;
  3703. if (!key) key = (sm && sm.cookie ? sm.cookie.name : '') || o.name; // look for a name/key
  3704. if (!key) key = "layout"+ (++parentPaneState.childIdx); // if no name/key found, generate one
  3705. else key = key.replace(/[^\w-]/gi, '_').replace(/_{2,}/g, '_'); // ensure is valid as a hash key
  3706. o.instanceKey = key;
  3707. $c.data("layoutInstanceKey", key); // useful if layout is destroyed and then recreated
  3708. return key;
  3709. }
  3710. /**
  3711. * @param {string} pane The pane being opened, ie: north, south, east, or west
  3712. * @param {Object=} newChild New child-layout Instance to add to this pane
  3713. */
  3714. , refreshChildren = function (pane, newChild) {
  3715. var $P = $Ps[pane]
  3716. , pC = children[pane]
  3717. , s = state[pane]
  3718. , o
  3719. ;
  3720. // check for destroy()ed layouts and update the child pointers & arrays
  3721. if ($.isPlainObject( pC )) {
  3722. $.each( pC, function (key, child) {
  3723. if (child.destroyed) delete pC[key]
  3724. });
  3725. // if no more children, remove the children hash
  3726. if ($.isEmptyObject( pC ))
  3727. pC = children[pane] = null; // clear children hash
  3728. }
  3729. // see if there is a directly-nested layout inside this pane
  3730. // if there is, then there can be only ONE child-layout, so check that...
  3731. if (!newChild && !pC) {
  3732. newChild = $P.data("layout");
  3733. }
  3734. // if a newChild instance was passed, add it to children[pane]
  3735. if (newChild) {
  3736. // update child.state
  3737. newChild.hasParentLayout = true; // set parent-flag in child
  3738. // instanceKey is a key-name used in both state and children
  3739. o = newChild.options;
  3740. // set a unique child-instance key for this layout, if not already set
  3741. setInstanceKey( newChild, s );
  3742. // add pointer to pane.children hash
  3743. if (!pC) pC = children[pane] = {}; // create an empty children hash
  3744. pC[ o.instanceKey ] = newChild.container.data("layout"); // add childLayout instance
  3745. }
  3746. // ALWAYS refresh the pane.children alias, even if null
  3747. Instance[pane].children = children[pane];
  3748. // if newChild was NOT passed - see if there is a child layout NOW
  3749. if (!newChild) {
  3750. createChildren(pane); // MAY create a child and re-call this method
  3751. }
  3752. }
  3753. , windowResize = function () {
  3754. var o = options
  3755. , delay = Number(o.resizeWithWindowDelay);
  3756. if (delay < 10) delay = 100; // MUST have a delay!
  3757. // resizing uses a delay-loop because the resize event fires repeatly - except in FF, but delay anyway
  3758. timer.clear("winResize"); // if already running
  3759. timer.set("winResize", function(){
  3760. timer.clear("winResize");
  3761. timer.clear("winResizeRepeater");
  3762. var dims = elDims( $N, o.inset );
  3763. // only trigger resizeAll() if container has changed size
  3764. if (dims.innerWidth !== sC.innerWidth || dims.innerHeight !== sC.innerHeight)
  3765. resizeAll();
  3766. }, delay);
  3767. // ALSO set fixed-delay timer, if not already running
  3768. if (!timer.data["winResizeRepeater"]) setWindowResizeRepeater();
  3769. }
  3770. , setWindowResizeRepeater = function () {
  3771. var delay = Number(options.resizeWithWindowMaxDelay);
  3772. if (delay > 0)
  3773. timer.set("winResizeRepeater", function(){ setWindowResizeRepeater(); resizeAll(); }, delay);
  3774. }
  3775. , unload = function () {
  3776. var o = options;
  3777. _runCallbacks("onunload_start");
  3778. // trigger plugin callabacks for this layout (eg: stateManagement)
  3779. runPluginCallbacks( Instance, $.layout.onUnload );
  3780. _runCallbacks("onunload_end");
  3781. }
  3782. /**
  3783. * Validate and initialize container CSS and events
  3784. *
  3785. * @see _create()
  3786. */
  3787. , _initContainer = function () {
  3788. var
  3789. N = $N[0]
  3790. , $H = $("html")
  3791. , tag = sC.tagName = N.tagName
  3792. , id = sC.id = N.id
  3793. , cls = sC.className = N.className
  3794. , o = options
  3795. , name = o.name
  3796. , props = "position,margin,padding,border"
  3797. , css = "layoutCSS"
  3798. , CSS = {}
  3799. , hid = "hidden" // used A LOT!
  3800. // see if this container is a 'pane' inside an outer-layout
  3801. , parent = $N.data("parentLayout") // parent-layout Instance
  3802. , pane = $N.data("layoutEdge") // pane-name in parent-layout
  3803. , isChild = parent && pane
  3804. , num = $.layout.cssNum
  3805. , $parent, n
  3806. ;
  3807. // sC = state.container
  3808. sC.selector = $N.selector.split(".slice")[0];
  3809. sC.ref = (o.name ? o.name +' layout / ' : '') + tag + (id ? "#"+id : cls ? '.['+cls+']' : ''); // used in messages
  3810. sC.isBody = (tag === "BODY");
  3811. // try to find a parent-layout
  3812. if (!isChild && !sC.isBody) {
  3813. $parent = $N.closest("."+ $.layout.defaults.panes.paneClass);
  3814. parent = $parent.data("parentLayout");
  3815. pane = $parent.data("layoutEdge");
  3816. isChild = parent && pane;
  3817. }
  3818. $N .data({
  3819. layout: Instance
  3820. , layoutContainer: sID // FLAG to indicate this is a layout-container - contains unique internal ID
  3821. })
  3822. .addClass(o.containerClass)
  3823. ;
  3824. var layoutMethods = {
  3825. destroy: ''
  3826. , initPanes: ''
  3827. , resizeAll: 'resizeAll'
  3828. , resize: 'resizeAll'
  3829. };
  3830. // loop hash and bind all methods - include layoutID namespacing
  3831. for (name in layoutMethods) {
  3832. $N.bind("layout"+ name.toLowerCase() +"."+ sID, Instance[ layoutMethods[name] || name ]);
  3833. }
  3834. // if this container is another layout's 'pane', then set child/parent pointers
  3835. if (isChild) {
  3836. // update parent flag
  3837. Instance.hasParentLayout = true;
  3838. // set pointers to THIS child-layout (Instance) in parent-layout
  3839. parent.refreshChildren( pane, Instance );
  3840. }
  3841. // SAVE original container CSS for use in destroy()
  3842. if (!$N.data(css)) {
  3843. // handle props like overflow different for BODY & HTML - has 'system default' values
  3844. if (sC.isBody) {
  3845. // SAVE <BODY> CSS
  3846. $N.data(css, $.extend( styles($N, props), {
  3847. height: $N.css("height")
  3848. , overflow: $N.css("overflow")
  3849. , overflowX: $N.css("overflowX")
  3850. , overflowY: $N.css("overflowY")
  3851. }));
  3852. // ALSO SAVE <HTML> CSS
  3853. $H.data(css, $.extend( styles($H, 'padding'), {
  3854. height: "auto" // FF would return a fixed px-size!
  3855. , overflow: $H.css("overflow")
  3856. , overflowX: $H.css("overflowX")
  3857. , overflowY: $H.css("overflowY")
  3858. }));
  3859. }
  3860. else // handle props normally for non-body elements
  3861. $N.data(css, styles($N, props+",top,bottom,left,right,width,height,overflow,overflowX,overflowY") );
  3862. }
  3863. try {
  3864. // common container CSS
  3865. CSS = {
  3866. overflow: hid
  3867. , overflowX: hid
  3868. , overflowY: hid
  3869. };
  3870. $N.css( CSS );
  3871. if (o.inset && !$.isPlainObject(o.inset)) {
  3872. // can specify a single number for equal outset all-around
  3873. n = parseInt(o.inset, 10) || 0
  3874. o.inset = {
  3875. top: n
  3876. , bottom: n
  3877. , left: n
  3878. , right: n
  3879. };
  3880. }
  3881. // format html & body if this is a full page layout
  3882. if (sC.isBody) {
  3883. // if HTML has padding, use this as an outer-spacing around BODY
  3884. if (!o.outset) {
  3885. // use padding from parent-elem (HTML) as outset
  3886. o.outset = {
  3887. top: num($H, "paddingTop")
  3888. , bottom: num($H, "paddingBottom")
  3889. , left: num($H, "paddingLeft")
  3890. , right: num($H, "paddingRight")
  3891. };
  3892. }
  3893. else if (!$.isPlainObject(o.outset)) {
  3894. // can specify a single number for equal outset all-around
  3895. n = parseInt(o.outset, 10) || 0
  3896. o.outset = {
  3897. top: n
  3898. , bottom: n
  3899. , left: n
  3900. , right: n
  3901. };
  3902. }
  3903. // HTML
  3904. $H.css( CSS ).css({
  3905. height: "100%"
  3906. , border: "none" // no border or padding allowed when using height = 100%
  3907. , padding: 0 // ditto
  3908. , margin: 0
  3909. });
  3910. // BODY
  3911. if (browser.isIE6) {
  3912. // IE6 CANNOT use the trick of setting absolute positioning on all 4 sides - must have 'height'
  3913. $N.css({
  3914. width: "100%"
  3915. , height: "100%"
  3916. , border: "none" // no border or padding allowed when using height = 100%
  3917. , padding: 0 // ditto
  3918. , margin: 0
  3919. , position: "relative"
  3920. });
  3921. // convert body padding to an inset option - the border cannot be measured in IE6!
  3922. if (!o.inset) o.inset = elDims( $N ).inset;
  3923. }
  3924. else { // use absolute positioning for BODY to allow borders & padding without overflow
  3925. $N.css({
  3926. width: "auto"
  3927. , height: "auto"
  3928. , margin: 0
  3929. , position: "absolute" // allows for border and padding on BODY
  3930. });
  3931. // apply edge-positioning created above
  3932. $N.css( o.outset );
  3933. }
  3934. // set current layout-container dimensions
  3935. $.extend(sC, elDims( $N, o.inset )); // passing inset means DO NOT include insetX values
  3936. }
  3937. else {
  3938. // container MUST have 'position'
  3939. var p = $N.css("position");
  3940. if (!p || !p.match(/(fixed|absolute|relative)/))
  3941. $N.css("position","relative");
  3942. // set current layout-container dimensions
  3943. if ( $N.is(":visible") ) {
  3944. $.extend(sC, elDims( $N, o.inset )); // passing inset means DO NOT change insetX (padding) values
  3945. if (sC.innerHeight < 1) // container has no 'height' - warn developer
  3946. _log( o.errors.noContainerHeight.replace(/CONTAINER/, sC.ref) );
  3947. }
  3948. }
  3949. // if container has min-width/height, then enable scrollbar(s)
  3950. if ( num($N, "minWidth") ) $N.parent().css("overflowX","auto");
  3951. if ( num($N, "minHeight") ) $N.parent().css("overflowY","auto");
  3952. } catch (ex) {}
  3953. }
  3954. /**
  3955. * Bind layout hotkeys - if options enabled
  3956. *
  3957. * @see _create() and addPane()
  3958. * @param {string=} [panes=""] The edge(s) to process
  3959. */
  3960. , initHotkeys = function (panes) {
  3961. panes = panes ? panes.split(",") : _c.borderPanes;
  3962. // bind keyDown to capture hotkeys, if option enabled for ANY pane
  3963. $.each(panes, function (i, pane) {
  3964. var o = options[pane];
  3965. if (o.enableCursorHotkey || o.customHotkey) {
  3966. $(document).bind("keydown."+ sID, keyDown); // only need to bind this ONCE
  3967. return false; // BREAK - binding was done
  3968. }
  3969. });
  3970. }
  3971. /**
  3972. * Build final OPTIONS data
  3973. *
  3974. * @see _create()
  3975. */
  3976. , initOptions = function () {
  3977. var data, d, pane, key, val, i, c, o;
  3978. // reprocess user's layout-options to have correct options sub-key structure
  3979. opts = $.layout.transformData( opts, true ); // panes = default subkey
  3980. // auto-rename old options for backward compatibility
  3981. opts = $.layout.backwardCompatibility.renameAllOptions( opts );
  3982. // if user-options has 'panes' key (pane-defaults), clean it...
  3983. if (!$.isEmptyObject(opts.panes)) {
  3984. // REMOVE any pane-defaults that MUST be set per-pane
  3985. data = $.layout.optionsMap.noDefault;
  3986. for (i=0, c=data.length; i<c; i++) {
  3987. key = data[i];
  3988. delete opts.panes[key]; // OK if does not exist
  3989. }
  3990. // REMOVE any layout-options specified under opts.panes
  3991. data = $.layout.optionsMap.layout;
  3992. for (i=0, c=data.length; i<c; i++) {
  3993. key = data[i];
  3994. delete opts.panes[key]; // OK if does not exist
  3995. }
  3996. }
  3997. // MOVE any NON-layout-options from opts-root to opts.panes
  3998. data = $.layout.optionsMap.layout;
  3999. var rootKeys = $.layout.config.optionRootKeys;
  4000. for (key in opts) {
  4001. val = opts[key];
  4002. if ($.inArray(key, rootKeys) < 0 && $.inArray(key, data) < 0) {
  4003. if (!opts.panes[key])
  4004. opts.panes[key] = $.isPlainObject(val) ? $.extend(true, {}, val) : val;
  4005. delete opts[key]
  4006. }
  4007. }
  4008. // START by updating ALL options from opts
  4009. $.extend(true, options, opts);
  4010. // CREATE final options (and config) for EACH pane
  4011. $.each(_c.allPanes, function (i, pane) {
  4012. // apply 'pane-defaults' to CONFIG.[PANE]
  4013. _c[pane] = $.extend(true, {}, _c.panes, _c[pane]);
  4014. d = options.panes;
  4015. o = options[pane];
  4016. // center-pane uses SOME keys in defaults.panes branch
  4017. if (pane === 'center') {
  4018. // ONLY copy keys from opts.panes listed in: $.layout.optionsMap.center
  4019. data = $.layout.optionsMap.center; // list of 'center-pane keys'
  4020. for (i=0, c=data.length; i<c; i++) { // loop the list...
  4021. key = data[i];
  4022. // only need to use pane-default if pane-specific value not set
  4023. if (!opts.center[key] && (opts.panes[key] || !o[key]))
  4024. o[key] = d[key]; // pane-default
  4025. }
  4026. }
  4027. else {
  4028. // border-panes use ALL keys in defaults.panes branch
  4029. o = options[pane] = $.extend(true, {}, d, o); // re-apply pane-specific opts AFTER pane-defaults
  4030. createFxOptions( pane );
  4031. // ensure all border-pane-specific base-classes exist
  4032. if (!o.resizerClass) o.resizerClass = "ui-layout-resizer";
  4033. if (!o.togglerClass) o.togglerClass = "ui-layout-toggler";
  4034. }
  4035. // ensure we have base pane-class (ALL panes)
  4036. if (!o.paneClass) o.paneClass = "ui-layout-pane";
  4037. });
  4038. // update options.zIndexes if a zIndex-option specified
  4039. var zo = opts.zIndex
  4040. , z = options.zIndexes;
  4041. if (zo > 0) {
  4042. z.pane_normal = zo;
  4043. z.content_mask = max(zo+1, z.content_mask); // MIN = +1
  4044. z.resizer_normal = max(zo+2, z.resizer_normal); // MIN = +2
  4045. }
  4046. // DELETE 'panes' key now that we are done - values were copied to EACH pane
  4047. delete options.panes;
  4048. function createFxOptions ( pane ) {
  4049. var o = options[pane]
  4050. , d = options.panes;
  4051. // ensure fxSettings key to avoid errors
  4052. if (!o.fxSettings) o.fxSettings = {};
  4053. if (!d.fxSettings) d.fxSettings = {};
  4054. $.each(["_open","_close","_size"], function (i,n) {
  4055. var
  4056. sName = "fxName"+ n
  4057. , sSpeed = "fxSpeed"+ n
  4058. , sSettings = "fxSettings"+ n
  4059. // recalculate fxName according to specificity rules
  4060. , fxName = o[sName] =
  4061. o[sName] // options.west.fxName_open
  4062. || d[sName] // options.panes.fxName_open
  4063. || o.fxName // options.west.fxName
  4064. || d.fxName // options.panes.fxName
  4065. || "none" // MEANS $.layout.defaults.panes.fxName == "" || false || null || 0
  4066. , fxExists = $.effects && ($.effects[fxName] || ($.effects.effect && $.effects.effect[fxName]))
  4067. ;
  4068. // validate fxName to ensure is valid effect - MUST have effect-config data in options.effects
  4069. if (fxName === "none" || !options.effects[fxName] || !fxExists)
  4070. fxName = o[sName] = "none"; // effect not loaded OR unrecognized fxName
  4071. // set vars for effects subkeys to simplify logic
  4072. var fx = options.effects[fxName] || {} // effects.slide
  4073. , fx_all = fx.all || null // effects.slide.all
  4074. , fx_pane = fx[pane] || null // effects.slide.west
  4075. ;
  4076. // create fxSpeed[_open|_close|_size]
  4077. o[sSpeed] =
  4078. o[sSpeed] // options.west.fxSpeed_open
  4079. || d[sSpeed] // options.west.fxSpeed_open
  4080. || o.fxSpeed // options.west.fxSpeed
  4081. || d.fxSpeed // options.panes.fxSpeed
  4082. || null // DEFAULT - let fxSetting.duration control speed
  4083. ;
  4084. // create fxSettings[_open|_close|_size]
  4085. o[sSettings] = $.extend(
  4086. true
  4087. , {}
  4088. , fx_all // effects.slide.all
  4089. , fx_pane // effects.slide.west
  4090. , d.fxSettings // options.panes.fxSettings
  4091. , o.fxSettings // options.west.fxSettings
  4092. , d[sSettings] // options.panes.fxSettings_open
  4093. , o[sSettings] // options.west.fxSettings_open
  4094. );
  4095. });
  4096. // DONE creating action-specific-settings for this pane,
  4097. // so DELETE generic options - are no longer meaningful
  4098. delete o.fxName;
  4099. delete o.fxSpeed;
  4100. delete o.fxSettings;
  4101. }
  4102. }
  4103. /**
  4104. * Initialize module objects, styling, size and position for all panes
  4105. *
  4106. * @see _initElements()
  4107. * @param {string} pane The pane to process
  4108. */
  4109. , getPane = function (pane) {
  4110. var sel = options[pane].paneSelector
  4111. if (sel.substr(0,1)==="#") // ID selector
  4112. // NOTE: elements selected 'by ID' DO NOT have to be 'children'
  4113. return $N.find(sel).eq(0);
  4114. else { // class or other selector
  4115. var $P = $N.children(sel).eq(0);
  4116. // look for the pane nested inside a 'form' element
  4117. return $P.length ? $P : $N.children("form:first").children(sel).eq(0);
  4118. }
  4119. }
  4120. /**
  4121. * @param {Object=} evt
  4122. */
  4123. , initPanes = function (evt) {
  4124. // stopPropagation if called by trigger("layoutinitpanes") - use evtPane utility
  4125. evtPane(evt);
  4126. // NOTE: do north & south FIRST so we can measure their height - do center LAST
  4127. $.each(_c.allPanes, function (idx, pane) {
  4128. addPane( pane, true );
  4129. });
  4130. // init the pane-handles NOW in case we have to hide or close the pane below
  4131. initHandles();
  4132. // now that all panes have been initialized and initially-sized,
  4133. // make sure there is really enough space available for each pane
  4134. $.each(_c.borderPanes, function (i, pane) {
  4135. if ($Ps[pane] && state[pane].isVisible) { // pane is OPEN
  4136. setSizeLimits(pane);
  4137. makePaneFit(pane); // pane may be Closed, Hidden or Resized by makePaneFit()
  4138. }
  4139. });
  4140. // size center-pane AGAIN in case we 'closed' a border-pane in loop above
  4141. sizeMidPanes("center");
  4142. // Chrome/Webkit sometimes fires callbacks BEFORE it completes resizing!
  4143. // Before RC30.3, there was a 10ms delay here, but that caused layout
  4144. // to load asynchrously, which is BAD, so try skipping delay for now
  4145. // process pane contents and callbacks, and init/resize child-layout if exists
  4146. $.each(_c.allPanes, function (idx, pane) {
  4147. afterInitPane(pane);
  4148. });
  4149. }
  4150. /**
  4151. * Add a pane to the layout - subroutine of initPanes()
  4152. *
  4153. * @see initPanes()
  4154. * @param {string} pane The pane to process
  4155. * @param {boolean=} [force=false] Size content after init
  4156. */
  4157. , addPane = function (pane, force) {
  4158. if (!force && !isInitialized()) return;
  4159. var
  4160. o = options[pane]
  4161. , s = state[pane]
  4162. , c = _c[pane]
  4163. , dir = c.dir
  4164. , fx = s.fx
  4165. , spacing = o.spacing_open || 0
  4166. , isCenter = (pane === "center")
  4167. , CSS = {}
  4168. , $P = $Ps[pane]
  4169. , size, minSize, maxSize, child
  4170. ;
  4171. // if pane-pointer already exists, remove the old one first
  4172. if ($P)
  4173. removePane( pane, false, true, false );
  4174. else
  4175. $Cs[pane] = false; // init
  4176. $P = $Ps[pane] = getPane(pane);
  4177. if (!$P.length) {
  4178. $Ps[pane] = false; // logic
  4179. return;
  4180. }
  4181. // SAVE original Pane CSS
  4182. if (!$P.data("layoutCSS")) {
  4183. var props = "position,top,left,bottom,right,width,height,overflow,zIndex,display,backgroundColor,padding,margin,border";
  4184. $P.data("layoutCSS", styles($P, props));
  4185. }
  4186. // create alias for pane data in Instance - initHandles will add more
  4187. Instance[pane] = {
  4188. name: pane
  4189. , pane: $Ps[pane]
  4190. , content: $Cs[pane]
  4191. , options: options[pane]
  4192. , state: state[pane]
  4193. , children: children[pane]
  4194. };
  4195. // add classes, attributes & events
  4196. $P .data({
  4197. parentLayout: Instance // pointer to Layout Instance
  4198. , layoutPane: Instance[pane] // NEW pointer to pane-alias-object
  4199. , layoutEdge: pane
  4200. , layoutRole: "pane"
  4201. })
  4202. .css(c.cssReq).css("zIndex", options.zIndexes.pane_normal)
  4203. .css(o.applyDemoStyles ? c.cssDemo : {}) // demo styles
  4204. .addClass( o.paneClass +" "+ o.paneClass+"-"+pane ) // default = "ui-layout-pane ui-layout-pane-west" - may be a dupe of 'paneSelector'
  4205. .bind("mouseenter."+ sID, addHover )
  4206. .bind("mouseleave."+ sID, removeHover )
  4207. ;
  4208. var paneMethods = {
  4209. hide: ''
  4210. , show: ''
  4211. , toggle: ''
  4212. , close: ''
  4213. , open: ''
  4214. , slideOpen: ''
  4215. , slideClose: ''
  4216. , slideToggle: ''
  4217. , size: 'sizePane'
  4218. , sizePane: 'sizePane'
  4219. , sizeContent: ''
  4220. , sizeHandles: ''
  4221. , enableClosable: ''
  4222. , disableClosable: ''
  4223. , enableSlideable: ''
  4224. , disableSlideable: ''
  4225. , enableResizable: ''
  4226. , disableResizable: ''
  4227. , swapPanes: 'swapPanes'
  4228. , swap: 'swapPanes'
  4229. , move: 'swapPanes'
  4230. , removePane: 'removePane'
  4231. , remove: 'removePane'
  4232. , createChildren: ''
  4233. , resizeChildren: ''
  4234. , resizeAll: 'resizeAll'
  4235. , resizeLayout: 'resizeAll'
  4236. }
  4237. , name;
  4238. // loop hash and bind all methods - include layoutID namespacing
  4239. for (name in paneMethods) {
  4240. $P.bind("layoutpane"+ name.toLowerCase() +"."+ sID, Instance[ paneMethods[name] || name ]);
  4241. }
  4242. // see if this pane has a 'scrolling-content element'
  4243. initContent(pane, false); // false = do NOT sizeContent() - called later
  4244. if (!isCenter) {
  4245. // call _parseSize AFTER applying pane classes & styles - but before making visible (if hidden)
  4246. // if o.size is auto or not valid, then MEASURE the pane and use that as its 'size'
  4247. size = s.size = _parseSize(pane, o.size);
  4248. minSize = _parseSize(pane,o.minSize) || 1;
  4249. maxSize = _parseSize(pane,o.maxSize) || 100000;
  4250. if (size > 0) size = max(min(size, maxSize), minSize);
  4251. s.autoResize = o.autoResize; // used with percentage sizes
  4252. // state for border-panes
  4253. s.isClosed = false; // true = pane is closed
  4254. s.isSliding = false; // true = pane is currently open by 'sliding' over adjacent panes
  4255. s.isResizing= false; // true = pane is in process of being resized
  4256. s.isHidden = false; // true = pane is hidden - no spacing, resizer or toggler is visible!
  4257. // array for 'pin buttons' whose classNames are auto-updated on pane-open/-close
  4258. if (!s.pins) s.pins = [];
  4259. }
  4260. // states common to ALL panes
  4261. s.tagName = $P[0].tagName;
  4262. s.edge = pane; // useful if pane is (or about to be) 'swapped' - easy find out where it is (or is going)
  4263. s.noRoom = false; // true = pane 'automatically' hidden due to insufficient room - will unhide automatically
  4264. s.isVisible = true; // false = pane is invisible - closed OR hidden - simplify logic
  4265. // init pane positioning
  4266. setPanePosition( pane );
  4267. // if pane is not visible,
  4268. if (dir === "horz") // north or south pane
  4269. CSS.height = cssH($P, size);
  4270. else if (dir === "vert") // east or west pane
  4271. CSS.width = cssW($P, size);
  4272. //else if (isCenter) {}
  4273. $P.css(CSS); // apply size -- top, bottom & height will be set by sizeMidPanes
  4274. if (dir != "horz") sizeMidPanes(pane, true); // true = skipCallback
  4275. // if manually adding a pane AFTER layout initialization, then...
  4276. if (state.initialized) {
  4277. initHandles( pane );
  4278. initHotkeys( pane );
  4279. }
  4280. // close or hide the pane if specified in settings
  4281. if (o.initClosed && o.closable && !o.initHidden)
  4282. close(pane, true, true); // true, true = force, noAnimation
  4283. else if (o.initHidden || o.initClosed)
  4284. hide(pane); // will be completely invisible - no resizer or spacing
  4285. else if (!s.noRoom)
  4286. // make the pane visible - in case was initially hidden
  4287. $P.css("display","block");
  4288. // ELSE setAsOpen() - called later by initHandles()
  4289. // RESET visibility now - pane will appear IF display:block
  4290. $P.css("visibility","visible");
  4291. // check option for auto-handling of pop-ups & drop-downs
  4292. if (o.showOverflowOnHover)
  4293. $P.hover( allowOverflow, resetOverflow );
  4294. // if manually adding a pane AFTER layout initialization, then...
  4295. if (state.initialized) {
  4296. afterInitPane( pane );
  4297. }
  4298. }
  4299. , afterInitPane = function (pane) {
  4300. var $P = $Ps[pane]
  4301. , s = state[pane]
  4302. , o = options[pane]
  4303. ;
  4304. if (!$P) return;
  4305. // see if there is a directly-nested layout inside this pane
  4306. if ($P.data("layout"))
  4307. refreshChildren( pane, $P.data("layout") );
  4308. // process pane contents and callbacks, and init/resize child-layout if exists
  4309. if (s.isVisible) { // pane is OPEN
  4310. if (state.initialized) // this pane was added AFTER layout was created
  4311. resizeAll(); // will also sizeContent
  4312. else
  4313. sizeContent(pane);
  4314. if (o.triggerEventsOnLoad)
  4315. _runCallbacks("onresize_end", pane);
  4316. else // automatic if onresize called, otherwise call it specifically
  4317. // resize child - IF inner-layout already exists (created before this layout)
  4318. resizeChildren(pane, true); // a previously existing childLayout
  4319. }
  4320. // init childLayouts - even if pane is not visible
  4321. if (o.initChildren && o.children)
  4322. createChildren(pane);
  4323. }
  4324. /**
  4325. * @param {string=} panes The pane(s) to process
  4326. */
  4327. , setPanePosition = function (panes) {
  4328. panes = panes ? panes.split(",") : _c.borderPanes;
  4329. // create toggler DIVs for each pane, and set object pointers for them, eg: $R.north = north toggler DIV
  4330. $.each(panes, function (i, pane) {
  4331. var $P = $Ps[pane]
  4332. , $R = $Rs[pane]
  4333. , o = options[pane]
  4334. , s = state[pane]
  4335. , side = _c[pane].side
  4336. , CSS = {}
  4337. ;
  4338. if (!$P) return; // pane does not exist - skip
  4339. // set css-position to account for container borders & padding
  4340. switch (pane) {
  4341. case "north": CSS.top = sC.inset.top;
  4342. CSS.left = sC.inset.left;
  4343. CSS.right = sC.inset.right;
  4344. break;
  4345. case "south": CSS.bottom = sC.inset.bottom;
  4346. CSS.left = sC.inset.left;
  4347. CSS.right = sC.inset.right;
  4348. break;
  4349. case "west": CSS.left = sC.inset.left; // top, bottom & height set by sizeMidPanes()
  4350. break;
  4351. case "east": CSS.right = sC.inset.right; // ditto
  4352. break;
  4353. case "center": // top, left, width & height set by sizeMidPanes()
  4354. }
  4355. // apply position
  4356. $P.css(CSS);
  4357. // update resizer position
  4358. if ($R && s.isClosed)
  4359. $R.css(side, sC.inset[side]);
  4360. else if ($R && !s.isHidden)
  4361. $R.css(side, sC.inset[side] + getPaneSize(pane));
  4362. });
  4363. }
  4364. /**
  4365. * Initialize module objects, styling, size and position for all resize bars and toggler buttons
  4366. *
  4367. * @see _create()
  4368. * @param {string=} [panes=""] The edge(s) to process
  4369. */
  4370. , initHandles = function (panes) {
  4371. panes = panes ? panes.split(",") : _c.borderPanes;
  4372. // create toggler DIVs for each pane, and set object pointers for them, eg: $R.north = north toggler DIV
  4373. $.each(panes, function (i, pane) {
  4374. var $P = $Ps[pane];
  4375. $Rs[pane] = false; // INIT
  4376. $Ts[pane] = false;
  4377. if (!$P) return; // pane does not exist - skip
  4378. var o = options[pane]
  4379. , s = state[pane]
  4380. , c = _c[pane]
  4381. , paneId = o.paneSelector.substr(0,1) === "#" ? o.paneSelector.substr(1) : ""
  4382. , rClass = o.resizerClass
  4383. , tClass = o.togglerClass
  4384. , spacing = (s.isVisible ? o.spacing_open : o.spacing_closed)
  4385. , _pane = "-"+ pane // used for classNames
  4386. , _state = (s.isVisible ? "-open" : "-closed") // used for classNames
  4387. , I = Instance[pane]
  4388. // INIT RESIZER BAR
  4389. , $R = I.resizer = $Rs[pane] = $("<div></div>")
  4390. // INIT TOGGLER BUTTON
  4391. , $T = I.toggler = (o.closable ? $Ts[pane] = $("<div></div>") : false)
  4392. ;
  4393. //if (s.isVisible && o.resizable) ... handled by initResizable
  4394. if (!s.isVisible && o.slidable)
  4395. $R.attr("title", o.tips.Slide).css("cursor", o.sliderCursor);
  4396. $R // if paneSelector is an ID, then create a matching ID for the resizer, eg: "#paneLeft" => "paneLeft-resizer"
  4397. .attr("id", paneId ? paneId +"-resizer" : "" )
  4398. .data({
  4399. parentLayout: Instance
  4400. , layoutPane: Instance[pane] // NEW pointer to pane-alias-object
  4401. , layoutEdge: pane
  4402. , layoutRole: "resizer"
  4403. })
  4404. .css(_c.resizers.cssReq).css("zIndex", options.zIndexes.resizer_normal)
  4405. .css(o.applyDemoStyles ? _c.resizers.cssDemo : {}) // add demo styles
  4406. .addClass(rClass +" "+ rClass+_pane)
  4407. .hover(addHover, removeHover) // ALWAYS add hover-classes, even if resizing is not enabled - handle with CSS instead
  4408. .hover(onResizerEnter, onResizerLeave) // ALWAYS NEED resizer.mouseleave to balance toggler.mouseenter
  4409. .appendTo($N) // append DIV to container
  4410. ;
  4411. if (o.resizerDblClickToggle)
  4412. $R.bind("dblclick."+ sID, toggle );
  4413. if ($T) {
  4414. $T // if paneSelector is an ID, then create a matching ID for the resizer, eg: "#paneLeft" => "#paneLeft-toggler"
  4415. .attr("id", paneId ? paneId +"-toggler" : "" )
  4416. .data({
  4417. parentLayout: Instance
  4418. , layoutPane: Instance[pane] // NEW pointer to pane-alias-object
  4419. , layoutEdge: pane
  4420. , layoutRole: "toggler"
  4421. })
  4422. .css(_c.togglers.cssReq) // add base/required styles
  4423. .css(o.applyDemoStyles ? _c.togglers.cssDemo : {}) // add demo styles
  4424. .addClass(tClass +" "+ tClass+_pane)
  4425. .hover(addHover, removeHover) // ALWAYS add hover-classes, even if toggling is not enabled - handle with CSS instead
  4426. .bind("mouseenter", onResizerEnter) // NEED toggler.mouseenter because mouseenter MAY NOT fire on resizer
  4427. .appendTo($R) // append SPAN to resizer DIV
  4428. ;
  4429. // ADD INNER-SPANS TO TOGGLER
  4430. if (o.togglerContent_open) // ui-layout-open
  4431. $("<span>"+ o.togglerContent_open +"</span>")
  4432. .data({
  4433. layoutEdge: pane
  4434. , layoutRole: "togglerContent"
  4435. })
  4436. .data("layoutRole", "togglerContent")
  4437. .data("layoutEdge", pane)
  4438. .addClass("content content-open")
  4439. .css("display","none")
  4440. .appendTo( $T )
  4441. //.hover( addHover, removeHover ) // use ui-layout-toggler-west-hover .content-open instead!
  4442. ;
  4443. if (o.togglerContent_closed) // ui-layout-closed
  4444. $("<span>"+ o.togglerContent_closed +"</span>")
  4445. .data({
  4446. layoutEdge: pane
  4447. , layoutRole: "togglerContent"
  4448. })
  4449. .addClass("content content-closed")
  4450. .css("display","none")
  4451. .appendTo( $T )
  4452. //.hover( addHover, removeHover ) // use ui-layout-toggler-west-hover .content-closed instead!
  4453. ;
  4454. // ADD TOGGLER.click/.hover
  4455. enableClosable(pane);
  4456. }
  4457. // add Draggable events
  4458. initResizable(pane);
  4459. // ADD CLASSNAMES & SLIDE-BINDINGS - eg: class="resizer resizer-west resizer-open"
  4460. if (s.isVisible)
  4461. setAsOpen(pane); // onOpen will be called, but NOT onResize
  4462. else {
  4463. setAsClosed(pane); // onClose will be called
  4464. bindStartSlidingEvents(pane, true); // will enable events IF option is set
  4465. }
  4466. });
  4467. // SET ALL HANDLE DIMENSIONS
  4468. sizeHandles();
  4469. }
  4470. /**
  4471. * Initialize scrolling ui-layout-content div - if exists
  4472. *
  4473. * @see initPane() - or externally after an Ajax injection
  4474. * @param {string} pane The pane to process
  4475. * @param {boolean=} [resize=true] Size content after init
  4476. */
  4477. , initContent = function (pane, resize) {
  4478. if (!isInitialized()) return;
  4479. var
  4480. o = options[pane]
  4481. , sel = o.contentSelector
  4482. , I = Instance[pane]
  4483. , $P = $Ps[pane]
  4484. , $C
  4485. ;
  4486. if (sel) $C = I.content = $Cs[pane] = (o.findNestedContent)
  4487. ? $P.find(sel).eq(0) // match 1-element only
  4488. : $P.children(sel).eq(0)
  4489. ;
  4490. if ($C && $C.length) {
  4491. $C.data("layoutRole", "content");
  4492. // SAVE original Content CSS
  4493. if (!$C.data("layoutCSS"))
  4494. $C.data("layoutCSS", styles($C, "height"));
  4495. $C.css( _c.content.cssReq );
  4496. if (o.applyDemoStyles) {
  4497. $C.css( _c.content.cssDemo ); // add padding & overflow: auto to content-div
  4498. $P.css( _c.content.cssDemoPane ); // REMOVE padding/scrolling from pane
  4499. }
  4500. // ensure no vertical scrollbar on pane - will mess up measurements
  4501. if ($P.css("overflowX").match(/(scroll|auto)/)) {
  4502. $P.css("overflow", "hidden");
  4503. }
  4504. state[pane].content = {}; // init content state
  4505. if (resize !== false) sizeContent(pane);
  4506. // sizeContent() is called AFTER init of all elements
  4507. }
  4508. else
  4509. I.content = $Cs[pane] = false;
  4510. }
  4511. /**
  4512. * Add resize-bars to all panes that specify it in options
  4513. * -dependancy: $.fn.resizable - will skip if not found
  4514. *
  4515. * @see _create()
  4516. * @param {string=} [panes=""] The edge(s) to process
  4517. */
  4518. , initResizable = function (panes) {
  4519. var draggingAvailable = $.layout.plugins.draggable
  4520. , side // set in start()
  4521. ;
  4522. panes = panes ? panes.split(",") : _c.borderPanes;
  4523. $.each(panes, function (idx, pane) {
  4524. var o = options[pane];
  4525. if (!draggingAvailable || !$Ps[pane] || !o.resizable) {
  4526. o.resizable = false;
  4527. return true; // skip to next
  4528. }
  4529. var s = state[pane]
  4530. , z = options.zIndexes
  4531. , c = _c[pane]
  4532. , side = c.dir=="horz" ? "top" : "left"
  4533. , $P = $Ps[pane]
  4534. , $R = $Rs[pane]
  4535. , base = o.resizerClass
  4536. , lastPos = 0 // used when live-resizing
  4537. , r, live // set in start because may change
  4538. // 'drag' classes are applied to the ORIGINAL resizer-bar while dragging is in process
  4539. , resizerClass = base+"-drag" // resizer-drag
  4540. , resizerPaneClass = base+"-"+pane+"-drag" // resizer-north-drag
  4541. // 'helper' class is applied to the CLONED resizer-bar while it is being dragged
  4542. , helperClass = base+"-dragging" // resizer-dragging
  4543. , helperPaneClass = base+"-"+pane+"-dragging" // resizer-north-dragging
  4544. , helperLimitClass = base+"-dragging-limit" // resizer-drag
  4545. , helperPaneLimitClass = base+"-"+pane+"-dragging-limit" // resizer-north-drag
  4546. , helperClassesSet = false // logic var
  4547. ;
  4548. if (!s.isClosed)
  4549. $R.attr("title", o.tips.Resize)
  4550. .css("cursor", o.resizerCursor); // n-resize, s-resize, etc
  4551. $R.draggable({
  4552. containment: $N[0] // limit resizing to layout container
  4553. , axis: (c.dir=="horz" ? "y" : "x") // limit resizing to horz or vert axis
  4554. , delay: 0
  4555. , distance: 1
  4556. , grid: o.resizingGrid
  4557. // basic format for helper - style it using class: .ui-draggable-dragging
  4558. , helper: "clone"
  4559. , opacity: o.resizerDragOpacity
  4560. , addClasses: false // avoid ui-state-disabled class when disabled
  4561. //, iframeFix: o.draggableIframeFix // TODO: consider using when bug is fixed
  4562. , zIndex: z.resizer_drag
  4563. , start: function (e, ui) {
  4564. // REFRESH options & state pointers in case we used swapPanes
  4565. o = options[pane];
  4566. s = state[pane];
  4567. // re-read options
  4568. live = o.livePaneResizing;
  4569. // ondrag_start callback - will CANCEL hide if returns false
  4570. // TODO: dragging CANNOT be cancelled like this, so see if there is a way?
  4571. if (false === _runCallbacks("ondrag_start", pane)) return false;
  4572. s.isResizing = true; // prevent pane from closing while resizing
  4573. state.paneResizing = pane; // easy to see if ANY pane is resizing
  4574. timer.clear(pane+"_closeSlider"); // just in case already triggered
  4575. // SET RESIZER LIMITS - used in drag()
  4576. setSizeLimits(pane); // update pane/resizer state
  4577. r = s.resizerPosition;
  4578. lastPos = ui.position[ side ]
  4579. $R.addClass( resizerClass +" "+ resizerPaneClass ); // add drag classes
  4580. helperClassesSet = false; // reset logic var - see drag()
  4581. // DISABLE TEXT SELECTION (probably already done by resizer.mouseOver)
  4582. $('body').disableSelection();
  4583. // MASK PANES CONTAINING IFRAMES, APPLETS OR OTHER TROUBLESOME ELEMENTS
  4584. showMasks( pane, { resizing: true });
  4585. }
  4586. , drag: function (e, ui) {
  4587. if (!helperClassesSet) { // can only add classes after clone has been added to the DOM
  4588. //$(".ui-draggable-dragging")
  4589. ui.helper
  4590. .addClass( helperClass +" "+ helperPaneClass ) // add helper classes
  4591. .css({ right: "auto", bottom: "auto" }) // fix dir="rtl" issue
  4592. .children().css("visibility","hidden") // hide toggler inside dragged resizer-bar
  4593. ;
  4594. helperClassesSet = true;
  4595. // draggable bug!? RE-SET zIndex to prevent E/W resize-bar showing through N/S pane!
  4596. if (s.isSliding) $Ps[pane].css("zIndex", z.pane_sliding);
  4597. }
  4598. // CONTAIN RESIZER-BAR TO RESIZING LIMITS
  4599. var limit = 0;
  4600. if (ui.position[side] < r.min) {
  4601. ui.position[side] = r.min;
  4602. limit = -1;
  4603. }
  4604. else if (ui.position[side] > r.max) {
  4605. ui.position[side] = r.max;
  4606. limit = 1;
  4607. }
  4608. // ADD/REMOVE dragging-limit CLASS
  4609. if (limit) {
  4610. ui.helper.addClass( helperLimitClass +" "+ helperPaneLimitClass ); // at dragging-limit
  4611. window.defaultStatus = (limit>0 && pane.match(/(north|west)/)) || (limit<0 && pane.match(/(south|east)/)) ? o.tips.maxSizeWarning : o.tips.minSizeWarning;
  4612. }
  4613. else {
  4614. ui.helper.removeClass( helperLimitClass +" "+ helperPaneLimitClass ); // not at dragging-limit
  4615. window.defaultStatus = "";
  4616. }
  4617. // DYNAMICALLY RESIZE PANES IF OPTION ENABLED
  4618. // won't trigger unless resizer has actually moved!
  4619. if (live && Math.abs(ui.position[side] - lastPos) >= o.liveResizingTolerance) {
  4620. lastPos = ui.position[side];
  4621. resizePanes(e, ui, pane)
  4622. }
  4623. }
  4624. , stop: function (e, ui) {
  4625. $('body').enableSelection(); // RE-ENABLE TEXT SELECTION
  4626. window.defaultStatus = ""; // clear 'resizing limit' message from statusbar
  4627. $R.removeClass( resizerClass +" "+ resizerPaneClass ); // remove drag classes from Resizer
  4628. s.isResizing = false;
  4629. state.paneResizing = false; // easy to see if ANY pane is resizing
  4630. resizePanes(e, ui, pane, true); // true = resizingDone
  4631. }
  4632. });
  4633. });
  4634. /**
  4635. * resizePanes
  4636. *
  4637. * Sub-routine called from stop() - and drag() if livePaneResizing
  4638. *
  4639. * @param {!Object} evt
  4640. * @param {!Object} ui
  4641. * @param {string} pane
  4642. * @param {boolean=} [resizingDone=false]
  4643. */
  4644. var resizePanes = function (evt, ui, pane, resizingDone) {
  4645. var dragPos = ui.position
  4646. , c = _c[pane]
  4647. , o = options[pane]
  4648. , s = state[pane]
  4649. , resizerPos
  4650. ;
  4651. switch (pane) {
  4652. case "north": resizerPos = dragPos.top; break;
  4653. case "west": resizerPos = dragPos.left; break;
  4654. case "south": resizerPos = sC.layoutHeight - dragPos.top - o.spacing_open; break;
  4655. case "east": resizerPos = sC.layoutWidth - dragPos.left - o.spacing_open; break;
  4656. };
  4657. // remove container margin from resizer position to get the pane size
  4658. var newSize = resizerPos - sC.inset[c.side];
  4659. // Disable OR Resize Mask(s) created in drag.start
  4660. if (!resizingDone) {
  4661. // ensure we meet liveResizingTolerance criteria
  4662. if (Math.abs(newSize - s.size) < o.liveResizingTolerance)
  4663. return; // SKIP resize this time
  4664. // resize the pane
  4665. manualSizePane(pane, newSize, false, true); // true = noAnimation
  4666. sizeMasks(); // resize all visible masks
  4667. }
  4668. else { // resizingDone
  4669. // ondrag_end callback
  4670. if (false !== _runCallbacks("ondrag_end", pane))
  4671. manualSizePane(pane, newSize, false, true); // true = noAnimation
  4672. hideMasks(true); // true = force hiding all masks even if one is 'sliding'
  4673. if (s.isSliding) // RE-SHOW 'object-masks' so objects won't show through sliding pane
  4674. showMasks( pane, { resizing: true });
  4675. }
  4676. };
  4677. }
  4678. /**
  4679. * sizeMask
  4680. *
  4681. * Needed to overlay a DIV over an IFRAME-pane because mask CANNOT be *inside* the pane
  4682. * Called when mask created, and during livePaneResizing
  4683. */
  4684. , sizeMask = function () {
  4685. var $M = $(this)
  4686. , pane = $M.data("layoutMask") // eg: "west"
  4687. , s = state[pane]
  4688. ;
  4689. // only masks over an IFRAME-pane need manual resizing
  4690. if (s.tagName == "IFRAME" && s.isVisible) // no need to mask closed/hidden panes
  4691. $M.css({
  4692. top: s.offsetTop
  4693. , left: s.offsetLeft
  4694. , width: s.outerWidth
  4695. , height: s.outerHeight
  4696. });
  4697. /* ALT Method...
  4698. var $P = $Ps[pane];
  4699. $M.css( $P.position() ).css({ width: $P[0].offsetWidth, height: $P[0].offsetHeight });
  4700. */
  4701. }
  4702. , sizeMasks = function () {
  4703. $Ms.each( sizeMask ); // resize all 'visible' masks
  4704. }
  4705. /**
  4706. * @param {string} pane The pane being resized, animated or isSliding
  4707. * @param {Object=} [args] (optional) Options: which masks to apply, and to which panes
  4708. */
  4709. , showMasks = function (pane, args) {
  4710. var c = _c[pane]
  4711. , panes = ["center"]
  4712. , z = options.zIndexes
  4713. , a = $.extend({
  4714. objectsOnly: false
  4715. , animation: false
  4716. , resizing: true
  4717. , sliding: state[pane].isSliding
  4718. }, args )
  4719. , o, s
  4720. ;
  4721. if (a.resizing)
  4722. panes.push( pane );
  4723. if (a.sliding)
  4724. panes.push( _c.oppositeEdge[pane] ); // ADD the oppositeEdge-pane
  4725. if (c.dir === "horz") {
  4726. panes.push("west");
  4727. panes.push("east");
  4728. }
  4729. $.each(panes, function(i,p){
  4730. s = state[p];
  4731. o = options[p];
  4732. if (s.isVisible && ( o.maskObjects || (!a.objectsOnly && o.maskContents) )) {
  4733. getMasks(p).each(function(){
  4734. sizeMask.call(this);
  4735. this.style.zIndex = s.isSliding ? z.pane_sliding+1 : z.pane_normal+1
  4736. this.style.display = "block";
  4737. });
  4738. }
  4739. });
  4740. }
  4741. /**
  4742. * @param {boolean=} force Hide masks even if a pane is sliding
  4743. */
  4744. , hideMasks = function (force) {
  4745. // ensure no pane is resizing - could be a timing issue
  4746. if (force || !state.paneResizing) {
  4747. $Ms.hide(); // hide ALL masks
  4748. }
  4749. // if ANY pane is sliding, then DO NOT remove masks from panes with maskObjects enabled
  4750. else if (!force && !$.isEmptyObject( state.panesSliding )) {
  4751. var i = $Ms.length - 1
  4752. , p, $M;
  4753. for (; i >= 0; i--) {
  4754. $M = $Ms.eq(i);
  4755. p = $M.data("layoutMask");
  4756. if (!options[p].maskObjects) {
  4757. $M.hide();
  4758. }
  4759. }
  4760. }
  4761. }
  4762. /**
  4763. * @param {string} pane
  4764. */
  4765. , getMasks = function (pane) {
  4766. var $Masks = $([])
  4767. , $M, i = 0, c = $Ms.length
  4768. ;
  4769. for (; i<c; i++) {
  4770. $M = $Ms.eq(i);
  4771. if ($M.data("layoutMask") === pane)
  4772. $Masks = $Masks.add( $M );
  4773. }
  4774. if ($Masks.length)
  4775. return $Masks;
  4776. else
  4777. return createMasks(pane);
  4778. }
  4779. /**
  4780. * createMasks
  4781. *
  4782. * Generates both DIV (ALWAYS used) and IFRAME (optional) elements as masks
  4783. * An IFRAME mask is created *under* the DIV when maskObjects=true, because a DIV cannot mask an applet
  4784. *
  4785. * @param {string} pane
  4786. */
  4787. , createMasks = function (pane) {
  4788. var
  4789. $P = $Ps[pane]
  4790. , s = state[pane]
  4791. , o = options[pane]
  4792. , z = options.zIndexes
  4793. //, objMask = o.maskObjects && s.tagName != "IFRAME" // check for option
  4794. , $Masks = $([])
  4795. , isIframe, el, $M, css, i
  4796. ;
  4797. if (!o.maskContents && !o.maskObjects) return $Masks;
  4798. // if o.maskObjects=true, then loop TWICE to create BOTH kinds of mask, else only create a DIV
  4799. for (i=0; i < (o.maskObjects ? 2 : 1); i++) {
  4800. isIframe = o.maskObjects && i==0;
  4801. el = document.createElement( isIframe ? "iframe" : "div" );
  4802. $M = $(el).data("layoutMask", pane); // add data to relate mask to pane
  4803. el.className = "ui-layout-mask ui-layout-mask-"+ pane; // for user styling
  4804. css = el.style;
  4805. // styles common to both DIVs and IFRAMES
  4806. css.display = "block";
  4807. css.position = "absolute";
  4808. css.background = "#FFF";
  4809. if (isIframe) { // IFRAME-only props
  4810. el.frameborder = 0;
  4811. el.src = "about:blank";
  4812. //el.allowTransparency = true; - for IE, but breaks masking ability!
  4813. css.opacity = 0;
  4814. css.filter = "Alpha(Opacity='0')";
  4815. css.border = 0;
  4816. }
  4817. // if pane is an IFRAME, then must mask the pane itself
  4818. if (s.tagName == "IFRAME") {
  4819. // NOTE sizing done by a subroutine so can be called during live-resizing
  4820. css.zIndex = z.pane_normal+1; // 1-higher than pane
  4821. $N.append( el ); // append to LAYOUT CONTAINER
  4822. }
  4823. // otherwise put masks *inside the pane* to mask its contents
  4824. else {
  4825. $M.addClass("ui-layout-mask-inside-pane");
  4826. css.zIndex = o.maskZindex || z.content_mask; // usually 1, but customizable
  4827. css.top = 0;
  4828. css.left = 0;
  4829. css.width = "100%";
  4830. css.height = "100%";
  4831. $P.append( el ); // append INSIDE pane element
  4832. }
  4833. // add to return object
  4834. $Masks = $Masks.add( el );
  4835. // add Mask to cached array so can be resized & reused
  4836. $Ms = $Ms.add( el );
  4837. }
  4838. return $Masks;
  4839. }
  4840. /**
  4841. * Destroy this layout and reset all elements
  4842. *
  4843. * @param {boolean=} [destroyChildren=false] Destory Child-Layouts first?
  4844. */
  4845. , destroy = function (evt_or_destroyChildren, destroyChildren) {
  4846. // UNBIND layout events and remove global object
  4847. $(window).unbind("."+ sID); // resize & unload
  4848. $(document).unbind("."+ sID); // keyDown (hotkeys)
  4849. if (typeof evt_or_destroyChildren === "object")
  4850. // stopPropagation if called by trigger("layoutdestroy") - use evtPane utility
  4851. evtPane(evt_or_destroyChildren);
  4852. else // no event, so transfer 1st param to destroyChildren param
  4853. destroyChildren = evt_or_destroyChildren;
  4854. // need to look for parent layout BEFORE we remove the container data, else skips a level
  4855. //var parentPane = Instance.hasParentLayout ? $.layout.getParentPaneInstance( $N ) : null;
  4856. // reset layout-container
  4857. $N .clearQueue()
  4858. .removeData("layout")
  4859. .removeData("layoutContainer")
  4860. .removeClass(options.containerClass)
  4861. .unbind("."+ sID) // remove ALL Layout events
  4862. ;
  4863. // remove all mask elements that have been created
  4864. $Ms.remove();
  4865. // loop all panes to remove layout classes, attributes and bindings
  4866. $.each(_c.allPanes, function (i, pane) {
  4867. removePane( pane, false, true, destroyChildren ); // true = skipResize
  4868. });
  4869. // do NOT reset container CSS if is a 'pane' (or 'content') in an outer-layout - ie, THIS layout is 'nested'
  4870. var css = "layoutCSS";
  4871. if ($N.data(css) && !$N.data("layoutRole")) // RESET CSS
  4872. $N.css( $N.data(css) ).removeData(css);
  4873. // for full-page layouts, also reset the <HTML> CSS
  4874. if (sC.tagName === "BODY" && ($N = $("html")).data(css)) // RESET <HTML> CSS
  4875. $N.css( $N.data(css) ).removeData(css);
  4876. // trigger plugins for this layout, if there are any
  4877. runPluginCallbacks( Instance, $.layout.onDestroy );
  4878. // trigger state-management and onunload callback
  4879. unload();
  4880. // clear the Instance of everything except for container & options (so could recreate)
  4881. // RE-CREATE: myLayout = myLayout.container.layout( myLayout.options );
  4882. for (var n in Instance)
  4883. if (!n.match(/^(container|options)$/)) delete Instance[ n ];
  4884. // add a 'destroyed' flag to make it easy to check
  4885. Instance.destroyed = true;
  4886. // if this is a child layout, CLEAR the child-pointer in the parent
  4887. /* for now the pointer REMAINS, but with only container, options and destroyed keys
  4888. if (parentPane) {
  4889. var layout = parentPane.pane.data("parentLayout")
  4890. , key = layout.options.instanceKey || 'error';
  4891. // THIS SYNTAX MAY BE WRONG!
  4892. parentPane.children[key] = layout.children[ parentPane.name ].children[key] = null;
  4893. }
  4894. */
  4895. return Instance; // for coding convenience
  4896. }
  4897. /**
  4898. * Remove a pane from the layout - subroutine of destroy()
  4899. *
  4900. * @see destroy()
  4901. * @param {(string|Object)} evt_or_pane The pane to process
  4902. * @param {boolean=} [remove=false] Remove the DOM element?
  4903. * @param {boolean=} [skipResize=false] Skip calling resizeAll()?
  4904. * @param {boolean=} [destroyChild=true] Destroy Child-layouts? If not passed, obeys options setting
  4905. */
  4906. , removePane = function (evt_or_pane, remove, skipResize, destroyChild) {
  4907. if (!isInitialized()) return;
  4908. var pane = evtPane.call(this, evt_or_pane)
  4909. , $P = $Ps[pane]
  4910. , $C = $Cs[pane]
  4911. , $R = $Rs[pane]
  4912. , $T = $Ts[pane]
  4913. ;
  4914. // NOTE: elements can still exist even after remove()
  4915. // so check for missing data(), which is cleared by removed()
  4916. if ($P && $.isEmptyObject( $P.data() )) $P = false;
  4917. if ($C && $.isEmptyObject( $C.data() )) $C = false;
  4918. if ($R && $.isEmptyObject( $R.data() )) $R = false;
  4919. if ($T && $.isEmptyObject( $T.data() )) $T = false;
  4920. if ($P) $P.stop(true, true);
  4921. var o = options[pane]
  4922. , s = state[pane]
  4923. , d = "layout"
  4924. , css = "layoutCSS"
  4925. , pC = children[pane]
  4926. , hasChildren = $.isPlainObject( pC ) && !$.isEmptyObject( pC )
  4927. , destroy = destroyChild !== undefined ? destroyChild : o.destroyChildren
  4928. ;
  4929. // FIRST destroy the child-layout(s)
  4930. if (hasChildren && destroy) {
  4931. $.each( pC, function (key, child) {
  4932. if (!child.destroyed)
  4933. child.destroy(true);// tell child-layout to destroy ALL its child-layouts too
  4934. if (child.destroyed) // destroy was successful
  4935. delete pC[key];
  4936. });
  4937. // if no more children, remove the children hash
  4938. if ($.isEmptyObject( pC )) {
  4939. pC = children[pane] = null; // clear children hash
  4940. hasChildren = false;
  4941. }
  4942. }
  4943. // Note: can't 'remove' a pane element with non-destroyed children
  4944. if ($P && remove && !hasChildren)
  4945. $P.remove(); // remove the pane-element and everything inside it
  4946. else if ($P && $P[0]) {
  4947. // create list of ALL pane-classes that need to be removed
  4948. var root = o.paneClass // default="ui-layout-pane"
  4949. , pRoot = root +"-"+ pane // eg: "ui-layout-pane-west"
  4950. , _open = "-open"
  4951. , _sliding= "-sliding"
  4952. , _closed = "-closed"
  4953. , classes = [ root, root+_open, root+_closed, root+_sliding, // generic classes
  4954. pRoot, pRoot+_open, pRoot+_closed, pRoot+_sliding ] // pane-specific classes
  4955. ;
  4956. $.merge(classes, getHoverClasses($P, true)); // ADD hover-classes
  4957. // remove all Layout classes from pane-element
  4958. $P .removeClass( classes.join(" ") ) // remove ALL pane-classes
  4959. .removeData("parentLayout")
  4960. .removeData("layoutPane")
  4961. .removeData("layoutRole")
  4962. .removeData("layoutEdge")
  4963. .removeData("autoHidden") // in case set
  4964. .unbind("."+ sID) // remove ALL Layout events
  4965. // TODO: remove these extra unbind commands when jQuery is fixed
  4966. //.unbind("mouseenter"+ sID)
  4967. //.unbind("mouseleave"+ sID)
  4968. ;
  4969. // do NOT reset CSS if this pane/content is STILL the container of a nested layout!
  4970. // the nested layout will reset its 'container' CSS when/if it is destroyed
  4971. if (hasChildren && $C) {
  4972. // a content-div may not have a specific width, so give it one to contain the Layout
  4973. $C.width( $C.width() );
  4974. $.each( pC, function (key, child) {
  4975. child.resizeAll(); // resize the Layout
  4976. });
  4977. }
  4978. else if ($C)
  4979. $C.css( $C.data(css) ).removeData(css).removeData("layoutRole");
  4980. // remove pane AFTER content in case there was a nested layout
  4981. if (!$P.data(d))
  4982. $P.css( $P.data(css) ).removeData(css);
  4983. }
  4984. // REMOVE pane resizer and toggler elements
  4985. if ($T) $T.remove();
  4986. if ($R) $R.remove();
  4987. // CLEAR all pointers and state data
  4988. Instance[pane] = $Ps[pane] = $Cs[pane] = $Rs[pane] = $Ts[pane] = false;
  4989. s = { removed: true };
  4990. if (!skipResize)
  4991. resizeAll();
  4992. }
  4993. /*
  4994. * ###########################
  4995. * ACTION METHODS
  4996. * ###########################
  4997. */
  4998. /**
  4999. * @param {string} pane
  5000. */
  5001. , _hidePane = function (pane) {
  5002. var $P = $Ps[pane]
  5003. , o = options[pane]
  5004. , s = $P[0].style
  5005. ;
  5006. if (o.useOffscreenClose) {
  5007. if (!$P.data(_c.offscreenReset))
  5008. $P.data(_c.offscreenReset, { left: s.left, right: s.right });
  5009. $P.css( _c.offscreenCSS );
  5010. }
  5011. else
  5012. $P.hide().removeData(_c.offscreenReset);
  5013. }
  5014. /**
  5015. * @param {string} pane
  5016. */
  5017. , _showPane = function (pane) {
  5018. var $P = $Ps[pane]
  5019. , o = options[pane]
  5020. , off = _c.offscreenCSS
  5021. , old = $P.data(_c.offscreenReset)
  5022. , s = $P[0].style
  5023. ;
  5024. $P .show() // ALWAYS show, just in case
  5025. .removeData(_c.offscreenReset);
  5026. if (o.useOffscreenClose && old) {
  5027. if (s.left == off.left)
  5028. s.left = old.left;
  5029. if (s.right == off.right)
  5030. s.right = old.right;
  5031. }
  5032. }
  5033. /**
  5034. * Completely 'hides' a pane, including its spacing - as if it does not exist
  5035. * The pane is not actually 'removed' from the source, so can use 'show' to un-hide it
  5036. *
  5037. * @param {(string|Object)} evt_or_pane The pane being hidden, ie: north, south, east, or west
  5038. * @param {boolean=} [noAnimation=false]
  5039. */
  5040. , hide = function (evt_or_pane, noAnimation) {
  5041. if (!isInitialized()) return;
  5042. var pane = evtPane.call(this, evt_or_pane)
  5043. , o = options[pane]
  5044. , s = state[pane]
  5045. , $P = $Ps[pane]
  5046. , $R = $Rs[pane]
  5047. ;
  5048. if (!$P || s.isHidden) return; // pane does not exist OR is already hidden
  5049. // onhide_start callback - will CANCEL hide if returns false
  5050. if (state.initialized && false === _runCallbacks("onhide_start", pane)) return;
  5051. s.isSliding = false; // just in case
  5052. delete state.panesSliding[pane];
  5053. // now hide the elements
  5054. if ($R) $R.hide(); // hide resizer-bar
  5055. if (!state.initialized || s.isClosed) {
  5056. s.isClosed = true; // to trigger open-animation on show()
  5057. s.isHidden = true;
  5058. s.isVisible = false;
  5059. if (!state.initialized)
  5060. _hidePane(pane); // no animation when loading page
  5061. sizeMidPanes(_c[pane].dir === "horz" ? "" : "center");
  5062. if (state.initialized || o.triggerEventsOnLoad)
  5063. _runCallbacks("onhide_end", pane);
  5064. }
  5065. else {
  5066. s.isHiding = true; // used by onclose
  5067. close(pane, false, noAnimation); // adjust all panes to fit
  5068. }
  5069. }
  5070. /**
  5071. * Show a hidden pane - show as 'closed' by default unless openPane = true
  5072. *
  5073. * @param {(string|Object)} evt_or_pane The pane being opened, ie: north, south, east, or west
  5074. * @param {boolean=} [openPane=false]
  5075. * @param {boolean=} [noAnimation=false]
  5076. * @param {boolean=} [noAlert=false]
  5077. */
  5078. , show = function (evt_or_pane, openPane, noAnimation, noAlert) {
  5079. if (!isInitialized()) return;
  5080. var pane = evtPane.call(this, evt_or_pane)
  5081. , o = options[pane]
  5082. , s = state[pane]
  5083. , $P = $Ps[pane]
  5084. , $R = $Rs[pane]
  5085. ;
  5086. if (!$P || !s.isHidden) return; // pane does not exist OR is not hidden
  5087. // onshow_start callback - will CANCEL show if returns false
  5088. if (false === _runCallbacks("onshow_start", pane)) return;
  5089. s.isShowing = true; // used by onopen/onclose
  5090. //s.isHidden = false; - will be set by open/close - if not cancelled
  5091. s.isSliding = false; // just in case
  5092. delete state.panesSliding[pane];
  5093. // now show the elements
  5094. //if ($R) $R.show(); - will be shown by open/close
  5095. if (openPane === false)
  5096. close(pane, true); // true = force
  5097. else
  5098. open(pane, false, noAnimation, noAlert); // adjust all panes to fit
  5099. }
  5100. /**
  5101. * Toggles a pane open/closed by calling either open or close
  5102. *
  5103. * @param {(string|Object)} evt_or_pane The pane being toggled, ie: north, south, east, or west
  5104. * @param {boolean=} [slide=false]
  5105. */
  5106. , toggle = function (evt_or_pane, slide) {
  5107. if (!isInitialized()) return;
  5108. var evt = evtObj(evt_or_pane)
  5109. , pane = evtPane.call(this, evt_or_pane)
  5110. , s = state[pane]
  5111. ;
  5112. if (evt) // called from to $R.dblclick OR triggerPaneEvent
  5113. evt.stopImmediatePropagation();
  5114. if (s.isHidden)
  5115. show(pane); // will call 'open' after unhiding it
  5116. else if (s.isClosed)
  5117. open(pane, !!slide);
  5118. else
  5119. close(pane);
  5120. }
  5121. /**
  5122. * Utility method used during init or other auto-processes
  5123. *
  5124. * @param {string} pane The pane being closed
  5125. * @param {boolean=} [setHandles=false]
  5126. */
  5127. , _closePane = function (pane, setHandles) {
  5128. var
  5129. $P = $Ps[pane]
  5130. , s = state[pane]
  5131. ;
  5132. _hidePane(pane);
  5133. s.isClosed = true;
  5134. s.isVisible = false;
  5135. if (setHandles) setAsClosed(pane);
  5136. }
  5137. /**
  5138. * Close the specified pane (animation optional), and resize all other panes as needed
  5139. *
  5140. * @param {(string|Object)} evt_or_pane The pane being closed, ie: north, south, east, or west
  5141. * @param {boolean=} [force=false]
  5142. * @param {boolean=} [noAnimation=false]
  5143. * @param {boolean=} [skipCallback=false]
  5144. */
  5145. , close = function (evt_or_pane, force, noAnimation, skipCallback) {
  5146. var pane = evtPane.call(this, evt_or_pane);
  5147. // if pane has been initialized, but NOT the complete layout, close pane instantly
  5148. if (!state.initialized && $Ps[pane]) {
  5149. _closePane(pane, true); // INIT pane as closed
  5150. return;
  5151. }
  5152. if (!isInitialized()) return;
  5153. var
  5154. $P = $Ps[pane]
  5155. , $R = $Rs[pane]
  5156. , $T = $Ts[pane]
  5157. , o = options[pane]
  5158. , s = state[pane]
  5159. , c = _c[pane]
  5160. , doFX, isShowing, isHiding, wasSliding;
  5161. // QUEUE in case another action/animation is in progress
  5162. $N.queue(function( queueNext ){
  5163. if ( !$P
  5164. || (!o.closable && !s.isShowing && !s.isHiding) // invalid request // (!o.resizable && !o.closable) ???
  5165. || (!force && s.isClosed && !s.isShowing) // already closed
  5166. ) return queueNext();
  5167. // onclose_start callback - will CANCEL hide if returns false
  5168. // SKIP if just 'showing' a hidden pane as 'closed'
  5169. var abort = !s.isShowing && false === _runCallbacks("onclose_start", pane);
  5170. // transfer logic vars to temp vars
  5171. isShowing = s.isShowing;
  5172. isHiding = s.isHiding;
  5173. wasSliding = s.isSliding;
  5174. // now clear the logic vars (REQUIRED before aborting)
  5175. delete s.isShowing;
  5176. delete s.isHiding;
  5177. if (abort) return queueNext();
  5178. doFX = !noAnimation && !s.isClosed && (o.fxName_close != "none");
  5179. s.isMoving = true;
  5180. s.isClosed = true;
  5181. s.isVisible = false;
  5182. // update isHidden BEFORE sizing panes
  5183. if (isHiding) s.isHidden = true;
  5184. else if (isShowing) s.isHidden = false;
  5185. if (s.isSliding) // pane is being closed, so UNBIND trigger events
  5186. bindStopSlidingEvents(pane, false); // will set isSliding=false
  5187. else // resize panes adjacent to this one
  5188. sizeMidPanes(_c[pane].dir === "horz" ? "" : "center", false); // false = NOT skipCallback
  5189. // if this pane has a resizer bar, move it NOW - before animation
  5190. setAsClosed(pane);
  5191. // CLOSE THE PANE
  5192. if (doFX) { // animate the close
  5193. lockPaneForFX(pane, true); // need to set left/top so animation will work
  5194. $P.hide( o.fxName_close, o.fxSettings_close, o.fxSpeed_close, function () {
  5195. lockPaneForFX(pane, false); // undo
  5196. if (s.isClosed) close_2();
  5197. queueNext();
  5198. });
  5199. }
  5200. else { // hide the pane without animation
  5201. _hidePane(pane);
  5202. close_2();
  5203. queueNext();
  5204. };
  5205. });
  5206. // SUBROUTINE
  5207. function close_2 () {
  5208. s.isMoving = false;
  5209. bindStartSlidingEvents(pane, true); // will enable if o.slidable = true
  5210. // if opposite-pane was autoClosed, see if it can be autoOpened now
  5211. var altPane = _c.oppositeEdge[pane];
  5212. if (state[ altPane ].noRoom) {
  5213. setSizeLimits( altPane );
  5214. makePaneFit( altPane );
  5215. }
  5216. if (!skipCallback && (state.initialized || o.triggerEventsOnLoad)) {
  5217. // onclose callback - UNLESS just 'showing' a hidden pane as 'closed'
  5218. if (!isShowing) _runCallbacks("onclose_end", pane);
  5219. // onhide OR onshow callback
  5220. if (isShowing) _runCallbacks("onshow_end", pane);
  5221. if (isHiding) _runCallbacks("onhide_end", pane);
  5222. }
  5223. }
  5224. }
  5225. /**
  5226. * @param {string} pane The pane just closed, ie: north, south, east, or west
  5227. */
  5228. , setAsClosed = function (pane) {
  5229. if (!$Rs[pane]) return; // handles not initialized yet!
  5230. var
  5231. $P = $Ps[pane]
  5232. , $R = $Rs[pane]
  5233. , $T = $Ts[pane]
  5234. , o = options[pane]
  5235. , s = state[pane]
  5236. , side = _c[pane].side
  5237. , rClass = o.resizerClass
  5238. , tClass = o.togglerClass
  5239. , _pane = "-"+ pane // used for classNames
  5240. , _open = "-open"
  5241. , _sliding= "-sliding"
  5242. , _closed = "-closed"
  5243. ;
  5244. $R
  5245. .css(side, sC.inset[side]) // move the resizer
  5246. .removeClass( rClass+_open +" "+ rClass+_pane+_open )
  5247. .removeClass( rClass+_sliding +" "+ rClass+_pane+_sliding )
  5248. .addClass( rClass+_closed +" "+ rClass+_pane+_closed )
  5249. ;
  5250. // DISABLE 'resizing' when closed - do this BEFORE bindStartSlidingEvents?
  5251. if (o.resizable && $.layout.plugins.draggable)
  5252. $R
  5253. .draggable("disable")
  5254. .removeClass("ui-state-disabled") // do NOT apply disabled styling - not suitable here
  5255. .css("cursor", "default")
  5256. .attr("title","")
  5257. ;
  5258. // if pane has a toggler button, adjust that too
  5259. if ($T) {
  5260. $T
  5261. .removeClass( tClass+_open +" "+ tClass+_pane+_open )
  5262. .addClass( tClass+_closed +" "+ tClass+_pane+_closed )
  5263. .attr("title", o.tips.Open) // may be blank
  5264. ;
  5265. // toggler-content - if exists
  5266. $T.children(".content-open").hide();
  5267. $T.children(".content-closed").css("display","block");
  5268. }
  5269. // sync any 'pin buttons'
  5270. syncPinBtns(pane, false);
  5271. if (state.initialized) {
  5272. // resize 'length' and position togglers for adjacent panes
  5273. sizeHandles();
  5274. }
  5275. }
  5276. /**
  5277. * Open the specified pane (animation optional), and resize all other panes as needed
  5278. *
  5279. * @param {(string|Object)} evt_or_pane The pane being opened, ie: north, south, east, or west
  5280. * @param {boolean=} [slide=false]
  5281. * @param {boolean=} [noAnimation=false]
  5282. * @param {boolean=} [noAlert=false]
  5283. */
  5284. , open = function (evt_or_pane, slide, noAnimation, noAlert) {
  5285. if (!isInitialized()) return;
  5286. var pane = evtPane.call(this, evt_or_pane)
  5287. , $P = $Ps[pane]
  5288. , $R = $Rs[pane]
  5289. , $T = $Ts[pane]
  5290. , o = options[pane]
  5291. , s = state[pane]
  5292. , c = _c[pane]
  5293. , doFX, isShowing
  5294. ;
  5295. // QUEUE in case another action/animation is in progress
  5296. $N.queue(function( queueNext ){
  5297. if ( !$P
  5298. || (!o.resizable && !o.closable && !s.isShowing) // invalid request
  5299. || (s.isVisible && !s.isSliding) // already open
  5300. ) return queueNext();
  5301. // pane can ALSO be unhidden by just calling show(), so handle this scenario
  5302. if (s.isHidden && !s.isShowing) {
  5303. queueNext(); // call before show() because it needs the queue free
  5304. show(pane, true);
  5305. return;
  5306. }
  5307. if (s.autoResize && s.size != o.size) // resize pane to original size set in options
  5308. sizePane(pane, o.size, true, true, true); // true=skipCallback/noAnimation/forceResize
  5309. else
  5310. // make sure there is enough space available to open the pane
  5311. setSizeLimits(pane, slide);
  5312. // onopen_start callback - will CANCEL open if returns false
  5313. var cbReturn = _runCallbacks("onopen_start", pane);
  5314. if (cbReturn === "abort")
  5315. return queueNext();
  5316. // update pane-state again in case options were changed in onopen_start
  5317. if (cbReturn !== "NC") // NC = "No Callback"
  5318. setSizeLimits(pane, slide);
  5319. if (s.minSize > s.maxSize) { // INSUFFICIENT ROOM FOR PANE TO OPEN!
  5320. syncPinBtns(pane, false); // make sure pin-buttons are reset
  5321. if (!noAlert && o.tips.noRoomToOpen)
  5322. alert(o.tips.noRoomToOpen);
  5323. return queueNext(); // ABORT
  5324. }
  5325. if (slide) // START Sliding - will set isSliding=true
  5326. bindStopSlidingEvents(pane, true); // BIND trigger events to close sliding-pane
  5327. else if (s.isSliding) // PIN PANE (stop sliding) - open pane 'normally' instead
  5328. bindStopSlidingEvents(pane, false); // UNBIND trigger events - will set isSliding=false
  5329. else if (o.slidable)
  5330. bindStartSlidingEvents(pane, false); // UNBIND trigger events
  5331. s.noRoom = false; // will be reset by makePaneFit if 'noRoom'
  5332. makePaneFit(pane);
  5333. // transfer logic var to temp var
  5334. isShowing = s.isShowing;
  5335. // now clear the logic var
  5336. delete s.isShowing;
  5337. doFX = !noAnimation && s.isClosed && (o.fxName_open != "none");
  5338. s.isMoving = true;
  5339. s.isVisible = true;
  5340. s.isClosed = false;
  5341. // update isHidden BEFORE sizing panes - WHY??? Old?
  5342. if (isShowing) s.isHidden = false;
  5343. if (doFX) { // ANIMATE
  5344. // mask adjacent panes with objects
  5345. lockPaneForFX(pane, true); // need to set left/top so animation will work
  5346. $P.show( o.fxName_open, o.fxSettings_open, o.fxSpeed_open, function() {
  5347. lockPaneForFX(pane, false); // undo
  5348. if (s.isVisible) open_2(); // continue
  5349. queueNext();
  5350. });
  5351. }
  5352. else { // no animation
  5353. _showPane(pane);// just show pane and...
  5354. open_2(); // continue
  5355. queueNext();
  5356. };
  5357. });
  5358. // SUBROUTINE
  5359. function open_2 () {
  5360. s.isMoving = false;
  5361. // cure iframe display issues
  5362. _fixIframe(pane);
  5363. // NOTE: if isSliding, then other panes are NOT 'resized'
  5364. if (!s.isSliding) { // resize all panes adjacent to this one
  5365. sizeMidPanes(_c[pane].dir=="vert" ? "center" : "", false); // false = NOT skipCallback
  5366. }
  5367. // set classes, position handles and execute callbacks...
  5368. setAsOpen(pane);
  5369. };
  5370. }
  5371. /**
  5372. * @param {string} pane The pane just opened, ie: north, south, east, or west
  5373. * @param {boolean=} [skipCallback=false]
  5374. */
  5375. , setAsOpen = function (pane, skipCallback) {
  5376. var
  5377. $P = $Ps[pane]
  5378. , $R = $Rs[pane]
  5379. , $T = $Ts[pane]
  5380. , o = options[pane]
  5381. , s = state[pane]
  5382. , side = _c[pane].side
  5383. , rClass = o.resizerClass
  5384. , tClass = o.togglerClass
  5385. , _pane = "-"+ pane // used for classNames
  5386. , _open = "-open"
  5387. , _closed = "-closed"
  5388. , _sliding= "-sliding"
  5389. ;
  5390. $R
  5391. .css(side, sC.inset[side] + getPaneSize(pane)) // move the resizer
  5392. .removeClass( rClass+_closed +" "+ rClass+_pane+_closed )
  5393. .addClass( rClass+_open +" "+ rClass+_pane+_open )
  5394. ;
  5395. if (s.isSliding)
  5396. $R.addClass( rClass+_sliding +" "+ rClass+_pane+_sliding )
  5397. else // in case 'was sliding'
  5398. $R.removeClass( rClass+_sliding +" "+ rClass+_pane+_sliding )
  5399. removeHover( 0, $R ); // remove hover classes
  5400. if (o.resizable && $.layout.plugins.draggable)
  5401. $R .draggable("enable")
  5402. .css("cursor", o.resizerCursor)
  5403. .attr("title", o.tips.Resize);
  5404. else if (!s.isSliding)
  5405. $R.css("cursor", "default"); // n-resize, s-resize, etc
  5406. // if pane also has a toggler button, adjust that too
  5407. if ($T) {
  5408. $T .removeClass( tClass+_closed +" "+ tClass+_pane+_closed )
  5409. .addClass( tClass+_open +" "+ tClass+_pane+_open )
  5410. .attr("title", o.tips.Close); // may be blank
  5411. removeHover( 0, $T ); // remove hover classes
  5412. // toggler-content - if exists
  5413. $T.children(".content-closed").hide();
  5414. $T.children(".content-open").css("display","block");
  5415. }
  5416. // sync any 'pin buttons'
  5417. syncPinBtns(pane, !s.isSliding);
  5418. // update pane-state dimensions - BEFORE resizing content
  5419. $.extend(s, elDims($P));
  5420. if (state.initialized) {
  5421. // resize resizer & toggler sizes for all panes
  5422. sizeHandles();
  5423. // resize content every time pane opens - to be sure
  5424. sizeContent(pane, true); // true = remeasure headers/footers, even if 'pane.isMoving'
  5425. }
  5426. if (!skipCallback && (state.initialized || o.triggerEventsOnLoad) && $P.is(":visible")) {
  5427. // onopen callback
  5428. _runCallbacks("onopen_end", pane);
  5429. // onshow callback - TODO: should this be here?
  5430. if (s.isShowing) _runCallbacks("onshow_end", pane);
  5431. // ALSO call onresize because layout-size *may* have changed while pane was closed
  5432. if (state.initialized)
  5433. _runCallbacks("onresize_end", pane);
  5434. }
  5435. // TODO: Somehow sizePane("north") is being called after this point???
  5436. }
  5437. /**
  5438. * slideOpen / slideClose / slideToggle
  5439. *
  5440. * Pass-though methods for sliding
  5441. */
  5442. , slideOpen = function (evt_or_pane) {
  5443. if (!isInitialized()) return;
  5444. var evt = evtObj(evt_or_pane)
  5445. , pane = evtPane.call(this, evt_or_pane)
  5446. , s = state[pane]
  5447. , delay = options[pane].slideDelay_open
  5448. ;
  5449. // prevent event from triggering on NEW resizer binding created below
  5450. if (evt) evt.stopImmediatePropagation();
  5451. if (s.isClosed && evt && evt.type === "mouseenter" && delay > 0)
  5452. // trigger = mouseenter - use a delay
  5453. timer.set(pane+"_openSlider", open_NOW, delay);
  5454. else
  5455. open_NOW(); // will unbind events if is already open
  5456. /**
  5457. * SUBROUTINE for timed open
  5458. */
  5459. function open_NOW () {
  5460. if (!s.isClosed) // skip if no longer closed!
  5461. bindStopSlidingEvents(pane, true); // BIND trigger events to close sliding-pane
  5462. else if (!s.isMoving)
  5463. open(pane, true); // true = slide - open() will handle binding
  5464. };
  5465. }
  5466. , slideClose = function (evt_or_pane) {
  5467. if (!isInitialized()) return;
  5468. var evt = evtObj(evt_or_pane)
  5469. , pane = evtPane.call(this, evt_or_pane)
  5470. , o = options[pane]
  5471. , s = state[pane]
  5472. , delay = s.isMoving ? 1000 : 300 // MINIMUM delay - option may override
  5473. ;
  5474. if (s.isClosed || s.isResizing)
  5475. return; // skip if already closed OR in process of resizing
  5476. else if (o.slideTrigger_close === "click")
  5477. close_NOW(); // close immediately onClick
  5478. else if (o.preventQuickSlideClose && s.isMoving)
  5479. return; // handle Chrome quick-close on slide-open
  5480. else if (o.preventPrematureSlideClose && evt && $.layout.isMouseOverElem(evt, $Ps[pane]))
  5481. return; // handle incorrect mouseleave trigger, like when over a SELECT-list in IE
  5482. else if (evt) // trigger = mouseleave - use a delay
  5483. // 1 sec delay if 'opening', else .3 sec
  5484. timer.set(pane+"_closeSlider", close_NOW, max(o.slideDelay_close, delay));
  5485. else // called programically
  5486. close_NOW();
  5487. /**
  5488. * SUBROUTINE for timed close
  5489. */
  5490. function close_NOW () {
  5491. if (s.isClosed) // skip 'close' if already closed!
  5492. bindStopSlidingEvents(pane, false); // UNBIND trigger events - TODO: is this needed here?
  5493. else if (!s.isMoving)
  5494. close(pane); // close will handle unbinding
  5495. };
  5496. }
  5497. /**
  5498. * @param {(string|Object)} evt_or_pane The pane being opened, ie: north, south, east, or west
  5499. */
  5500. , slideToggle = function (evt_or_pane) {
  5501. var pane = evtPane.call(this, evt_or_pane);
  5502. toggle(pane, true);
  5503. }
  5504. /**
  5505. * Must set left/top on East/South panes so animation will work properly
  5506. *
  5507. * @param {string} pane The pane to lock, 'east' or 'south' - any other is ignored!
  5508. * @param {boolean} doLock true = set left/top, false = remove
  5509. */
  5510. , lockPaneForFX = function (pane, doLock) {
  5511. var $P = $Ps[pane]
  5512. , s = state[pane]
  5513. , o = options[pane]
  5514. , z = options.zIndexes
  5515. ;
  5516. if (doLock) {
  5517. showMasks( pane, { animation: true, objectsOnly: true });
  5518. $P.css({ zIndex: z.pane_animate }); // overlay all elements during animation
  5519. if (pane=="south")
  5520. $P.css({ top: sC.inset.top + sC.innerHeight - $P.outerHeight() });
  5521. else if (pane=="east")
  5522. $P.css({ left: sC.inset.left + sC.innerWidth - $P.outerWidth() });
  5523. }
  5524. else { // animation DONE - RESET CSS
  5525. hideMasks();
  5526. $P.css({ zIndex: (s.isSliding ? z.pane_sliding : z.pane_normal) });
  5527. if (pane=="south")
  5528. $P.css({ top: "auto" });
  5529. // if pane is positioned 'off-screen', then DO NOT screw with it!
  5530. else if (pane=="east" && !$P.css("left").match(/\-99999/))
  5531. $P.css({ left: "auto" });
  5532. // fix anti-aliasing in IE - only needed for animations that change opacity
  5533. if (browser.msie && o.fxOpacityFix && o.fxName_open != "slide" && $P.css("filter") && $P.css("opacity") == 1)
  5534. $P[0].style.removeAttribute('filter');
  5535. }
  5536. }
  5537. /**
  5538. * Toggle sliding functionality of a specific pane on/off by adding removing 'slide open' trigger
  5539. *
  5540. * @see open(), close()
  5541. * @param {string} pane The pane to enable/disable, 'north', 'south', etc.
  5542. * @param {boolean} enable Enable or Disable sliding?
  5543. */
  5544. , bindStartSlidingEvents = function (pane, enable) {
  5545. var o = options[pane]
  5546. , $P = $Ps[pane]
  5547. , $R = $Rs[pane]
  5548. , evtName = o.slideTrigger_open.toLowerCase()
  5549. ;
  5550. if (!$R || (enable && !o.slidable)) return;
  5551. // make sure we have a valid event
  5552. if (evtName.match(/mouseover/))
  5553. evtName = o.slideTrigger_open = "mouseenter";
  5554. else if (!evtName.match(/(click|dblclick|mouseenter)/))
  5555. evtName = o.slideTrigger_open = "click";
  5556. // must remove double-click-toggle when using dblclick-slide
  5557. if (o.resizerDblClickToggle && evtName.match(/click/)) {
  5558. $R[enable ? "unbind" : "bind"]('dblclick.'+ sID, toggle)
  5559. }
  5560. $R
  5561. // add or remove event
  5562. [enable ? "bind" : "unbind"](evtName +'.'+ sID, slideOpen)
  5563. // set the appropriate cursor & title/tip
  5564. .css("cursor", enable ? o.sliderCursor : "default")
  5565. .attr("title", enable ? o.tips.Slide : "")
  5566. ;
  5567. }
  5568. /**
  5569. * Add or remove 'mouseleave' events to 'slide close' when pane is 'sliding' open or closed
  5570. * Also increases zIndex when pane is sliding open
  5571. * See bindStartSlidingEvents for code to control 'slide open'
  5572. *
  5573. * @see slideOpen(), slideClose()
  5574. * @param {string} pane The pane to process, 'north', 'south', etc.
  5575. * @param {boolean} enable Enable or Disable events?
  5576. */
  5577. , bindStopSlidingEvents = function (pane, enable) {
  5578. var o = options[pane]
  5579. , s = state[pane]
  5580. , c = _c[pane]
  5581. , z = options.zIndexes
  5582. , evtName = o.slideTrigger_close.toLowerCase()
  5583. , action = (enable ? "bind" : "unbind")
  5584. , $P = $Ps[pane]
  5585. , $R = $Rs[pane]
  5586. ;
  5587. timer.clear(pane+"_closeSlider"); // just in case
  5588. if (enable) {
  5589. s.isSliding = true;
  5590. state.panesSliding[pane] = true;
  5591. // remove 'slideOpen' event from resizer
  5592. // ALSO will raise the zIndex of the pane & resizer
  5593. bindStartSlidingEvents(pane, false);
  5594. }
  5595. else {
  5596. s.isSliding = false;
  5597. delete state.panesSliding[pane];
  5598. }
  5599. // RE/SET zIndex - increases when pane is sliding-open, resets to normal when not
  5600. $P.css("zIndex", enable ? z.pane_sliding : z.pane_normal);
  5601. $R.css("zIndex", enable ? z.pane_sliding+2 : z.resizer_normal); // NOTE: mask = pane_sliding+1
  5602. // make sure we have a valid event
  5603. if (!evtName.match(/(click|mouseleave)/))
  5604. evtName = o.slideTrigger_close = "mouseleave"; // also catches 'mouseout'
  5605. // add/remove slide triggers
  5606. $R[action](evtName, slideClose); // base event on resize
  5607. // need extra events for mouseleave
  5608. if (evtName === "mouseleave") {
  5609. // also close on pane.mouseleave
  5610. $P[action]("mouseleave."+ sID, slideClose);
  5611. // cancel timer when mouse moves between 'pane' and 'resizer'
  5612. $R[action]("mouseenter."+ sID, cancelMouseOut);
  5613. $P[action]("mouseenter."+ sID, cancelMouseOut);
  5614. }
  5615. if (!enable)
  5616. timer.clear(pane+"_closeSlider");
  5617. else if (evtName === "click" && !o.resizable) {
  5618. // IF pane is not resizable (which already has a cursor and tip)
  5619. // then set the a cursor & title/tip on resizer when sliding
  5620. $R.css("cursor", enable ? o.sliderCursor : "default");
  5621. $R.attr("title", enable ? o.tips.Close : ""); // use Toggler-tip, eg: "Close Pane"
  5622. }
  5623. // SUBROUTINE for mouseleave timer clearing
  5624. function cancelMouseOut (evt) {
  5625. timer.clear(pane+"_closeSlider");
  5626. evt.stopPropagation();
  5627. }
  5628. }
  5629. /**
  5630. * Hides/closes a pane if there is insufficient room - reverses this when there is room again
  5631. * MUST have already called setSizeLimits() before calling this method
  5632. *
  5633. * @param {string} pane The pane being resized
  5634. * @param {boolean=} [isOpening=false] Called from onOpen?
  5635. * @param {boolean=} [skipCallback=false] Should the onresize callback be run?
  5636. * @param {boolean=} [force=false]
  5637. */
  5638. , makePaneFit = function (pane, isOpening, skipCallback, force) {
  5639. var o = options[pane]
  5640. , s = state[pane]
  5641. , c = _c[pane]
  5642. , $P = $Ps[pane]
  5643. , $R = $Rs[pane]
  5644. , isSidePane = c.dir==="vert"
  5645. , hasRoom = false
  5646. ;
  5647. // special handling for center & east/west panes
  5648. if (pane === "center" || (isSidePane && s.noVerticalRoom)) {
  5649. // see if there is enough room to display the pane
  5650. // ERROR: hasRoom = s.minHeight <= s.maxHeight && (isSidePane || s.minWidth <= s.maxWidth);
  5651. hasRoom = (s.maxHeight >= 0);
  5652. if (hasRoom && s.noRoom) { // previously hidden due to noRoom, so show now
  5653. _showPane(pane);
  5654. if ($R) $R.show();
  5655. s.isVisible = true;
  5656. s.noRoom = false;
  5657. if (isSidePane) s.noVerticalRoom = false;
  5658. _fixIframe(pane);
  5659. }
  5660. else if (!hasRoom && !s.noRoom) { // not currently hidden, so hide now
  5661. _hidePane(pane);
  5662. if ($R) $R.hide();
  5663. s.isVisible = false;
  5664. s.noRoom = true;
  5665. }
  5666. }
  5667. // see if there is enough room to fit the border-pane
  5668. if (pane === "center") {
  5669. // ignore center in this block
  5670. }
  5671. else if (s.minSize <= s.maxSize) { // pane CAN fit
  5672. hasRoom = true;
  5673. if (s.size > s.maxSize) // pane is too big - shrink it
  5674. sizePane(pane, s.maxSize, skipCallback, true, force); // true = noAnimation
  5675. else if (s.size < s.minSize) // pane is too small - enlarge it
  5676. sizePane(pane, s.minSize, skipCallback, true, force); // true = noAnimation
  5677. // need s.isVisible because new pseudoClose method keeps pane visible, but off-screen
  5678. else if ($R && s.isVisible && $P.is(":visible")) {
  5679. // make sure resizer-bar is positioned correctly
  5680. // handles situation where nested layout was 'hidden' when initialized
  5681. var pos = s.size + sC.inset[c.side];
  5682. if ($.layout.cssNum( $R, c.side ) != pos) $R.css( c.side, pos );
  5683. }
  5684. // if was previously hidden due to noRoom, then RESET because NOW there is room
  5685. if (s.noRoom) {
  5686. // s.noRoom state will be set by open or show
  5687. if (s.wasOpen && o.closable) {
  5688. if (o.autoReopen)
  5689. open(pane, false, true, true); // true = noAnimation, true = noAlert
  5690. else // leave the pane closed, so just update state
  5691. s.noRoom = false;
  5692. }
  5693. else
  5694. show(pane, s.wasOpen, true, true); // true = noAnimation, true = noAlert
  5695. }
  5696. }
  5697. else { // !hasRoom - pane CANNOT fit
  5698. if (!s.noRoom) { // pane not set as noRoom yet, so hide or close it now...
  5699. s.noRoom = true; // update state
  5700. s.wasOpen = !s.isClosed && !s.isSliding;
  5701. if (s.isClosed){} // SKIP
  5702. else if (o.closable) // 'close' if possible
  5703. close(pane, true, true); // true = force, true = noAnimation
  5704. else // 'hide' pane if cannot just be closed
  5705. hide(pane, true); // true = noAnimation
  5706. }
  5707. }
  5708. }
  5709. /**
  5710. * manualSizePane is an exposed flow-through method allowing extra code when pane is 'manually resized'
  5711. *
  5712. * @param {(string|Object)} evt_or_pane The pane being resized
  5713. * @param {number} size The *desired* new size for this pane - will be validated
  5714. * @param {boolean=} [skipCallback=false] Should the onresize callback be run?
  5715. * @param {boolean=} [noAnimation=false]
  5716. * @param {boolean=} [force=false] Force resizing even if does not seem necessary
  5717. */
  5718. , manualSizePane = function (evt_or_pane, size, skipCallback, noAnimation, force) {
  5719. if (!isInitialized()) return;
  5720. var pane = evtPane.call(this, evt_or_pane)
  5721. , o = options[pane]
  5722. , s = state[pane]
  5723. // if resizing callbacks have been delayed and resizing is now DONE, force resizing to complete...
  5724. , forceResize = force || (o.livePaneResizing && !s.isResizing)
  5725. ;
  5726. // ANY call to manualSizePane disables autoResize - ie, percentage sizing
  5727. s.autoResize = false;
  5728. // flow-through...
  5729. sizePane(pane, size, skipCallback, noAnimation, forceResize); // will animate resize if option enabled
  5730. }
  5731. /**
  5732. * sizePane is called only by internal methods whenever a pane needs to be resized
  5733. *
  5734. * @param {(string|Object)} evt_or_pane The pane being resized
  5735. * @param {number} size The *desired* new size for this pane - will be validated
  5736. * @param {boolean=} [skipCallback=false] Should the onresize callback be run?
  5737. * @param {boolean=} [noAnimation=false]
  5738. * @param {boolean=} [force=false] Force resizing even if does not seem necessary
  5739. */
  5740. , sizePane = function (evt_or_pane, size, skipCallback, noAnimation, force) {
  5741. if (!isInitialized()) return;
  5742. var pane = evtPane.call(this, evt_or_pane) // probably NEVER called from event?
  5743. , o = options[pane]
  5744. , s = state[pane]
  5745. , $P = $Ps[pane]
  5746. , $R = $Rs[pane]
  5747. , side = _c[pane].side
  5748. , dimName = _c[pane].sizeType.toLowerCase()
  5749. , skipResizeWhileDragging = s.isResizing && !o.triggerEventsDuringLiveResize
  5750. , doFX = noAnimation !== true && o.animatePaneSizing
  5751. , oldSize, newSize
  5752. ;
  5753. // QUEUE in case another action/animation is in progress
  5754. $N.queue(function( queueNext ){
  5755. // calculate 'current' min/max sizes
  5756. setSizeLimits(pane); // update pane-state
  5757. oldSize = s.size;
  5758. size = _parseSize(pane, size); // handle percentages & auto
  5759. size = max(size, _parseSize(pane, o.minSize));
  5760. size = min(size, s.maxSize);
  5761. if (size < s.minSize) { // not enough room for pane!
  5762. queueNext(); // call before makePaneFit() because it needs the queue free
  5763. makePaneFit(pane, false, skipCallback); // will hide or close pane
  5764. return;
  5765. }
  5766. // IF newSize is same as oldSize, then nothing to do - abort
  5767. if (!force && size === oldSize)
  5768. return queueNext();
  5769. s.newSize = size;
  5770. // onresize_start callback CANNOT cancel resizing because this would break the layout!
  5771. if (!skipCallback && state.initialized && s.isVisible)
  5772. _runCallbacks("onresize_start", pane);
  5773. // resize the pane, and make sure its visible
  5774. newSize = cssSize(pane, size);
  5775. if (doFX && $P.is(":visible")) { // ANIMATE
  5776. var fx = $.layout.effects.size[pane] || $.layout.effects.size.all
  5777. , easing = o.fxSettings_size.easing || fx.easing
  5778. , z = options.zIndexes
  5779. , props = {};
  5780. props[ dimName ] = newSize +'px';
  5781. s.isMoving = true;
  5782. // overlay all elements during animation
  5783. $P.css({ zIndex: z.pane_animate })
  5784. .show().animate( props, o.fxSpeed_size, easing, function(){
  5785. // reset zIndex after animation
  5786. $P.css({ zIndex: (s.isSliding ? z.pane_sliding : z.pane_normal) });
  5787. s.isMoving = false;
  5788. delete s.newSize;
  5789. sizePane_2(); // continue
  5790. queueNext();
  5791. });
  5792. }
  5793. else { // no animation
  5794. $P.css( dimName, newSize ); // resize pane
  5795. delete s.newSize;
  5796. // if pane is visible, then
  5797. if ($P.is(":visible"))
  5798. sizePane_2(); // continue
  5799. else {
  5800. // pane is NOT VISIBLE, so just update state data...
  5801. // when pane is *next opened*, it will have the new size
  5802. s.size = size; // update state.size
  5803. $.extend(s, elDims($P)); // update state dimensions
  5804. }
  5805. queueNext();
  5806. };
  5807. });
  5808. // SUBROUTINE
  5809. function sizePane_2 () {
  5810. /* Panes are sometimes not sized precisely in some browsers!?
  5811. * This code will resize the pane up to 3 times to nudge the pane to the correct size
  5812. */
  5813. var actual = dimName==='width' ? $P.outerWidth() : $P.outerHeight()
  5814. , tries = [{
  5815. pane: pane
  5816. , count: 1
  5817. , target: size
  5818. , actual: actual
  5819. , correct: (size === actual)
  5820. , attempt: size
  5821. , cssSize: newSize
  5822. }]
  5823. , lastTry = tries[0]
  5824. , thisTry = {}
  5825. , msg = 'Inaccurate size after resizing the '+ pane +'-pane.'
  5826. ;
  5827. while ( !lastTry.correct ) {
  5828. thisTry = { pane: pane, count: lastTry.count+1, target: size };
  5829. if (lastTry.actual > size)
  5830. thisTry.attempt = max(0, lastTry.attempt - (lastTry.actual - size));
  5831. else // lastTry.actual < size
  5832. thisTry.attempt = max(0, lastTry.attempt + (size - lastTry.actual));
  5833. thisTry.cssSize = cssSize(pane, thisTry.attempt);
  5834. $P.css( dimName, thisTry.cssSize );
  5835. thisTry.actual = dimName=='width' ? $P.outerWidth() : $P.outerHeight();
  5836. thisTry.correct = (size === thisTry.actual);
  5837. // log attempts and alert the user of this *non-fatal error* (if showDebugMessages)
  5838. if ( tries.length === 1) {
  5839. _log(msg, false, true);
  5840. _log(lastTry, false, true);
  5841. }
  5842. _log(thisTry, false, true);
  5843. // after 4 tries, is as close as its gonna get!
  5844. if (tries.length > 3) break;
  5845. tries.push( thisTry );
  5846. lastTry = tries[ tries.length - 1 ];
  5847. }
  5848. // END TESTING CODE
  5849. // update pane-state dimensions
  5850. s.size = size;
  5851. $.extend(s, elDims($P));
  5852. if (s.isVisible && $P.is(":visible")) {
  5853. // reposition the resizer-bar
  5854. if ($R) $R.css( side, size + sC.inset[side] );
  5855. // resize the content-div
  5856. sizeContent(pane);
  5857. }
  5858. if (!skipCallback && !skipResizeWhileDragging && state.initialized && s.isVisible)
  5859. _runCallbacks("onresize_end", pane);
  5860. // resize all the adjacent panes, and adjust their toggler buttons
  5861. // when skipCallback passed, it means the controlling method will handle 'other panes'
  5862. if (!skipCallback) {
  5863. // also no callback if live-resize is in progress and NOT triggerEventsDuringLiveResize
  5864. if (!s.isSliding) sizeMidPanes(_c[pane].dir=="horz" ? "" : "center", skipResizeWhileDragging, force);
  5865. sizeHandles();
  5866. }
  5867. // if opposite-pane was autoClosed, see if it can be autoOpened now
  5868. var altPane = _c.oppositeEdge[pane];
  5869. if (size < oldSize && state[ altPane ].noRoom) {
  5870. setSizeLimits( altPane );
  5871. makePaneFit( altPane, false, skipCallback );
  5872. }
  5873. // DEBUG - ALERT user/developer so they know there was a sizing problem
  5874. if (tries.length > 1)
  5875. _log(msg +'\nSee the Error Console for details.', true, true);
  5876. }
  5877. }
  5878. /**
  5879. * @see initPanes(), sizePane(), resizeAll(), open(), close(), hide()
  5880. * @param {(Array.<string>|string)} panes The pane(s) being resized, comma-delmited string
  5881. * @param {boolean=} [skipCallback=false] Should the onresize callback be run?
  5882. * @param {boolean=} [force=false]
  5883. */
  5884. , sizeMidPanes = function (panes, skipCallback, force) {
  5885. panes = (panes ? panes : "east,west,center").split(",");
  5886. $.each(panes, function (i, pane) {
  5887. if (!$Ps[pane]) return; // NO PANE - skip
  5888. var
  5889. o = options[pane]
  5890. , s = state[pane]
  5891. , $P = $Ps[pane]
  5892. , $R = $Rs[pane]
  5893. , isCenter= (pane=="center")
  5894. , hasRoom = true
  5895. , CSS = {}
  5896. // if pane is not visible, show it invisibly NOW rather than for *each call* in this script
  5897. , visCSS = $.layout.showInvisibly($P)
  5898. , newCenter = calcNewCenterPaneDims()
  5899. ;
  5900. // update pane-state dimensions
  5901. $.extend(s, elDims($P));
  5902. if (pane === "center") {
  5903. if (!force && s.isVisible && newCenter.width === s.outerWidth && newCenter.height === s.outerHeight) {
  5904. $P.css(visCSS);
  5905. return true; // SKIP - pane already the correct size
  5906. }
  5907. // set state for makePaneFit() logic
  5908. $.extend(s, cssMinDims(pane), {
  5909. maxWidth: newCenter.width
  5910. , maxHeight: newCenter.height
  5911. });
  5912. CSS = newCenter;
  5913. s.newWidth = CSS.width;
  5914. s.newHeight = CSS.height;
  5915. // convert OUTER width/height to CSS width/height
  5916. CSS.width = cssW($P, CSS.width);
  5917. // NEW - allow pane to extend 'below' visible area rather than hide it
  5918. CSS.height = cssH($P, CSS.height);
  5919. hasRoom = CSS.width >= 0 && CSS.height >= 0; // height >= 0 = ALWAYS TRUE NOW
  5920. // during layout init, try to shrink east/west panes to make room for center
  5921. if (!state.initialized && o.minWidth > newCenter.width) {
  5922. var
  5923. reqPx = o.minWidth - s.outerWidth
  5924. , minE = options.east.minSize || 0
  5925. , minW = options.west.minSize || 0
  5926. , sizeE = state.east.size
  5927. , sizeW = state.west.size
  5928. , newE = sizeE
  5929. , newW = sizeW
  5930. ;
  5931. if (reqPx > 0 && state.east.isVisible && sizeE > minE) {
  5932. newE = max( sizeE-minE, sizeE-reqPx );
  5933. reqPx -= sizeE-newE;
  5934. }
  5935. if (reqPx > 0 && state.west.isVisible && sizeW > minW) {
  5936. newW = max( sizeW-minW, sizeW-reqPx );
  5937. reqPx -= sizeW-newW;
  5938. }
  5939. // IF we found enough extra space, then resize the border panes as calculated
  5940. if (reqPx === 0) {
  5941. if (sizeE && sizeE != minE)
  5942. sizePane('east', newE, true, true, force); // true = skipCallback/noAnimation - initPanes will handle when done
  5943. if (sizeW && sizeW != minW)
  5944. sizePane('west', newW, true, true, force); // true = skipCallback/noAnimation
  5945. // now start over!
  5946. sizeMidPanes('center', skipCallback, force);
  5947. $P.css(visCSS);
  5948. return; // abort this loop
  5949. }
  5950. }
  5951. }
  5952. else { // for east and west, set only the height, which is same as center height
  5953. // set state.min/maxWidth/Height for makePaneFit() logic
  5954. if (s.isVisible && !s.noVerticalRoom)
  5955. $.extend(s, elDims($P), cssMinDims(pane))
  5956. if (!force && !s.noVerticalRoom && newCenter.height === s.outerHeight) {
  5957. $P.css(visCSS);
  5958. return true; // SKIP - pane already the correct size
  5959. }
  5960. // east/west have same top, bottom & height as center
  5961. CSS.top = newCenter.top;
  5962. CSS.bottom = newCenter.bottom;
  5963. s.newSize = newCenter.height
  5964. // NEW - allow pane to extend 'below' visible area rather than hide it
  5965. CSS.height = cssH($P, newCenter.height);
  5966. s.maxHeight = CSS.height;
  5967. hasRoom = (s.maxHeight >= 0); // ALWAYS TRUE NOW
  5968. if (!hasRoom) s.noVerticalRoom = true; // makePaneFit() logic
  5969. }
  5970. if (hasRoom) {
  5971. // resizeAll passes skipCallback because it triggers callbacks after ALL panes are resized
  5972. if (!skipCallback && state.initialized)
  5973. _runCallbacks("onresize_start", pane);
  5974. $P.css(CSS); // apply the CSS to pane
  5975. if (pane !== "center")
  5976. sizeHandles(pane); // also update resizer length
  5977. if (s.noRoom && !s.isClosed && !s.isHidden)
  5978. makePaneFit(pane); // will re-open/show auto-closed/hidden pane
  5979. if (s.isVisible) {
  5980. $.extend(s, elDims($P)); // update pane dimensions
  5981. if (state.initialized) sizeContent(pane); // also resize the contents, if exists
  5982. }
  5983. }
  5984. else if (!s.noRoom && s.isVisible) // no room for pane
  5985. makePaneFit(pane); // will hide or close pane
  5986. // reset visibility, if necessary
  5987. $P.css(visCSS);
  5988. delete s.newSize;
  5989. delete s.newWidth;
  5990. delete s.newHeight;
  5991. if (!s.isVisible)
  5992. return true; // DONE - next pane
  5993. /*
  5994. * Extra CSS for IE6 or IE7 in Quirks-mode - add 'width' to NORTH/SOUTH panes
  5995. * Normally these panes have only 'left' & 'right' positions so pane auto-sizes
  5996. * ALSO required when pane is an IFRAME because will NOT default to 'full width'
  5997. * TODO: Can I use width:100% for a north/south iframe?
  5998. * TODO: Sounds like a job for $P.outerWidth( sC.innerWidth ) SETTER METHOD
  5999. */
  6000. if (pane === "center") { // finished processing midPanes
  6001. var fix = browser.isIE6 || !browser.boxModel;
  6002. if ($Ps.north && (fix || state.north.tagName=="IFRAME"))
  6003. $Ps.north.css("width", cssW($Ps.north, sC.innerWidth));
  6004. if ($Ps.south && (fix || state.south.tagName=="IFRAME"))
  6005. $Ps.south.css("width", cssW($Ps.south, sC.innerWidth));
  6006. }
  6007. // resizeAll passes skipCallback because it triggers callbacks after ALL panes are resized
  6008. if (!skipCallback && state.initialized)
  6009. _runCallbacks("onresize_end", pane);
  6010. });
  6011. }
  6012. /**
  6013. * @see window.onresize(), callbacks or custom code
  6014. * @param {(Object|boolean)=} evt_or_refresh If 'true', then also reset pane-positioning
  6015. */
  6016. , resizeAll = function (evt_or_refresh) {
  6017. var oldW = sC.innerWidth
  6018. , oldH = sC.innerHeight
  6019. ;
  6020. // stopPropagation if called by trigger("layoutdestroy") - use evtPane utility
  6021. evtPane(evt_or_refresh);
  6022. // cannot size layout when 'container' is hidden or collapsed
  6023. if (!$N.is(":visible")) return;
  6024. if (!state.initialized) {
  6025. _initLayoutElements();
  6026. return; // no need to resize since we just initialized!
  6027. }
  6028. if (evt_or_refresh === true && $.isPlainObject(options.outset)) {
  6029. // update container CSS in case outset option has changed
  6030. $N.css( options.outset );
  6031. }
  6032. // UPDATE container dimensions
  6033. $.extend(sC, elDims( $N, options.inset ));
  6034. if (!sC.outerHeight) return;
  6035. // if 'true' passed, refresh pane & handle positioning too
  6036. if (evt_or_refresh === true) {
  6037. setPanePosition();
  6038. }
  6039. // onresizeall_start will CANCEL resizing if returns false
  6040. // state.container has already been set, so user can access this info for calcuations
  6041. if (false === _runCallbacks("onresizeall_start")) return false;
  6042. var // see if container is now 'smaller' than before
  6043. shrunkH = (sC.innerHeight < oldH)
  6044. , shrunkW = (sC.innerWidth < oldW)
  6045. , $P, o, s
  6046. ;
  6047. // NOTE special order for sizing: S-N-E-W
  6048. $.each(["south","north","east","west"], function (i, pane) {
  6049. if (!$Ps[pane]) return; // no pane - SKIP
  6050. o = options[pane];
  6051. s = state[pane];
  6052. if (s.autoResize && s.size != o.size) // resize pane to original size set in options
  6053. sizePane(pane, o.size, true, true, true); // true=skipCallback/noAnimation/forceResize
  6054. else {
  6055. setSizeLimits(pane);
  6056. makePaneFit(pane, false, true, true); // true=skipCallback/forceResize
  6057. }
  6058. });
  6059. sizeMidPanes("", true, true); // true=skipCallback/forceResize
  6060. sizeHandles(); // reposition the toggler elements
  6061. // trigger all individual pane callbacks AFTER layout has finished resizing
  6062. $.each(_c.allPanes, function (i, pane) {
  6063. $P = $Ps[pane];
  6064. if (!$P) return; // SKIP
  6065. if (state[pane].isVisible) // undefined for non-existent panes
  6066. _runCallbacks("onresize_end", pane); // callback - if exists
  6067. });
  6068. _runCallbacks("onresizeall_end");
  6069. //_triggerLayoutEvent(pane, 'resizeall');
  6070. }
  6071. /**
  6072. * Whenever a pane resizes or opens that has a nested layout, trigger resizeAll
  6073. *
  6074. * @param {(string|Object)} evt_or_pane The pane just resized or opened
  6075. */
  6076. , resizeChildren = function (evt_or_pane, skipRefresh) {
  6077. var pane = evtPane.call(this, evt_or_pane);
  6078. if (!options[pane].resizeChildren) return;
  6079. // ensure the pane-children are up-to-date
  6080. if (!skipRefresh) refreshChildren( pane );
  6081. var pC = children[pane];
  6082. if ($.isPlainObject( pC )) {
  6083. // resize one or more children
  6084. $.each( pC, function (key, child) {
  6085. if (!child.destroyed) child.resizeAll();
  6086. });
  6087. }
  6088. }
  6089. /**
  6090. * IF pane has a content-div, then resize all elements inside pane to fit pane-height
  6091. *
  6092. * @param {(string|Object)} evt_or_panes The pane(s) being resized
  6093. * @param {boolean=} [remeasure=false] Should the content (header/footer) be remeasured?
  6094. */
  6095. , sizeContent = function (evt_or_panes, remeasure) {
  6096. if (!isInitialized()) return;
  6097. var panes = evtPane.call(this, evt_or_panes);
  6098. panes = panes ? panes.split(",") : _c.allPanes;
  6099. $.each(panes, function (idx, pane) {
  6100. var
  6101. $P = $Ps[pane]
  6102. , $C = $Cs[pane]
  6103. , o = options[pane]
  6104. , s = state[pane]
  6105. , m = s.content // m = measurements
  6106. ;
  6107. if (!$P || !$C || !$P.is(":visible")) return true; // NOT VISIBLE - skip
  6108. // if content-element was REMOVED, update OR remove the pointer
  6109. if (!$C.length) {
  6110. initContent(pane, false); // false = do NOT sizeContent() - already there!
  6111. if (!$C) return; // no replacement element found - pointer have been removed
  6112. }
  6113. // onsizecontent_start will CANCEL resizing if returns false
  6114. if (false === _runCallbacks("onsizecontent_start", pane)) return;
  6115. // skip re-measuring offsets if live-resizing
  6116. if ((!s.isMoving && !s.isResizing) || o.liveContentResizing || remeasure || m.top == undefined) {
  6117. _measure();
  6118. // if any footers are below pane-bottom, they may not measure correctly,
  6119. // so allow pane overflow and re-measure
  6120. if (m.hiddenFooters > 0 && $P.css("overflow") === "hidden") {
  6121. $P.css("overflow", "visible");
  6122. _measure(); // remeasure while overflowing
  6123. $P.css("overflow", "hidden");
  6124. }
  6125. }
  6126. // NOTE: spaceAbove/Below *includes* the pane paddingTop/Bottom, but not pane.borders
  6127. var newH = s.innerHeight - (m.spaceAbove - s.css.paddingTop) - (m.spaceBelow - s.css.paddingBottom);
  6128. if (!$C.is(":visible") || m.height != newH) {
  6129. // size the Content element to fit new pane-size - will autoHide if not enough room
  6130. setOuterHeight($C, newH, true); // true=autoHide
  6131. m.height = newH; // save new height
  6132. };
  6133. if (state.initialized)
  6134. _runCallbacks("onsizecontent_end", pane);
  6135. function _below ($E) {
  6136. return max(s.css.paddingBottom, (parseInt($E.css("marginBottom"), 10) || 0));
  6137. };
  6138. function _measure () {
  6139. var
  6140. ignore = options[pane].contentIgnoreSelector
  6141. , $Fs = $C.nextAll().not(".ui-layout-mask").not(ignore || ":lt(0)") // not :lt(0) = ALL
  6142. , $Fs_vis = $Fs.filter(':visible')
  6143. , $F = $Fs_vis.filter(':last')
  6144. ;
  6145. m = {
  6146. top: $C[0].offsetTop
  6147. , height: $C.outerHeight()
  6148. , numFooters: $Fs.length
  6149. , hiddenFooters: $Fs.length - $Fs_vis.length
  6150. , spaceBelow: 0 // correct if no content footer ($E)
  6151. }
  6152. m.spaceAbove = m.top; // just for state - not used in calc
  6153. m.bottom = m.top + m.height;
  6154. if ($F.length)
  6155. //spaceBelow = (LastFooter.top + LastFooter.height) [footerBottom] - Content.bottom + max(LastFooter.marginBottom, pane.paddingBotom)
  6156. m.spaceBelow = ($F[0].offsetTop + $F.outerHeight()) - m.bottom + _below($F);
  6157. else // no footer - check marginBottom on Content element itself
  6158. m.spaceBelow = _below($C);
  6159. };
  6160. });
  6161. }
  6162. /**
  6163. * Called every time a pane is opened, closed, or resized to slide the togglers to 'center' and adjust their length if necessary
  6164. *
  6165. * @see initHandles(), open(), close(), resizeAll()
  6166. * @param {(string|Object)=} evt_or_panes The pane(s) being resized
  6167. */
  6168. , sizeHandles = function (evt_or_panes) {
  6169. var panes = evtPane.call(this, evt_or_panes)
  6170. panes = panes ? panes.split(",") : _c.borderPanes;
  6171. $.each(panes, function (i, pane) {
  6172. var
  6173. o = options[pane]
  6174. , s = state[pane]
  6175. , $P = $Ps[pane]
  6176. , $R = $Rs[pane]
  6177. , $T = $Ts[pane]
  6178. , $TC
  6179. ;
  6180. if (!$P || !$R) return;
  6181. var
  6182. dir = _c[pane].dir
  6183. , _state = (s.isClosed ? "_closed" : "_open")
  6184. , spacing = o["spacing"+ _state]
  6185. , togAlign = o["togglerAlign"+ _state]
  6186. , togLen = o["togglerLength"+ _state]
  6187. , paneLen
  6188. , left
  6189. , offset
  6190. , CSS = {}
  6191. ;
  6192. if (spacing === 0) {
  6193. $R.hide();
  6194. return;
  6195. }
  6196. else if (!s.noRoom && !s.isHidden) // skip if resizer was hidden for any reason
  6197. $R.show(); // in case was previously hidden
  6198. // Resizer Bar is ALWAYS same width/height of pane it is attached to
  6199. if (dir === "horz") { // north/south
  6200. //paneLen = $P.outerWidth(); // s.outerWidth ||
  6201. paneLen = sC.innerWidth; // handle offscreen-panes
  6202. s.resizerLength = paneLen;
  6203. left = $.layout.cssNum($P, "left")
  6204. $R.css({
  6205. width: cssW($R, paneLen) // account for borders & padding
  6206. , height: cssH($R, spacing) // ditto
  6207. , left: left > -9999 ? left : sC.inset.left // handle offscreen-panes
  6208. });
  6209. }
  6210. else { // east/west
  6211. paneLen = $P.outerHeight(); // s.outerHeight ||
  6212. s.resizerLength = paneLen;
  6213. $R.css({
  6214. height: cssH($R, paneLen) // account for borders & padding
  6215. , width: cssW($R, spacing) // ditto
  6216. , top: sC.inset.top + getPaneSize("north", true) // TODO: what if no North pane?
  6217. //, top: $.layout.cssNum($Ps["center"], "top")
  6218. });
  6219. }
  6220. // remove hover classes
  6221. removeHover( o, $R );
  6222. if ($T) {
  6223. if (togLen === 0 || (s.isSliding && o.hideTogglerOnSlide)) {
  6224. $T.hide(); // always HIDE the toggler when 'sliding'
  6225. return;
  6226. }
  6227. else
  6228. $T.show(); // in case was previously hidden
  6229. if (!(togLen > 0) || togLen === "100%" || togLen > paneLen) {
  6230. togLen = paneLen;
  6231. offset = 0;
  6232. }
  6233. else { // calculate 'offset' based on options.PANE.togglerAlign_open/closed
  6234. if (isStr(togAlign)) {
  6235. switch (togAlign) {
  6236. case "top":
  6237. case "left": offset = 0;
  6238. break;
  6239. case "bottom":
  6240. case "right": offset = paneLen - togLen;
  6241. break;
  6242. case "middle":
  6243. case "center":
  6244. default: offset = round((paneLen - togLen) / 2); // 'default' catches typos
  6245. }
  6246. }
  6247. else { // togAlign = number
  6248. var x = parseInt(togAlign, 10); //
  6249. if (togAlign >= 0) offset = x;
  6250. else offset = paneLen - togLen + x; // NOTE: x is negative!
  6251. }
  6252. }
  6253. if (dir === "horz") { // north/south
  6254. var width = cssW($T, togLen);
  6255. $T.css({
  6256. width: width // account for borders & padding
  6257. , height: cssH($T, spacing) // ditto
  6258. , left: offset // TODO: VERIFY that toggler positions correctly for ALL values
  6259. , top: 0
  6260. });
  6261. // CENTER the toggler content SPAN
  6262. $T.children(".content").each(function(){
  6263. $TC = $(this);
  6264. $TC.css("marginLeft", round((width-$TC.outerWidth())/2)); // could be negative
  6265. });
  6266. }
  6267. else { // east/west
  6268. var height = cssH($T, togLen);
  6269. $T.css({
  6270. height: height // account for borders & padding
  6271. , width: cssW($T, spacing) // ditto
  6272. , top: offset // POSITION the toggler
  6273. , left: 0
  6274. });
  6275. // CENTER the toggler content SPAN
  6276. $T.children(".content").each(function(){
  6277. $TC = $(this);
  6278. $TC.css("marginTop", round((height-$TC.outerHeight())/2)); // could be negative
  6279. });
  6280. }
  6281. // remove ALL hover classes
  6282. removeHover( 0, $T );
  6283. }
  6284. // DONE measuring and sizing this resizer/toggler, so can be 'hidden' now
  6285. if (!state.initialized && (o.initHidden || s.isHidden)) {
  6286. $R.hide();
  6287. if ($T) $T.hide();
  6288. }
  6289. });
  6290. }
  6291. /**
  6292. * @param {(string|Object)} evt_or_pane
  6293. */
  6294. , enableClosable = function (evt_or_pane) {
  6295. if (!isInitialized()) return;
  6296. var pane = evtPane.call(this, evt_or_pane)
  6297. , $T = $Ts[pane]
  6298. , o = options[pane]
  6299. ;
  6300. if (!$T) return;
  6301. o.closable = true;
  6302. $T .bind("click."+ sID, function(evt){ evt.stopPropagation(); toggle(pane); })
  6303. .css("visibility", "visible")
  6304. .css("cursor", "pointer")
  6305. .attr("title", state[pane].isClosed ? o.tips.Open : o.tips.Close) // may be blank
  6306. .show();
  6307. }
  6308. /**
  6309. * @param {(string|Object)} evt_or_pane
  6310. * @param {boolean=} [hide=false]
  6311. */
  6312. , disableClosable = function (evt_or_pane, hide) {
  6313. if (!isInitialized()) return;
  6314. var pane = evtPane.call(this, evt_or_pane)
  6315. , $T = $Ts[pane]
  6316. ;
  6317. if (!$T) return;
  6318. options[pane].closable = false;
  6319. // is closable is disable, then pane MUST be open!
  6320. if (state[pane].isClosed) open(pane, false, true);
  6321. $T .unbind("."+ sID)
  6322. .css("visibility", hide ? "hidden" : "visible") // instead of hide(), which creates logic issues
  6323. .css("cursor", "default")
  6324. .attr("title", "");
  6325. }
  6326. /**
  6327. * @param {(string|Object)} evt_or_pane
  6328. */
  6329. , enableSlidable = 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 || !$R.data('draggable')) return;
  6335. options[pane].slidable = true;
  6336. if (state[pane].isClosed)
  6337. bindStartSlidingEvents(pane, true);
  6338. }
  6339. /**
  6340. * @param {(string|Object)} evt_or_pane
  6341. */
  6342. , disableSlidable = function (evt_or_pane) {
  6343. if (!isInitialized()) return;
  6344. var pane = evtPane.call(this, evt_or_pane)
  6345. , $R = $Rs[pane]
  6346. ;
  6347. if (!$R) return;
  6348. options[pane].slidable = false;
  6349. if (state[pane].isSliding)
  6350. close(pane, false, true);
  6351. else {
  6352. bindStartSlidingEvents(pane, false);
  6353. $R .css("cursor", "default")
  6354. .attr("title", "");
  6355. removeHover(null, $R[0]); // in case currently hovered
  6356. }
  6357. }
  6358. /**
  6359. * @param {(string|Object)} evt_or_pane
  6360. */
  6361. , enableResizable = function (evt_or_pane) {
  6362. if (!isInitialized()) return;
  6363. var pane = evtPane.call(this, evt_or_pane)
  6364. , $R = $Rs[pane]
  6365. , o = options[pane]
  6366. ;
  6367. if (!$R || !$R.data('draggable')) return;
  6368. o.resizable = true;
  6369. $R.draggable("enable");
  6370. if (!state[pane].isClosed)
  6371. $R .css("cursor", o.resizerCursor)
  6372. .attr("title", o.tips.Resize);
  6373. }
  6374. /**
  6375. * @param {(string|Object)} evt_or_pane
  6376. */
  6377. , disableResizable = function (evt_or_pane) {
  6378. if (!isInitialized()) return;
  6379. var pane = evtPane.call(this, evt_or_pane)
  6380. , $R = $Rs[pane]
  6381. ;
  6382. if (!$R || !$R.data('draggable')) return;
  6383. options[pane].resizable = false;
  6384. $R .draggable("disable")
  6385. .css("cursor", "default")
  6386. .attr("title", "");
  6387. removeHover(null, $R[0]); // in case currently hovered
  6388. }
  6389. /**
  6390. * Move a pane from source-side (eg, west) to target-side (eg, east)
  6391. * If pane exists on target-side, move that to source-side, ie, 'swap' the panes
  6392. *
  6393. * @param {(string|Object)} evt_or_pane1 The pane/edge being swapped
  6394. * @param {string} pane2 ditto
  6395. */
  6396. , swapPanes = function (evt_or_pane1, pane2) {
  6397. if (!isInitialized()) return;
  6398. var pane1 = evtPane.call(this, evt_or_pane1);
  6399. // change state.edge NOW so callbacks can know where pane is headed...
  6400. state[pane1].edge = pane2;
  6401. state[pane2].edge = pane1;
  6402. // run these even if NOT state.initialized
  6403. if (false === _runCallbacks("onswap_start", pane1)
  6404. || false === _runCallbacks("onswap_start", pane2)
  6405. ) {
  6406. state[pane1].edge = pane1; // reset
  6407. state[pane2].edge = pane2;
  6408. return;
  6409. }
  6410. var
  6411. oPane1 = copy( pane1 )
  6412. , oPane2 = copy( pane2 )
  6413. , sizes = {}
  6414. ;
  6415. sizes[pane1] = oPane1 ? oPane1.state.size : 0;
  6416. sizes[pane2] = oPane2 ? oPane2.state.size : 0;
  6417. // clear pointers & state
  6418. $Ps[pane1] = false;
  6419. $Ps[pane2] = false;
  6420. state[pane1] = {};
  6421. state[pane2] = {};
  6422. // ALWAYS remove the resizer & toggler elements
  6423. if ($Ts[pane1]) $Ts[pane1].remove();
  6424. if ($Ts[pane2]) $Ts[pane2].remove();
  6425. if ($Rs[pane1]) $Rs[pane1].remove();
  6426. if ($Rs[pane2]) $Rs[pane2].remove();
  6427. $Rs[pane1] = $Rs[pane2] = $Ts[pane1] = $Ts[pane2] = false;
  6428. // transfer element pointers and data to NEW Layout keys
  6429. move( oPane1, pane2 );
  6430. move( oPane2, pane1 );
  6431. // cleanup objects
  6432. oPane1 = oPane2 = sizes = null;
  6433. // make panes 'visible' again
  6434. if ($Ps[pane1]) $Ps[pane1].css(_c.visible);
  6435. if ($Ps[pane2]) $Ps[pane2].css(_c.visible);
  6436. // fix any size discrepancies caused by swap
  6437. resizeAll();
  6438. // run these even if NOT state.initialized
  6439. _runCallbacks("onswap_end", pane1);
  6440. _runCallbacks("onswap_end", pane2);
  6441. return;
  6442. function copy (n) { // n = pane
  6443. var
  6444. $P = $Ps[n]
  6445. , $C = $Cs[n]
  6446. ;
  6447. return !$P ? false : {
  6448. pane: n
  6449. , P: $P ? $P[0] : false
  6450. , C: $C ? $C[0] : false
  6451. , state: $.extend(true, {}, state[n])
  6452. , options: $.extend(true, {}, options[n])
  6453. }
  6454. };
  6455. function move (oPane, pane) {
  6456. if (!oPane) return;
  6457. var
  6458. P = oPane.P
  6459. , C = oPane.C
  6460. , oldPane = oPane.pane
  6461. , c = _c[pane]
  6462. // save pane-options that should be retained
  6463. , s = $.extend(true, {}, state[pane])
  6464. , o = options[pane]
  6465. // RETAIN side-specific FX Settings - more below
  6466. , fx = { resizerCursor: o.resizerCursor }
  6467. , re, size, pos
  6468. ;
  6469. $.each("fxName,fxSpeed,fxSettings".split(","), function (i, k) {
  6470. fx[k +"_open"] = o[k +"_open"];
  6471. fx[k +"_close"] = o[k +"_close"];
  6472. fx[k +"_size"] = o[k +"_size"];
  6473. });
  6474. // update object pointers and attributes
  6475. $Ps[pane] = $(P)
  6476. .data({
  6477. layoutPane: Instance[pane] // NEW pointer to pane-alias-object
  6478. , layoutEdge: pane
  6479. })
  6480. .css(_c.hidden)
  6481. .css(c.cssReq)
  6482. ;
  6483. $Cs[pane] = C ? $(C) : false;
  6484. // set options and state
  6485. options[pane] = $.extend(true, {}, oPane.options, fx);
  6486. state[pane] = $.extend(true, {}, oPane.state);
  6487. // change classNames on the pane, eg: ui-layout-pane-east ==> ui-layout-pane-west
  6488. re = new RegExp(o.paneClass +"-"+ oldPane, "g");
  6489. P.className = P.className.replace(re, o.paneClass +"-"+ pane);
  6490. // ALWAYS regenerate the resizer & toggler elements
  6491. initHandles(pane); // create the required resizer & toggler
  6492. // if moving to different orientation, then keep 'target' pane size
  6493. if (c.dir != _c[oldPane].dir) {
  6494. size = sizes[pane] || 0;
  6495. setSizeLimits(pane); // update pane-state
  6496. size = max(size, state[pane].minSize);
  6497. // use manualSizePane to disable autoResize - not useful after panes are swapped
  6498. manualSizePane(pane, size, true, true); // true/true = skipCallback/noAnimation
  6499. }
  6500. else // move the resizer here
  6501. $Rs[pane].css(c.side, sC.inset[c.side] + (state[pane].isVisible ? getPaneSize(pane) : 0));
  6502. // ADD CLASSNAMES & SLIDE-BINDINGS
  6503. if (oPane.state.isVisible && !s.isVisible)
  6504. setAsOpen(pane, true); // true = skipCallback
  6505. else {
  6506. setAsClosed(pane);
  6507. bindStartSlidingEvents(pane, true); // will enable events IF option is set
  6508. }
  6509. // DESTROY the object
  6510. oPane = null;
  6511. };
  6512. }
  6513. /**
  6514. * INTERNAL method to sync pin-buttons when pane is opened or closed
  6515. * Unpinned means the pane is 'sliding' - ie, over-top of the adjacent panes
  6516. *
  6517. * @see open(), setAsOpen(), setAsClosed()
  6518. * @param {string} pane These are the params returned to callbacks by layout()
  6519. * @param {boolean} doPin True means set the pin 'down', False means 'up'
  6520. */
  6521. , syncPinBtns = function (pane, doPin) {
  6522. if ($.layout.plugins.buttons)
  6523. $.each(state[pane].pins, function (i, selector) {
  6524. $.layout.buttons.setPinState(Instance, $(selector), pane, doPin);
  6525. });
  6526. }
  6527. ; // END var DECLARATIONS
  6528. /**
  6529. * Capture keys when enableCursorHotkey - toggle pane if hotkey pressed
  6530. *
  6531. * @see document.keydown()
  6532. */
  6533. function keyDown (evt) {
  6534. if (!evt) return true;
  6535. var code = evt.keyCode;
  6536. if (code < 33) return true; // ignore special keys: ENTER, TAB, etc
  6537. var
  6538. PANE = {
  6539. 38: "north" // Up Cursor - $.ui.keyCode.UP
  6540. , 40: "south" // Down Cursor - $.ui.keyCode.DOWN
  6541. , 37: "west" // Left Cursor - $.ui.keyCode.LEFT
  6542. , 39: "east" // Right Cursor - $.ui.keyCode.RIGHT
  6543. }
  6544. , ALT = evt.altKey // no worky!
  6545. , SHIFT = evt.shiftKey
  6546. , CTRL = evt.ctrlKey
  6547. , CURSOR = (CTRL && code >= 37 && code <= 40)
  6548. , o, k, m, pane
  6549. ;
  6550. if (CURSOR && options[PANE[code]].enableCursorHotkey) // valid cursor-hotkey
  6551. pane = PANE[code];
  6552. else if (CTRL || SHIFT) // check to see if this matches a custom-hotkey
  6553. $.each(_c.borderPanes, function (i, p) { // loop each pane to check its hotkey
  6554. o = options[p];
  6555. k = o.customHotkey;
  6556. m = o.customHotkeyModifier; // if missing or invalid, treated as "CTRL+SHIFT"
  6557. if ((SHIFT && m=="SHIFT") || (CTRL && m=="CTRL") || (CTRL && SHIFT)) { // Modifier matches
  6558. if (k && code === (isNaN(k) || k <= 9 ? k.toUpperCase().charCodeAt(0) : k)) { // Key matches
  6559. pane = p;
  6560. return false; // BREAK
  6561. }
  6562. }
  6563. });
  6564. // validate pane
  6565. if (!pane || !$Ps[pane] || !options[pane].closable || state[pane].isHidden)
  6566. return true;
  6567. toggle(pane);
  6568. evt.stopPropagation();
  6569. evt.returnValue = false; // CANCEL key
  6570. return false;
  6571. };
  6572. /*
  6573. * ######################################
  6574. * UTILITY METHODS
  6575. * called externally or by initButtons
  6576. * ######################################
  6577. */
  6578. /**
  6579. * Change/reset a pane overflow setting & zIndex to allow popups/drop-downs to work
  6580. *
  6581. * @param {Object=} [el] (optional) Can also be 'bound' to a click, mouseOver, or other event
  6582. */
  6583. function allowOverflow (el) {
  6584. if (!isInitialized()) return;
  6585. if (this && this.tagName) el = this; // BOUND to element
  6586. var $P;
  6587. if (isStr(el))
  6588. $P = $Ps[el];
  6589. else if ($(el).data("layoutRole"))
  6590. $P = $(el);
  6591. else
  6592. $(el).parents().each(function(){
  6593. if ($(this).data("layoutRole")) {
  6594. $P = $(this);
  6595. return false; // BREAK
  6596. }
  6597. });
  6598. if (!$P || !$P.length) return; // INVALID
  6599. var
  6600. pane = $P.data("layoutEdge")
  6601. , s = state[pane]
  6602. ;
  6603. // if pane is already raised, then reset it before doing it again!
  6604. // this would happen if allowOverflow is attached to BOTH the pane and an element
  6605. if (s.cssSaved)
  6606. resetOverflow(pane); // reset previous CSS before continuing
  6607. // if pane is raised by sliding or resizing, or its closed, then abort
  6608. if (s.isSliding || s.isResizing || s.isClosed) {
  6609. s.cssSaved = false;
  6610. return;
  6611. }
  6612. var
  6613. newCSS = { zIndex: (options.zIndexes.resizer_normal + 1) }
  6614. , curCSS = {}
  6615. , of = $P.css("overflow")
  6616. , ofX = $P.css("overflowX")
  6617. , ofY = $P.css("overflowY")
  6618. ;
  6619. // determine which, if any, overflow settings need to be changed
  6620. if (of != "visible") {
  6621. curCSS.overflow = of;
  6622. newCSS.overflow = "visible";
  6623. }
  6624. if (ofX && !ofX.match(/(visible|auto)/)) {
  6625. curCSS.overflowX = ofX;
  6626. newCSS.overflowX = "visible";
  6627. }
  6628. if (ofY && !ofY.match(/(visible|auto)/)) {
  6629. curCSS.overflowY = ofX;
  6630. newCSS.overflowY = "visible";
  6631. }
  6632. // save the current overflow settings - even if blank!
  6633. s.cssSaved = curCSS;
  6634. // apply new CSS to raise zIndex and, if necessary, make overflow 'visible'
  6635. $P.css( newCSS );
  6636. // make sure the zIndex of all other panes is normal
  6637. $.each(_c.allPanes, function(i, p) {
  6638. if (p != pane) resetOverflow(p);
  6639. });
  6640. };
  6641. /**
  6642. * @param {Object=} [el] (optional) Can also be 'bound' to a click, mouseOver, or other event
  6643. */
  6644. function resetOverflow (el) {
  6645. if (!isInitialized()) return;
  6646. if (this && this.tagName) el = this; // BOUND to element
  6647. var $P;
  6648. if (isStr(el))
  6649. $P = $Ps[el];
  6650. else if ($(el).data("layoutRole"))
  6651. $P = $(el);
  6652. else
  6653. $(el).parents().each(function(){
  6654. if ($(this).data("layoutRole")) {
  6655. $P = $(this);
  6656. return false; // BREAK
  6657. }
  6658. });
  6659. if (!$P || !$P.length) return; // INVALID
  6660. var
  6661. pane = $P.data("layoutEdge")
  6662. , s = state[pane]
  6663. , CSS = s.cssSaved || {}
  6664. ;
  6665. // reset the zIndex
  6666. if (!s.isSliding && !s.isResizing)
  6667. $P.css("zIndex", options.zIndexes.pane_normal);
  6668. // reset Overflow - if necessary
  6669. $P.css( CSS );
  6670. // clear var
  6671. s.cssSaved = false;
  6672. };
  6673. /*
  6674. * #####################
  6675. * CREATE/RETURN LAYOUT
  6676. * #####################
  6677. */
  6678. try {
  6679. // validate that container exists
  6680. var $N = $(this).eq(0); // FIRST matching Container element
  6681. if (!$N.length) {
  6682. return _log( options.errors.containerMissing );
  6683. };
  6684. // Users retrieve Instance of a layout with: $N.layout() OR $N.data("layout")
  6685. // return the Instance-pointer if layout has already been initialized
  6686. if ($N.data("layoutContainer") && $N.data("layout"))
  6687. return $N.data("layout"); // cached pointer
  6688. } catch(e){
  6689. console.log("eeeee",e)
  6690. }
  6691. // init global vars
  6692. var
  6693. $Ps = {} // Panes x5 - set in initPanes()
  6694. , $Cs = {} // Content x5 - set in initPanes()
  6695. , $Rs = {} // Resizers x4 - set in initHandles()
  6696. , $Ts = {} // Togglers x4 - set in initHandles()
  6697. , $Ms = $([]) // Masks - up to 2 masks per pane (IFRAME + DIV)
  6698. // aliases for code brevity
  6699. , sC = state.container // alias for easy access to 'container dimensions'
  6700. , sID = state.id // alias for unique layout ID/namespace - eg: "layout435"
  6701. ;
  6702. // create Instance object to expose data & option Properties, and primary action Methods
  6703. var Instance = {
  6704. // layout data
  6705. options: options // property - options hash
  6706. , state: state // property - dimensions hash
  6707. // object pointers
  6708. , container: $N // property - object pointers for layout container
  6709. , panes: $Ps // property - object pointers for ALL Panes: panes.north, panes.center
  6710. , contents: $Cs // property - object pointers for ALL Content: contents.north, contents.center
  6711. , resizers: $Rs // property - object pointers for ALL Resizers, eg: resizers.north
  6712. , togglers: $Ts // property - object pointers for ALL Togglers, eg: togglers.north
  6713. // border-pane open/close
  6714. , hide: hide // method - ditto
  6715. , show: show // method - ditto
  6716. , toggle: toggle // method - pass a 'pane' ("north", "west", etc)
  6717. , open: open // method - ditto
  6718. , close: close // method - ditto
  6719. , slideOpen: slideOpen // method - ditto
  6720. , slideClose: slideClose // method - ditto
  6721. , slideToggle: slideToggle // method - ditto
  6722. // pane actions
  6723. , setSizeLimits: setSizeLimits // method - pass a 'pane' - update state min/max data
  6724. , _sizePane: sizePane // method -intended for user by plugins only!
  6725. , sizePane: manualSizePane // method - pass a 'pane' AND an 'outer-size' in pixels or percent, or 'auto'
  6726. , sizeContent: sizeContent // method - pass a 'pane'
  6727. , swapPanes: swapPanes // method - pass TWO 'panes' - will swap them
  6728. , showMasks: showMasks // method - pass a 'pane' OR list of panes - default = all panes with mask option set
  6729. , hideMasks: hideMasks // method - ditto'
  6730. // pane element methods
  6731. , initContent: initContent // method - ditto
  6732. , addPane: addPane // method - pass a 'pane'
  6733. , removePane: removePane // method - pass a 'pane' to remove from layout, add 'true' to delete the pane-elem
  6734. , createChildren: createChildren // method - pass a 'pane' and (optional) layout-options (OVERRIDES options[pane].children
  6735. , refreshChildren: refreshChildren // method - pass a 'pane' and a layout-instance
  6736. // special pane option setting
  6737. , enableClosable: enableClosable // method - pass a 'pane'
  6738. , disableClosable: disableClosable // method - ditto
  6739. , enableSlidable: enableSlidable // method - ditto
  6740. , disableSlidable: disableSlidable // method - ditto
  6741. , enableResizable: enableResizable // method - ditto
  6742. , disableResizable: disableResizable// method - ditto
  6743. // utility methods for panes
  6744. , allowOverflow: allowOverflow // utility - pass calling element (this)
  6745. , resetOverflow: resetOverflow // utility - ditto
  6746. // layout control
  6747. , destroy: destroy // method - no parameters
  6748. , initPanes: isInitialized // method - no parameters
  6749. , resizeAll: resizeAll // method - no parameters
  6750. // callback triggering
  6751. , runCallbacks: _runCallbacks // method - pass evtName & pane (if a pane-event), eg: trigger("onopen", "west")
  6752. // alias collections of options, state and children - created in addPane and extended elsewhere
  6753. , hasParentLayout: false // set by initContainer()
  6754. , children: children // pointers to child-layouts, eg: Instance.children.west.layoutName
  6755. , north: false // alias group: { name: pane, pane: $Ps[pane], options: options[pane], state: state[pane], children: children[pane] }
  6756. , south: false // ditto
  6757. , west: false // ditto
  6758. , east: false // ditto
  6759. , center: false // ditto
  6760. };
  6761. // create the border layout NOW
  6762. if (_create() === 'cancel') // onload_start callback returned false to CANCEL layout creation
  6763. return null;
  6764. else // true OR false -- if layout-elements did NOT init (hidden or do not exist), can auto-init later
  6765. return Instance; // return the Instance object
  6766. }
  6767. })( jQuery );
  6768. // END Layout - keep internal vars internal!
  6769. // START Plugins - shared wrapper, no global vars
  6770. (function ($) {
  6771. /**
  6772. * jquery.layout.state 1.0
  6773. * $Date: 2011-07-16 08:00:00 (Sat, 16 July 2011) $
  6774. *
  6775. * Copyright (c) 2012
  6776. * Kevin Dalman (http://allpro.net)
  6777. *
  6778. * Dual licensed under the GPL (http://www.gnu.org/licenses/gpl.html)
  6779. * and MIT (http://www.opensource.org/licenses/mit-license.php) licenses.
  6780. *
  6781. * @requires: UI Layout 1.3.0.rc30.1 or higher
  6782. * @requires: $.ui.cookie (above)
  6783. *
  6784. * @see: http://groups.google.com/group/jquery-ui-layout
  6785. */
  6786. /*
  6787. * State-management options stored in options.stateManagement, which includes a .cookie hash
  6788. * Default options saves ALL KEYS for ALL PANES, ie: pane.size, pane.isClosed, pane.isHidden
  6789. *
  6790. * // STATE/COOKIE OPTIONS
  6791. * @example $(el).layout({
  6792. stateManagement: {
  6793. enabled: true
  6794. , stateKeys: "east.size,west.size,east.isClosed,west.isClosed"
  6795. , cookie: { name: "appLayout", path: "/" }
  6796. }
  6797. })
  6798. * @example $(el).layout({ stateManagement__enabled: true }) // enable auto-state-management using cookies
  6799. * @example $(el).layout({ stateManagement__cookie: { name: "appLayout", path: "/" } })
  6800. * @example $(el).layout({ stateManagement__cookie__name: "appLayout", stateManagement__cookie__path: "/" })
  6801. *
  6802. * // STATE/COOKIE METHODS
  6803. * @example myLayout.saveCookie( "west.isClosed,north.size,south.isHidden", {expires: 7} );
  6804. * @example myLayout.loadCookie();
  6805. * @example myLayout.deleteCookie();
  6806. * @example var JSON = myLayout.readState(); // CURRENT Layout State
  6807. * @example var JSON = myLayout.readCookie(); // SAVED Layout State (from cookie)
  6808. * @example var JSON = myLayout.state.stateData; // LAST LOADED Layout State (cookie saved in layout.state hash)
  6809. *
  6810. * CUSTOM STATE-MANAGEMENT (eg, saved in a database)
  6811. * @example var JSON = myLayout.readState( "west.isClosed,north.size,south.isHidden" );
  6812. * @example myLayout.loadState( JSON );
  6813. */
  6814. /**
  6815. * UI COOKIE UTILITY
  6816. *
  6817. * A $.cookie OR $.ui.cookie namespace *should be standard*, but until then...
  6818. * This creates $.ui.cookie so Layout does not need the cookie.jquery.js plugin
  6819. * NOTE: This utility is REQUIRED by the layout.state plugin
  6820. *
  6821. * Cookie methods in Layout are created as part of State Management
  6822. */
  6823. if (!$.ui) $.ui = {};
  6824. $.ui.cookie = {
  6825. // cookieEnabled is not in DOM specs, but DOES works in all browsers,including IE6
  6826. acceptsCookies: !!navigator.cookieEnabled
  6827. , read: function (name) {
  6828. var c = document.cookie
  6829. , cs = c ? c.split(';') : []
  6830. , pair // loop var
  6831. ;
  6832. for (var i=0, n=cs.length; i < n; i++) {
  6833. pair = $.trim(cs[i]).split('='); // name=value pair
  6834. if (pair[0] == name) // found the layout cookie
  6835. return decodeURIComponent(pair[1]);
  6836. }
  6837. return null;
  6838. }
  6839. , write: function (name, val, cookieOpts) {
  6840. var params = ""
  6841. , date = ""
  6842. , clear = false
  6843. , o = cookieOpts || {}
  6844. , x = o.expires || null
  6845. , t = $.type(x)
  6846. ;
  6847. if (t === "date")
  6848. date = x;
  6849. else if (t === "string" && x > 0) {
  6850. x = parseInt(x,10);
  6851. t = "number";
  6852. }
  6853. if (t === "number") {
  6854. date = new Date();
  6855. if (x > 0)
  6856. date.setDate(date.getDate() + x);
  6857. else {
  6858. date.setFullYear(1970);
  6859. clear = true;
  6860. }
  6861. }
  6862. if (date) params += ";expires="+ date.toUTCString();
  6863. if (o.path) params += ";path="+ o.path;
  6864. if (o.domain) params += ";domain="+ o.domain;
  6865. if (o.secure) params += ";secure";
  6866. document.cookie = name +"="+ (clear ? "" : encodeURIComponent( val )) + params; // write or clear cookie
  6867. }
  6868. , clear: function (name) {
  6869. $.ui.cookie.write(name, "", {expires: -1});
  6870. }
  6871. };
  6872. // if cookie.jquery.js is not loaded, create an alias to replicate it
  6873. // this may be useful to other plugins or code dependent on that plugin
  6874. if (!$.cookie) $.cookie = function (k, v, o) {
  6875. var C = $.ui.cookie;
  6876. if (v === null)
  6877. C.clear(k);
  6878. else if (v === undefined)
  6879. return C.read(k);
  6880. else
  6881. C.write(k, v, o);
  6882. };
  6883. // tell Layout that the state plugin is available
  6884. $.layout.plugins.stateManagement = true;
  6885. // Add State-Management options to layout.defaults
  6886. $.layout.config.optionRootKeys.push("stateManagement");
  6887. $.layout.defaults.stateManagement = {
  6888. enabled: false // true = enable state-management, even if not using cookies
  6889. , autoSave: true // Save a state-cookie when page exits?
  6890. , autoLoad: true // Load the state-cookie when Layout inits?
  6891. , animateLoad: true // animate panes when loading state into an active layout
  6892. , includeChildren: true // recurse into child layouts to include their state as well
  6893. // List state-data to save - must be pane-specific
  6894. , stateKeys: "north.size,south.size,east.size,west.size,"+
  6895. "north.isClosed,south.isClosed,east.isClosed,west.isClosed,"+
  6896. "north.isHidden,south.isHidden,east.isHidden,west.isHidden"
  6897. , cookie: {
  6898. name: "" // If not specified, will use Layout.name, else just "Layout"
  6899. , domain: "" // blank = current domain
  6900. , path: "" // blank = current page, "/" = entire website
  6901. , expires: "" // 'days' to keep cookie - leave blank for 'session cookie'
  6902. , secure: false
  6903. }
  6904. };
  6905. // Set stateManagement as a layout-option, NOT a pane-option
  6906. $.layout.optionsMap.layout.push("stateManagement");
  6907. /*
  6908. * State Management methods
  6909. */
  6910. $.layout.state = {
  6911. /**
  6912. * Get the current layout state and save it to a cookie
  6913. *
  6914. * myLayout.saveCookie( keys, cookieOpts )
  6915. *
  6916. * @param {Object} inst
  6917. * @param {(string|Array)=} keys
  6918. * @param {Object=} cookieOpts
  6919. */
  6920. saveCookie: function (inst, keys, cookieOpts) {
  6921. var o = inst.options
  6922. , sm = o.stateManagement
  6923. , oC = $.extend(true, {}, sm.cookie, cookieOpts || null)
  6924. , data = inst.state.stateData = inst.readState( keys || sm.stateKeys ) // read current panes-state
  6925. ;
  6926. $.ui.cookie.write( oC.name || o.name || "Layout", $.layout.state.encodeJSON(data), oC );
  6927. return $.extend(true, {}, data); // return COPY of state.stateData data
  6928. }
  6929. /**
  6930. * Remove the state cookie
  6931. *
  6932. * @param {Object} inst
  6933. */
  6934. , deleteCookie: function (inst) {
  6935. var o = inst.options;
  6936. $.ui.cookie.clear( o.stateManagement.cookie.name || o.name || "Layout" );
  6937. }
  6938. /**
  6939. * Read & return data from the cookie - as JSON
  6940. *
  6941. * @param {Object} inst
  6942. */
  6943. , readCookie: function (inst) {
  6944. var o = inst.options;
  6945. var c = $.ui.cookie.read( o.stateManagement.cookie.name || o.name || "Layout" );
  6946. // convert cookie string back to a hash and return it
  6947. return c ? $.layout.state.decodeJSON(c) : {};
  6948. }
  6949. /**
  6950. * Get data from the cookie and USE IT to loadState
  6951. *
  6952. * @param {Object} inst
  6953. */
  6954. , loadCookie: function (inst) {
  6955. var c = $.layout.state.readCookie(inst); // READ the cookie
  6956. if (c) {
  6957. inst.state.stateData = $.extend(true, {}, c); // SET state.stateData
  6958. inst.loadState(c); // LOAD the retrieved state
  6959. }
  6960. return c;
  6961. }
  6962. /**
  6963. * Update layout options from the cookie, if one exists
  6964. *
  6965. * @param {Object} inst
  6966. * @param {Object=} stateData
  6967. * @param {boolean=} animate
  6968. */
  6969. , loadState: function (inst, data, opts) {
  6970. if (!$.isPlainObject( data ) || $.isEmptyObject( data )) return;
  6971. // normalize data & cache in the state object
  6972. data = inst.state.stateData = $.layout.transformData( data ); // panes = default subkey
  6973. // add missing/default state-restore options
  6974. var smo = inst.options.stateManagement;
  6975. opts = $.extend({
  6976. animateLoad: false //smo.animateLoad
  6977. , includeChildren: smo.includeChildren
  6978. }, opts );
  6979. if (!inst.state.initialized) {
  6980. /*
  6981. * layout NOT initialized, so just update its options
  6982. */
  6983. // MUST remove pane.children keys before applying to options
  6984. // use a copy so we don't remove keys from original data
  6985. var o = $.extend(true, {}, data);
  6986. //delete o.center; // center has no state-data - only children
  6987. $.each($.layout.config.allPanes, function (idx, pane) {
  6988. if (o[pane]) delete o[pane].children;
  6989. });
  6990. // update CURRENT layout-options with saved state data
  6991. $.extend(true, inst.options, o);
  6992. }
  6993. else {
  6994. /*
  6995. * layout already initialized, so modify layout's configuration
  6996. */
  6997. var noAnimate = !opts.animateLoad
  6998. , o, c, h, state, open
  6999. ;
  7000. $.each($.layout.config.borderPanes, function (idx, pane) {
  7001. o = data[ pane ];
  7002. if (!$.isPlainObject( o )) return; // no key, skip pane
  7003. s = o.size;
  7004. c = o.initClosed;
  7005. h = o.initHidden;
  7006. ar = o.autoResize
  7007. state = inst.state[pane];
  7008. open = state.isVisible;
  7009. // reset autoResize
  7010. if (ar)
  7011. state.autoResize = ar;
  7012. // resize BEFORE opening
  7013. if (!open)
  7014. inst._sizePane(pane, s, false, false, false); // false=skipCallback/noAnimation/forceResize
  7015. // open/close as necessary - DO NOT CHANGE THIS ORDER!
  7016. if (h === true) inst.hide(pane, noAnimate);
  7017. else if (c === true) inst.close(pane, false, noAnimate);
  7018. else if (c === false) inst.open (pane, false, noAnimate);
  7019. else if (h === false) inst.show (pane, false, noAnimate);
  7020. // resize AFTER any other actions
  7021. if (open)
  7022. inst._sizePane(pane, s, false, false, noAnimate); // animate resize if option passed
  7023. });
  7024. /*
  7025. * RECURSE INTO CHILD-LAYOUTS
  7026. */
  7027. if (opts.includeChildren) {
  7028. var paneStateChildren, childState;
  7029. $.each(inst.children, function (pane, paneChildren) {
  7030. paneStateChildren = data[pane] ? data[pane].children : 0;
  7031. if (paneStateChildren && paneChildren) {
  7032. $.each(paneChildren, function (stateKey, child) {
  7033. childState = paneStateChildren[stateKey];
  7034. if (child && childState)
  7035. child.loadState( childState );
  7036. });
  7037. }
  7038. });
  7039. }
  7040. }
  7041. }
  7042. /**
  7043. * Get the *current layout state* and return it as a hash
  7044. *
  7045. * @param {Object=} inst // Layout instance to get state for
  7046. * @param {object=} [opts] // State-Managements override options
  7047. */
  7048. , readState: function (inst, opts) {
  7049. // backward compatility
  7050. if ($.type(opts) === 'string') opts = { keys: opts };
  7051. if (!opts) opts = {};
  7052. var sm = inst.options.stateManagement
  7053. , ic = opts.includeChildren
  7054. , recurse = ic !== undefined ? ic : sm.includeChildren
  7055. , keys = opts.stateKeys || sm.stateKeys
  7056. , alt = { isClosed: 'initClosed', isHidden: 'initHidden' }
  7057. , state = inst.state
  7058. , panes = $.layout.config.allPanes
  7059. , data = {}
  7060. , pair, pane, key, val
  7061. , ps, pC, child, array, count, branch
  7062. ;
  7063. if ($.isArray(keys)) keys = keys.join(",");
  7064. // convert keys to an array and change delimiters from '__' to '.'
  7065. keys = keys.replace(/__/g, ".").split(',');
  7066. // loop keys and create a data hash
  7067. for (var i=0, n=keys.length; i < n; i++) {
  7068. pair = keys[i].split(".");
  7069. pane = pair[0];
  7070. key = pair[1];
  7071. if ($.inArray(pane, panes) < 0) continue; // bad pane!
  7072. val = state[ pane ][ key ];
  7073. if (val == undefined) continue;
  7074. if (key=="isClosed" && state[pane]["isSliding"])
  7075. val = true; // if sliding, then *really* isClosed
  7076. ( data[pane] || (data[pane]={}) )[ alt[key] ? alt[key] : key ] = val;
  7077. }
  7078. // recurse into the child-layouts for each pane
  7079. if (recurse) {
  7080. $.each(panes, function (idx, pane) {
  7081. pC = inst.children[pane];
  7082. ps = state.stateData[pane];
  7083. if ($.isPlainObject( pC ) && !$.isEmptyObject( pC )) {
  7084. // ensure a key exists for this 'pane', eg: branch = data.center
  7085. branch = data[pane] || (data[pane] = {});
  7086. if (!branch.children) branch.children = {};
  7087. $.each( pC, function (key, child) {
  7088. // ONLY read state from an initialize layout
  7089. if ( child.state.initialized )
  7090. branch.children[ key ] = $.layout.state.readState( child );
  7091. // if we have PREVIOUS (onLoad) state for this child-layout, KEEP IT!
  7092. else if ( ps && ps.children && ps.children[ key ] ) {
  7093. branch.children[ key ] = $.extend(true, {}, ps.children[ key ] );
  7094. }
  7095. });
  7096. }
  7097. });
  7098. }
  7099. return data;
  7100. }
  7101. /**
  7102. * Stringify a JSON hash so can save in a cookie or db-field
  7103. */
  7104. , encodeJSON: function (JSON) {
  7105. return parse(JSON);
  7106. function parse (h) {
  7107. var D=[], i=0, k, v, t // k = key, v = value
  7108. , a = $.isArray(h)
  7109. ;
  7110. for (k in h) {
  7111. v = h[k];
  7112. t = typeof v;
  7113. if (t == 'string') // STRING - add quotes
  7114. v = '"'+ v +'"';
  7115. else if (t == 'object') // SUB-KEY - recurse into it
  7116. v = parse(v);
  7117. D[i++] = (!a ? '"'+ k +'":' : '') + v;
  7118. }
  7119. return (a ? '[' : '{') + D.join(',') + (a ? ']' : '}');
  7120. };
  7121. }
  7122. /**
  7123. * Convert stringified JSON back to a hash object
  7124. * @see $.parseJSON(), adding in jQuery 1.4.1
  7125. */
  7126. , decodeJSON: function (str) {
  7127. try { return $.parseJSON ? $.parseJSON(str) : window["eval"]("("+ str +")") || {}; }
  7128. catch (e) { return {}; }
  7129. }
  7130. , _create: function (inst) {
  7131. var _ = $.layout.state
  7132. , o = inst.options
  7133. , sm = o.stateManagement
  7134. ;
  7135. // ADD State-Management plugin methods to inst
  7136. $.extend( inst, {
  7137. // readCookie - update options from cookie - returns hash of cookie data
  7138. readCookie: function () { return _.readCookie(inst); }
  7139. // deleteCookie
  7140. , deleteCookie: function () { _.deleteCookie(inst); }
  7141. // saveCookie - optionally pass keys-list and cookie-options (hash)
  7142. , saveCookie: function (keys, cookieOpts) { return _.saveCookie(inst, keys, cookieOpts); }
  7143. // loadCookie - readCookie and use to loadState() - returns hash of cookie data
  7144. , loadCookie: function () { return _.loadCookie(inst); }
  7145. // loadState - pass a hash of state to use to update options
  7146. , loadState: function (stateData, opts) { _.loadState(inst, stateData, opts); }
  7147. // readState - returns hash of current layout-state
  7148. , readState: function (keys) { return _.readState(inst, keys); }
  7149. // add JSON utility methods too...
  7150. , encodeJSON: _.encodeJSON
  7151. , decodeJSON: _.decodeJSON
  7152. });
  7153. // init state.stateData key, even if plugin is initially disabled
  7154. inst.state.stateData = {};
  7155. // autoLoad MUST BE one of: data-array, data-hash, callback-function, or TRUE
  7156. if ( !sm.autoLoad ) return;
  7157. // When state-data exists in the autoLoad key USE IT,
  7158. // even if stateManagement.enabled == false
  7159. if ($.isPlainObject( sm.autoLoad )) {
  7160. if (!$.isEmptyObject( sm.autoLoad )) {
  7161. inst.loadState( sm.autoLoad );
  7162. }
  7163. }
  7164. else if ( sm.enabled ) {
  7165. // update the options from cookie or callback
  7166. // if options is a function, call it to get stateData
  7167. if ($.isFunction( sm.autoLoad )) {
  7168. var d = {};
  7169. try {
  7170. d = sm.autoLoad( inst, inst.state, inst.options, inst.options.name || '' ); // try to get data from fn
  7171. } catch (e) {}
  7172. if (d && $.isPlainObject( d ) && !$.isEmptyObject( d ))
  7173. inst.loadState(d);
  7174. }
  7175. else // any other truthy value will trigger loadCookie
  7176. inst.loadCookie();
  7177. }
  7178. }
  7179. , _unload: function (inst) {
  7180. var sm = inst.options.stateManagement;
  7181. if (sm.enabled && sm.autoSave) {
  7182. // if options is a function, call it to save the stateData
  7183. if ($.isFunction( sm.autoSave )) {
  7184. try {
  7185. sm.autoSave( inst, inst.state, inst.options, inst.options.name || '' ); // try to get data from fn
  7186. } catch (e) {}
  7187. }
  7188. else // any truthy value will trigger saveCookie
  7189. inst.saveCookie();
  7190. }
  7191. }
  7192. };
  7193. // add state initialization method to Layout's onCreate array of functions
  7194. $.layout.onCreate.push( $.layout.state._create );
  7195. $.layout.onUnload.push( $.layout.state._unload );
  7196. /**
  7197. * jquery.layout.buttons 1.0
  7198. * $Date: 2011-07-16 08:00:00 (Sat, 16 July 2011) $
  7199. *
  7200. * Copyright (c) 2012
  7201. * Kevin Dalman (http://allpro.net)
  7202. *
  7203. * Dual licensed under the GPL (http://www.gnu.org/licenses/gpl.html)
  7204. * and MIT (http://www.opensource.org/licenses/mit-license.php) licenses.
  7205. *
  7206. * @requires: UI Layout 1.3.0.rc30.1 or higher
  7207. *
  7208. * @see: http://groups.google.com/group/jquery-ui-layout
  7209. *
  7210. * Docs: [ to come ]
  7211. * Tips: [ to come ]
  7212. */
  7213. // tell Layout that the state plugin is available
  7214. $.layout.plugins.buttons = true;
  7215. // Add buttons options to layout.defaults
  7216. $.layout.defaults.autoBindCustomButtons = false;
  7217. // Specify autoBindCustomButtons as a layout-option, NOT a pane-option
  7218. $.layout.optionsMap.layout.push("autoBindCustomButtons");
  7219. /*
  7220. * Button methods
  7221. */
  7222. $.layout.buttons = {
  7223. /**
  7224. * Searches for .ui-layout-button-xxx elements and auto-binds them as layout-buttons
  7225. *
  7226. * @see _create()
  7227. *
  7228. * @param {Object} inst Layout Instance object
  7229. */
  7230. init: function (inst) {
  7231. var pre = "ui-layout-button-"
  7232. , layout = inst.options.name || ""
  7233. , name;
  7234. $.each("toggle,open,close,pin,toggle-slide,open-slide".split(","), function (i, action) {
  7235. $.each($.layout.config.borderPanes, function (ii, pane) {
  7236. $("."+pre+action+"-"+pane).each(function(){
  7237. // if button was previously 'bound', data.layoutName was set, but is blank if layout has no 'name'
  7238. name = $(this).data("layoutName") || $(this).attr("layoutName");
  7239. if (name == undefined || name === layout)
  7240. inst.bindButton(this, action, pane);
  7241. });
  7242. });
  7243. });
  7244. }
  7245. /**
  7246. * Helper function to validate params received by addButton utilities
  7247. *
  7248. * Two classes are added to the element, based on the buttonClass...
  7249. * The type of button is appended to create the 2nd className:
  7250. * - ui-layout-button-pin // action btnClass
  7251. * - ui-layout-button-pin-west // action btnClass + pane
  7252. * - ui-layout-button-toggle
  7253. * - ui-layout-button-open
  7254. * - ui-layout-button-close
  7255. *
  7256. * @param {Object} inst Layout Instance object
  7257. * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button"
  7258. * @param {string} pane Name of the pane the button is for: 'north', 'south', etc.
  7259. *
  7260. * @return {Array.<Object>} If both params valid, the element matching 'selector' in a jQuery wrapper - otherwise returns null
  7261. */
  7262. , get: function (inst, selector, pane, action) {
  7263. var $E = $(selector)
  7264. , o = inst.options
  7265. , err = o.errors.addButtonError
  7266. ;
  7267. if (!$E.length) { // element not found
  7268. $.layout.msg(err +" "+ o.errors.selector +": "+ selector, true);
  7269. }
  7270. else if ($.inArray(pane, $.layout.config.borderPanes) < 0) { // invalid 'pane' sepecified
  7271. $.layout.msg(err +" "+ o.errors.pane +": "+ pane, true);
  7272. $E = $(""); // NO BUTTON
  7273. }
  7274. else { // VALID
  7275. var btn = o[pane].buttonClass +"-"+ action;
  7276. $E .addClass( btn +" "+ btn +"-"+ pane )
  7277. .data("layoutName", o.name); // add layout identifier - even if blank!
  7278. }
  7279. return $E;
  7280. }
  7281. /**
  7282. * NEW syntax for binding layout-buttons - will eventually replace addToggle, addOpen, etc.
  7283. *
  7284. * @param {Object} inst Layout Instance object
  7285. * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button"
  7286. * @param {string} action
  7287. * @param {string} pane
  7288. */
  7289. , bind: function (inst, selector, action, pane) {
  7290. var _ = $.layout.buttons;
  7291. switch (action.toLowerCase()) {
  7292. case "toggle": _.addToggle (inst, selector, pane); break;
  7293. case "open": _.addOpen (inst, selector, pane); break;
  7294. case "close": _.addClose (inst, selector, pane); break;
  7295. case "pin": _.addPin (inst, selector, pane); break;
  7296. case "toggle-slide": _.addToggle (inst, selector, pane, true); break;
  7297. case "open-slide": _.addOpen (inst, selector, pane, true); break;
  7298. }
  7299. return inst;
  7300. }
  7301. /**
  7302. * Add a custom Toggler button for a pane
  7303. *
  7304. * @param {Object} inst Layout Instance object
  7305. * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button"
  7306. * @param {string} pane Name of the pane the button is for: 'north', 'south', etc.
  7307. * @param {boolean=} slide true = slide-open, false = pin-open
  7308. */
  7309. , addToggle: function (inst, selector, pane, slide) {
  7310. $.layout.buttons.get(inst, selector, pane, "toggle")
  7311. .click(function(evt){
  7312. inst.toggle(pane, !!slide);
  7313. evt.stopPropagation();
  7314. });
  7315. return inst;
  7316. }
  7317. /**
  7318. * Add a custom Open button for a pane
  7319. *
  7320. * @param {Object} inst Layout Instance object
  7321. * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button"
  7322. * @param {string} pane Name of the pane the button is for: 'north', 'south', etc.
  7323. * @param {boolean=} slide true = slide-open, false = pin-open
  7324. */
  7325. , addOpen: function (inst, selector, pane, slide) {
  7326. $.layout.buttons.get(inst, selector, pane, "open")
  7327. .attr("title", inst.options[pane].tips.Open)
  7328. .click(function (evt) {
  7329. inst.open(pane, !!slide);
  7330. evt.stopPropagation();
  7331. });
  7332. return inst;
  7333. }
  7334. /**
  7335. * Add a custom Close button for a pane
  7336. *
  7337. * @param {Object} inst Layout Instance object
  7338. * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button"
  7339. * @param {string} pane Name of the pane the button is for: 'north', 'south', etc.
  7340. */
  7341. , addClose: function (inst, selector, pane) {
  7342. $.layout.buttons.get(inst, selector, pane, "close")
  7343. .attr("title", inst.options[pane].tips.Close)
  7344. .click(function (evt) {
  7345. inst.close(pane);
  7346. evt.stopPropagation();
  7347. });
  7348. return inst;
  7349. }
  7350. /**
  7351. * Add a custom Pin button for a pane
  7352. *
  7353. * Four classes are added to the element, based on the paneClass for the associated pane...
  7354. * Assuming the default paneClass and the pin is 'up', these classes are added for a west-pane pin:
  7355. * - ui-layout-pane-pin
  7356. * - ui-layout-pane-west-pin
  7357. * - ui-layout-pane-pin-up
  7358. * - ui-layout-pane-west-pin-up
  7359. *
  7360. * @param {Object} inst Layout Instance object
  7361. * @param {(string|!Object)} selector jQuery selector (or element) for button, eg: ".ui-layout-north .toggle-button"
  7362. * @param {string} pane Name of the pane the pin is for: 'north', 'south', etc.
  7363. */
  7364. , addPin: function (inst, selector, pane) {
  7365. var _ = $.layout.buttons
  7366. , $E = _.get(inst, selector, pane, "pin");
  7367. if ($E.length) {
  7368. var s = inst.state[pane];
  7369. $E.click(function (evt) {
  7370. _.setPinState(inst, $(this), pane, (s.isSliding || s.isClosed));
  7371. if (s.isSliding || s.isClosed) inst.open( pane ); // change from sliding to open
  7372. else inst.close( pane ); // slide-closed
  7373. evt.stopPropagation();
  7374. });
  7375. // add up/down pin attributes and classes
  7376. _.setPinState(inst, $E, pane, (!s.isClosed && !s.isSliding));
  7377. // add this pin to the pane data so we can 'sync it' automatically
  7378. // PANE.pins key is an array so we can store multiple pins for each pane
  7379. s.pins.push( selector ); // just save the selector string
  7380. }
  7381. return inst;
  7382. }
  7383. /**
  7384. * Change the class of the pin button to make it look 'up' or 'down'
  7385. *
  7386. * @see addPin(), syncPins()
  7387. *
  7388. * @param {Object} inst Layout Instance object
  7389. * @param {Array.<Object>} $Pin The pin-span element in a jQuery wrapper
  7390. * @param {string} pane These are the params returned to callbacks by layout()
  7391. * @param {boolean} doPin true = set the pin 'down', false = set it 'up'
  7392. */
  7393. , setPinState: function (inst, $Pin, pane, doPin) {
  7394. var updown = $Pin.attr("pin");
  7395. if (updown && doPin === (updown=="down")) return; // already in correct state
  7396. var
  7397. o = inst.options[pane]
  7398. , pin = o.buttonClass +"-pin"
  7399. , side = pin +"-"+ pane
  7400. , UP = pin +"-up "+ side +"-up"
  7401. , DN = pin +"-down "+side +"-down"
  7402. ;
  7403. $Pin
  7404. .attr("pin", doPin ? "down" : "up") // logic
  7405. .attr("title", doPin ? o.tips.Unpin : o.tips.Pin)
  7406. .removeClass( doPin ? UP : DN )
  7407. .addClass( doPin ? DN : UP )
  7408. ;
  7409. }
  7410. /**
  7411. * INTERNAL function to sync 'pin buttons' when pane is opened or closed
  7412. * Unpinned means the pane is 'sliding' - ie, over-top of the adjacent panes
  7413. *
  7414. * @see open(), close()
  7415. *
  7416. * @param {Object} inst Layout Instance object
  7417. * @param {string} pane These are the params returned to callbacks by layout()
  7418. * @param {boolean} doPin True means set the pin 'down', False means 'up'
  7419. */
  7420. , syncPinBtns: function (inst, pane, doPin) {
  7421. // REAL METHOD IS _INSIDE_ LAYOUT - THIS IS HERE JUST FOR REFERENCE
  7422. $.each(inst.state[pane].pins, function (i, selector) {
  7423. $.layout.buttons.setPinState(inst, $(selector), pane, doPin);
  7424. });
  7425. }
  7426. , _load: function (inst) {
  7427. var _ = $.layout.buttons;
  7428. // ADD Button methods to Layout Instance
  7429. // Note: sel = jQuery Selector string
  7430. $.extend( inst, {
  7431. bindButton: function (sel, action, pane) { return _.bind(inst, sel, action, pane); }
  7432. // DEPRECATED METHODS
  7433. , addToggleBtn: function (sel, pane, slide) { return _.addToggle(inst, sel, pane, slide); }
  7434. , addOpenBtn: function (sel, pane, slide) { return _.addOpen(inst, sel, pane, slide); }
  7435. , addCloseBtn: function (sel, pane) { return _.addClose(inst, sel, pane); }
  7436. , addPinBtn: function (sel, pane) { return _.addPin(inst, sel, pane); }
  7437. });
  7438. // init state array to hold pin-buttons
  7439. for (var i=0; i<4; i++) {
  7440. var pane = $.layout.config.borderPanes[i];
  7441. inst.state[pane].pins = [];
  7442. }
  7443. // auto-init buttons onLoad if option is enabled
  7444. if ( inst.options.autoBindCustomButtons )
  7445. _.init(inst);
  7446. }
  7447. , _unload: function (inst) {
  7448. // TODO: unbind all buttons???
  7449. }
  7450. };
  7451. // add initialization method to Layout's onLoad array of functions
  7452. $.layout.onLoad.push( $.layout.buttons._load );
  7453. //$.layout.onUnload.push( $.layout.buttons._unload );
  7454. /**
  7455. * jquery.layout.browserZoom 1.0
  7456. * $Date: 2011-12-29 08:00:00 (Thu, 29 Dec 2011) $
  7457. *
  7458. * Copyright (c) 2012
  7459. * Kevin Dalman (http://allpro.net)
  7460. *
  7461. * Dual licensed under the GPL (http://www.gnu.org/licenses/gpl.html)
  7462. * and MIT (http://www.opensource.org/licenses/mit-license.php) licenses.
  7463. *
  7464. * @requires: UI Layout 1.3.0.rc30.1 or higher
  7465. *
  7466. * @see: http://groups.google.com/group/jquery-ui-layout
  7467. *
  7468. * TODO: Extend logic to handle other problematic zooming in browsers
  7469. * TODO: Add hotkey/mousewheel bindings to _instantly_ respond to these zoom event
  7470. */
  7471. // tell Layout that the plugin is available
  7472. $.layout.plugins.browserZoom = true;
  7473. $.layout.defaults.browserZoomCheckInterval = 1000;
  7474. $.layout.optionsMap.layout.push("browserZoomCheckInterval");
  7475. /*
  7476. * browserZoom methods
  7477. */
  7478. $.layout.browserZoom = {
  7479. _init: function (inst) {
  7480. // abort if browser does not need this check
  7481. if ($.layout.browserZoom.ratio() !== false)
  7482. $.layout.browserZoom._setTimer(inst);
  7483. }
  7484. , _setTimer: function (inst) {
  7485. // abort if layout destroyed or browser does not need this check
  7486. if (inst.destroyed) return;
  7487. var o = inst.options
  7488. , s = inst.state
  7489. // don't need check if inst has parentLayout, but check occassionally in case parent destroyed!
  7490. // MINIMUM 100ms interval, for performance
  7491. , ms = inst.hasParentLayout ? 5000 : Math.max( o.browserZoomCheckInterval, 100 )
  7492. ;
  7493. // set the timer
  7494. setTimeout(function(){
  7495. if (inst.destroyed || !o.resizeWithWindow) return;
  7496. var d = $.layout.browserZoom.ratio();
  7497. if (d !== s.browserZoom) {
  7498. s.browserZoom = d;
  7499. inst.resizeAll();
  7500. }
  7501. // set a NEW timeout
  7502. $.layout.browserZoom._setTimer(inst);
  7503. }
  7504. , ms );
  7505. }
  7506. , ratio: function () {
  7507. var w = window
  7508. , s = screen
  7509. , d = document
  7510. , dE = d.documentElement || d.body
  7511. , b = $.layout.browser
  7512. , v = b.version
  7513. , r, sW, cW
  7514. ;
  7515. // we can ignore all browsers that fire window.resize event onZoom
  7516. if ((b.msie && v > 8)
  7517. || !b.msie
  7518. ) return false; // don't need to track zoom
  7519. if (s.deviceXDPI && s.systemXDPI) // syntax compiler hack
  7520. return calc(s.deviceXDPI, s.systemXDPI);
  7521. // everything below is just for future reference!
  7522. if (b.webkit && (r = d.body.getBoundingClientRect))
  7523. return calc((r.left - r.right), d.body.offsetWidth);
  7524. if (b.webkit && (sW = w.outerWidth))
  7525. return calc(sW, w.innerWidth);
  7526. if ((sW = s.width) && (cW = dE.clientWidth))
  7527. return calc(sW, cW);
  7528. return false; // no match, so cannot - or don't need to - track zoom
  7529. function calc (x,y) { return (parseInt(x,10) / parseInt(y,10) * 100).toFixed(); }
  7530. }
  7531. };
  7532. // add initialization method to Layout's onLoad array of functions
  7533. $.layout.onReady.push( $.layout.browserZoom._init );
  7534. })( jQuery );