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 mt...@apache.org on 2007/03/13 04:32:19 UTC

svn commit: r517524 - /incubator/xap/trunk/codebase/src/xap/bridges/dojo/TableBridge.js

Author: mturyn
Date: Mon Mar 12 21:32:16 2007
New Revision: 517524

URL: http://svn.apache.org/viewvc?view=rev&rev=517524
Log:
Put in less buggy setVisibleAttribute() method; now it just moves the table offscreen---it was seeming-impossible to get decent behaviour across browsers when an initially-hidden table was desired, the browser seemed to need to have the object visible, if not on-screen, when it was setting it up.  If it was invisible, would often miss all but the last column when the table's visibility were restored.

Modified:
    incubator/xap/trunk/codebase/src/xap/bridges/dojo/TableBridge.js

Modified: incubator/xap/trunk/codebase/src/xap/bridges/dojo/TableBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/bridges/dojo/TableBridge.js?view=diff&rev=517524&r1=517523&r2=517524
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/bridges/dojo/TableBridge.js (original)
+++ incubator/xap/trunk/codebase/src/xap/bridges/dojo/TableBridge.js Mon Mar 12 21:32:16 2007
@@ -49,30 +49,13 @@
 
 
 xap.bridges.dojo.TableBridge.prototype.init = function() {
-	this._initted = false ;
 	xap.bridges.dojo.DojoWidgetBridge.prototype.init.call(this);
 	dojo.event.connect(this.getPeer(), "onActivateRow",this,"onActivateRow");	
 	dojo.event.connect(this.getPeer(), "onSelectRow",this,"onSelectRow");	
 	dojo.event.connect(this.getPeer(), "onDeselectRow",this,"onDeselectRow");
 	dojo.event.connect(this.getPeer(), "onExpandRow",this,"onExpandRow");	
-	this._initted = true ;
-	if( dojo.render.html.mozilla ){	
-		dojo.lang.setTimeout(this,this._initialTableRefresh,500) ;
-	}
-}
-
-// Under Firefox we'll not have set the initial visibility to false
-// even if the element would set it that way, since this can screw up 
-// the rendering of the columns under Firefox.  Under _both_ browsers, 
-// we needed a little delay in the initial visibility setting to false
-// in order to make it hide the columns:
-xap.bridges.dojo.TableBridge.prototype._initialTableRefresh = function() {
-	this.getPeer()._resizeTable() ;
-	this.setVisibleAttribute(this._visibility) ;	
 }
 
-
-
 xap.bridges.dojo.TableBridge.prototype.getPeerString = function(){
 	return "TreeTable" ;
 }
@@ -164,32 +147,36 @@
 	}
 }
 
-if( dojo.render.html.mozilla ){
-	//This allows the peer to be built completely before it's
-	// set invisible, which Firefox needs to get the width right:
-	xap.bridges.dojo.TableBridge.prototype.setVisibleAttribute = function(pszTf){
-		if( !this._initted ){
+xap.bridges.dojo.TableBridge.hidingDisplacement = 10000 ;
+
+xap.bridges.dojo.TableBridge.prototype.setVisibleAttribute = function(pszTf){
+// Problems laying out the table correctly if it's invisible at the
+// start, so it's better to make "hide"=="move offscreen"	
+	var bVis = (pszTf=="false")?false:true ;
 	
-			(xap.bridges.dojo.TableBridge.superclass
-				).setVisibleAttribute.call(this,"true") ;
-							
-			this._visibility = pszTf ;
-		} else {
-			(xap.bridges.dojo.TableBridge.superclass
-				).setVisibleAttribute.call(this,pszTf) ;
-		}			
-	}
-} else {
-	// Superclass method works fine under IE except for columns; 
-	// this formal "delay" appears to fix that.  It's magic; that's
-	// why it should be avoided whenever possible.
-	// TODO: find a non-alchemical way of fixing this.
-	xap.bridges.dojo.TableBridge.prototype.setVisibleAttribute = function(pszTf){
-		dojo.lang.setTimeout(
-								this,
-								xap.bridges.basic.AbstractWidgetBridge.prototype.setVisibleAttribute,
-								0,
-								pszTf
-							) ;
-	}					
-}
+	//  hide
+	if(!bVis ){
+		var y = this.getElement().getAttribute("y") ;
+		if(y){
+			this.setYAttribute(y) ;
+		}
+		y = this.getRootDomNode().offsetTop ;
+		// Don't move offscreen if we've already been moved offscreen:
+		if( !this._wasDisplacedOffscreen){
+			y -= xap.bridges.dojo.TableBridge.hidingDisplacement ;
+		}				
+		this.setYAttribute(y +"px") ;
+		this._wasDisplacedOffscreen = true ;
+	} else {
+		// We're showing a table which was hidden, and
+		// so moved offscreen---move it back:
+		y = this.getRootDomNode().offsetTop ;
+		// Don't move back onscreen unless we've started offscreen:
+		if( this._wasDisplacedOffscreen){
+			y += xap.bridges.dojo.TableBridge.hidingDisplacement ;
+		}		
+		this.setYAttribute(y+"px") ;
+		this._wasDisplacedOffscreen = false ;
+		//this.getPeer()._resizeTable() ;
+	} 
+}
\ No newline at end of file