[richfaces-svn-commits] JBoss Rich Faces SVN: r18636 - in trunk: ui/output/ui/src/main/java/org/richfaces/component and 3 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Sat Aug 14 10:35:28 EDT 2010


Author: Alex.Kolonitsky
Date: 2010-08-14 10:35:28 -0400 (Sat, 14 Aug 2010)
New Revision: 18636

Modified:
   trunk/examples/output-demo/src/main/webapp/examples/accordion.xhtml
   trunk/examples/output-demo/src/main/webapp/examples/togglePanel-client.xhtml
   trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractAccordion.java
   trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/AccordionRenderer.java
   trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TogglePanelRenderer.java
   trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/AccordionItem.js
   trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/TogglePanel.js
   trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/accordion.ecss
   trunk/ui/output/ui/src/test/java/org/richfaces/component/AbstractTogglePanelTest.java
Log:


Modified: trunk/examples/output-demo/src/main/webapp/examples/accordion.xhtml
===================================================================
--- trunk/examples/output-demo/src/main/webapp/examples/accordion.xhtml	2010-08-14 08:30:20 UTC (rev 18635)
+++ trunk/examples/output-demo/src/main/webapp/examples/accordion.xhtml	2010-08-14 14:35:28 UTC (rev 18636)
@@ -16,7 +16,7 @@
 
         <h:form id="f" style="border:blue solid thin;">
             <pn:accordion>
-                <pn:accordionItem header="label 1">content 1</pn:accordionItem>
+                <pn:accordionItem header="label 1">Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here.</pn:accordionItem>
                 <pn:accordionItem header="label 2">content 2</pn:accordionItem>
                 <pn:accordionItem header="label 3">content 3</pn:accordionItem>
             </pn:accordion>

Modified: trunk/examples/output-demo/src/main/webapp/examples/togglePanel-client.xhtml
===================================================================
--- trunk/examples/output-demo/src/main/webapp/examples/togglePanel-client.xhtml	2010-08-14 08:30:20 UTC (rev 18635)
+++ trunk/examples/output-demo/src/main/webapp/examples/togglePanel-client.xhtml	2010-08-14 14:35:28 UTC (rev 18636)
@@ -13,7 +13,7 @@
 
     <ui:define name="body">
         <h:form id="f">
-            <pn:togglePanel id="panel" activeItem="name1" switchType="client" lang="en">
+            <pn:togglePanel id="panel" switchType="client" lang="en">
                 <pn:togglePanelItem name="name1">hello name1</pn:togglePanelItem>
                 <pn:togglePanelItem name="name2">hello name2</pn:togglePanelItem>
                 <pn:togglePanelItem name="name3">hello name3</pn:togglePanelItem>

Modified: trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractAccordion.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractAccordion.java	2010-08-14 08:30:20 UTC (rev 18635)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/component/AbstractAccordion.java	2010-08-14 14:35:28 UTC (rev 18636)
@@ -28,7 +28,7 @@
  * @author akolonitsky
  * @since 2010-08-05
  */
-public abstract class AbstractAccordion extends UITogglePanel {
+public class AbstractAccordion extends UITogglePanel {
 
     public static final String COMPONENT_TYPE = "org.richfaces.Accordion";
 
@@ -43,6 +43,12 @@
         return COMPONENT_FAMILY;
     }
 
-
-
+    @Override
+    public String getActiveItem() {
+        String res = super.getActiveItem();
+        if (res == null) {
+            res = getFirstItem().getName();
+        }
+        return res;
+    }
 }

Modified: trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/AccordionRenderer.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/AccordionRenderer.java	2010-08-14 08:30:20 UTC (rev 18635)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/AccordionRenderer.java	2010-08-14 14:35:28 UTC (rev 18636)
@@ -57,7 +57,7 @@
 
     @Override
     protected String getStyleClass(UIComponent component) {
-        return "rf-ac" + attributeAsString(component, "styleClass");
+        return "rf-ac " + attributeAsString(component, "styleClass");
     }
 
     @Override

Modified: trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TogglePanelRenderer.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TogglePanelRenderer.java	2010-08-14 08:30:20 UTC (rev 18635)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/TogglePanelRenderer.java	2010-08-14 14:35:28 UTC (rev 18636)
@@ -133,7 +133,7 @@
         AbstractTogglePanel panel = (AbstractTogglePanel) component;
 
         Map<String, Object> options = new HashMap<String, Object>(5);
-        options.put("activeItem", panel.getValue());
+        options.put("activeItem", panel.getActiveItem());
         options.put("items", getChildrenScriptObjects(context, panel));
         options.put("ajax", getAjaxOptions(context, panel));
 

Modified: trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/AccordionItem.js
===================================================================
--- trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/AccordionItem.js	2010-08-14 08:30:20 UTC (rev 18635)
+++ trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/AccordionItem.js	2010-08-14 14:35:28 UTC (rev 18636)
@@ -51,17 +51,25 @@
         },
 
         /**
-         * @return {DOMElement}
+         * @param state {string} = inactive | active | disabled
+         *     in that case looking header by css class appropriate to this state
+         *
+         * @return {jQuery Object}
          * */
