You are viewing a plain text version of this content. The canonical link for it is here.
Posted to xap-commits@incubator.apache.org by jm...@apache.org on 2007/10/31 21:45:25 UTC

svn commit: r590846 - in /incubator/xap/trunk/codebase/src/xap/widgets/dojo: TreeTable.js Window.js

Author: jmargaris
Date: Wed Oct 31 14:45:17 2007
New Revision: 590846

URL: http://svn.apache.org/viewvc?rev=590846&view=rev
Log:
From Michael Mikhaylov: Row visible attribute fix, faster table rendering changes and fixes.

Modified:
    incubator/xap/trunk/codebase/src/xap/widgets/dojo/TreeTable.js
    incubator/xap/trunk/codebase/src/xap/widgets/dojo/Window.js

Modified: incubator/xap/trunk/codebase/src/xap/widgets/dojo/TreeTable.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/widgets/dojo/TreeTable.js?rev=590846&r1=590845&r2=590846&view=diff
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/widgets/dojo/TreeTable.js (original)
+++ incubator/xap/trunk/codebase/src/xap/widgets/dojo/TreeTable.js Wed Oct 31 14:45:17 2007
@@ -213,7 +213,7 @@
 		// explicitly set all column widths
 		this._fixColumnWidths();
 				
-		// clear all pending tasks
+		// clear pending task if any (?)
 		window.clearTimeout(this._resizeTableTask);
 		this._resizeTableTask = null;
 		
@@ -246,6 +246,8 @@
 			}
 			if (firstRow && firstRow.childNodes[i]){
 				dojo.html.setMarginBox( firstRow.childNodes[i], boxObject ) ;					
+			} else if (this.table.childNodes[i]) {
+				this.table.childNodes[i].style.width = width;
 			}
 			// update header width to fill all available space
 			if (this.headerRow && this.headerRow.childNodes[i] && this.headerRow.childNodes[i].childNodes[0]) {
@@ -304,16 +306,17 @@
 		}
 		
 		this.tbody = document.createElement("tbody");		
+		this.table.appendChild(this.tbody);
 		
 		//now populate the body rows
 		for (var i =0; i<this._rows.length; i++){
 			this._rebuildRow(this._rows[i], 0);
 		}
 		
-		this.table.appendChild(this.tbody);
+
 		// resize columns in the case of new rows added
-		this._resizeTable ();
 		this._recolorAlternateRows();
+		this._resizeTableLater();
 	},
 	
 	/**
@@ -399,20 +402,22 @@
 	_recolorAlternateRows: function(row){
 		
 		if (this._alternateRowClass === undefined) { return; }
-		
+
+		// recolor only subsequent siblings of an immediate child row
+		// if expanded row is not an immediate child then recolor everything
+		var i = xap.util.ArrayHelper.indexOf(this._rows, row);
 		var isAlternateRow = false;
-		
-		// recolor only subsequent rows
-		var i = (row === undefined) ? 0 : xap.util.ArrayHelper.indexOf(this._rows, row) + 1;
-		while (i < this._rows.length){
-			var current = this._rows[i++];
-			isAlternateRow = this._recolorRow(current, isAlternateRow);
+		if(i > 0) { 
+			isAlternateRow = row._alternateRow;
+		} else {
+			i = 0;
+		}
+		while (i < this._rows.length) {
+				isAlternateRow = this._recolorRow(this._rows[i++], isAlternateRow);
 		}
 	},
 	
-	_recolorRow: function(row, isAlternateRow ) {
-	
-		
+	_recolorRow: function(row, isAlternateRow) {
 		// do nothing if invisible
 		var style = row.domNode.style;
 		if(style.visibility == "hidden" && style.display == "none") {
@@ -420,7 +425,7 @@
 		}
 
 		// only update style when needed 
-		if(row._alternateRow != isAlternateRow) {
+		if(row._alternateRow !== isAlternateRow) {
 		
 			// save new value
 			row._alternateRow = isAlternateRow;
@@ -430,18 +435,18 @@
 			} else {
 				xap.util.CssUtils.setClass(row.domNode, ' ');
 			}
+		 }
 		
-			// flip row
-			isAlternateRow = ! isAlternateRow;
-			
-			// recolor children
-			if (row._expanded) {
-				for (var i = 0; i<row._rows.length; i++){
-					isAlternateRow = this._recolorRow(row._rows[i], isAlternateRow);
-				}
+		// flip row
+		isAlternateRow = ! isAlternateRow;
+
+		// recolor children
+		if (row._expanded) {
+			for (var i = 0; i<row._rows.length; i++){
+				isAlternateRow = this._recolorRow(row._rows[i], isAlternateRow);
 			}
 		}
-			
+
 		return isAlternateRow;
 	},
 	
@@ -658,7 +663,7 @@
 	 */	
 	 
 	 onExpandRow : function(row, expanded){
-	 	this._recolorAlternateRows( row );
+	 	// empty
 	 },
 	 
 	onScrollCallback : function(event){
@@ -746,18 +751,8 @@
 		if (aVal==bVal) return 0;
 		if (aVal<bVal) return -1;
 		return 1;
-	},
-	
-	_fixNewStatedColumnWidth: function(column) {
-		var firstRow = (this._rows.length > 0) ? this._rows[0].domNode : null;
-	
-		// sets column width to "width" (note: ends with "px")
-		for (var i=0; i<this._columns.length;i++) {
-			if (this._columns[i] == column)
-				_fixColumnWidth(column, i, firstRow);
-		}
 	}
