|
From: <tri...@us...> - 2007-11-10 23:11:33
|
Revision: 145
http://equanda.svn.sourceforge.net/equanda/?rev=145&view=rev
Author: triathlon98
Date: 2007-11-10 15:11:22 -0800 (Sat, 10 Nov 2007)
Log Message:
-----------
EQ-79 accordion component base version
Modified Paths:
--------------
trunk/equanda-tapestry5/pom.xml
trunk/equanda-tapestry5/src/main/java/org/equanda/tapestry5/services/EquandaModule.java
Added Paths:
-----------
trunk/equanda-tapestry5/src/main/java/org/equanda/tapestry5/components/Accordion.java
trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/components/Accordion.tml
trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/resources/accordion.js
Modified: trunk/equanda-tapestry5/pom.xml
===================================================================
--- trunk/equanda-tapestry5/pom.xml 2007-11-09 14:09:23 UTC (rev 144)
+++ trunk/equanda-tapestry5/pom.xml 2007-11-10 23:11:22 UTC (rev 145)
@@ -12,6 +12,22 @@
<version>0.9-SNAPSHOT</version>
<name>equanda-tapestry5</name>
<url>http://equanda.org</url>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ <configuration>
+ <archive>
+ <manifestEntries>
+ <Tapestry-Module-Classes>org.equanda.tapestry5.services.EquandaModule</Tapestry-Module-Classes>
+ </manifestEntries>
+ </archive>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
<dependencies>
<dependency>
<groupId>junit</groupId>
@@ -24,8 +40,8 @@
<version>${tapestry-release-version}</version>
</dependency>
</dependencies>
-
+
<properties>
<tapestry-release-version>5.0.6</tapestry-release-version>
- </properties>
+ </properties>
</project>
Added: trunk/equanda-tapestry5/src/main/java/org/equanda/tapestry5/components/Accordion.java
===================================================================
--- trunk/equanda-tapestry5/src/main/java/org/equanda/tapestry5/components/Accordion.java (rev 0)
+++ trunk/equanda-tapestry5/src/main/java/org/equanda/tapestry5/components/Accordion.java 2007-11-10 23:11:22 UTC (rev 145)
@@ -0,0 +1,281 @@
+/**
+ * This file is part of the equanda project.
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
+ * ANY KIND, either express or implied. See the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ */
+
+package org.equanda.tapestry5.components;
+
+import org.apache.tapestry.*;
+import org.apache.tapestry.annotations.*;
+import org.apache.tapestry.ioc.annotations.Inject;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Accordion component
+ *
+ * @author <a href="mailto:jo...@pr...">Joachim Van der Auwera</a>
+ */
+public class Accordion
+{
+ private static final int MAX_PANELS = 21; // max number of supported panels
+
+ @Inject
+ @Path( "${tapestry.scriptaculous}/prototype.js" )
+ private Asset prototype;
+
+ @Inject
+ @Path( "classpath:/org/equanda/tapestry5/resources/accordion.js" )
+ private Asset script;
+
+ @Environmental
+ private PageRenderSupport pageRenderSupport;
+
+ @Inject
+ private ComponentResources resources;
+
+ @Parameter
+ Block titleIcon;
+
+ @Parameter
+ private Block title1, content1;
+ @Parameter
+ private Block title2, content2;
+ @Parameter
+ private Block title3, content3;
+ @Parameter
+ private Block title4, content4;
+ @Parameter
+ private Block title5, content5;
+ @Parameter
+ private Block title6, content6;
+ @Parameter
+ private Block title7, content7;
+ @Parameter
+ private Block title8, content8;
+ @Parameter
+ private Block title9, content9;
+ @Parameter
+ private Block title10, content10;
+ @Parameter
+ private Block title11, content11;
+ @Parameter
+ private Block title12, content12;
+ @Parameter
+ private Block title13, content13;
+ @Parameter
+ private Block title14, content14;
+ @Parameter
+ private Block title15, content15;
+ @Parameter
+ private Block title16, content16;
+ @Parameter
+ private Block title17, content17;
+ @Parameter
+ private Block title18, content18;
+ @Parameter
+ private Block title19, content19;
+ @Parameter
+ private Block title20, content20;
+ @Parameter
+ private Block title21, content21;
+
+ private TwoBlocks panel;
+
+ @BeginRender
+ void doBeginRender( MarkupWriter writer )
+ {
+ pageRenderSupport.addScriptLink( prototype, script );
+ }
+
+ @AfterRender
+ void doAfterRender( MarkupWriter writer )
+ {
+ pageRenderSupport.addScript( "equandaAccordionInit('%s'); ", resources.getId() );
+ }
+
+ public String getId()
+ {
+ return resources.getId();
+ }
+
+ public Block getTitleIcon()
+ {
+ return titleIcon;
+ }
+
+ public void setTitleIcon( Block titleIcon )
+ {
+ this.titleIcon = titleIcon;
+ }
+
+ public TwoBlocks getPanel()
+ {
+ return panel;
+ }
+
+ public void setPanel( TwoBlocks panel )
+ {
+ this.panel = panel;
+ }
+
+ public List<TwoBlocks> getPanels()
+ {
+ List<TwoBlocks> list = new ArrayList<TwoBlocks>();
+ for ( int i = 0; i < MAX_PANELS ; i++ )
+ {
+ String index = Integer.toString( i + 1 );
+ if ( resources.isBound( "title" + index ) && resources.isBound( "content" + index ) )
+ {
+ list.add( new TwoBlocks( i + 1 ) );
+ }
+ }
+ return list;
+ }
+
+ public class TwoBlocks
+ {
+ private Block title, content;
+ private boolean active;
+
+ public TwoBlocks( int index )
+ {
+ switch ( index )
+ {
+ case 1:
+ title = title1;
+ content = content1;
+ active = true;
+ break;
+ case 2:
+ title = title2;
+ content = content2;
+ break;
+ case 3:
+ title = title3;
+ content = content3;
+ break;
+ case 4:
+ title = title4;
+ content = content4;
+ break;
+ case 5:
+ title = title5;
+ content = content5;
+ break;
+ case 6:
+ title = title6;
+ content = content6;
+ break;
+ case 7:
+ title = title7;
+ content = content7;
+ break;
+ case 8:
+ title = title8;
+ content = content8;
+ break;
+ case 9:
+ title = title9;
+ content = content9;
+ break;
+ case 11:
+ title = title11;
+ content = content11;
+ break;
+ case 12:
+ title = title12;
+ content = content12;
+ break;
+ case 13:
+ title = title13;
+ content = content13;
+ break;
+ case 14:
+ title = title14;
+ content = content14;
+ break;
+ case 15:
+ title = title15;
+ content = content15;
+ break;
+ case 16:
+ title = title16;
+ content = content16;
+ break;
+ case 17:
+ title = title17;
+ content = content17;
+ break;
+ case 18:
+ title = title18;
+ content = content18;
+ break;
+ case 19:
+ title = title19;
+ content = content19;
+ break;
+ case 20:
+ title = title20;
+ content = content20;
+ break;
+ case 21:
+ title = title21;
+ content = content21;
+ break;
+ default:
+ throw new RuntimeException( "invalid index " + index );
+ }
+ }
+
+ public Block getTitle()
+ {
+ return title;
+ }
+
+ public void setTitle( Block title )
+ {
+ this.title = title;
+ }
+
+ public Block getContent()
+ {
+ return content;
+ }
+
+ public void setContent( Block content )
+ {
+ this.content = content;
+ }
+
+ public boolean isActive()
+ {
+ return active;
+ }
+
+ public void setActive( boolean active )
+ {
+ this.active = active;
+ }
+ }
+}
Modified: trunk/equanda-tapestry5/src/main/java/org/equanda/tapestry5/services/EquandaModule.java
===================================================================
--- trunk/equanda-tapestry5/src/main/java/org/equanda/tapestry5/services/EquandaModule.java 2007-11-09 14:09:23 UTC (rev 144)
+++ trunk/equanda-tapestry5/src/main/java/org/equanda/tapestry5/services/EquandaModule.java 2007-11-10 23:11:22 UTC (rev 145)
@@ -34,8 +34,8 @@
*/
public class EquandaModule
{
- public static void contributeComponentClassResolver(Configuration<LibraryMapping> configuration)
+ public static void contributeComponentClassResolver( Configuration<LibraryMapping> configuration )
{
- configuration.add(new LibraryMapping("equanda", "be.equanda.tapestry5"));
+ configuration.add( new LibraryMapping( "equanda", "org.equanda.tapestry5" ) );
}
}
Added: trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/components/Accordion.tml
===================================================================
--- trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/components/Accordion.tml (rev 0)
+++ trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/components/Accordion.tml 2007-11-10 23:11:22 UTC (rev 145)
@@ -0,0 +1,23 @@
+<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
+
+<div class="equandaAccordion" id="${id}">
+ <t:loop source="Panels" value="Panel">
+ <t:if test="${panel.active}">
+ <div class="${id}_title ${id}_title_active" onClick="equandaAccordion(this)">
+ <t:delegate to="titleIcon"/>
+ <t:delegate to="panel.title"/>
+ </div>
+ <t:parameter name="else">
+ <div class="${id}_title" onClick="equandaAccordion(this)">
+ <t:delegate to="titleIcon"/>
+ <t:delegate to="panel.title"/>
+ </div>
+ </t:parameter>
+ </t:if>
+ <div class="${id}_content">
+ <t:delegate to="panel.content"/>
+ </div>
+ </t:loop>
+</div>
+
+</html>
\ No newline at end of file
Added: trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/resources/accordion.js
===================================================================
--- trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/resources/accordion.js (rev 0)
+++ trunk/equanda-tapestry5/src/main/resources/org/equanda/tapestry5/resources/accordion.js 2007-11-10 23:11:22 UTC (rev 145)
@@ -0,0 +1,46 @@
+/**
+ * This file is part of the equanda project.
+ *
+ * The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF
+ * ANY KIND, either express or implied. See the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ */
+
+function equandaAccordion(el)
+{
+ var accordionId = el.parentNode.id;
+ if (!Element.hasClassName(el,accordionId+"_title_active")) {
+ $$('.'+accordionId+'_title_active').each(function deactivate(object){
+ object.next().setStyle({display:'none'});
+ object.removeClassName(accordionId+'_title_active');
+ });
+ el.addClassName(accordionId+'_title_active');
+ el.next().setStyle({display:'block'});
+ }
+}
+
+function equandaAccordionInit(elementName)
+{
+ var objects = $$('#'+elementName+' .'+elementName+'_title');
+ objects.each(function hide(object){
+ if (!Element.hasClassName(object,elementName+"_title_active")) {
+ object.next().setStyle({display:'none'});
+ }
+ })
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|