From: <gr...@us...> - 2008-09-15 14:16:57
|
Revision: 720 http://equanda.svn.sourceforge.net/equanda/?rev=720&view=rev Author: grizze Date: 2008-09-15 14:16:44 +0000 (Mon, 15 Sep 2008) Log Message: ----------- EQ-229 intermediate checkin. Make the Tabs component remember its active tab via cookies. Use MemTabs instead of Tabs in the equanda generated edit components Todo: user documentation, make sure javascript for MemTabs doesn't write a cookie, management of active tab in Tabs and Accordeon component should work in exactly the same way Modified Paths: -------------- trunk/equanda-generate/src/main/velocity/t5gui/edit-tml/pages.tml.vm trunk/equanda-tapestry5/src/main/java/org/equanda/tapestry5/base/TitleContent.java trunk/equanda-tapestry5/src/main/java/org/equanda/tapestry5/components/MemTabs.java trunk/equanda-tapestry5/src/main/java/org/equanda/tapestry5/components/Tabs.java trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/resources/tabs.js Modified: trunk/equanda-generate/src/main/velocity/t5gui/edit-tml/pages.tml.vm =================================================================== --- trunk/equanda-generate/src/main/velocity/t5gui/edit-tml/pages.tml.vm 2008-09-15 14:13:34 UTC (rev 719) +++ trunk/equanda-generate/src/main/velocity/t5gui/edit-tml/pages.tml.vm 2008-09-15 14:16:44 UTC (rev 720) @@ -1,4 +1,4 @@ -<span t:type="equanda/Tabs" t:exclude="prop:tabsExcludeIndex"> +<span t:type="equanda/MemTabs" t:id="tabs_${table.Name}" t:exclude="prop:tabsExcludeIndex"> ## page titles #set( $pageindex = 1 ) #foreach( $page in $table.Pages ) Modified: trunk/equanda-tapestry5/src/main/java/org/equanda/tapestry5/base/TitleContent.java =================================================================== --- trunk/equanda-tapestry5/src/main/java/org/equanda/tapestry5/base/TitleContent.java 2008-09-15 14:13:34 UTC (rev 719) +++ trunk/equanda-tapestry5/src/main/java/org/equanda/tapestry5/base/TitleContent.java 2008-09-15 14:16:44 UTC (rev 720) @@ -93,6 +93,11 @@ this.useCookies = useCookies; } + protected int getActiveIndex() + { + return activeIndex; + } + public String getId() { return assignedId; Modified: trunk/equanda-tapestry5/src/main/java/org/equanda/tapestry5/components/MemTabs.java =================================================================== --- trunk/equanda-tapestry5/src/main/java/org/equanda/tapestry5/components/MemTabs.java 2008-09-15 14:13:34 UTC (rev 719) +++ trunk/equanda-tapestry5/src/main/java/org/equanda/tapestry5/components/MemTabs.java 2008-09-15 14:16:44 UTC (rev 720) @@ -34,7 +34,6 @@ * Sibling of the Tabs component. But where the Tabs component uses cookies to remember the current tab, * the MemTabs component uses AJAX and a persistent field (currentTab). * - * @author <a href="mailto:jo...@pr...">Joachim Van der Auwera</a> * @author <a href="mailto:ge...@bl...">Geert Mergan</a> */ @SupportsInformalParameters Modified: trunk/equanda-tapestry5/src/main/java/org/equanda/tapestry5/components/Tabs.java =================================================================== --- trunk/equanda-tapestry5/src/main/java/org/equanda/tapestry5/components/Tabs.java 2008-09-15 14:13:34 UTC (rev 719) +++ trunk/equanda-tapestry5/src/main/java/org/equanda/tapestry5/components/Tabs.java 2008-09-15 14:16:44 UTC (rev 720) @@ -38,7 +38,6 @@ public class Tabs extends TitleContent { - private static final int CURRENT = 0; @Inject @Path( "${tapestry.scriptaculous}/prototype.js" ) private Asset prototype; @@ -118,7 +117,7 @@ */ public String getActive() { - if ( getIndex() == CURRENT ) return "equandaTabsActive equandaTraverseSkip"; + if ( (getIndex() + 1) == getActiveIndex() ) return "equandaTabsActive equandaTraverseSkip"; return ""; } @@ -129,7 +128,7 @@ */ public String getDisplay() { - if ( getIndex() == CURRENT ) return "block"; + if ( (getIndex() + 1 ) == getActiveIndex() ) return "block"; return "none"; } } Modified: trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/resources/tabs.js =================================================================== --- trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/resources/tabs.js 2008-09-15 14:13:34 UTC (rev 719) +++ trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/resources/tabs.js 2008-09-15 14:16:44 UTC (rev 720) @@ -6,6 +6,10 @@ function equandaTabsClick( title, content ) { + var tabsId = title.up().up().up().readAttribute( "id" ); + var titleId = title.readAttribute( "id" ); + var indexstr = titleId.substr( titleId.length - 1); + var index = parseInt( indexstr ); if ( !title.hasClassName( EQUANDA_TABS_ACTIVE ) ) { title.addClassName( EQUANDA_TABS_ACTIVE ); @@ -18,5 +22,6 @@ if ( !el.hasClassName( EQUANDA_TABS_ALL ) ) el.style.display = "none"; } ); } + document.cookie = "active_index_" + tabsId + "=" + ( index + 1) + "; path=/"; return false; } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |