Author: A.Skokov
Date: 2007-06-12 10:54:01 -0400 (Tue, 12 Jun 2007)
New Revision: 1138
Modified:
trunk/richfaces/panelbar/src/main/config/component/panelbar.xml
trunk/richfaces/panelbar/src/main/resources/org/richfaces/renderkit/html/scripts/panelbar.js
trunk/richfaces/panelbar/src/main/templates/panelBar.jspx
Log:
http://jira.jboss.com/jira/browse/RF-51
Modified: trunk/richfaces/panelbar/src/main/config/component/panelbar.xml
===================================================================
--- trunk/richfaces/panelbar/src/main/config/component/panelbar.xml 2007-06-12 13:53:13
UTC (rev 1137)
+++ trunk/richfaces/panelbar/src/main/config/component/panelbar.xml 2007-06-12 14:54:01
UTC (rev 1138)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE components PUBLIC "-//AJAX4JSF//CDK Generator config/EN"
"https://ajax4jsf.dev.java.net/nonav/dtds/component-config.dtd" >
-<!--
+<!--
<!DOCTYPE components PUBLIC "-//EXADEL//Generator config/EN"
"http://exadel.com/dtds/component-config.dtd" >
-->
<components>
@@ -49,7 +49,7 @@
<description>
A ValueExpression enabled attribute that, if present, will be used as the text of
the validator message, replacing any message that comes from the validator
</description>
- </property>
+ </property>
<property>
<name>width</name>
<classname>java.lang.String</classname>
@@ -98,7 +98,7 @@
<description>
Id of Converter to be used or reference to a Converter
</description>
- </property>
+ </property>
<property hidden="true">
<name>localValueSet</name>
<classname>boolean</classname>
@@ -107,8 +107,12 @@
<name>switchType</name>
<classname>java.lang.String</classname>
</property>
-
-
+ <property>
+ <name>onclick</name>
+ <classname>java.lang.String</classname>
+ <description>JavaScript code for call before header
onclick</description>
+ </property>
+
&ui_component_attributes;
&header_component_attributes;
&content_component_attributes;
@@ -140,7 +144,7 @@
<superclass>org.ajax4jsf.framework.taglib.HtmlComponentTagBase</superclass>
<description>A child component of a slide panel component</description>
</tag>
-
+
<property>
<name>label</name>
<classname>java.lang.String</classname>
@@ -158,8 +162,8 @@
<classname>java.lang.String</classname>
<description>The component header style class
active</description>
</property>
-
- &ui_component_attributes;
+
+ &ui_component_attributes;
&header_component_attributes;
&content_component_attributes;
<property hidden="true">
Modified:
trunk/richfaces/panelbar/src/main/resources/org/richfaces/renderkit/html/scripts/panelbar.js
===================================================================
---
trunk/richfaces/panelbar/src/main/resources/org/richfaces/renderkit/html/scripts/panelbar.js 2007-06-12
13:53:13 UTC (rev 1137)
+++
trunk/richfaces/panelbar/src/main/resources/org/richfaces/renderkit/html/scripts/panelbar.js 2007-06-12
14:54:01 UTC (rev 1138)
@@ -5,8 +5,8 @@
Exadel.PanelBar.prototype = {
- initialize: function(panelId) {
-
+ initialize: function(panelId, onclick) {
+
this.FF = (RichFaces.navigatorType() == "FF")?true:false;
this.isIE = ((navigator.userAgent.toLowerCase().indexOf("msie")!=-1) ||
(navigator.userAgent.toLowerCase().indexOf("explorer")!=-1))?true:false;
this.panel=$(panelId); //+"_p"
@@ -19,21 +19,21 @@
this.STEP=0;
this.slides=new Array();
this.ch=this.panel.clientHeight;
- this._attachBehaviors();
-
+
+ this.onclick = onclick;
+ this._attachBehaviors();
+
this.input=$(panelId+"_panelBarInput");
this.defaultIndex=this.findPanelById($F(panelId+"_panelBarInput"));
-
+
Event.observe(window,'load',this.handleOnLoad.bindAsEventListener(this));
-
- this.showSlide(this.slides[this.defaultIndex]);
+ this.showSlide(this.slides[this.defaultIndex]);
- this.contentHight = -1;
-
- },
-
+ this.contentHight = -1;
+ },
+
handleOnLoad: function() {
if ( this.timer ){
clearTimeout(this.timer);
@@ -42,19 +42,19 @@
this.contentHight = -1;
this.timer = setTimeout(this.handleOnLoad.bind(this), 100);
}
-
-
- this.showSlide(this.slides[this.defaultIndex]);
+
+
+ this.showSlide(this.slides[this.defaultIndex]);
},
getContentHeight: function() {
-
+
if(this.contentHight) {
}
else{
this.contentHight = -1;
}
-
+
if(this.contentHight <= -1) {
var h=0;
this.hclient=0;
@@ -66,7 +66,7 @@
this.hclient=h;
this.contentHight = this.panel.clientHeight-h;
}
-
+
return this.contentHight;
},
@@ -86,18 +86,18 @@
this.input.value=this.current.item.id;
},
-
+
_attachBehaviors: function() {
var rows=this._getDirectChildrenByTag(this.panel,'DIV');
for(var i=0; i<rows.length; i++) {
var subrows=this._getDirectChildrenByTag(rows[i],'DIV');
- this.slides.push(new
Exadel.PanelBar.Slide(this,rows[i],subrows[0],subrows[1],subrows[2],i)); //ndex
+ this.slides.push(new
Exadel.PanelBar.Slide(this,rows[i],subrows[0],subrows[1],subrows[2],i,this.onclick));
//ndex
}
},
_getDirectChildrenByTag: function( e, tagName ) {
-
+
var kids = new Array();
var allKids = e.childNodes;
for( var i = 0 ; i < allKids.length ; i++ ) {
@@ -109,21 +109,21 @@
return kids;
},
-
+
findPanelById: function(value) {
for(var i = 0; i<this.slides.length; i++) {
if (this.slides[i].item.id==value) return i;
}
return 0;
}
-
+
}
Exadel.PanelBar.Slide = Class.create();
Exadel.PanelBar.Slide.prototype = {
- initialize: function(slidePanel,item,header,header_act,content,index){
+ initialize: function(slidePanel,item,header,header_act,content,index,onclick){
this.index=index;
this.slidePanel=slidePanel;
@@ -153,31 +153,40 @@
}
}
-
+ if (onclick && onclick != ""){
+ this.onclickFunction = new Function("return " + onclick +
";").bindAsEventListener(this);
+ }
},
showContent: function() {
this.content.style.display="block";
this.content.firstChild.style.height="";
this.header.style.display="none";
- this.header_act.style.display="";
-
+ this.header_act.style.display="";
+
},
hideContent: function() {
this.content.style.display="none";
this.content.firstChild.style.height="100%";
},
-
+
hideHeader: function() {
this.header_act.style.display="none";
- this.header.style.display="";
+ this.header.style.display="";
},
headerOnClick: function() {
- if (this.content.style.display=="block") return;
+ if (this.onclickFunction){
+ var result = this.onclickFunction();
+ if (result != undefined && !result) {
+ return;
+ }
+ }
+
+ if (this.content.style.display=="block") return;
//this.header.style.display="none";
- //this.header_act.style.display="";
+ //this.header_act.style.display="";
this.slidePanel.showSlide(this);
this.slidePanel.panel.style.maxHeight="";
this.slidePanel.panel.style.minHeight="";
Modified: trunk/richfaces/panelbar/src/main/templates/panelBar.jspx
===================================================================
--- trunk/richfaces/panelbar/src/main/templates/panelBar.jspx 2007-06-12 13:53:13 UTC (rev
1137)
+++ trunk/richfaces/panelbar/src/main/templates/panelBar.jspx 2007-06-12 14:54:01 UTC (rev
1138)
@@ -9,18 +9,18 @@
class="org.richfaces.renderkit.html.PanelBarRenderer"
baseclass="org.richfaces.renderkit.html.PanelBarRendererBase"
component="org.richfaces.component.UIPanelBar">
-
+
<h:styles>css/panelbar.xcss</h:styles>
-
- <f:clientid var="clientId" />
+
+ <f:clientid var="clientId" />
<div id="#{clientId}" class="dr-pnlbar rich-panelbar dr-pnlbar-b
#{component.attributes['styleClass']}" style="padding: 0px;
#{this:height(context, component)} #{this:width(context, component)}
#{component.attributes['style']}">
<vcp:body>
<f:call name="renderChildren" />
</vcp:body>
- <f:clientid var="clientId" />
+ <f:clientid var="clientId" />
<input type="hidden" name="#{clientId}"
id="#{clientId}_panelBarInput"
- value="#{this:expanded(context, component)}"/>
- <script type="text/javascript">new
Exadel.PanelBar("#{clientId}");</script>
+ value="#{this:expanded(context, component)}"/>
+ <script type="text/javascript">new
Exadel.PanelBar("#{clientId}",
"#{component.attributes['onclick']}");</script>
</div>
</f:root>