-}
+  }
 );
 
 
@@ -850,7 +845,8 @@
 				}
 				element = element.nextSibling;
 			}
-			// resize table
+			// resize & recolor table
+			this._table._recolorAlternateRows(this);
 			this._table._resizeTableLater();
 		}
 	}
@@ -999,10 +995,11 @@
 	setExpanded : function (expanded){
 		this._expanded = expanded;
 		for (var i = 0; i<this._rows.length; i++){
-			this._rows[i].setVisible(this._expanded, false);
+			this._rows[i].setVisible(this._expanded, true);
 		}
 		this._adjustImage();
 		if(this._table) {
+			this._table._recolorAlternateRows(this);
 			this._table._resizeTableLater();
 		}		
 	},
@@ -1029,18 +1026,20 @@
 	
 	//if we set to invis, set all children to invis as well
 	//if we set it back, set children back ONLY if we are expanded!
-	setVisible : function (visible, refreshTable){
+	setVisible : function (visible, supressRefresh){
+		
 		var visibility = visible === true ? "visible" : "hidden";	
 		var display = visible === true ? "" : "none";
 		this.domNode.style.visibility = visibility;
 		this.domNode.style.display = display;
+		
 		for (var i = 0; i<this._rows.length; i++){
 			if (!visible || this._expanded){
-				this._rows[i].setVisible(visible, refreshTable);
+				this._rows[i].setVisible(visible, true);
 			}
 		}
-		if(this._table && refreshTable !== false) {
-			this._table._recolorAlternateRows();
+		if( this._table && (! supressRefresh) ) {
+			this._table._recolorAlternateRows(this);
 			this._table._resizeTableLater();
 		}
 	},

Modified: incubator/xap/trunk/codebase/src/xap/widgets/dojo/Window.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/widgets/dojo/Window.js?rev=590846&r1=590845&r2=590846&view=diff
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/widgets/dojo/Window.js (original)
+++ incubator/xap/trunk/codebase/src/xap/widgets/dojo/Window.js Wed Oct 31 14:45:17 2007
@@ -40,8 +40,9 @@
 	dojo.widget.FloatingPane.call(this);
 	this._visible = true;
 	this.previous = {};
-	//hardcode an initial height/width
-
+	
+	//hardcode an initial height/width (?)
+	dojo.lang.setTimeout(this,"postCreate",0) ;
 }
 
 dojo.inherits(xap.widgets.dojo.Window,dojo.widget.FloatingPane);