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/05/21 23:28:56 UTC

svn commit: r540356 - /incubator/xap/trunk/codebase/src/xap/widgets/dojo/TreeTable.js

Author: mturyn
Date: Mon May 21 16:28:55 2007
New Revision: 540356

URL: http://svn.apache.org/viewvc?view=rev&rev=540356
Log:
Made splitter sizers only headerTable in height, but kept moving sizer full height 
(since we can't show the columns themselves moving).  Many small changes to support 
this, including coding to suppress sizer flashing, and clean-up.

Modified:
    incubator/xap/trunk/codebase/src/xap/widgets/dojo/TreeTable.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?view=diff&rev=540356&r1=540355&r2=540356
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/widgets/dojo/TreeTable.js (original)
+++ incubator/xap/trunk/codebase/src/xap/widgets/dojo/TreeTable.js Mon May 21 16:28:55 2007
@@ -65,7 +65,7 @@
 	this._initialResizePending = true;
 	
 	// width of each column sizer, in pixels:
-	this._sizerWidth = 6 ;
+	this._sizerWidth = 8 ;
 
 };
 
@@ -1171,7 +1171,7 @@
 			dojo.widget.createWidget(
 										"SplitContainer",
 										{
-											height:box.height,
+											height:1,
 											width:box.width,
 											sizerWidth:1,
 											persist:false,
@@ -1180,14 +1180,14 @@
 										splitterContainer
 										);
 
+		this._alterSizerMethods() ;
+
 		splitterContainerStyle.zIndex = 0 ;
 		
 		var borderFudge = null ;		
 
 		var h = this.domNode.offsetHeight +"px" ;
-				
-		var foundTrueSizerWidth = false ;		
-							
+								
 															
 		for (var ii = 0; ii<this.headerRow.childNodes.length; ++ii){
 			var node = this.headerRow.childNodes[ii] ;
@@ -1209,7 +1209,7 @@
 // many of them, and appears to be unneeded:
 //		this.columnsSizer.postCreate() ;
 
-		this._applyBasicSizerStyling() ;
+		dojo.lang.setTimeout(this,this._applyBasicSizerStyling,600) ;
 
 		
 		//this.columnsSizer._layoutPanels();
@@ -1230,28 +1230,29 @@
 							this,
 							this.onBeginSizing
 							) ;
-							
+						
 		this._redoSplitPanelStyling(0) ;
 		// The results we get after dragging seem better:
-		
+
 		this.onEndSizing() ;
 	},	
 	
 	_applyBasicSizerStyling: function(){
 	
-//debug		var rainbow=["red","orange","yellow","green",
+// debug sizer vis:	
+//		var rainbow=["red","orange","yellow","green",
 //						"blue","indigo","violet"
 //					] ;
 	
 		for( var idx = 0; idx < this.columnsSizer.sizers.length; ++idx){
+
 			var aSizer = this.columnsSizer.sizers[idx] ;
-/*debug*/			aSizer.id = this.domNode.id + "_sizer_"+idx ;
-/*debug*/			aSizer.setAttribute("id",aSizer.id) ;
-/*debug*/ 	dojo.html.addClass(aSizer, "sizer_"+idx) ;
+//*debug*/			aSizer.id = this.domNode.id + "_sizer_"+idx ;
+//*debug*/			aSizer.setAttribute("id",aSizer.id) ;
+//*debug*/ 	dojo.html.addClass(aSizer, "sizer_"+idx) ;
 			aSizer.style.visibility="hidden" ;		
 			aSizer.style.height = 
-				(this.headerTable.offsetHeight
-					+ this.scrollDiv.offsetHeight) +"px" ;			
+				(this.headerTable.offsetHeight) +"px" ;			
 			dojo.html.removeClass(aSizer, "dojoSplitContainerSizerH") ;
 			dojo.html.addClass(aSizer, "xapTableStationarySizers") ;
 			// No need to see the sizers; they should
@@ -1264,18 +1265,42 @@
 			// splitter container desendent:
 			aSizer.style.visibility="visible" ;
 	
- // /*debug:*/	aSizer.style.backgroundColor = rainbow[idx] ;			
-				
+// debug sizer vis:	
+//			aSizer.style.backgroundColor =rainbow[idx] ;			
+
+// debug sizer visibility by increasing opacity to (say) 30/0.3:				
 			if( dojo.render.html.ie ){
 				aSizer.style.filter = "alpha(opacity=0)" ;				
 			} else {
 				aSizer.style.opacity = 0.0 ;				
 			}
 			
-			aSizer._xapReformatted = true ;	
+			this._fixSizerWidthAndPosition(idx) ;
+												
+			aSizer._xapReformatted = true ;				
 		}	
+		if( dojo.render.html.ie ){
+			// splitters don't refresh properly on their 
+			// once they're moved, under IE6/7:
+			this.onScrollCallback() ;
+		}
 	},
 	