-        __header : function () {
-            return rf.getDomElement(this.id + ":header");
+        __header : function (state) {
+            var res = $(rf.getDomElement(this.id + ":header"));
+            if (state) {
+                return res.find(".rf-aci-h-" + state);
+            }
+
+            return res;
         },
 
         /**
-         * @return {DOMElement}
+         * @return {jQuery Object}
          * */
         __content : function () {
-            return rf.getDomElement(this.id + ":content");
+            return $(rf.getDomElement(this.id + ":content"));
         },
 
         /**
@@ -79,12 +87,13 @@
                     h -= items[i].getHeight();
                 }
 
-                $(this.__content()).height(h);
+                this.__content().height(h);
             }
 
-            this.__content().style.display = "block";
+            this.__content().show();
+            this.__header("inactive").hide();
+            this.__header("active").show();
 
-
             return this.__fireEnter();
         },
 
@@ -107,7 +116,10 @@
                 return false;
             }
 
-            this.__content().style.display = "none";
+            this.__content().hide();
+            this.__header("active").hide();
+            this.__header("inactive").show();
+
             return true;
         },
 

Modified: trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/TogglePanel.js
===================================================================
--- trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/TogglePanel.js	2010-08-14 08:30:20 UTC (rev 18635)
+++ trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/TogglePanel.js	2010-08-14 14:35:28 UTC (rev 18636)
@@ -57,10 +57,11 @@
          * @return {Boolean} false
          * */
         execServer : function (oldPanel, newPanel) {
-            var continueProcess = oldPanel.__leave();
-            if (!continueProcess) {
-
-                return false;
+            if (oldPanel) {
+                var continueProcess = oldPanel.__leave();
+                if (!continueProcess) {
+                    return false;
+                }
             }
 
             this.__setActiveItem(newPanel.getName());
@@ -82,8 +83,11 @@
 
             this.__setActiveItem(newPanel.getName());
             rf.ajax(this.comp.id, null, options);
-            this.__setActiveItem(oldPanel.getName());
 
+            if (oldPanel) {
+                this.__setActiveItem(oldPanel.getName());
+            }
+
             return false;
         },
 
@@ -97,9 +101,11 @@
          *             - true  - in other cases
          * */
         execClient : function (oldPanel, newPanel) {
-            var continueProcess = oldPanel.__leave();
-            if (!continueProcess) {
-                return false;
+            if (oldPanel) {
+                var continueProcess = oldPanel.__leave();
+                if (!continueProcess) {
+                    return false;
+                }
             }
 
             this.__setActiveItem(newPanel.getName());

Modified: trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/accordion.ecss
===================================================================
--- trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/accordion.ecss	2010-08-14 08:30:20 UTC (rev 18635)
+++ trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/accordion.ecss	2010-08-14 14:35:28 UTC (rev 18636)
@@ -1,26 +1,27 @@
 .rf-ac {
     width: 300px; /*visible width*/
-    border: 1px solid #a6a6a6; /*panelBorderColor*/
+    border: 1px solid #{richSkin.panelBorderColor}; 
     border-bottom: 0px;
-    background: #FFFFFF; /*generalBackgroundColor*/
+    background: #{richSkin.generalBackgroundColor};
 }
 
 .rf-aci-h {
-    border-bottom: 1px solid #a6a6a6; /*panelBorderColor*/
-    background: url(images/bg_header.png) /*from headerGradientColor to headerBackgroundColor, picture height 20px*/ repeat-x top left #C0D1E7 /*headerBackgroundColor*/;
+    border-bottom: 1px solid #{richSkin.panelBorderColor};
+    background: url(images/bg_header.png) /*from headerGradientColor to headerBackgroundColor, picture height 20px*/ repeat-x top left #{richSkin.headerBackgroundColor};
     position: relative;
     padding: 8px 10px 7px 10px;
-    font-weight: bold /*headerWeightFont*/;
-    color: #000000 /*headerTextColor*/;
-    font-family: verdana /*headerFamilyFont*/;
-    font-size: 11px /*headerSizeFont*/;
+    font-weight: #{richSkin.headerWeightFont};
+    color: #{richSkin.headerTextColor};
+    font-family: #{richSkin.headerFamilyFont};
+    font-size: #{richSkin.headerSizeFont};
     cursor: pointer;
 }
 
 .rf-aci-c {
-    border-bottom: 1px solid #a6a6a6 /*panelBorderColor*/;
+    border-bottom: 1px solid #{richSkin.panelBorderColor};
     height: 100px /*visible modal panel height minus header height*/;
     position: relative;
     overflow: auto;
     overflow-x: hidden;
+    padding: 10px;
 }
\ No newline at end of file

Modified: trunk/ui/output/ui/src/test/java/org/richfaces/component/AbstractTogglePanelTest.java
===================================================================
--- trunk/ui/output/ui/src/test/java/org/richfaces/component/AbstractTogglePanelTest.java	2010-08-14 08:30:20 UTC (rev 18635)
+++ trunk/ui/output/ui/src/test/java/org/richfaces/component/AbstractTogglePanelTest.java	2010-08-14 14:35:28 UTC (rev 18636)
@@ -59,6 +59,15 @@
     }
 
     @Test
+    public void testDefaultActiveItem() {
+        Assert.assertNotNull(panel);
+        Assert.assertEquals(null, panel.getActiveItem());
+
+        panel.setActiveItem(ITEM2);
+        Assert.assertEquals(ITEM2, panel.getActiveItem());
+    }
+
+    @Test
     public void testGetItemByIndex() {
         panel.setActiveItem(ITEM1);
 



More information about the richfaces-svn-commits mailing list