JBoss Rich Faces SVN: r807 - in trunk/richfaces/panelmenu/src/main: java/org/richfaces/component/panelmenu and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: sergeyhalipov
Date: 2007-05-18 10:58:11 -0400 (Fri, 18 May 2007)
New Revision: 807
Modified:
trunk/richfaces/panelmenu/src/main/config/component/panelMenu.xml
trunk/richfaces/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenuGroup.java
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRenderer.java
trunk/richfaces/panelmenu/src/main/resources/org/richfaces/renderkit/html/scripts/panelMenu.js
Log:
Panel menu: add support for "event" attribute and onexpand/oncollapse attributes.
Modified: trunk/richfaces/panelmenu/src/main/config/component/panelMenu.xml
===================================================================
--- trunk/richfaces/panelmenu/src/main/config/component/panelMenu.xml 2007-05-18 13:07:07 UTC (rev 806)
+++ trunk/richfaces/panelmenu/src/main/config/component/panelMenu.xml 2007-05-18 14:58:11 UTC (rev 807)
@@ -357,6 +357,18 @@
&ui_input_attributes;
&html_events;
<property>
+ <name>oncollapse</name>
+ <classname>java.lang.String</classname>
+ <description></description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
+ </property>
+ <property>
+ <name>onexpand</name>
+ <classname>java.lang.String</classname>
+ <description></description>
+ <defaultvalue><![CDATA[""]]></defaultvalue>
+ </property>
+ <property>
<name>hoverClass</name>
<classname>java.lang.String</classname>
<description>Class to be applied to hovered items.</description>
Modified: trunk/richfaces/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenuGroup.java
===================================================================
--- trunk/richfaces/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenuGroup.java 2007-05-18 13:07:07 UTC (rev 806)
+++ trunk/richfaces/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenuGroup.java 2007-05-18 14:58:11 UTC (rev 807)
@@ -67,6 +67,10 @@
public abstract void setIconClass(String iconClass);
public abstract String getIconStyle();
public abstract void setIconStyle(String iconStyle);
+ public abstract String getOncollapse();
+ public abstract void setOncollapse(String ongroupcollapse);
+ public abstract String getOnexpand();
+ public abstract void setOnexpand(String ongroupexpand);
}
Modified: trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRenderer.java
===================================================================
--- trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRenderer.java 2007-05-18 13:07:07 UTC (rev 806)
+++ trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRenderer.java 2007-05-18 14:58:11 UTC (rev 807)
@@ -91,10 +91,17 @@
}
UIPanelMenu parentMenu = findMenu(child);
+
+ String event = parentMenu.getEvent();
+ if ("".equals(event))
+ event = "click";
+ else if (event.startsWith("on"))
+ event = event.substring(2);
+
String onopen = child instanceof UIPanelMenuGroup ?
- parentMenu.getOngroupexpand() : "";
+ parentMenu.getOngroupexpand() + ";" + ((UIPanelMenuGroup)child).getOnexpand() : "";
String onclose = child instanceof UIPanelMenuGroup ?
- parentMenu.getOngroupcollapse() : "";
+ parentMenu.getOngroupcollapse() + ";" + ((UIPanelMenuGroup)child).getOncollapse() : "";
String hoveredStyle = (child instanceof UIPanelMenuGroup ?
parentMenu.getHoveredGroupStyle() : parentMenu.getHoveredItemStyle())
+ ";" + (child instanceof UIPanelMenuGroup ?
@@ -116,6 +123,7 @@
.append((String) child.getParent().getClientId(context))
.append("'},{type:" + (child instanceof UIPanelMenuItem ? "\"item\"":"\"node\""))
.append(",onopen:"+(onopen.equals("") ? "\"\"" : "\"" + onopen + "\"")+",onclose:"+(onclose.equals("") ? "\"\"" : "\"" + onclose + "\""))
+ .append(",event:\"" + event + "\"")
.append("},{");
Modified: trunk/richfaces/panelmenu/src/main/resources/org/richfaces/renderkit/html/scripts/panelMenu.js
===================================================================
--- trunk/richfaces/panelmenu/src/main/resources/org/richfaces/renderkit/html/scripts/panelMenu.js 2007-05-18 13:07:07 UTC (rev 806)
+++ trunk/richfaces/panelmenu/src/main/resources/org/richfaces/renderkit/html/scripts/panelMenu.js 2007-05-18 14:58:11 UTC (rev 807)
@@ -22,6 +22,7 @@
this.type = options.type;
this.onopen = options.onopen;
this.onclose = options.onclose;
+ this.event = options.event;
this.hoveredStyles = hoveredStyles;
this.hoveredClasses = hoveredClasses;
this.tdhider = $("tdhide"+ids.myId);
@@ -160,7 +161,7 @@
if(this.action){
if (this.action=='panelMenuNodeAction'){
if (this.expanded){
- if (this.type="node"){
+ if ("node" == this.type){
if (new Function(this.onclose+";return true;")()){
this.collapse();
}
@@ -173,7 +174,7 @@
if (this.parentObj.lastExpanded!=null){
this.parentObj.lastExpanded.collapse();
}
- if (this.type="node"){
+ if ("node" == this.type){
if (new Function(this.onopen+";return true;")()){
this.expand();
}
@@ -183,7 +184,7 @@
}
this.parentObj.lastExpanded = this;
} else {
- if (this.type="node"){
+ if ("node" == this.type){
if (new Function(this.onopen+";return true;")()){
this.expand();
}
@@ -196,8 +197,8 @@
}
} else {
if (this.expanded){
- if (this.type="node"){
- if (new Function(this.onopen+";return true;")()){
+ if ("node" == this.type){
+ if (new Function(this.onclose + ";return true;")()){
this.collapse();
}
}
@@ -209,7 +210,7 @@
if (this.parentObj.lastExpanded!=null){
this.parentObj.lastExpanded.collapse();
}
- if (this.type="node"){
+ if ("node" == this.type){
if (new Function(this.onopen+";return true;")()){
this.expand();
}
@@ -219,7 +220,7 @@
}
this.parentObj.lastExpanded = this;
} else {
- if (this.type="node"){
+ if ("node" == this.type){
if (new Function(this.onopen+";return true;")()){
this.expand();
}
@@ -269,7 +270,10 @@
},
_attachBehaviors: function() {
- Event.observe(this.obj, "click", this.itemClicked.bindAsEventListener(this), false);
+ if (this.event)
+ Event.observe(this.obj, this.event, this.itemClicked.bindAsEventListener(this), false);
+ else
+ Event.observe(this.obj, "click", this.itemClicked.bindAsEventListener(this), false);
Event.observe(this.obj, "mouseover", this.addHoverStyles.bindAsEventListener(this), false);
Event.observe(this.obj, "mouseout", this.removeHoverStyles.bindAsEventListener(this), false);
}
17 years, 8 months
JBoss Rich Faces SVN: r806 - in trunk/richfaces/panelmenu/src/main/java/org/richfaces: renderkit and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: dbiatenia
Date: 2007-05-18 09:07:07 -0400 (Fri, 18 May 2007)
New Revision: 806
Modified:
trunk/richfaces/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenuGroup.java
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuGroupRenderer.java
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuItemRenderer.java
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java
Log:
Modified: trunk/richfaces/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenuGroup.java
===================================================================
--- trunk/richfaces/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenuGroup.java 2007-05-18 13:06:45 UTC (rev 805)
+++ trunk/richfaces/panelmenu/src/main/java/org/richfaces/component/panelmenu/UIPanelMenuGroup.java 2007-05-18 13:07:07 UTC (rev 806)
@@ -34,7 +34,11 @@
public abstract String getMode();
public abstract void setMode(String mode);
public abstract String getIconExpanded();
- public abstract void setIconExpanded(String iconExpanded);
+ public abstract void setIconExpanded(String expanded);
+
+ public abstract boolean isExpanded();
+ public abstract void setExpanded(boolean expanded);
+
public abstract String getIconCollapsed();
public abstract void setIconCollapsed(String iconCollapsed);
public abstract String getIconDisabled();
Modified: trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuGroupRenderer.java
===================================================================
--- trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuGroupRenderer.java 2007-05-18 13:06:45 UTC (rev 805)
+++ trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuGroupRenderer.java 2007-05-18 13:07:07 UTC (rev 806)
@@ -97,14 +97,14 @@
Object iconCollapsed = component.getAttributes().get("iconCollapsed");
Object iconExpanded = component.getAttributes().get("iconExpanded");
-
- if (( isOpened ? iconExpanded : iconCollapsed ).equals("")){
+ String icon = (isOpened ? iconExpanded : iconCollapsed).toString();
+ if (icon.equals("")){
source = getIconByType("custom", isTopLevel,context, component);
} else {
if (iconNode.equals("none")){
return;
} else {
- source = getIconByType(data.equals("spacer")?"custom":iconCollapsed.toString(),isTopLevel,context,component);
+ source = getIconByType(data.equals("spacer") ? "custom" : icon, isTopLevel, context, component);
}
}
Modified: trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuItemRenderer.java
===================================================================
--- trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuItemRenderer.java 2007-05-18 13:06:45 UTC (rev 805)
+++ trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuItemRenderer.java 2007-05-18 13:07:07 UTC (rev 806)
@@ -24,13 +24,13 @@
import java.io.IOException;
import java.util.Map;
-import javax.faces.component.UICommand;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
import javax.faces.event.ActionEvent;
import org.ajax4jsf.framework.renderer.compiler.TemplateContext;
+import org.ajax4jsf.framework.util.style.CSSFormat;
import org.richfaces.component.panelmenu.UIPanelMenu;
import org.richfaces.component.panelmenu.UIPanelMenuGroup;
import org.richfaces.component.panelmenu.UIPanelMenuItem;
@@ -156,5 +156,29 @@
.append(item.getDisabledStyle());
return styleBuffer.toString();
}
+
+ @Override
+ public String getHideStyle(FacesContext context, UIComponent component) {
+ // TODO Auto-generated method stub
+ if (!(component.getParent() instanceof UIPanelMenu)) {
+ CSSFormat format = new CSSFormat();
+ format.add("display", "none");
+ if(component.getParent() instanceof UIPanelMenuGroup) {
+ UIPanelMenuGroup parent = (UIPanelMenuGroup)component.getParent();
+ PanelMenuGroupRenderer renderer = (PanelMenuGroupRenderer) context.getRenderKit().getRenderer(parent.getFamily(), parent.getRendererType());
+ try {
+ if ( renderer.isOpened(context, parent).equals("opened") ){
+ return "";
+ } else
+ return format.toString();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ } else return format.toString();
+ }
+ return "";
+ }
+
}
Modified: trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java
===================================================================
--- trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java 2007-05-18 13:06:45 UTC (rev 805)
+++ trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java 2007-05-18 13:07:07 UTC (rev 806)
@@ -34,6 +34,7 @@
import org.ajax4jsf.framework.skin.Skin;
import org.ajax4jsf.framework.util.style.CSSFormat;
import org.richfaces.component.panelmenu.UIPanelMenu;
+import org.richfaces.component.panelmenu.UIPanelMenuGroup;
import org.richfaces.renderkit.iconImages.PanelMenuIconArrow;
import org.richfaces.renderkit.iconImages.PanelMenuIconArrowDown;
import org.richfaces.renderkit.iconImages.PanelMenuIconArrowUp;
@@ -160,10 +161,34 @@
if (value.equals("opened")) {
return "opened";
}
+ } else {
+ if(component instanceof UIPanelMenuGroup){
+ if( ((UIPanelMenuGroup)component).isExpanded() ){
+ return "opened";
+ } else {
+ //check expanded attributes in children groups, if exists
+ return isChildrenExpanded(component) ? "opened" : "closed";
+ }
+ }
}
return "closed";
}
+ public boolean isChildrenExpanded(UIComponent component){
+ if (component.getChildren() != null){
+ for(Object child : component.getChildren()){
+ if(child instanceof UIPanelMenuGroup){
+ if( ((UIPanelMenuGroup)child).isExpanded() ){
+ return true;
+ } else {
+ return isChildrenExpanded((UIComponent)child);
+ }
+ }
+ }
+ }
+ return false;
+ }
+
protected boolean isSubmitted(FacesContext context, UIComponent component){
boolean submitted = false;
String clientId = component.getClientId(context);
@@ -177,4 +202,5 @@
}
return submitted;
}
+
}
17 years, 8 months
JBoss Rich Faces SVN: r805 - trunk/richfaces/panelmenu/src/main/config/component.
by richfaces-svn-commits@lists.jboss.org
Author: dbiatenia
Date: 2007-05-18 09:06:45 -0400 (Fri, 18 May 2007)
New Revision: 805
Modified:
trunk/richfaces/panelmenu/src/main/config/component/panelMenu.xml
Log:
Modified: trunk/richfaces/panelmenu/src/main/config/component/panelMenu.xml
===================================================================
--- trunk/richfaces/panelmenu/src/main/config/component/panelMenu.xml 2007-05-18 12:42:08 UTC (rev 804)
+++ trunk/richfaces/panelmenu/src/main/config/component/panelMenu.xml 2007-05-18 13:06:45 UTC (rev 805)
@@ -308,7 +308,13 @@
<classname>java.lang.String</classname>
<description>Path to the icon to be displayed for the collapsed item state</description>
<defaultvalue><![CDATA[""]]></defaultvalue>
- </property>
+ </property>
+ <property>
+ <name>expanded</name>
+ <classname>boolean</classname>
+ <description>If “true” group will be displayed expanded initially.</description>
+ <defaultvalue>false</defaultvalue>
+ </property>
<property>
<name>iconDisabled</name>
<classname>java.lang.String</classname>
17 years, 8 months
JBoss Rich Faces SVN: r804 - in trunk/richfaces/panelmenu/src/main: templates/org/richfaces and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: sergeyhalipov
Date: 2007-05-18 08:42:08 -0400 (Fri, 18 May 2007)
New Revision: 804
Modified:
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuGroupRenderer.java
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuItemRenderer.java
trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java
trunk/richfaces/panelmenu/src/main/templates/org/richfaces/htmlPanelMenuGroup.jspx
trunk/richfaces/panelmenu/src/main/templates/org/richfaces/htmlPanelMenuItem.jspx
Log:
Panel menu: fixed support for actions and for mouse events.
Modified: trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuGroupRenderer.java
===================================================================
--- trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuGroupRenderer.java 2007-05-18 10:21:54 UTC (rev 803)
+++ trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuGroupRenderer.java 2007-05-18 12:42:08 UTC (rev 804)
@@ -27,6 +27,7 @@
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
+import javax.faces.event.ActionEvent;
import org.ajax4jsf.framework.util.style.CSSFormat;
import org.richfaces.component.panelmenu.UIPanelMenu;
@@ -37,6 +38,26 @@
return UIComponent.class;
}
+ protected void doDecode(FacesContext context, UIComponent component) {
+ String clientId = component.getClientId(context);
+ Map requestMap =context.getExternalContext().getRequestParameterMap();
+
+ if(requestMap.containsKey("panelMenuState"+clientId)){
+ Object property = requestMap.get("panelMenuState"+clientId);
+
+ if (property.equals("opened")) {
+ component.getAttributes().put("expanded", "true");
+ } else if (property.equals("closed")) {
+ component.getAttributes().put("expanded", "false");
+ }
+
+ }
+ if(isSubmitted(context, component)){
+ ActionEvent actionEvent = new ActionEvent(component);
+ component.queueEvent(actionEvent);
+ }
+ }
+
public void insertImage(FacesContext context, UIComponent component, Object data)
throws IOException {
Modified: trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuItemRenderer.java
===================================================================
--- trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuItemRenderer.java 2007-05-18 10:21:54 UTC (rev 803)
+++ trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuItemRenderer.java 2007-05-18 12:42:08 UTC (rev 804)
@@ -22,10 +22,13 @@
package org.richfaces.renderkit;
import java.io.IOException;
+import java.util.Map;
+import javax.faces.component.UICommand;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
+import javax.faces.event.ActionEvent;
import org.ajax4jsf.framework.renderer.compiler.TemplateContext;
import org.richfaces.component.panelmenu.UIPanelMenu;
@@ -37,9 +40,21 @@
return UIComponent.class;
}
- public String getOnClick(TemplateContext templateContext){
- FacesContext context = templateContext.getFacesContext();
- UIComponent component = templateContext.getComponent();
+ protected void doEncodeBegin(ResponseWriter writer, FacesContext context,UIComponent component) throws IOException {
+
+ }
+ protected void doDecode(FacesContext context, UIComponent component) {
+ if(isSubmitted(context, component)){
+ ActionEvent actionEvent = new ActionEvent(component);
+ component.queueEvent(actionEvent);
+ }
+ }
+
+ protected void doEncodeEnd(ResponseWriter writer, FacesContext context, UIComponent component) throws IOException {
+
+ }
+
+ public String getOnClick(FacesContext context, UIComponent component) {
String clientId = component.getClientId(context);
return ";PanelMenuStorage['" + clientId + "'].trigger(event);";
}
Modified: trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java
===================================================================
--- trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java 2007-05-18 10:21:54 UTC (rev 803)
+++ trunk/richfaces/panelmenu/src/main/java/org/richfaces/renderkit/PanelMenuRendererBase.java 2007-05-18 12:42:08 UTC (rev 804)
@@ -24,6 +24,7 @@
import java.io.IOException;
import java.util.Map;
+import javax.faces.component.UICommand;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;
@@ -162,4 +163,18 @@
}
return "closed";
}
+
+ protected boolean isSubmitted(FacesContext context, UIComponent component){
+ boolean submitted = false;
+ String clientId = component.getClientId(context);
+ Map requestParameterMap = context.getExternalContext().getRequestParameterMap();
+
+ Object value = requestParameterMap.get("panelMenuAction"+clientId);
+ if (clientId!=null&&value!=null){
+ if (value.equals(clientId)) {
+ submitted = true;
+ }
+ }
+ return submitted;
+ }
}
Modified: trunk/richfaces/panelmenu/src/main/templates/org/richfaces/htmlPanelMenuGroup.jspx
===================================================================
--- trunk/richfaces/panelmenu/src/main/templates/org/richfaces/htmlPanelMenuGroup.jspx 2007-05-18 10:21:54 UTC (rev 803)
+++ trunk/richfaces/panelmenu/src/main/templates/org/richfaces/htmlPanelMenuGroup.jspx 2007-05-18 12:42:08 UTC (rev 804)
@@ -18,6 +18,10 @@
id="tablehide#{clientId}"
class="rich-pmenu-group dr-pmenu-group #{this:getFullStyleClass( context, component )}"
style="#{this:getFullStyle( context, component )}" >
+
+ <f:call name="utils.encodeAttributes">
+ <f:parameter value="onclick,onmousedown,onmouseup,onmousemove" />
+ </f:call>
<f:call name="utils.encodePassThru" />
<tr>
<f:call name="utils.encodeId" />
Modified: trunk/richfaces/panelmenu/src/main/templates/org/richfaces/htmlPanelMenuItem.jspx
===================================================================
--- trunk/richfaces/panelmenu/src/main/templates/org/richfaces/htmlPanelMenuItem.jspx 2007-05-18 10:21:54 UTC (rev 803)
+++ trunk/richfaces/panelmenu/src/main/templates/org/richfaces/htmlPanelMenuItem.jspx 2007-05-18 12:42:08 UTC (rev 804)
@@ -15,12 +15,12 @@
<tr id="tdhide#{clientId}" style="#{this:getHideStyle(context, component)}" >
<td>
<table cellpadding="0" cellspacing="0" border="0" width="100%"
- onclick="#{onClick}"
+ onclick="#{component.attributes['onclick']};#{this:getOnClick( context, component )}"
class="rich-pmenu-item dr-pmenu-item #{this:getFullStyleClass( context, component )}"
style="#{this:getFullStyle( context, component )}"
id="tablehide#{clientId}" >
- <f:call name="utils.encodePassThruWithExclusions">
- <f:parameter value="onclick"/>
+ <f:call name="utils.encodeAttributes">
+ <f:parameter value="onmousedown,onmouseup,onmousemove" />
</f:call>
<tr>
<f:call name="utils.encodeId"/>
17 years, 8 months
JBoss Rich Faces SVN: r803 - trunk/sandbox/scrollable-grid.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-05-18 06:21:54 -0400 (Fri, 18 May 2007)
New Revision: 803
Modified:
trunk/sandbox/scrollable-grid/generatescript.xml
Log:
Modified: trunk/sandbox/scrollable-grid/generatescript.xml
===================================================================
--- trunk/sandbox/scrollable-grid/generatescript.xml 2007-05-18 10:21:45 UTC (rev 802)
+++ trunk/sandbox/scrollable-grid/generatescript.xml 2007-05-18 10:21:54 UTC (rev 803)
@@ -38,7 +38,6 @@
<file name="/ClientUI/controls/grid/GridHeader2.js"/>
<file name="/ClientUI/controls/grid/GridBody2.js"/>
<file name="/ClientUI/controls/grid/GridFooter2.js"/>
- <file name="/ClientUI/controls/grid/CellsStrip.js"/>
<file name="/ClientUI/controls/grid/Grid2.js"/>
</filelist>
</concat>
17 years, 8 months
JBoss Rich Faces SVN: r802 - trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-05-18 06:21:45 -0400 (Fri, 18 May 2007)
New Revision: 802
Modified:
trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid-cell.jspx
trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid-header-cell.jspx
Log:
Modified: trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid-cell.jspx
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid-cell.jspx 2007-05-18 10:21:31 UTC (rev 801)
+++ trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid-cell.jspx 2007-05-18 10:21:45 UTC (rev 802)
@@ -12,8 +12,8 @@
>
<td class="ClientUI_Grid_BC" id="#{client_id}:c_#{cell_id}">
- <span style="width: #{component.attributes['width']}" id="#{client_id}:bc_#{cell_id}" class="ClientUI_Grid_BCBody1">
- <span class="ClientUI_Grid_FCBody" id="#{client_id}:bcc_#{cell_id}">
+ <span style="width: #{component.attributes['width']}" id="#{client_id}:#{column_type}:bc_#{cell_index}_#{row_index}" class="ClientUI_Grid_BCBody1">
+ <span class="ClientUI_Grid_FCBody" id="#{client_id}:#{column_type}:bcc_#{cell_id}">
<vcp:body/>
</span>
</span>
Modified: trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid-header-cell.jspx
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid-header-cell.jspx 2007-05-18 10:21:31 UTC (rev 801)
+++ trunk/sandbox/scrollable-grid/src/main/templates/org/richfaces/scrollable-grid-header-cell.jspx 2007-05-18 10:21:45 UTC (rev 802)
@@ -13,7 +13,7 @@
<td class="ClientUI_Grid_HC" id="#{client_id}hc_#{cell_id}">
<span style="width: #{component.attributes['width']}" id="#{client_id}:hcc_#{cell_id}" class="ClientUI_Grid_HCBody1">
- <span id="#{clientId}:hcb_#{cell_id}" class="ClientUI_Grid_HCBody">
+ <span id="#{clientId}:hcb_#{cell_index}" class="ClientUI_Grid_HCBody">
<table width="100%" cellspacing="0" cellpadding="0" border="0" align="center">
<tbody>
<tr>
@@ -33,7 +33,7 @@
</table>
</span>
</span>
- <span column="#{cell_index}" id="#{client_id}:hsep_#{cell_id}" style="left: ${sepOffset - 3}px;" class="ClientUI_Grid_HSep" />
+ <span column="#{cell_index}" id="#{client_id}:hsep_#{cell_index}" style="left: ${sepOffset - 3}px;" class="ClientUI_Grid_HSep" />
</td>
</f:root>
\ No newline at end of file
17 years, 8 months
JBoss Rich Faces SVN: r801 - trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-05-18 06:21:31 -0400 (Fri, 18 May 2007)
New Revision: 801
Modified:
trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer2.java
Log:
Modified: trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer2.java
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer2.java 2007-05-18 10:21:22 UTC (rev 800)
+++ trunk/sandbox/scrollable-grid/src/main/java/org/richfaces/renderkit/html/ScrollableGridBaseRenderer2.java 2007-05-18 10:21:31 UTC (rev 801)
@@ -22,8 +22,10 @@
import org.richfaces.renderkit.CompositeRenderer;
import org.richfaces.utils.TemplateLoader;
+import com.sun.org.apache.bcel.internal.generic.NEW;
+
/**
* @author Anton Belevich
*
@@ -71,15 +73,15 @@
public void renderContent(FacesContext context, UIScrollableGridColumn column, ResponseWriter writer, GridRendererState state) throws IOException {
- int index = state.getCellIndex();
- Integer cell_index = new Integer(index);
+
+ int cell_index = state.getCellIndex();
String client_id = state.getClientId();
- String cell_id = state.getColumnType()+ ":" + state.getRowIndex()+ ":" + index;
+ String cell_id = state.getColumnType()+ ":" + state.getRowIndex()+ ":" + cell_index;
headerCellTemplate = getHeaderCellTemplate();
ComponentVariables variables = ComponentsVariableResolver.getVariables(headerCellTemplate, column);
variables.setVariable("cell_id",cell_id);
variables.setVariable("client_id", client_id);
- variables.setVariable("cell_index", cell_index);
+ variables.setVariable("cell_index", new Integer(cell_index));
headerCellTemplate.encodeBegin(context, column);
UIComponent component = column.getFacet(HEADER_PART);
@@ -95,13 +97,14 @@
public void renderContent(FacesContext context, UIScrollableGridColumn column, ResponseWriter writer, GridRendererState state) throws IOException {
- String cell_id = state.getColumnType()+ ":" + state.getRowIndex()+ ":" + state.getCellIndex();
+ int cell_index = state.getCellIndex();
+ String cell_id = state.getColumnType()+ ":" + state.getRowIndex()+ ":" + cell_index;
String client_id = state.getClientId();
-
footerCellTemplate = getFooterCellTemplate();
ComponentVariables variables = ComponentsVariableResolver.getVariables(footerCellTemplate, column);
variables.setVariable("cell_id",cell_id);
variables.setVariable("client_id", client_id);
+ variables.setVariable("cell_index", new Integer(cell_index));
footerCellTemplate.encodeBegin(context, column);
UIComponent component = column.getFacet(FOOTER_PART);
if(component != null){
@@ -116,13 +119,19 @@
public void renderContent(FacesContext context, UIScrollableGridColumn column, ResponseWriter writer, GridRendererState state) throws IOException {
- String cell_id = state.getColumnType()+ ":" + state.getRowIndex()+ ":" + state.getCellIndex();
+ int cell_index = state.getCellIndex();
+ String cell_id = state.getRowIndex()+ "_" + state.getCellIndex();
+ String column_type = state.getColumnType();
+ int row_index = state.getRowIndex();
String client_id = state.getClientId();
cellTemplate = getCellTemplate();
ComponentVariables variables = ComponentsVariableResolver.getVariables(cellTemplate, column);
variables.setVariable("cell_id",cell_id);
+ variables.setVariable("row_index",new Integer(row_index));
+ variables.setVariable("column_type", column_type);
variables.setVariable("client_id", client_id);
+ variables.setVariable("cell_index",new Integer(cell_index));
cellTemplate.encodeBegin(context, column);
renderChildren(context, column);
cellTemplate.encodeEnd(context, column);
@@ -143,7 +152,7 @@
int index = ((Integer)rowIndex).intValue();
state.setRowIndex(index);
- String row_id = state.getClientId() + ":" + "row_" + state.getColumnType() + ":" + index;
+ String row_id = "row_" + index;
ResponseWriter writer = context.getResponseWriter();
writer.startElement(HTML.TR_ELEMENT, grid);
state.setFrozenColumnCount(((Integer)grid.getAttributes().get("frozenColCount")).intValue());
@@ -163,10 +172,10 @@
if(state.isFrozenColumn()){
int i = state.getFrozenColumnCount();
state.setFrozenColumnCount(i-1);
- state.setCellIdPrefix(CELL_ID_PREFFIX + COLUMN_FROZEN_TYPE);
+ state.setCellIdPrefix(COLUMN_FROZEN_TYPE +":"+ CELL_ID_PREFFIX);
renderContent(context, column, writer,state);
}else{
- state.setCellIdPrefix(CELL_ID_PREFFIX + COLUMN_NORMAL_TYPE);
+ state.setCellIdPrefix(COLUMN_NORMAL_TYPE + ":" + CELL_ID_PREFFIX);
renderContent(context, column, writer,state);
}
return 1;
@@ -176,7 +185,7 @@
writer.startElement(HTML.SPAN_ELEM, column);
String columnWidth = (String)column.getAttributes().get("width");
- String cell_id = state.getClientId() + ":" + state.getCellIdPrefix() + ":" + state.getRowIndex()+":" + state.getCellIndex();
+ String cell_id = state.getClientId() + ":" + state.getCellIdPrefix() + state.getRowIndex()+ "_" + state.getCellIndex();
getUtils().writeAttribute(writer, "id",cell_id);
getUtils().writeAttribute(writer, "class", "ClientUI_Grid_BCBody");
getUtils().writeAttribute(writer, "style", "width:" + columnWidth);
17 years, 8 months
JBoss Rich Faces SVN: r800 - trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-05-18 06:21:22 -0400 (Fri, 18 May 2007)
New Revision: 800
Removed:
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/CellsStrip.js
Modified:
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Grid2.js
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody2.js
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridFooter2.js
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridHeader2.js
Log:
Deleted: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/CellsStrip.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/CellsStrip.js 2007-05-17 18:50:09 UTC (rev 799)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/CellsStrip.js 2007-05-18 10:21:22 UTC (rev 800)
@@ -1,126 +0,0 @@
-/**
- * CellsStrip.js Date created: 6.04.2007
- * Copyright (c) 2007 Exadel Inc.
- * @author Denis Morozov <dmorozov(a)exadel.com>
- */
-ClientUILib.declarePackage("ClientUI.controls.grid.CellsStrip");
-
-ClientUI.controls.grid.CellsStrip = Class.create({
- CLASSDEF: {
- name: 'ClientUI.controls.grid.CellsStrip'
- }
-
-});
-
-Object.extend(ClientUI.controls.grid.CellsStrip.prototype, {
- columnWidth: 0,
- basePos: 0,
- currOffset: 0,
-
- initialize: function(options) {
- this._hash = [];
- this.columnWidth = 0;
- this.basePos = 0;
-
- if(options) {
- Object.extend(this, options);
- }
- },
-
- length: function() {
- return this._hash.length;
- },
-
- add: function(key, value) {
- value.key = key;
- this._hash.push(value);
- },
-
- remove: function(key) {
- var count = this._hash.length;
- for(var i=0; i<count; i++) {
- if(this._hash[i].key == key) {
- this._hash.slice(i, i);
- break;
- }
- }
- },
-
- // set cells offset
- setOffset: function(offset, updateBasePos, silent) {
- if(!silent) {
- var basePos = this.basePos;
- this._hash.each(function(item){
- item.setOffset(basePos + offset);
- });
- }
-
- this.currOffset = offset;
- if(updateBasePos) {
- this.basePos += offset;
- this.currOffset = 0;
- }
- },
- // set cells width
- setWidth: function(newWidth, silent) {
- if(!silent) {
- this._hash.each(function(item){
- item.setWidth(newWidth);
- });
- }
- this.columnWidth = newWidth;
- },
-
- getWidth: function() {
- return this.columnWidth;
- },
-
- getOffset: function() {
- return this.currOffset;
- }
-});
-
-ClientUI.controls.grid.ColumnCell = Class.create({
- CLASSDEF: {
- name: 'ClientUI.controls.grid.ColumnCell'
- },
- initialize: function(cellObj, parentStrip) {
- this.cellObj = new ClientUI.common.box.Box(cellObj, null, true);
- this.parentStrip = parentStrip;
- },
-
- // shift column cell in horizontal
- setOffset: function(offset, updateBasePos) {
- var newOffset = offset;
- if(this.separator) {
- newOffset += this.parentStrip.getWidth() - this.cellObj.getWidth()/2 - 1;
- }
- this.cellObj.moveToX(newOffset);
- },
-
- // set column width
- setWidth: function(newWidth) {
- if(!this.separator) {
- this.cellObj.setWidth(newWidth);
- if(this.cellObj.getElement().childNodes.length > 0) {
- var childs = $A(this.cellObj.getElement().childNodes);
-
- var fixedWidth = newWidth;
- if(ClientUILib.isGecko) {
- var oldElement = this.cellObj.getElement();
- var i = 0;
- while(i<childs.length && !childs[i].tagName) i++;
- if(i<childs.length) {
- this.cellObj.element = childs[i];
- fixedWidth -= this.cellObj.getBorderWidth("lr") + this.cellObj.getPadding("lr");
- $(childs[i]).setStyle({width: fixedWidth + "px"});
- }
- this.cellObj.element = oldElement;
- }
- }
- }
- else {
- this.setOffset(this.parentStrip.basePos + (newWidth - this.parentStrip.getWidth()));
- }
- }
-});
Modified: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Grid2.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Grid2.js 2007-05-17 18:50:09 UTC (rev 799)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Grid2.js 2007-05-18 10:21:22 UTC (rev 800)
@@ -9,7 +9,6 @@
ClientUILib.requireClass("ClientUI.controls.grid.GridHeader");
ClientUILib.requireClass("ClientUI.controls.grid.GridBody");
ClientUILib.requireClass("ClientUI.controls.grid.GridFooter");
-ClientUILib.requireClass("ClientUI.controls.grid.CellsStrip");
/*
* grid.js - Grid library on top of Prototype
@@ -44,6 +43,10 @@
* Occured when content header clicked
*/
eventOnSort: {},
+ /**
+ * Occured when column width adjusted
+ */
+ eventOnResizeColumn: {},
initialize: function(element, dataModel, templates) {
ClientUI.controls.grid.Grid.parentClass.constructor().call(this, element);
@@ -54,6 +57,7 @@
this.templates = $A(templates);
this.eventOnSort = new ClientUI.common.utils.CustomEvent('OnSort');
+ this.eventOnResizeColumn = new ClientUI.common.utils.CustomEvent('OnResizeColumn');
this.createControl();
},
@@ -138,7 +142,8 @@
this.getHeader().adjustColumnWidth(index, width);
this.getBody().adjustColumnWidth(index, width);
this.getFooter().adjustColumnWidth(index, width);
- this.updateLayout();
+ this.updateLayout();
+ this.eventOnResizeColumn.fire(index, width);
},
adjustScrollPosition: function(pos) {
if(pos<0) {pos = 0;}
@@ -147,26 +152,15 @@
this.getBody().adjustScrollPosition(pos);
if(this.getFooter()) {this.getFooter().adjustScrollPosition(pos);}
},
- loadData: function() {
- this.getBody().adjustDataPosition(0);
+ getScrollOffset: function() {
+ return this.currentScrollPos;
},
- frozeColumn: function(index, froze) {
- if(index<0 || index>=this.getHeader().getColumns().length)
- return false;
- this.getHeader().getColumns()[index].frozen = froze;
- },
setColumnMinWidth: function(index, width) {
if(index<0 || index>=this.getHeader().getColumns().length)
return false;
this.getHeader().getColumns()[index].minWidth = width;
return true;
},
- _isSeparator: function(element) {
- return Element.hasClassName(element, this.getHeader().CLASSDEF.sepStyleClass);
- },
- _isCell: function(element) {
- return element.tagName && element.tagName.toLowerCase()!="iframe";
- },
getColumnsTotalWidth: function() {
var totalWidth = 0;
var columns = this.getHeader().getColumns();
@@ -176,20 +170,22 @@
return totalWidth;
},
getColumnsFrozenWidth: function() {
- /*var totalWidth = 0;
+ var totalWidth = 0;
var columns = this.getHeader().getColumns();
var i = 0;
while(i<columns.length && columns[i].frozen) {
totalWidth += columns[i++].width;
}
- return totalWidth;*/
- return this.getBody().frozenContentBox.getWidth();
+ return totalWidth;
},
invalidate: function(params) {
this.getBody().invalidate(params);
},
- test: function() {
- this.getBody().test();
+ adjustColumnsWidth: function() {
+ var columns = this.getHeader().getColumns();
+ for(var i=0; i<columns.length; i++) {
+ this.adjustColumnWidth(i, columns[i].width);
+ }
}
})
Modified: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody2.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody2.js 2007-05-17 18:50:09 UTC (rev 799)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody2.js 2007-05-18 10:21:22 UTC (rev 800)
@@ -29,18 +29,8 @@
* Count of rows loaded additianally to dataVisible rows
*/
dataDelta: 5,
-
+
/**
- * Contains loaded data
- */
- dataView: [],
-
- /**
- * Pool for rows. Targeted to improve perfomance
- */
- rowsPool: [],
-
- /**
* Current data position
*/
currentPos: 0,
@@ -63,16 +53,22 @@
this.registerEvents();
this.updateLayout();
},
+ registerEvents: function() {
+ Event.observe(this.scrollBox.eventHScroll, "grid body hscroll", this._eventOnHScroll);
+ Event.observe(this.scrollBox.eventVScroll, "grid body vscroll", this._eventOnVScroll);
+ Event.observe(this.grid.dataModel.eventDataReady, "grid data is loaded", this._eventOnDataReady);
+
+ this._eventOnStartLoadData = this.startLoadData.bindAsEventListener(this);
+ },
+ destroy: function() {
+ Event.stopObserving(this.scrollBox.eventHScroll, "grid body hscroll", this._eventOnHScroll);
+ Event.stopObserving(this.scrollBox.eventVScroll, "grid body vscroll", this._eventOnVScroll);
+ Event.stopObserving(this.grid.dataModel.eventDataReady, "grid data is loaded", this._eventOnDataReady);
+ },
// event listeners
_onContentHScroll: function(xpos) {
this.grid.adjustScrollPosition(xpos);
},
- _onContentVScroll: function(ypos) {
- //this.helpObject1.moveToY(this.sizeBox.getHeight()+ this.defaultRowHeight + 5);
- //this.helpObject2.moveToY(this.sizeBox.getHeight()+ this.defaultRowHeight + 5);
- this.setScrollPos(ypos);
- this.adjustDataPosition(ypos);
- },
_onDataReady: function(options) {
// load rows data
var currTime = (new Date()).getTime();
@@ -97,16 +93,12 @@
ClientUILib.log(ClientUILogger.WARNING, "load data delta time: " + (this.taskStartTime - this.taskDefineTime));
ClientUILib.log(ClientUILogger.WARNING, "data prepare time: " + (this.taskStartLoadingTime - this.taskStartTime));
},
- registerEvents: function() {
- Event.observe(this.scrollBox.eventHScroll, "grid body hscroll", this._eventOnHScroll);
- Event.observe(this.scrollBox.eventVScroll, "grid body vscroll", this._eventOnVScroll);
- Event.observe(this.grid.dataModel.eventDataReady, "grid data is loaded", this._eventOnDataReady);
+ _onContentVScroll: function(ypos) {
+ this.helpObject1.moveToY(this.sizeBox.getHeight()+ this.defaultRowHeight + 5);
+ this.helpObject2.moveToY(this.sizeBox.getHeight()+ this.defaultRowHeight + 5);
+ this.setScrollPos(ypos);
+ this.adjustDataPosition(ypos);
},
- destroy: function() {
- Event.stopObserving(this.scrollBox.eventHScroll, "grid body hscroll", this._eventOnHScroll);
- Event.stopObserving(this.scrollBox.eventVScroll, "grid body vscroll", this._eventOnVScroll);
- Event.stopObserving(this.grid.dataModel.eventDataReady, "grid data is loaded", this._eventOnDataReady);
- },
createControl: function(template) {
var childs = template.childNodes;
@@ -128,10 +120,10 @@
var normal = null, frozen = null;
var childs = this.container.getElement().childNodes;
for(var i=0; i<childs.length; i++) {
- if(childs[i].id && childs[i].id == "FrozenBox") {
+ if(childs[i].id && childs[i].id.indexOf("FrozenBox")>=0) {
frozen = childs[i];
}
- else if(childs[i].id && childs[i].id == "NormalBox"){
+ else if(childs[i].id && childs[i].id.indexOf("NormalBox")>=0){
normal = childs[i];
}
}
@@ -146,7 +138,7 @@
this.frozenContentBox = new ClientUI.common.box.Box(frozen);
this.frozenContentBox.makeAbsolute();
- /*
+
this.helpObject1 = new ClientUI.common.box.Box($(document.createElement("img")), this.contentBox.getElement());
this.helpObject1.setWidth(10);
this.helpObject1.setHeight(10);
@@ -155,13 +147,14 @@
this.helpObject2.setWidth(10);
this.helpObject2.setHeight(10);
this.helpObject2.makeAbsolute();
- */
+
// create row template
var ch = this.frozenContentBox.getElement().firstChild;
while(ch) {
if(ch.tagName && ch.tagName.toLowerCase()=="table") {
this.templFrozen = new ClientUI.common.box.Box($(ch), null, true);
+ this.templFrozen.makeAbsolute();
break;
}
ch = ch.nextSibling;
@@ -170,6 +163,7 @@
while(ch) {
if(ch.tagName && ch.tagName.toLowerCase()=="table") {
this.templNormal = new ClientUI.common.box.Box($(ch), null, true);
+ this.templNormal.makeAbsolute();
break;
}
ch = ch.nextSibling;
@@ -200,9 +194,6 @@
return true;
},
- getColumns: function() {
- return this._columns;
- },
setScrollPos: function(pos) {
this.contentBox.getElement().scrollTop = pos;
this.frozenContentBox.getElement().scrollTop = pos;
@@ -219,30 +210,29 @@
if(!this.scrollBox || !this.contentBox || !this.sizeBox) {
return;
}
+
+ var totalWidth = this.grid.getColumnsTotalWidth();
+ this.scrollBox.moveTo(0, 0);
+ this.scrollBox.setWidth(this.getWidth()+1);
+ this.scrollBox.setHeight(this.getHeight()+1);
+ this.scrollBox.setWidth(this.getWidth());
+ this.scrollBox.setHeight(this.getHeight());
var scrollLeft = this.contentBox.getElement().scrollLeft;
var height = this.scrollBox.getViewportHeight();
var fixH = this.grid.getFooter() ? this.grid.getFooter().getHeight() : 0;
if(fixH > height) fixH = 0;
- var totalWidth = this.grid.getColumnsTotalWidth();
+
var frozenContentWidth = this.grid.getColumnsFrozenWidth();
- this.scrollBox.moveTo(0, 0);
- this.sizeBox.moveTo(0, 0);
this.frozenContentBox.moveTo(0, 0);
this.contentBox.moveTo(frozenContentWidth, 0);
-
+ this.sizeBox.moveTo(0, 0);
this.sizeBox.setWidth(totalWidth);
this.sizeBox.setHeight(this.defaultRowHeight * this.grid.dataModel.getCount() + fixH);
- //this.helpObject1.moveToY(this.sizeBox.getHeight()+ this.defaultRowHeight + 5);
- //this.helpObject2.moveToY(this.sizeBox.getHeight()+ this.defaultRowHeight + 5);
-
- // NOTE: this needed to force this.scrollBox update scrolled area
- this.scrollBox.setWidth(this.getWidth()+1);
- this.scrollBox.setHeight(this.getHeight()+1);
- this.scrollBox.setWidth(this.getWidth());
- this.scrollBox.setHeight(this.getHeight());
-
+ this.helpObject1.moveToY(this.sizeBox.getHeight()+ this.defaultRowHeight + 5);
+ this.helpObject2.moveToY(this.sizeBox.getHeight()+ this.defaultRowHeight + 5);
+
this.container.setWidth(totalWidth + 100);
this.contentBox.setWidth(this.scrollBox.getViewportWidth()-frozenContentWidth);
this.contentBox.setHeight(height - fixH);
@@ -251,8 +241,10 @@
var scrollPos = Math.min(totalWidth - frozenContentWidth - this.contentBox.getWidth(), scrollLeft);
this.grid.adjustScrollPosition(scrollPos);
-
+
this.dataVisible = parseInt(this.contentBox.getHeight() / this.defaultRowHeight, 10) + 1;
+ this.dataVisible = Math.min(this.dataVisible, this.rowsCount);
+ //this.dataVisible = this.rowsCount;
if(height > 0) {
this.adjustDataPosition(this.currentPos);
}
@@ -266,182 +258,13 @@
getScrollYPosition: function() {
return this.contentBox.getElement().scrollTop;
},
- _getRowDesc: function(parent, idPrefix, headerRow, headerFrozenRow) {
- var rowDesc = {
- id: headerRow.getElement().id,
- idprefix: idPrefix,
- parent: parent,
- frozen: headerFrozenRow,
- normal: headerRow,
- moveToY: function(y) {
- this.frozen.moveToY(y);
- this.normal.moveToY(y);
- },
- getId: function() {
- return this.id;
- },
- getIdForCell: function(row, column) {
- return "c_"+ row +"_" + column;
- },
- setId: function(id) {
- this.id = id;
- this.frozen.getElement().id = id;
- this.normal.getElement().id = id;
-
- var cellObj, cB;
- var i, index = 0;
- var cnt = this.frozen.getElement().childNodes.length;
- for(i=0; i<cnt; i++) {
- cellObj = this.frozen.getElement().childNodes[i];
- cellObj.id = this.getIdForCell(this.rowindex, index++);
- cellObj.childNodes[0].id = "b"+ cellObj.id;
-
- }
- cnt = this.normal.getElement().childNodes.length;
- for(i=0; i<cnt; i++) {
- cellObj = this.normal.getElement().childNodes[i];
- cellObj.id = this.getIdForCell(this.rowindex, index++);
- cellObj.childNodes[0].id = "b"+ cellObj.id;
- }
- },
- setRowIndex: function(index) {
- this.rowindex = index;
- this.frozen.getElement().rowindex = index;
- this.normal.getElement().rowindex = index;
- this.setId(this.idprefix + this.rowindex);
- },
- setRowClass: function(isOdd) {
- if(isOdd) {
- this.frozen.getElement().removeClassName("ClientUI_Grid_BREven");
- this.normal.getElement().removeClassName("ClientUI_Grid_BREven");
- this.frozen.getElement().addClassName("ClientUI_Grid_BROdd");
- this.normal.getElement().addClassName("ClientUI_Grid_BROdd");
- }
- else {
- this.frozen.getElement().removeClassName("ClientUI_Grid_BROdd");
- this.normal.getElement().removeClassName("ClientUI_Grid_BROdd");
- this.frozen.getElement().addClassName("ClientUI_Grid_BREven");
- this.normal.getElement().addClassName("ClientUI_Grid_BREven");
- }
- },
- setCellValue: function(index, newValue) {
- var i = index;
- var cnt1 = this.frozen.getElement().childNodes.length;
- if(i < cnt1) {
- var cellObj = this.frozen.getElement().childNodes[i];
- Element.update(cellObj.firstChild, newValue);
- return true;
- }
- i -= cnt1;
- var cellObj = this.normal.getElement().childNodes[i];
- Element.update(cellObj.firstChild, newValue);
- return true;
- },
- show: function() {
- this.frozen.show();
- this.normal.show();
- },
- showWaitData: function(show) {
- // process frozen
- var cells = this.frozen.getElement().childNodes;
- var i = 0, startIndex = 0;
- var method = !show ? Element.show : Element.hide;
- for(i=startIndex;i<cells.length; i++) {
- method(cells[i]);
- }
-
- //process normal
- cells = this.normal.getElement().childNodes;
- for(i=0;i<cells.length; i++) {
- method(cells[i]);
- }
- },
- hide: function() {
- this.frozen.hide();
- this.normal.hide();
- },
- showEmpty: function() {
- this.moveToY(this.parent.defaultRowHeight * this.rowindex);
- this.setRowClass(this.rowindex%2 ? false : true);
- //this.show();
- //this.showWaitData(true);
- },
- showNormal: function() {
- this.show();
- this.showWaitData(false);
- },
- loadRowData: function(row, index, rowData) {
-
- // replace data patterns in content with real data from row
- var count = this.parent.grid.getHeader().getColumns().length;
- var columns = this.parent.getColumns();
- for(var i = 0; i<count; i++) {
- var value = this.parent.parseExpression(columns[i].value, rowData, {
- row: index,
- cid: row.getId() + ":" + i,
- rid: row.getId()
- });
- this.setCellValue(i, value);
- }
-
- this.showNormal();
- return true;
- },
- getCellsToUpdate: function() {
- var count = this.parent.grid.getHeader().getColumns().length;
- var ids = [];
- for(var i=0; i<count; i++)
- ids.push("b"+ this.getIdForCell(this.rowindex, i));
- return ids;
- }
- };
-
- return rowDesc;
- },
- /**
- * Parse values of cell's value and title
- * Predefined patterns:
- * - $(row) Index of current row
- * - $(cid) Cell's DOM id
- * - $(rid) Row's DOM id
- * - $(N) Row Data index
- * @param {Object} expr Value to parse. Can be defined over expression in next manner: "$(index_0) and $(index_4) will be over $(index_2) higher!". Where 1,5,3 - indexes in <code>data</code> array param.
- * @param {Object} data Data to replace within expression.
- */
- parseExpression: function(expr, data, params) {
- var pattern = /\$\(row\)/i;
- var rez = expr.gsub(pattern, function(item) {
- return params.row;
- });
- pattern = /\$\(cid\)/i;
- rez = rez.gsub(pattern, function(item) {
- return params.cid;
- })
- pattern = /\$\(rid\)/i;
- rez = rez.gsub(pattern, function(item) {
- return params.rid;
- })
-
- pattern = /\$\((\d*)\)/i;
- rez = rez.gsub(pattern, function(item) {
- if(!item || !item[1]) {
- return "!ERROR!";
- }
- var index = parseFloat(item[1]);
- return data.length > index ? data[index] : "!ERROR!";
- });
-
- return rez;
- },
- deleteRow: function(row) {
- row.hide();
- row.rowindex = -1;
- this.rowsPool.push(row);
- },
adjustDataPosition: function (pos) {
+ if(this.currentPos == pos) {
+ return;
+ }
// 1. calculate direction and range to load next data
- var forwardDir = this.currentPos <= pos;
+ var forwardDir = (this.currentPos <= pos) ? true : false;
this.currentPos = pos;
// first visible row index
@@ -449,8 +272,8 @@
if(first < 0) first = 0;
// TODO: check direction and predict some next rows
- var from = Math.max(first - this.dataDelta, 0);
- var to = Math.min(first + this.dataVisible+this.dataDelta, this.grid.dataModel.getCount());
+ var from = Math.max(first - (forwardDir ? 1 : (this.rowsCount - this.dataVisible - 1)), 0);
+ var to = Math.min(first + (forwardDir ? this.rowsCount-1 : this.dataVisible + 1), this.grid.dataModel.getCount());
var range = $R(from, to);
if(from >= to) {
@@ -459,8 +282,7 @@
}
// stop timed adjusting
- var task = this._getPendingTask();
- clearTimeout(task.timer);
+ var task = this._getPendingTask();
if(to - from > 0) {
task.timer = null;
task.from = from;
@@ -478,14 +300,64 @@
to: 0
};
}
+ else {
+ if(this.pendingTask.timer) {
+ clearTimeout(this.pendingTask.timer);
+ this.pendingTask.timer = null;
+ }
+
+ }
return this.pendingTask;
},
- _setPendingTask: function(task) {
+ _setPendingTask: function(task) {
+ this.pendingTask = task;
+
// and plan other agjusting over the time
+ if(!this.startObserving) {
+ this.startObserving = true;
+
+ Event.observe(document, 'mousemove', this._eventOnStartLoadData);
+ Event.observe(document, 'mouseup', this._eventOnStartLoadData);
+ Event.observe(this.scrollBox.getElement(), 'mouseup', this._eventOnStartLoadData);
+ }
+ },
+ adjustColumnWidth: function(column, width) {
+ var frozenColumns = this.grid.getHeader().headerFrozenRow.getElement().rows[0].cells.length;
+ var realColumn = column;
+ var table = null;
+ if(column < frozenColumns) {
+ table = this.frozenContentBox.getElement();
+ }
+ else {
+ table = this.contentBox.getElement();
+ realColumn -= frozenColumns;
+ }
+
+ var helpObj = this.helpObj;
+ var id = "bc_" + column;
+ var spans = $A(table.getElementsByTagName("span"));
+ spans.each(function(cell) {
+ if(cell.id.indexOf(id)>=0) {
+ helpObj.element = $(cell);
+ helpObj.setWidth(width);
+ }
+ });
+ },
+ startLoadData: function() {
+ if(this.startObserving) {
+ this.startObserving = false;
+ Event.stopObserving(document, 'mousemove', this._eventOnStartLoadData);
+ Event.stopObserving(document, 'mouseup', this._eventOnStartLoadData);
+ Event.stopObserving(this.scrollBox.getElement(), 'mouseup', this._eventOnStartLoadData);
+ }
+
this.taskDefineTime = (new Date()).getTime();
+ var task = this._getPendingTask();
+ // Make timer to handle quick clicks on scrollbar arrows
task.timer = setTimeout(function() {
this.taskStartTime = (new Date()).getTime();
-
+
+ var task = this._getPendingTask();
var range = $R(task.from, task.to);
// if we have intersepted ranges than rearrange rows
@@ -495,12 +367,11 @@
|| this.currRange.start > range.end) {
switchRows = false;
}
-
- this.startIndex = range.start;
- this.countToLoad = range.end - range.start;
-
+
if(!switchRows) {
this.startRow = this.templFrozen.getElement().rows[0].index;
+ this.startIndex = range.start;
+ this.countToLoad = range.end - range.start;
this.prepareRows(0, range.end - range.start);
var pos = this.defaultRowHeight * range.start;
@@ -514,9 +385,10 @@
var normalTbl = this.templNormal.getElement();
if(range.start > this.currRange.start
&& range.start < this.currRange.end) {
-
+
this.countToLoad = range.start - this.currRange.start;
this.startRow = frozenTbl.rows[0].index;
+ this.startIndex = range.start + this.countToLoad;
// store visible row pos to restore after rows reerrange
var visibleRowPos = this.templFrozen.getY() + this.countToLoad * this.defaultRowHeight;
@@ -524,61 +396,80 @@
for(i=0; i<this.countToLoad; i++) {
row = frozenTbl.rows[0];
cloned = row.cloneNode(true);
+ cloned.index = row.index;
frozenTbl.deleteRow(row.rowIndex);
- rownew = frozenTbl.insertRow(this.rowsCount-1);
+ rownew = frozenTbl.insertRow(-1);
rownew.parentNode.replaceChild(cloned,rownew);
row = normalTbl.rows[0];
cloned = row.cloneNode(true);
+ cloned.index = row.index;
normalTbl.deleteRow(row.rowIndex);
- rownew = normalTbl.insertRow(this.rowsCount-1);
+ rownew = normalTbl.insertRow(-1);
rownew.parentNode.replaceChild(cloned,rownew);
}
this.templFrozen.moveToY(visibleRowPos);
- this.templNormal.moveToY(visibleRowPos);
-/*
- // prepare array of column elements for sorting
- var count = this.body.rows.length;
- var elements = new Array(count);
- for(var i=0; i<count; i++) {
- var callbackProc = this.getSortFunction(nColumn);
- elements[i] = { row: this.body.rows[i], element: this.body.rows[i].cells[nColumn], callback: callbackProc };
- }
-
- // sort
- elements.sort(MyTableObject.defaultCompareCallback);
- if (sortOrder == "descending")elements.reverse();
-
- var nextSibling = this.body.nextSibling;
- if (removeChilds) { // remove all rows
- var p = this.body.parentNode;
- p.removeChild(this.body);
- }
-
- // insert in the new order
- var l = elements.length;
- for (var i = 0; i < l; i++)
- this.body.appendChild(elements[i].row);
-
- if(removeChilds)
- p.insertBefore(this.body, nextSibling);
-*/
+ this.templNormal.moveToY(visibleRowPos);
}
else {
this.countToLoad = this.currRange.start - range.start;
+ this.startIndex = range.start;
// store visible row pos to restore after rows reerrange
var visibleRowPos = this.templFrozen.getY() - this.countToLoad * this.defaultRowHeight;
- var frows = [], nrows = [];
+
+ var count = frozenTbl.rows.length;
+ var frows = new Array(count), nrows = new Array(count);
+ var j = 0;
+ for(i=this.rowsCount - this.countToLoad; i<this.rowsCount; i++) {
+ frows[j] = frozenTbl.rows[i];
+ nrows[j] = normalTbl.rows[i];
+ j++;
+ }
+ for(i=0; i<this.rowsCount - this.countToLoad; i++) {
+ frows[j] = frozenTbl.rows[i];
+ nrows[j] = normalTbl.rows[i];
+ j++;
+ }
+
+ // Mozilla is faster when doing the DOM manipulations on
+ // an orphaned element. MSIE is not
+ var removeChilds = navigator.product == "Gecko";
+ var fbody = frozenTbl.tBodies[0];
+ var nbody = normalTbl.tBodies[0];
+ var fnextSibling = fbody.nextSibling;
+ var nnextSibling = nbody.nextSibling;
+
+ if (removeChilds) { // remove all rows
+ fp = fbody.parentNode;
+ fp.removeChild(fbody);
+ np = nbody.parentNode;
+ np.removeChild(nbody);
+ }
+
+ // insert in the new order
+ for (i = 0; i < count; i++) {
+ fbody.appendChild(frows[i]);
+ nbody.appendChild(nrows[i]);
+ }
+
+ if(removeChilds) {
+ fp.insertBefore(fbody, fnextSibling);
+ np.insertBefore(nbody, nnextSibling);
+ }
+
+ /*
for(i=this.rowsCount-1; i>=this.rowsCount - this.countToLoad; i--) {
row = frozenTbl.rows[i];
cloned = row.cloneNode(true);
+ cloned.index = row.index;
frows.push(cloned);
frozenTbl.deleteRow(row.rowIndex);
row = normalTbl.rows[i];
cloned = row.cloneNode(true);
+ cloned.index = row.index;
nrows.push(cloned);
normalTbl.deleteRow(row.rowIndex);
}
@@ -591,14 +482,14 @@
row = nrows[i];
rownew = normalTbl.insertRow(0);
rownew.parentNode.replaceChild(row, rownew);
- }
+ }*/
this.templFrozen.moveToY(visibleRowPos);
this.templNormal.moveToY(visibleRowPos);
- this.startRow = frozenTbl.rows[0].index;
+ this.startRow = frozenTbl.rows[0].index;
}
}
-
+
this.taskStartLoadingTime = (new Date()).getTime();
// 4. start data loading
@@ -608,21 +499,17 @@
count: this.countToLoad,
startRow: this.startRow});
}
-
- clearTimeout(task.timer);
- task.timer = null;
- task.from = 0;
- task.to = 0;
- this.currRange = range;
- }.bind(this), this.grid.dataModel.getRequestDelay());
-
- this.pendingTask = task;
+ this.currRange = range;
+ }.bind(this), 150/*this.grid.dataModel.getRequestDelay()*/);
},
+
+ /**
+ * show hiden rows after loading them from datasource
+ * @param {Object} options
+ */
invalidate: function(options) {
- this.dataView.each(function(row) {
- row.show();
- });
+ // TODO: implement invalidate for body !!
},
/**
@@ -633,27 +520,5 @@
// this.rowsCount
//this.templFrozen.moveToY(pos);
//this.templNormal.moveToY(pos);
- },
- adjustColumnWidth: function(column, width) {
- var frozenColumns = this.grid.getHeader().headerFrozenRow.getElement().rows[0].cells.length;
- var realColumn = column;
- var table = null;
- if(column < frozenColumns) {
- table = this.frozenContentBox.getElement();
- }
- else {
- table = this.contentBox.getElement();
- realColumn -= frozenColumns;
- }
-
- var helpObj = this.helpObj;
- var id = "bc_" + column;
- var spans = $A(table.getElementsByTagName("span"));
- spans.each(function(cell) {
- if(cell.id == id) {
- helpObj.element = $(cell);
- helpObj.setWidth(width);
- }
- });
}
});
Modified: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridFooter2.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridFooter2.js 2007-05-17 18:50:09 UTC (rev 799)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridFooter2.js 2007-05-18 10:21:22 UTC (rev 800)
@@ -45,23 +45,6 @@
this.controlCreated = true;
this.updateLayout();
},
- getRow: function() {
- if(!this.footerRow) {
- var rowDesc = {
- id: "footer",
- frozen: this.headerFrozenRow,
- normal: this.headerRow,
- moveToY: function(y) {
- this.frozen.moveToY(y);
- this.normal.moveToY(y);
- }
- };
-
- this.footerRow = rowDesc;
- }
-
- return this.footerRow;
- },
parseTemplate: function(template) {
if(!template) {
return false;
@@ -78,10 +61,10 @@
var normal = null, frozen = null;
var childs = this.container.childNodes;
for(var i=0; i<childs.length; i++) {
- if(childs[i].id && childs[i].id == "FrozenBox") {
+ if(childs[i].id && childs[i].id.indexOf("FrozenBox")>=0) {
frozen = childs[i];
}
- else if(childs[i].id && childs[i].id == "NormalBox"){
+ else if(childs[i].id && childs[i].id.indexOf("NormalBox")>=0){
normal = childs[i];
}
}
@@ -130,9 +113,6 @@
}
return true;
},
- getColumns: function() {
- return this._columns;
- },
updateLayout: function() {
if(!this.controlCreated || !this.grid.controlCreated) {
return;
@@ -174,7 +154,7 @@
var id = "fc_" + column;
var spans = $A(table.getElementsByTagName("span"));
spans.each(function(cell) {
- if(cell.id == id) {
+ if(cell.id.indexOf(id)>=0) {
helpObj.element = $(cell);
helpObj.setWidth(width);
}
Modified: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridHeader2.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridHeader2.js 2007-05-17 18:50:09 UTC (rev 799)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridHeader2.js 2007-05-18 10:21:22 UTC (rev 800)
@@ -82,10 +82,10 @@
var normal = null, frozen = null;
var childs = this.container.childNodes;
for(var i=0; i<childs.length; i++) {
- if(childs[i].id && childs[i].id == "FrozenBox") {
+ if(childs[i].id && childs[i].id.indexOf("FrozenBox")>=0) {
frozen = childs[i];
}
- else if(childs[i].id && childs[i].id == "NormalBox"){
+ else if(childs[i].id && childs[i].id.indexOf("NormalBox")>=0){
normal = childs[i];
}
}
@@ -223,29 +223,11 @@
this._columns[i].sep.moveToX(offset - 4);
}
},
- getRow: function() {
- if(!this.footerRow) {
- var rowDesc = {
- id: "header",
- frozen: this.headerFrozenRow,
- normal: this.headerRow,
- moveToY: function(y) {
- this.frozen.moveToY(y);
- this.normal.moveToY(y);
- }
- };
-
- this.footerRow = rowDesc;
- }
-
- return this.footerRow;
- },
updateLayout: function() {
if(!this.controlCreated || !this.grid.controlCreated) {
return;
}
ClientUI.controls.grid.GridHeader.parentClass.method("updateLayout").call(this);
-
var height = this.getViewportHeight();
var totalWidth = this.grid.getColumnsTotalWidth();
var frozenContentWidth = this.grid.getColumnsFrozenWidth();
@@ -316,7 +298,7 @@
var pos = this.dragColumnInfo.sep.getX();
if(!this.getColumns()[index].frozen) {
- ;//pos += this.grid.getColumnsFrozenWidth();
+ pos += this.grid.getColumnsFrozenWidth() - this.grid.getScrollOffset();
}
this.dragColumnInfo.originalX = pos;
this.columnSplitter.show();
@@ -428,6 +410,7 @@
});
}
- this._columns[column].width = width;
+ this._columns[column].width = width;
+ this.agjustSeparators();
}
});
17 years, 8 months
JBoss Rich Faces SVN: r799 - trunk/sandbox-samples/scrollable-grid-demo/src/main/webapp/pages.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-05-17 14:50:09 -0400 (Thu, 17 May 2007)
New Revision: 799
Modified:
trunk/sandbox-samples/scrollable-grid-demo/src/main/webapp/pages/scrollable-grid.xhtml
Log:
Modified: trunk/sandbox-samples/scrollable-grid-demo/src/main/webapp/pages/scrollable-grid.xhtml
===================================================================
--- trunk/sandbox-samples/scrollable-grid-demo/src/main/webapp/pages/scrollable-grid.xhtml 2007-05-17 18:46:57 UTC (rev 798)
+++ trunk/sandbox-samples/scrollable-grid-demo/src/main/webapp/pages/scrollable-grid.xhtml 2007-05-17 18:50:09 UTC (rev 799)
@@ -36,7 +36,14 @@
<f:view>
<h:form>
- <sg:scrollable-grid value="#{selectionBean.dataModel}" var="issues" frozenColCount="2" first="0" rows="30">
+ <sg:scrollable-grid value="#{selectionBean.dataModel}"
+ var="issues"
+ frozenColCount="2"
+ first="0"
+ rows="40"
+ width="800px"
+ height="500px">
+
<sg:column width="200px">
<f:facet name="header">
<h:outputText value="Key"></h:outputText>
17 years, 8 months
JBoss Rich Faces SVN: r798 - trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid.
by richfaces-svn-commits@lists.jboss.org
Author: abelevich
Date: 2007-05-17 14:46:57 -0400 (Thu, 17 May 2007)
New Revision: 798
Added:
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridFooter2.js
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridHeader2.js
Modified:
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Grid2.js
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody2.js
trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridHeader.js
Log:
Modified: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Grid2.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Grid2.js 2007-05-17 18:46:43 UTC (rev 797)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/Grid2.js 2007-05-17 18:46:57 UTC (rev 798)
@@ -7,7 +7,7 @@
ClientUILib.requireClass("ClientUI.common.box.Box");
ClientUILib.requireClass("ClientUI.controls.grid.GridHeader");
-ClientUILib.requireClass("ClientUI.controls.grid.GridBody2");
+ClientUILib.requireClass("ClientUI.controls.grid.GridBody");
ClientUILib.requireClass("ClientUI.controls.grid.GridFooter");
ClientUILib.requireClass("ClientUI.controls.grid.CellsStrip");
@@ -30,23 +30,23 @@
* var grid = new ClientUI.controls.grid.Grid('id_of_trigger_element', 'a nice description')
* </script>
*/
-ClientUI.controls.grid.Grid2 = Class.create({
+ClientUI.controls.grid.Grid = Class.create({
CLASSDEF: {
- name: 'ClientUI.controls.grid.Grid2',
+ name: 'ClientUI.controls.grid.Grid',
parent: ClientUI.common.box.Box
}
});
-Object.extend(ClientUI.controls.grid.Grid2.prototype, {
+Object.extend(ClientUI.controls.grid.Grid.prototype, {
// Custom events
/**
* Occured when content header clicked
*/
eventOnSort: {},
- initialize: function(element, dataModel, templates, options) {
- ClientUI.controls.grid.Grid2.parentClass.constructor().call(this, element);
+ initialize: function(element, dataModel, templates) {
+ ClientUI.controls.grid.Grid.parentClass.constructor().call(this, element);
if(!element || !element.id)
this.element.id = "ClientUI_Grid" + ClientUI_controls_grid_Grid_idGenerator++;
@@ -55,62 +55,72 @@
this.eventOnSort = new ClientUI.common.utils.CustomEvent('OnSort');
- // grid options
- this.options = {
- showIndexColumn: false,
- indexColumnWidth: 30
- };
- if(options) { Object.extend(this.options, options); }
-
this.createControl();
},
createControl: function() {
+ //TODO: delete
+ document.gridStartTime = (new Date()).getTime();
+
var grid = this;
var layout = new ClientUI.layouts.GridLayoutManager(null, this.getElement());
this.layout = layout;
-
+
this.templates.each(function(item) {
switch(item.pane) {
- case GridLayout_Enum.HEADER:
+ case GridLayout_Enum.HEADER: {
+ //TODO: delete
+ document.headerStartTime = (new Date()).getTime();
+
var header = new ClientUI.controls.grid.GridHeader($(item.ref), grid);
layout.addPane(GridLayout_Enum.HEADER, header);
+
+ //TODO: delete
+ document.headerStopTime = (new Date()).getTime();
+
break;
- case GridLayout_Enum.BODY:
- var body = new ClientUI.controls.grid.GridBody2($(item.ref), grid);
+ }
+ case GridLayout_Enum.BODY: {
+ //TODO: delete
+ document.bodyStartTime = (new Date()).getTime();
+
+ var body = new ClientUI.controls.grid.GridBody($(item.ref), grid);
layout.addPane(GridLayout_Enum.BODY, body);
+
+ //TODO: delete
+ document.bodyStopTime = (new Date()).getTime();
+
break;
- case GridLayout_Enum.FOOTER:
+ }
+ case GridLayout_Enum.FOOTER: {
+ //TODO: delete
+ document.footerStartTime = (new Date()).getTime();
+
var footer = new ClientUI.controls.grid.GridFooter($(item.ref), grid);
layout.addPane(GridLayout_Enum.FOOTER, footer);
+
+ //TODO: delete
+ document.footerStopTime = (new Date()).getTime();
+
break;
+ }
}
});
- // create cells strips
- this._columnsStrip = [];
- var columns = this.getHeader().getColumns();
- for(var i=0; i<columns.length; i++) {
- this._columnsStrip[i] = new ClientUI.controls.grid.CellsStrip({
- columnWidth: columns[i].object.getWidth(),
- basePos: columns[i].object.getX(),
- frozen: columns[i].frozen
- });
- }
+ //TODO: delete
+ document.gridParseTime = (new Date()).getTime();
- this._parseRowAndAddToStrips("header", this.getHeader().getRow());
- if(this.getFooter()) {
- this._parseRowAndAddToStrips("footer", this.getFooter().getRow());
- }
-
this.currentScrollPos = 0;
this.controlCreated = true;
this.updateLayout();
+
+ //TODO: delete
+ document.gridEndTime = (new Date()).getTime();
},
updateLayout: function() {
if(!this.controlCreated) {
return;
}
- ClientUI.controls.grid.Grid2.parentClass.method("updateLayout").call(this);
+ ClientUI.controls.grid.Grid.parentClass.method("updateLayout").call(this);
if(this.layout) {
this.layout.updateLayout();
}
@@ -124,71 +134,15 @@
getBody: function() {
return this.layout.getPane(GridLayout_Enum.BODY);
},
- _getVisibleHeaderControls: function() {
- var controls = [];
- var columns = this.getHeader().getColumns();
- columns.each(function(column){
- var ctrls = $A(column.body.getElement().getElementsByTagName("select"));
- ctrls.each(function(ctrl){
- if(Element.visible(ctrl)) {
- controls.push(ctrl);
- }
- });
- });
- return controls;
- },
adjustColumnWidth: function(index, width) {
- var oldWidth = this.getHeader().getColumns()[index].object.getWidth();
-
- // 1. set new width
- this._columnsStrip[index].setWidth(width);
-
- // Hide controls in IE that flipped in other case
- var ctrlsIE = [];
- if(ClientUILib.isIE) {
- ctrlsIE = this._getVisibleHeaderControls();
- ctrlsIE.each(function(ctrl){
- Element.hide(ctrl);
- });
- }
-
- // 2. shift right side columns
- if(index < this._columnsStrip.length-1) {
- var count = this._columnsStrip.length;
- if(this._columnsStrip[index].frozen) {
- // if current column is frozen, lets find last frozen column index
- var i=index+1;
- while(this._columnsStrip[i].frozen && i<count) {
- i++;
- }
- count = i;
- }
-
- var offset = width - oldWidth;
- for(var i=index+1; i<count; i++) {
- this._columnsStrip[i].setOffset(offset, true);
- }
- }
-
+ this.getHeader().adjustColumnWidth(index, width);
this.getBody().adjustColumnWidth(index, width);
- this.updateLayout();
-
- if(ClientUILib.isIE) {
- ctrlsIE.each(function(ctrl){
- Element.show(ctrl);
- });
- }
+ this.getFooter().adjustColumnWidth(index, width);
+ this.updateLayout();
},
adjustScrollPosition: function(pos) {
if(pos<0) {pos = 0;}
this.currentScrollPos = pos;
- var i=0;
- while(i<this._columnsStrip.lenth && this._columnsStrip[i].frozen) i++;
- if(i<this._columnsStrip.length) {
- while(i<this._columnsStrip.length) {
- this._columnsStrip[i++].setOffset(pos, false, true);
- }
- }
this.getHeader().adjustScrollPosition(pos);
this.getBody().adjustScrollPosition(pos);
if(this.getFooter()) {this.getFooter().adjustScrollPosition(pos);}
@@ -213,93 +167,23 @@
_isCell: function(element) {
return element.tagName && element.tagName.toLowerCase()!="iframe";
},
- // helper method parse row of elements and add separately into rows and columns list
- _parseRowAndAddToStrips: function(id, object) {
- var i=0, j=0, cells, cell, count=0;
- if(object.frozen && object.normal) {
- // process frozen columns
- cells = object.frozen.getElement().childNodes;
- count = cells.length;
- for(i=0, j=0; i<count; i++) {
- cell = cells[i];
- if(this._isCell(cell) && !this._isSeparator(cell)) {
- this._columnsStrip[j].add(id, new ClientUI.controls.grid.ColumnCell(
- cell,
- this._columnsStrip[j]));
- j++;
- }
- }
- var sripIndex = j;
- for(i=0, j=0; i<count; i++) { // process separators
- cell = cells[i];
- if(this._isSeparator(cell)) {
- var columnCell = new ClientUI.controls.grid.ColumnCell(
- cell,
- this._columnsStrip[j]);
- columnCell.separator = true;
- this._columnsStrip[j].add(id, columnCell);
- j++;
- }
- }
-
- // process normal columns
- i = sripIndex;
- cells = object.normal.getElement().childNodes;
- for(j=0; j<cells.length; j++) {
- cell = cells[j];
- if(this._isCell(cell) && !this._isSeparator(cell)) {
- this._columnsStrip[i].add(id, new ClientUI.controls.grid.ColumnCell(
- cell,
- this._columnsStrip[i]));
- i++;
- }
- }
- i = sripIndex;
- for(j=0; j<cells.length; j++) { // process separators
- cell = cells[j];
- if(this._isSeparator(cell)) {
- var columnCell = new ClientUI.controls.grid.ColumnCell(
- cell,
- this._columnsStrip[i]);
- columnCell.separator = true;
- this._columnsStrip[i].add(id, columnCell);
- i++;
- }
- }
- }
- },
- _getParsedRowsCount: function() {
- return this._columnsStrip[0].length();
- },
- _removeRowFromStrips: function(id) {
- this._columnsStrip.each(function(strip){
- strip.remove(id);
- });
- },
- getColumnScrollX: function(index) {
- if(index) {
- return index<this._columnsStrip.length ? this._columnsStrip[index].currOffset : this.currentScrollPos;
- }
-
- return this.currentScrollPos;
- },
getColumnsTotalWidth: function() {
var totalWidth = 0;
- this.getHeader().getColumns().each(function(column){
- totalWidth += column.object.getWidth();
- });
-
+ var columns = this.getHeader().getColumns();
+ for(var i=0; i<columns.length; i++) {
+ totalWidth += columns[i].width;
+ }
return totalWidth;
},
getColumnsFrozenWidth: function() {
- var totalWidth = 0;
+ /*var totalWidth = 0;
var columns = this.getHeader().getColumns();
var i = 0;
while(i<columns.length && columns[i].frozen) {
- totalWidth += columns[i++].object.getWidth();
+ totalWidth += columns[i++].width;
}
- return totalWidth;
-
+ return totalWidth;*/
+ return this.getBody().frozenContentBox.getWidth();
},
invalidate: function(params) {
this.getBody().invalidate(params);
Modified: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody2.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody2.js 2007-05-17 18:46:43 UTC (rev 797)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridBody2.js 2007-05-17 18:46:57 UTC (rev 798)
@@ -3,7 +3,7 @@
*
* ...
*/
-ClientUILib.declarePackage("ClientUI.controls.grid.GridBody2");
+ClientUILib.declarePackage("ClientUI.controls.grid.GridBody");
ClientUILib.requireClass("ClientUI.common.box.Box");
@@ -11,15 +11,15 @@
* GridHeader.js - Grid control header pane
* TODO: add comments
*/
-ClientUI.controls.grid.GridBody2 = Class.create({
+ClientUI.controls.grid.GridBody = Class.create({
CLASSDEF: {
- name: 'ClientUI.controls.grid.GridBody2',
+ name: 'ClientUI.controls.grid.GridBody',
parent: ClientUI.common.box.Box
}
});
-Object.extend(ClientUI.controls.grid.GridBody2.prototype, {
+Object.extend(ClientUI.controls.grid.GridBody.prototype, {
/**
* Count of rows can be viewed in the same time in grid
*/
@@ -52,8 +52,7 @@
*/
initialize: function(template, grid) {
this.grid = grid;
- ClientUI.controls.grid.GridBody2.parentClass.constructor().call(this, null, grid.getElement());
- this.element.id = this.grid.getElement().id + "_Body";
+ ClientUI.controls.grid.GridBody.parentClass.constructor().call(this, template);
// declare event listeners
this._eventOnHScroll = this._onContentHScroll.bind(this);
@@ -69,8 +68,8 @@
this.grid.adjustScrollPosition(xpos);
},
_onContentVScroll: function(ypos) {
- this.helpObject1.moveToY(this.sizeBox.getHeight()+ this.defaultRowHeight + 5);
- this.helpObject2.moveToY(this.sizeBox.getHeight()+ this.defaultRowHeight + 5);
+ //this.helpObject1.moveToY(this.sizeBox.getHeight()+ this.defaultRowHeight + 5);
+ //this.helpObject2.moveToY(this.sizeBox.getHeight()+ this.defaultRowHeight + 5);
this.setScrollPos(ypos);
this.adjustDataPosition(ypos);
},
@@ -90,7 +89,6 @@
// This trick to force IE rerender rows
if(ClientUILib.isIE && !ClientUILib.isIE7) {
this.setScrollPos(this.currentPos);
- this.adjustScrollPosition(this.grid.getColumnScrollX());
}
*/
@@ -110,17 +108,25 @@
Event.stopObserving(this.grid.dataModel.eventDataReady, "grid data is loaded", this._eventOnDataReady);
},
createControl: function(template) {
- // validate template
- template.parentNode.removeChild(template);
+ var childs = template.childNodes;
+ for(var i=0; i<childs.length; i++) {
+ if(childs[i].tagName && childs[i].tagName.toLowerCase() == "div") {
+ this.container = new ClientUI.common.box.Box(childs[i], null, true);
+ break;
+ }
+ }
+
// create scroll box
this.scrollBox = new ClientUI.common.box.ScrollableBox(null, this.getElement());
this.scrollBox.makeAbsolute();
+ this.scrollBox.setWidth(this.getWidth());
+ this.scrollBox.setHeight(this.getHeight());
this.sizeBox = new ClientUI.common.box.Box(null, this.scrollBox.getElement());
this.sizeBox.makeAbsolute();
var normal = null, frozen = null;
- var childs = $(template).childNodes;
+ var childs = this.container.getElement().childNodes;
for(var i=0; i<childs.length; i++) {
if(childs[i].id && childs[i].id == "FrozenBox") {
frozen = childs[i];
@@ -130,17 +136,17 @@
}
}
- if(normal) {
- this.contentBox = new ClientUI.common.box.Box(normal);
- this.contentBox.setParent(this.getElement());
- this.contentBox.makeAbsolute();
+ if(!normal || !frozen) {
+ errMsg = "Unable to parse template for GridBody. Unable to find FrozenBox or NormalBox.";
+ ClientUILib.log(ClientUILogger.ERROR, errMsg);
+ throw(errMsg);
}
- if(frozen) {
- this.frozenContentBox = new ClientUI.common.box.Box(frozen);
- this.frozenContentBox.setParent(this.getElement());
- this.frozenContentBox.makeAbsolute();
- }
+ this.contentBox = new ClientUI.common.box.Box(normal);
+ this.contentBox.makeAbsolute();
+ this.frozenContentBox = new ClientUI.common.box.Box(frozen);
+ this.frozenContentBox.makeAbsolute();
+ /*
this.helpObject1 = new ClientUI.common.box.Box($(document.createElement("img")), this.contentBox.getElement());
this.helpObject1.setWidth(10);
this.helpObject1.setHeight(10);
@@ -149,28 +155,27 @@
this.helpObject2.setWidth(10);
this.helpObject2.setHeight(10);
this.helpObject2.makeAbsolute();
+ */
// create row template
- var ch = this.contentBox.getElement().firstChild;
+ var ch = this.frozenContentBox.getElement().firstChild;
while(ch) {
if(ch.tagName && ch.tagName.toLowerCase()=="table") {
- this.templNormal = new ClientUI.common.box.Box($(ch), null, true);
+ this.templFrozen = new ClientUI.common.box.Box($(ch), null, true);
break;
}
ch = ch.nextSibling;
}
- ch = this.frozenContentBox.getElement().firstChild;
+ ch = this.contentBox.getElement().firstChild;
while(ch) {
if(ch.tagName && ch.tagName.toLowerCase()=="table") {
- this.templFrozen = new ClientUI.common.box.Box($(ch), null, true);
+ this.templNormal = new ClientUI.common.box.Box($(ch), null, true);
break;
}
ch = ch.nextSibling;
}
- this.parseTemplate(this.templFrozen.getElement(), this.templNormal.getElement());
- this.updateColumns();
- // control created
+ this.parseTemplate(this.templFrozen.getElement(), this.templNormal.getElement());
this.controlCreated = true;
},
parseTemplate: function(templFrozen, templNormal) {
@@ -195,13 +200,6 @@
return true;
},
- updateColumns: function() {
- var width = 0;
- var columns = this.grid.getHeader().getColumns();
- for(var i=0; i<columns.length; i++) {
- this.adjustColumnWidth(i, columns[i].width);
- }
- },
getColumns: function() {
return this._columns;
},
@@ -217,11 +215,11 @@
if(!this.controlCreated || !this.grid.controlCreated) {
return;
}
- ClientUI.controls.grid.GridBody2.parentClass.method("updateLayout").call(this);
+ ClientUI.controls.grid.GridBody.parentClass.method("updateLayout").call(this);
if(!this.scrollBox || !this.contentBox || !this.sizeBox) {
return;
}
-
+
var scrollLeft = this.contentBox.getElement().scrollLeft;
var height = this.scrollBox.getViewportHeight();
var fixH = this.grid.getFooter() ? this.grid.getFooter().getHeight() : 0;
@@ -236,8 +234,8 @@
this.sizeBox.setWidth(totalWidth);
this.sizeBox.setHeight(this.defaultRowHeight * this.grid.dataModel.getCount() + fixH);
- this.helpObject1.moveToY(this.sizeBox.getHeight()+ this.defaultRowHeight + 5);
- this.helpObject2.moveToY(this.sizeBox.getHeight()+ this.defaultRowHeight + 5);
+ //this.helpObject1.moveToY(this.sizeBox.getHeight()+ this.defaultRowHeight + 5);
+ //this.helpObject2.moveToY(this.sizeBox.getHeight()+ this.defaultRowHeight + 5);
// NOTE: this needed to force this.scrollBox update scrolled area
this.scrollBox.setWidth(this.getWidth()+1);
@@ -245,10 +243,11 @@
this.scrollBox.setWidth(this.getWidth());
this.scrollBox.setHeight(this.getHeight());
+ this.container.setWidth(totalWidth + 100);
this.contentBox.setWidth(this.scrollBox.getViewportWidth()-frozenContentWidth);
this.contentBox.setHeight(height - fixH);
this.frozenContentBox.setWidth(frozenContentWidth);
- this.frozenContentBox.setHeight(height - fixH);
+ this.frozenContentBox.setHeight(height - fixH);
var scrollPos = Math.min(totalWidth - frozenContentWidth - this.contentBox.getWidth(), scrollLeft);
this.grid.adjustScrollPosition(scrollPos);
@@ -346,10 +345,6 @@
// process frozen
var cells = this.frozen.getElement().childNodes;
var i = 0, startIndex = 0;
- if(this.parent.grid.options.showIndexColumn) {
- startIndex = 1;
- this.setCellValue(0, ""+this.rowindex);
- }
var method = !show ? Element.show : Element.hide;
for(i=startIndex;i<cells.length; i++) {
method(cells[i]);
@@ -380,8 +375,7 @@
// replace data patterns in content with real data from row
var count = this.parent.grid.getHeader().getColumns().length;
var columns = this.parent.getColumns();
- var i = this.parent.grid.options.showIndexColumn ? 1 : 0;
- for(; i<count; i++) {
+ for(var i = 0; i<count; i++) {
var value = this.parent.parseExpression(columns[i].value, rowData, {
row: index,
cid: row.getId() + ":" + i,
@@ -404,38 +398,6 @@
return rowDesc;
},
- createRow: function() {
- var row = null;
- var rowFrozen = null;
- if(this.templateRow) { // use existing template to inherit cell's width & offset
- row = this.templateRow.normal.getElement().cloneNode(true);
- rowFrozen = this.templateRow.frozen.getElement().cloneNode(true);
- }
- else { // first time
- row = this.headerRowTemplate.getElement().cloneNode(true);
- rowFrozen = this.headerFrozenRowTemplate.getElement().cloneNode(true);
- }
-
- var headerRow = new ClientUI.common.box.InlineBox(row, this.contentBox.getElement(), true);
- headerRow.setParent(this.contentBox.getElement());
- var headerFrozenRow = new ClientUI.common.box.InlineBox(rowFrozen, this.frozenContentBox.getElement(), true);
- headerFrozenRow.setParent(this.frozenContentBox.getElement());
-
- var rowDesc = this._getRowDesc(this, this.getElement().id + "BR", headerRow, headerFrozenRow);
-
- // create sample row that will be cloned
- if(!this.templateRow) {
- this.templateRow = rowDesc;
- this.templateRow.setId("trow");
- this.grid._parseRowAndAddToStrips(this.templateRow.id, this.templateRow);
- this.templateRow.setRowIndex(-100);
- this.templateRow.showEmpty();
- this.templateRow.hide();
- }
-
- this.grid._parseRowAndAddToStrips("" + (this.grid._getParsedRowsCount()+1), rowDesc);
- return rowDesc;
- },
/**
* Parse values of cell's value and title
* Predefined patterns:
@@ -471,21 +433,6 @@
return rez;
},
- loadRow: function(index, id) {
- var row = null;
- if(this.dataViewHash) {
- row = this.dataViewHash[index];
- }
- if(row) {
- var rowData = this.grid.dataModel.getRow(index);
- if(rowData && rowData.length && rowData.length > 0) {
- row.loadRowData(row, index, rowData);
- }
- }
- },
- getRow: function() {
- return this.rowsPool.length>0 ? this.rowsPool.pop() : this.createRow();
- },
deleteRow: function(row) {
row.hide();
row.rowindex = -1;
@@ -688,34 +635,25 @@
//this.templNormal.moveToY(pos);
},
adjustColumnWidth: function(column, width) {
- var w = width, ch;
- var frozenColumns = this.templFrozen.getElement().rows[0].cells.length;
+ var frozenColumns = this.grid.getHeader().headerFrozenRow.getElement().rows[0].cells.length;
var realColumn = column;
var table = null;
if(column < frozenColumns) {
- table = this.templFrozen.getElement();
+ table = this.frozenContentBox.getElement();
}
else {
- table = this.templNormal.getElement();
+ table = this.contentBox.getElement();
realColumn -= frozenColumns;
}
- for(var i=0; i<this.rowsCount; i++) {
- var childs = table.rows[i].cells[realColumn].childNodes;
- for (var j=0; j<childs.length; j++) {
- ch = childs[j];
- if(ch.tagName && ch.tagName.toLowerCase() == "span") {
-
- w = width;
- if(ClientUILib.isGecko) {
- this.helpObj.element = ch.parentNode;
- w -= this.helpObj.getBorderWidth("lr") + this.helpObj.getPadding("lr");
- }
- this.helpObj.element = $(ch);
- this.helpObj.setWidth(w);
- break;
- }
- }
- }
+ var helpObj = this.helpObj;
+ var id = "bc_" + column;
+ var spans = $A(table.getElementsByTagName("span"));
+ spans.each(function(cell) {
+ if(cell.id == id) {
+ helpObj.element = $(cell);
+ helpObj.setWidth(width);
+ }
+ });
}
});
Added: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridFooter2.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridFooter2.js (rev 0)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridFooter2.js 2007-05-17 18:46:57 UTC (rev 798)
@@ -0,0 +1,183 @@
+/*
+ * TODO: Copyright (c) 2007 Denis Morozov <dmorozov(a)exadel.com>
+ *
+ * ...
+ */
+ClientUILib.declarePackage("ClientUI.controls.grid.GridFooter");
+
+ClientUILib.requireClass("ClientUI.common.box.Box");
+
+/*
+/* GridHeader.js - Grid control header pane
+ * TODO: add comments
+ */
+ClientUI.controls.grid.GridFooter = Class.create({
+ CLASSDEF: {
+ name: 'ClientUI.controls.grid.GridFooter',
+ parent: ClientUI.common.box.Box
+ }
+
+});
+
+Object.extend(ClientUI.controls.grid.GridFooter.prototype, {
+ initialize: function(template, grid) {
+ this.grid = grid;
+ ClientUI.controls.grid.GridFooter.parentClass.constructor().call(this, template);
+ this.createControl(template);
+ },
+ createControl: function(template) {
+ var errMsg = "";
+ if(!template) {
+ errMsg = "Invalid template specified for GridFooter.";
+ ClientUILib.log(ClientUILogger.ERROR, errMsg);
+ throw(errMsg);
+ }
+
+ if(!this.parseTemplate(template)) {
+ errMsg = "Unable to parse template. GridFooter requires template specified over table element with one row.";
+ ClientUILib.log(ClientUILogger.ERROR, errMsg);
+ throw(errMsg);
+ }
+
+ // Set dimensions
+ this.setHeight(this.defaultHeight);
+ this.setWidth(this.defaultWidth);
+ this.controlCreated = true;
+ this.updateLayout();
+ },
+ getRow: function() {
+ if(!this.footerRow) {
+ var rowDesc = {
+ id: "footer",
+ frozen: this.headerFrozenRow,
+ normal: this.headerRow,
+ moveToY: function(y) {
+ this.frozen.moveToY(y);
+ this.normal.moveToY(y);
+ }
+ };
+
+ this.footerRow = rowDesc;
+ }
+
+ return this.footerRow;
+ },
+ parseTemplate: function(template) {
+ if(!template) {
+ return false;
+ }
+
+ var childs = template.childNodes;
+ for(var i=0; i<childs.length; i++) {
+ if(childs[i].tagName && childs[i].tagName.toLowerCase() == "div") {
+ this.container = $(childs[i]);
+ break;
+ }
+ }
+
+ var normal = null, frozen = null;
+ var childs = this.container.childNodes;
+ for(var i=0; i<childs.length; i++) {
+ if(childs[i].id && childs[i].id == "FrozenBox") {
+ frozen = childs[i];
+ }
+ else if(childs[i].id && childs[i].id == "NormalBox"){
+ normal = childs[i];
+ }
+ }
+
+ if(!normal || !frozen) {
+ errMsg = "Unable to parse template for GridFooter. Unable to find FrozenBox or NormalBox.";
+ ClientUILib.log(ClientUILogger.ERROR, errMsg);
+ throw(errMsg);
+ }
+ this.contentBox = new ClientUI.common.box.Box(normal);
+ this.contentBox.makeAbsolute();
+ this.frozenContentBox = new ClientUI.common.box.Box(frozen);
+ this.frozenContentBox.makeAbsolute();
+
+ // create row template
+ var ch = this.contentBox.getElement().firstChild;
+ while(ch) {
+ if(ch.tagName && ch.tagName.toLowerCase()=="table") {
+ this.headerRow = new ClientUI.common.box.Box($(ch), null, true);
+ break;
+ }
+ ch = ch.nextSibling;
+ }
+ ch = this.frozenContentBox.getElement().firstChild;
+ while(ch) {
+ if(ch.tagName && ch.tagName.toLowerCase()=="table") {
+ this.headerFrozenRow = new ClientUI.common.box.Box($(ch), null, true);
+ break;
+ }
+ ch = ch.nextSibling;
+ }
+
+ this.helpObj = new ClientUI.common.box.Box(this.frozenContentBox.getElement(), null, true);
+ this.defaultWidth = this.grid.getHeader().defaultWidth;
+ this.defaultHeight = Element.getHeight(this.headerRow.getElement().rows[0].cells[0]);
+ if(ClientUILib.isGecko) {
+ this.defaultHeight -= this.getBorderWidth("tb") + this.getPadding("tb");
+ //this.defaultWidth -= this.getBorderWidth("lr") + this.getPadding("lr");
+ }
+
+ if(ClientUILib.isIE) {
+ this.frozenSubstrate = new ClientUI.common.box.Substrate(null, this.getElement());
+ this.frozenSubstrate.getElement().name = this.getElement().id + "FRFrm";
+ Element.addClassName(this.frozenSubstrate.getElement(), "ClientUI_HRFrm");
+ this.frozenSubstrate.setHeight(this.defaultHeight);
+ }
+ return true;
+ },
+ getColumns: function() {
+ return this._columns;
+ },
+ updateLayout: function() {
+ if(!this.controlCreated || !this.grid.controlCreated) {
+ return;
+ }
+ ClientUI.controls.grid.GridFooter.parentClass.method("updateLayout").call(this);
+
+ var height = this.getViewportHeight();
+ var totalWidth = this.grid.getColumnsTotalWidth();
+ var frozenContentWidth = this.grid.getColumnsFrozenWidth();
+
+ this.contentBox.setWidth(Math.max(this.getWidth(), totalWidth));
+ this.contentBox.setHeight(height);
+ this.contentBox.moveTo(frozenContentWidth, 0);
+ this.frozenContentBox.setWidth(frozenContentWidth);
+ this.frozenContentBox.setHeight(height);
+ this.frozenContentBox.moveTo(0, 0);
+ var frozenContentWidth = this.grid.getBody().frozenContentBox.getWidth();
+ var width = frozenContentWidth+this.grid.getBody().contentBox.getWidth();
+ this.setWidth(width);
+ if(ClientUILib.isIE)
+ this.frozenSubstrate.setWidth(frozenContentWidth);
+ },
+ adjustScrollPosition: function(pos) {
+ this.contentBox.moveToX(this.grid.getColumnsFrozenWidth()-pos);
+ },
+ adjustColumnWidth: function(column, width) {
+ var frozenColumns = this.headerFrozenRow.getElement().rows[0].cells.length;
+ var realColumn = column;
+ var table = null;
+ if(column < frozenColumns) {
+ table = this.headerFrozenRow.getElement();
+ }
+ else {
+ table = this.headerRow.getElement();
+ realColumn -= frozenColumns;
+ }
+
+ var helpObj = this.helpObj;
+ var id = "fc_" + column;
+ var spans = $A(table.getElementsByTagName("span"));
+ spans.each(function(cell) {
+ if(cell.id == id) {
+ helpObj.element = $(cell);
+ helpObj.setWidth(width);
+ }
+ });
+ }
+})
Modified: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridHeader.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridHeader.js 2007-05-17 18:46:43 UTC (rev 797)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridHeader.js 2007-05-17 18:46:57 UTC (rev 798)
@@ -45,7 +45,6 @@
// create grid header control
createControl: function(template) {
-
// validate template
var ch = $(template).firstChild;
while(ch) {
@@ -65,12 +64,16 @@
ClientUILib.log(ClientUILogger.ERROR, errMsg);
throw(errMsg);
}
+
if(!this.parseTemplate(this.template)) {
errMsg = "Unable to parse template. GridHeader requires template specified over table element with one row.";
ClientUILib.log(ClientUILogger.ERROR, errMsg);
throw(errMsg);
}
+ //TODO: delete
+ document.generateDOMTime = (new Date()).getTime();
+
this.contentBox = new ClientUI.common.box.Box(null, this.getElement());
this.contentBox.makeAbsolute();
this.frozenContentBox = new ClientUI.common.box.Box(null, this.getElement());
@@ -87,6 +90,8 @@
this.setWidth(this.defaultWidth);
this.controlCreated = true;
this.updateLayout();
+
+ document.generateDOMEndTime = (new Date()).getTime();
},
parseTemplate: function(template) {
if(!template || !template.rows || template.rows.length===0) {
Added: trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridHeader2.js
===================================================================
--- trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridHeader2.js (rev 0)
+++ trunk/sandbox/scrollable-grid/src/main/javascript/ClientUI/controls/grid/GridHeader2.js 2007-05-17 18:46:57 UTC (rev 798)
@@ -0,0 +1,433 @@
+/*
+ * TODO: Copyright (c) 2007 Denis Morozov <dmorozov(a)exadel.com>
+ *
+ * ...
+ */
+ClientUILib.declarePackage("ClientUI.controls.grid.GridHeader");
+
+ClientUILib.requireClass("ClientUI.common.box.Box");
+ClientUILib.requireClass("ClientUI.common.box.InlineBox");
+
+/*
+ * GridHeader.js - Grid control header pane
+ * TODO: add comments
+ */
+ClientUI.controls.grid.GridHeader = Class.create({
+ CLASSDEF: {
+ name: 'ClientUI.controls.grid.GridHeader',
+ parent: ClientUI.common.box.Box,
+ sepStyleClass: "ClientUI_Grid_HSep"
+ }
+
+});
+
+Object.extend(ClientUI.controls.grid.GridHeader.prototype, {
+ // internal variables
+ _columns: [],
+
+ // constructor
+ initialize: function(template, grid) {
+ this.grid = grid;
+
+ ClientUI.controls.grid.GridHeader.parentClass.constructor().call(this, template);
+
+ // register event handlers
+ this.eventSepDblClick = this.OnSepDblClick.bindAsEventListener(this);
+ this.eventSepMouseDown = this.OnSepMouseDown.bindAsEventListener(this);
+ this.eventSepMouseUp = this.OnSepMouseUp.bindAsEventListener(this);
+ this.eventSepMouseMove = this.OnSepMouseMove.bindAsEventListener(this);
+ this.eventCellMouseDown = this.OnCellMouseDown.bindAsEventListener(this);
+ Event.observe(document, 'mousemove', this.eventSepMouseMove, true);
+ Event.observe(document, 'mouseup', this.eventSepMouseUp, true);
+
+ this.createControl(template);
+ },
+
+ // create grid header control
+ createControl: function(template) {
+ var errMsg = "";
+ if(!template) {
+ errMsg = "Invalid template specified for GridHeader.";
+ ClientUILib.log(ClientUILogger.ERROR, errMsg);
+ throw(errMsg);
+ }
+
+ if(!this.parseTemplate(template)) {
+ errMsg = "Unable to parse template. GridHeader requires template specified over table element with one row.";
+ ClientUILib.log(ClientUILogger.ERROR, errMsg);
+ throw(errMsg);
+ }
+
+ // Set dimensions
+ this.setHeight(this.defaultHeight);
+ this.setWidth(this.defaultWidth);
+ this.controlCreated = true;
+ this.updateLayout();
+ this.hide();
+ this.show();
+ },
+ parseTemplate: function(template) {
+ if(!template) {
+ return false;
+ }
+
+ var childs = template.childNodes;
+ for(var i=0; i<childs.length; i++) {
+ if(childs[i].tagName && childs[i].tagName.toLowerCase() == "div") {
+ this.container = $(childs[i]);
+ break;
+ }
+ }
+
+ var normal = null, frozen = null;
+ var childs = this.container.childNodes;
+ for(var i=0; i<childs.length; i++) {
+ if(childs[i].id && childs[i].id == "FrozenBox") {
+ frozen = childs[i];
+ }
+ else if(childs[i].id && childs[i].id == "NormalBox"){
+ normal = childs[i];
+ }
+ }
+
+ if(!normal || !frozen) {
+ errMsg = "Unable to parse template for GridHeader. Unable to find FrozenBox or NormalBox.";
+ ClientUILib.log(ClientUILogger.ERROR, errMsg);
+ throw(errMsg);
+ }
+ this.contentBox = new ClientUI.common.box.Box(normal);
+ this.contentBox.makeAbsolute();
+ this.frozenContentBox = new ClientUI.common.box.Box(frozen);
+ this.frozenContentBox.makeAbsolute();
+
+ // create row template
+ var ch = this.contentBox.getElement().firstChild;
+ while(ch) {
+ if(ch.tagName && ch.tagName.toLowerCase()=="table") {
+ this.headerRow = new ClientUI.common.box.Box($(ch), null, true);
+ break;
+ }
+ ch = ch.nextSibling;
+ }
+ ch = this.frozenContentBox.getElement().firstChild;
+ while(ch) {
+ if(ch.tagName && ch.tagName.toLowerCase()=="table") {
+ this.headerFrozenRow = new ClientUI.common.box.Box($(ch), null, true);
+ break;
+ }
+ ch = ch.nextSibling;
+ }
+
+ this.helpObj = new ClientUI.common.box.Box(this.frozenContentBox.getElement(), null, true);
+
+ var columns = [];
+ var defaultWidth = 0;
+ var defaultHeight = 0;
+
+ var eventCellMouseDown = this.eventCellMouseDown.bind(this);
+
+ // Get columns information
+ var i = 0, h;
+ var cells = $A(this.headerFrozenRow.getElement().rows[0].cells);
+ cells.each(function(cell) {
+ columns[i] = {
+ width: Element.getWidth(cell),
+ innerHTML: cell.innerHTML,
+ styleClass: cell.className,
+ id: cell.id,
+ align: cell.align,
+ valign: cell.vAlign,
+ title: cell.title,
+ minWidth: 10,
+ frozen: true,
+ fixedWidth: Validators.getBoolean(cell.getAttribute("fixedWidth"), false),
+ sortable: Validators.getBoolean(cell.getAttribute("sortable"), true),
+ sorted: Validators.getBoolean(cell.getAttribute("sorted"), "desc")
+ };
+
+ if(columns[i].sortable)
+ Event.observe(cell, 'click', eventCellMouseDown);
+ h = Element.getHeight(cell);
+ if(h > defaultHeight) defaultHeight = h;
+ defaultWidth += columns[i].width;
+ columns[i].object = new ClientUI.common.box.InlineBox(cell, null, true);
+ i++;
+ });
+
+ cells = $A(this.headerRow.getElement().rows[0].cells);
+ cells.each(function(cell) {
+ columns[i] = {
+ width: Element.getWidth(cell),
+ innerHTML: cell.innerHTML,
+ styleClass: cell.className,
+ id: cell.id,
+ align: cell.align,
+ valign: cell.vAlign,
+ title: cell.title,
+ minWidth: 10,
+ frozen: false,
+ fixedWidth: Validators.getBoolean(cell.getAttribute("fixedWidth"), false),
+ sortable: Validators.getBoolean(cell.getAttribute("sortable"), true),
+ sorted: Validators.getBoolean(cell.getAttribute("sorted"), "desc")
+ };
+
+ if(columns[i].sortable)
+ Event.observe(cell, 'click', eventCellMouseDown);
+ h = Element.getHeight(cell);
+ if(h > defaultHeight) defaultHeight = h;
+ defaultWidth += columns[i].width;
+ columns[i].object = new ClientUI.common.box.InlineBox(cell, null, true);
+ i++;
+ });
+
+ this._columns = columns;
+ this.defaultHeight = defaultHeight;
+ this.defaultWidth = defaultWidth;
+ if(ClientUILib.isGecko) {
+ this.defaultWidth -= this.getBorderWidth("lr") + this.getPadding("lr");
+ this.defaultHeight -= this.getBorderWidth("tb") + this.getPadding("tb");
+ }
+
+ var sep, column;
+ var seps = document.getElementsByClassName("ClientUI_Grid_HSep", this.getElement());
+ for(i = 0; i<seps.length; i++) {
+ sep = seps[i];
+ column = parseInt(sep.getAttribute("column"));
+ this._columns[column].sep = new ClientUI.common.box.InlineBox(sep, null, true);
+ sep.columnIndex = column;
+ if(!this._columns[column].fixedWidth) {
+ Event.observe(sep, 'dblclick', this.eventSepDblClick);
+ Event.observe(sep, 'mousedown', this.eventSepMouseDown);
+ }
+ else {
+ sep.setStyle({cursor: 'auto'});
+ }
+ }
+ this.agjustSeparators();
+
+ if(ClientUILib.isIE) {
+ this.frozenSubstrate = new ClientUI.common.box.Substrate(null, this.getElement());
+ this.frozenSubstrate.getElement().name = this.getElement().id + "HRFrm";
+ Element.addClassName(this.frozenSubstrate.getElement(), "ClientUI_HRFrm");
+ this.frozenSubstrate.setHeight(this.headerRow.getViewportHeight());
+ }
+
+ return true;
+ },
+ agjustSeparators: function() {
+ var offset = 0;
+ var fcnt = this.headerFrozenRow.getElement().rows[0].cells.length;
+ for(var i=0; i<this._columns.length; i++) {
+ if(i == fcnt) offset = 0;
+ offset += this._columns[i].width;
+ this._columns[i].sep.moveToX(offset - 4);
+ }
+ },
+ getRow: function() {
+ if(!this.footerRow) {
+ var rowDesc = {
+ id: "header",
+ frozen: this.headerFrozenRow,
+ normal: this.headerRow,
+ moveToY: function(y) {
+ this.frozen.moveToY(y);
+ this.normal.moveToY(y);
+ }
+ };
+
+ this.footerRow = rowDesc;
+ }
+
+ return this.footerRow;
+ },
+ updateLayout: function() {
+ if(!this.controlCreated || !this.grid.controlCreated) {
+ return;
+ }
+ ClientUI.controls.grid.GridHeader.parentClass.method("updateLayout").call(this);
+
+ var height = this.getViewportHeight();
+ var totalWidth = this.grid.getColumnsTotalWidth();
+ var frozenContentWidth = this.grid.getColumnsFrozenWidth();
+
+ this.contentBox.setWidth(Math.max(this.getWidth(), totalWidth));
+ this.contentBox.setHeight(height);
+ this.contentBox.moveTo(frozenContentWidth, 0);
+ this.frozenContentBox.setWidth(frozenContentWidth);
+ this.frozenContentBox.setHeight(height);
+ this.frozenContentBox.moveTo(0, 0);
+ if(ClientUILib.isIE)
+ this.frozenSubstrate.setWidth(frozenContentWidth);
+ },
+ getColumns: function() {
+ return this._columns;
+ },
+ // lets implement column resizer
+ OnSepMouseDown: function(event) {
+ this.dragColumnInfo = {
+ srcElement: Event.element(event),
+ dragStarted: false,
+ mouseDown: true,
+ startX: Event.pointerX(event),
+ originalX: 0
+ };
+ this.dragColumnInfo.object = this.getColumns()[this.dragColumnInfo.srcElement.columnIndex].object;
+ this.dragColumnInfo.sep = this.getColumns()[this.dragColumnInfo.srcElement.columnIndex].sep;
+ this.dragColumnInfo.minWidth = this.getColumns()[this.dragColumnInfo.srcElement.columnIndex].minWidth;
+
+ Event.stop(event);
+ },
+ OnSepMouseUp: function(event) {
+ if(this.dragColumnInfo && this.dragColumnInfo.dragStarted) {
+ this.dragColumnInfo.dragStarted = false;
+ this.dragColumnInfo.mouseDown = false;
+ var delta = Event.pointerX(event) - this.dragColumnInfo.startX;
+ var newWidth = this.dragColumnInfo.object.getWidth() + delta;
+ setTimeout(function() {
+ this.grid.adjustColumnWidth(this.dragColumnInfo.srcElement.columnIndex, newWidth);
+ }.bind(this), 10);
+ }
+ this._hideSplitter();
+ },
+ OnSepMouseMove: function(event) {
+ if(this.dragColumnInfo && this.dragColumnInfo.mouseDown) {
+ if(!this.dragColumnInfo.dragStarted) {
+ this.dragColumnInfo.dragStarted = true;
+ this._showSplitter(this.dragColumnInfo.srcElement.columnIndex);
+ }
+ else {
+ var delta = Event.pointerX(event) - this.dragColumnInfo.startX;
+ var minColumnWidth = this.dragColumnInfo.object.getWidth() - this.dragColumnInfo.minWidth;
+ if(delta >= -minColumnWidth) {
+ var x = this.dragColumnInfo.originalX + delta;
+ this.columnSplitter.moveToX(x - 6);
+ }
+ }
+ Event.stop(event);
+ }
+ },
+ OnSepDblClick: function(event) {
+ ClientUILib.log(ClientUILogger.INFO, "OnSepDblClick");
+ },
+ _showSplitter: function(index) {
+ if(!this.columnSplitter) {
+ this._createSplitter();
+ }
+
+ var pos = this.dragColumnInfo.sep.getX();
+ if(!this.getColumns()[index].frozen) {
+ ;//pos += this.grid.getColumnsFrozenWidth();
+ }
+ this.dragColumnInfo.originalX = pos;
+ this.columnSplitter.show();
+ this.columnSplitter.setHeight(this.defaultHeight + this.grid.getBody().contentBox.getHeight());
+ this.columnSplitter.moveTo(pos, 0);
+ },
+ _hideSplitter: function() {
+ if(this.columnSplitter) {
+ this.columnSplitter.hide();
+ }
+ },
+ _createSplitter: function() {
+ this.columnSplitter = new ClientUI.common.box.Box(null, this.grid.getElement());
+ this.columnSplitter.makeAbsolute();
+ this.columnSplitter.getElement().addClassName("ClientUI_Grid_HSplit");
+ this.columnSplitter.setWidth(10);
+ this.columnSplitter.getElement().setStyle({backgroundColor: ''});
+ this.columnSplitter.getElement().setStyle({zIndex: '100'});
+ this.columnSplitter.hide();
+ },
+ adjustScrollPosition: function(pos) {
+ this.contentBox.moveToX(this.grid.getColumnsFrozenWidth()-pos);
+ },
+ OnCellMouseDown: function(event) {
+ var el = Event.element(event);
+ while(el && !Element.hasClassName(el, "ClientUI_Grid_HC")) {
+ el = el.parentNode;
+ }
+
+ if(el && el.columnIndex>=0) {
+ var order = this.getColumns()[el.columnIndex].sorted;
+ order = (order == "asc") ? "desc" : "asc";
+ this.getColumns()[el.columnIndex].sorted = order;
+
+ for(var i = 0, len = this.getColumns().length; i < len; i++) {
+ var h = this.getColumns()[i];
+ if(i != el.columnIndex) {
+ Element.setStyle(h.sortDesc, {display: 'none'});
+ Element.setStyle(h.sortAsc, {display: 'none'});
+ } else{
+ Element.setStyle(h.sortDesc, {display: (order == 'desc' ? 'block' : 'none')});
+ Element.setStyle(h.sortAsc, {display: (order == 'asc' ? 'block' : 'none')});
+ }
+ }
+
+ this.grid.eventOnSort.fire(el.columnIndex, order);
+ Event.stop(event);
+ }
+ },
+ _getVisibleHeaderControls: function() {
+ var controls = [];
+ var columns = this.getColumns();
+ columns.each(function(column){
+ var ctrls = column.object.getElement().getElementsByTagName("select");
+ if(ctrls && ctrls.length>0) {
+ ctrls = $A(ctrls);
+ ctrls.each(function(ctrl){
+ if(Element.visible(ctrl)) {
+ controls.push(ctrl);
+ }
+ });
+ }
+ });
+ return controls;
+ },
+ adjustColumnWidth: function(column, width) {
+ var w = width, ch;
+ var frozenColumns = this.headerFrozenRow.getElement().rows[0].cells.length;
+ var realColumn = column;
+ var table = null;
+ if(column < frozenColumns) {
+ table = this.headerFrozenRow.getElement();
+ }
+ else {
+ table = this.headerRow.getElement();
+ realColumn -= frozenColumns;
+ }
+
+ // Hide controls in IE that flipped in other case
+ var ctrlsIE = [];
+ if(ClientUILib.isIE) {
+ ctrlsIE = this._getVisibleHeaderControls();
+ ctrlsIE.each(function(ctrl){
+ Element.hide(ctrl);
+ });
+ }
+
+ var childs = table.rows[0].cells[realColumn].childNodes;
+ this.helpObj.element = $(table.rows[0].cells[realColumn]);
+ var delta = 0;
+ if(ClientUILib.isGecko) {
+ delta = this.helpObj.getBorderWidth("lr") + this.helpObj.getPadding("lr");
+ }
+ this.helpObj.setWidth(width - delta);
+ delta *= 2;
+
+ for (var j=0; j<childs.length; j++) {
+ ch = childs[j];
+ if(ch.tagName && ch.tagName.toLowerCase() == "span") {
+ this.helpObj.element = $(ch);
+ this.helpObj.setWidth(width - delta);
+ break;
+ }
+ }
+
+ if(ClientUILib.isIE) {
+ ctrlsIE.each(function(ctrl){
+ Element.show(ctrl);
+ });
+ }
+
+ this._columns[column].width = width;
+ }
+});
17 years, 8 months