+	_fixSizerWidthAndPosition: function(index){
+			var sizerNode = this.columnsSizer.sizers[index] ;
+			var left = null ;
+			if( index < this.headerRow.childNodes.length - 1 ){	
+				left = this.headerRow.childNodes[index+1].offsetLeft ;
+			} else {
+				// Pseudo-column at the end:
+				left= this.headerRow.scrollWidth ;						
+			}
+			sizerNode.style.left 
+				= (left -Math.round(this._sizerWidth/2)) +"px";	
+			sizerNode.style.width=this._sizerWidth +"px" ;
+			sizerNode.style.height = this.headerTable.offsetHeight+"px";				
+	},
+
 
 	_redoSplitPanelStyling: function(delay){   //debug::this.loggit('_redoSplitPanelStyling') ;
 		if( delay != undefined ){
@@ -1339,6 +1364,8 @@
 			}					
 		}
 		sizer._layoutPanels() ;
+		
+		this._hideSplitterPanelsAndShowSizers(500) ;
 	},
 
 	_hideSplitterPanelsAndShowSizers: function(delay){   //debug::this.loggit('_hideSplitterPanelsAndShowSizers') ;
@@ -1386,10 +1413,10 @@
 				
 
 		for(var ii=0; ii < this._columns.length; ++ii){
-			var child = sizerHandles[ii] ;
-			var childStyle = child.style ;
-			childStyle.visibility = "visible" ;
-			childStyle.zIndex = 0 ;
+			var sizerHandle = sizerHandles[ii] ;
+			var sizerHandleStyle = sizerHandle.style ;
+			sizerHandleStyle.visibility = "visible" ;
+			sizerHandleStyle.zIndex = 0 ;
 
 			if(isXpIe6){
 				/* Can't set it to "transparent" in CSS because
@@ -1397,9 +1424,11 @@
 				   ---instead, apply it in code to IE6/XP, which is
 				   the only place it's needed,as the stylesheet's
 				   {0 opacity} xor {alpha-filter stuff} works fine in Fire-
-				   fox, IE7, and IE6/Win2K.
+				   fox, IE7, and IE6/Win2K.foo
 				*/
-				childStyle.backgroundColor="transparent" ;			
+				// To debug, you'll probably want to
+				// set this to something more noticeable:		
+				sizerHandleStyle.backgroundColor="transparent" ;		
 			}			
 		}	
 
@@ -1417,16 +1446,10 @@
 		// headers:
 		var headers = this.headerRow.childNodes ;
 		for(var kk=0; kk < sizerHandles.length ; ++kk){
-			var child = sizerHandles[kk] ;			
-			var w = this._sizerWidth ;
 			// Widen the sizers so they're more selectable:
 			//---sizers behave more accurately when they're
-			// slimmer, but are harder to select....		
-			child.style.width = this._sizerWidth+"px" ;
-			child.style.left 
-				= (child.offsetLeft 
-					- Math.floor(w/2)							
-					) + "px" ;			
+			// slimmer, but are harder to select....
+			this._fixSizerWidthAndPosition(kk) ;
 		}
 		
 	
@@ -1508,6 +1531,7 @@
 								this._grabbedSizerIndex + 1
 								) ;
 		} else {
+			// Can't identify the sizer grabbed:
 			dojo.lang.setTimeout(
 								this,
 								this._reconcileHeaderAndBodyColumns,
@@ -1578,7 +1602,36 @@
 		// they're over:
 		this._hideSplitterPanelsAndShowSizers(10) ;	
 
-	}
+	} ,
+	
+	
+	_alterSizerMethods: function(){
+	    this.columnsSizer._addSizer=function() {
+	    // Altered so that the sizer won't flash
+	    // on creation:
+	        var i = this.sizers.length;
+	
+	        this.sizers[i] = document.createElement('div');
+	        this.sizers[i].style.position = 'absolute';
+	        /* Altered:*/
+// debug sizer visibility by increasing opacity to (say) 30/0.3:				
+			if( dojo.render.html.ie ){
+				this.sizers[i].style.filter = "alpha(opacity=0)" ;				
+			} else {
+				this.sizers[i].style.opacity = 0.0 ;				
+			}	        
+	        this.sizers[i].style.height="1px" ;
+	        /* Altered. */
+	        this.sizers[i].className = this.isHorizontal ? 'dojoSplitContainerSizerH' : 'dojoSplitContainerSizerV';
+	
+	        var self = this;
+	        var handler = (function(){ var sizer_i = i; return function(e){ self.beginSizing(e, sizer_i); } })();
+	        dojo.event.connect(this.sizers[i], "onmousedown", handler);
+	
+	        this.domNode.appendChild(this.sizers[i]);
+	        dojo.html.disableSelection(this.sizers[i]);
+	    }
+	}	
 	
 	
 }
@@ -1917,6 +1970,11 @@
 	}	
 	
 });
+
+
+
+
+
 
 //Debugging: