Thanks Raluca! Please, see below.
On 3/7/11 7:51 AM, Raluca Stavro wrote: > Hello, > > On Mon, Mar 7, 2011 at 12:39 AM, Ricardo Rodriguez [eBioTIC.] > <[email protected] <mailto:[email protected]>> > wrote: > > Hi all! > > I'm still struggling to understand how expanded/collapsed state of > panels do work. > > I'm currently using a 2.4.30451 XE/XEM installation. > > Looking for macros controlling this state in macros.vm, I see: > > *** > #macro(panelheader $title) > #set($cookieName = "${context.user.replaceAll(':','')}_${panel}") > #set($expanded = $xwiki.getUserPreferenceFromCookie($cookieName)) > #if(!$expanded) > #set($expanded = 'expanded') > #end > ## Note: We pass the Panel name as an HTML class attribute so that > it's > possible to style > ## the Panels selectively using CSS. > #set ($specialClassAttribute = "") > #if ($paneldoc && $paneldoc != "") > #set ($specialClassAttribute = > $util.convertToAlphaNumeric($paneldoc.name <http://paneldoc.name>)) > #end > <div class="panel $expanded $specialClassAttribute"> > <h1 class="xwikipaneltitle" > onclick="togglePanelVisibility(this.parentNode, > '${cookieName}');">$title</h1> > <div class="xwikipanelcontents"> > #end > *** > > This macro creates an expanded panel. By clicking the panel title, the > system creates a cookie that stores her current state. > > But if I modify this macro and says... > > #if(!$expanded) > #set($expanded = 'collapsed') > #end > > No macro is created and panels are always collapsed when loaded and > after relaoding. > > > That is because 'collapsed' is used as a class name for the panel dom > element and there is also a CSS rule which says that panels with > 'collapsed' class name are being displayed as collapsed. > So, the default logic is like this: > > 1) take the $expanded value from a cookie > 2) set the panel dom element class name as being the value of $expanded > 3) on loading the page, with the help of CSS, display the panel as > being 'collapsed' or 'expanded', depending on the value of $expanded > > And in your case, this is the logic: > > 1) set the value of $expanded as being 'collapsed' > 2) set the panel dom element class name as being the value of > $expanded (which is 'collapsed') > 3) on loading the page, with the help of CSS, display the panel as > being 'collapsed', this being the value of $expanded > > I hope that this helps you understand the logic behind 'collapsed' and > 'expanded' panels. > > Raluca. Yes, it helps. Thus, to control the initial state of a panel (collapsed or expanded) the first time I load a page (no cookie has been set for that panel) what I need is to create a cookie with the desired value. Please, is this correct? If yes, could you point me to the best way of creating that cookie at loading time? Thanks!!! > > Please, could you me understand why? > > Thank you so much!!! > > Ricardo > > -- > Ricardo RodrÃguez > CTO > eBioTIC. > Life Sciences, Data Modeling and Information Management Systems > > _______________________________________________ > users mailing list > [email protected] <mailto:[email protected]> > http://lists.xwiki.org/mailman/listinfo/users > > -- Ricardo RodrÃguez CTO eBioTIC. Life Sciences, Data Modeling and Information Management Systems _______________________________________________ users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users
