incubator-xap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mtu...@apache.org
Subject svn commit: r495446 - /incubator/xap/trunk/src/xap/widgets/dojo/Window.js
Date Thu, 11 Jan 2007 23:55:13 GMT
Author: mturyn
Date: Thu Jan 11 15:55:13 2007
New Revision: 495446

URL: http://svn.apache.org/viewvc?view=rev&rev=495446
Log:
1.) Worked around an IE6-specific bug that created a 2-line titlebar with a couple of 
chars from the title's end on the second line---they're not in the titleBarText node 
itself, I think an unoccupied area in the titlebar clipped a bit of the screen, perhaps
an area next to an action icon, since the ghost title-end looks about that width, and
the title might have been right next to one of them.
2.) Tweaked minimised window management to look decent across browsers.

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

Modified: incubator/xap/trunk/src/xap/widgets/dojo/Window.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/widgets/dojo/Window.js?view=diff&rev=495446&r1=495445&r2=495446
==============================================================================
--- incubator/xap/trunk/src/xap/widgets/dojo/Window.js (original)
+++ incubator/xap/trunk/src/xap/widgets/dojo/Window.js Thu Jan 11 15:55:13 2007
@@ -70,27 +70,27 @@
 		if( this.windowState != "maximized" ){
 			this.setPrevious() ;
 		}
+
+
+
+
 		
 		this.resizeBar.style.visibility="hidden" ;
+
+
+
+
 		// Show just the top bar, narrowed to 8 icons' worth:
-		var wI=0 ;
-		for(var action in  this.windowActions ){
-			wI = this[action].offsetWidth ;
-			if(wI>0){
-				break ;
-			}		
-		}	
-		wI=Math.max(4,wI);
-		var newW = 8*wI ;
 
-		this.positionMinimizedWindow(newW) ;
+		var newW = this.minimizedWindowWidth() ;
 
 		var newH = dojo.style.getOuterHeight(this.titleBar); // + dojo.style.getOuterHeight(this.resizeBar);
 	
 		this.resizeTo(newW,newH) ; 
 			
-			
-
+		// Keep container node from intruding into titleBar
+		// when minimised:
+		this.containerNode.style.visibility = "hidden" ;
 		
 		this.minimizeAction.style.display="none";
 		
@@ -98,29 +98,30 @@
 		var nextNode = this.restoreAction.nextSibling ;
 		restoreParent.removeChild(this.restoreAction);
 		restoreParent.insertBefore(this.restoreAction,nextNode);
-		
-		// Keep container node from intruding into titleBar
-		// when minimised:
-		this.containerNode.style.visibility = "hidden" ;
+	
 		
 		this.restoreAction.style.display="";
 		this.windowState="minimized";	
+		this.positionMinimizedWindow() ;
+
 	},
 	//Let's play window-manager:
-	positionMinimizedWindow:function(newW){
+	positionMinimizedWindow:function(){
 		var parent = this.domNode.parentNode ;
 		if( !parent ){
 			// nowhere to minimise to:
 			return ;
 		}
+		var newW = this.minimizedWindowWidth() ;
 		// Arrange window next to previous minimised window:
 		if(!parent.minWins){
 			parent.minWins = {} ;
 			parent.minWins.owner = parent ;
-			parent.minWins.nRows = 1 ;
+			parent.minWins.nRows = 0 ;
 			parent.minWins.nextLeft = 1 ;
 			parent.minWins.slots = new Object() ;
-			parent.minWins.titleBarHeightPct = 5 ;			
+			parent.minWins.titleBarHeightPct = 5 ;
+			parent.minWins.nextTopPct = null ;
 		}
 
 		var slot = parent.minWins.slots[this.widgetId] ;
@@ -130,34 +131,40 @@
 			this.domNode.style.top = slot.top  ;
 		} else {		
 			// Create another row if we're too far over:
-			if(parent.minWins.nextLeft> parent.clientWidth -newW){
+			if( (parent.minWins.nextLeft> parent.clientWidth -newW)
+					|| !parent.minWins.nextTopPct
+				){
 				++parent.minWins.nRows ;
 				parent.minWins.nextLeft = 1 ; //+parent.minsRows*5 ;			
-			}
 			
-			// Find the height of the window as a percentage of
-			// the parent's:
-			var newHeightPct
-				= Math.round((100*this.titleBar.clientHeight)/parent.clientHeight);
-
-			// ...but make sure we don't interfere with other rows,
-			// by never decreasing that percentage:
-			if( (""+newHeightPct)!= "NaN"){
-				parent.minWins.titleBarHeightPct 
-					= Math.max(newHeightPct, parent.minWins.titleBarHeightPct );
+				// Find the height of the window as a percentage of
+				// the parent's:
+				var fNewHeightPct
+					= (100*this.titleBar.clientHeight)/parent.clientHeight ;
+	
+				// ...but make sure we don't interfere with other rows,
+				// by never decreasing that percentage:
+				if( (""+fNewHeightPct)!= "NaN"){
+					parent.minWins.titleBarHeightPct 
+						= Math.max(fNewHeightPct, parent.minWins.titleBarHeightPct );
+				}
+				// ...within reason:
+				parent.minWins.titleBarHeightPct
+					=Math.min(7,parent.minWins.titleBarHeightPct) ;
+	
+				parent.minWins.nextTopPct
+						= (99 - 
+							(parent.minWins.titleBarHeightPct*parent.minWins.nRows)
+								) ;
+				parent.minWins.nextTopPct								
+					= Math.round(parent.minWins.nextTopPct) ;								
 			}
-
-//alert("parent.minWins.titleBarHeightPct"+parent.minWins.titleBarHeightPct
-//			+"parent.minWins.nRows"+parent.minWins.nRows);
-
-			this.domNode.style.top 
-				= (99 - 
-					(parent.minWins.titleBarHeightPct*parent.minWins.nRows)
-						)+"%" ;
+			this.domNode.style.top = parent.minWins.nextTopPct +"%" ;
 			this.domNode.style.left = parent.minWins.nextLeft+"px" ;
 			
+			
 			parent.minWins.slots[this.widgetId] 
-				= {top:this.domNode.style.top,
+				= {top:parent.minWins.nextTopPct +"%" ,
 					left:parent.minWins.nextLeft
 					} ;
 						
@@ -166,7 +173,7 @@
 	
 	},
 	
-	restoreWindow:function(evt){	
+	restoreWindow:function(evt){
 		this.containerNode.style.visibility = "visible" ;	
 		if (evt && xap.util.Event.getPreventDefault(evt)){
 			return;
@@ -182,6 +189,17 @@
 		this.minimizeAction.style.display=this.displayMinimizeAction ? "" : "none";
 	
 	},
+	minimizedWindowWidth:function(){
+		var wI=0 ;
+		for(var action in  this.windowActions ){
+			wI = this[action].offsetWidth ;
+			if(wI>0){
+				break ;
+			}		
+		}	
+		wI=Math.max(4,wI);
+		return wI*8 ;			
+	},
 	
 	maximizeWindow:function(evt){
 		this.containerNode.style.visibility = "visible" ;
@@ -368,15 +386,25 @@
 		}
 	},
 	setTitle:function(val){
-		this.titleBarText.innerHTML = val ;
-		this.resetTitleTextBox() ;	
+		if( !val){
+			this.setTitle(this.title) ;
+			return ;
+		}
+		this.titleBarText.innerHTML=val ;
+		this.resetTitleTextBox() ;		
+		this.title = val ;
 	},
-	resetTitleTextBox:function(oneLineHeight){	
+	resetTitleTextBox:function(oneLineBoxHeight){
 		this.titleBar.style.overflow="hidden" ;
-		this.titleBarText.style.overflow="hidden" ;	
+		this.titleBar.style.verticalAlign="middle" ;		
+		this.titleBarText.style.verticalAlign="middle" ;
+		this.titleBarText.style.overflow="hidden" ;			
+//For debugging:		this.titleBarText.style.backgroundColor = "black" ;
 		var titleWidthPx = this.titleBar.offsetWidth ;
 		var maxTextWidthPx = this.titleBar.offsetWidth ;
-		var iconWidth = false ;
+		// look at the css file
+		//...but to be sure:
+		var iconWidth = 11 ;
 		for(var action in  this.windowActions ){
 			var w = this[action].offsetWidth ;		
 			if(w){
@@ -392,8 +420,15 @@
 		}
 		maxTextWidthPx = Math.max(maxTextWidthPx,0) ;
 		this.titleBarText.style.width= maxTextWidthPx+"px";
-		if(oneLineHeight){
-			this.titleBarText.style.height= oneLineHeight+"px";		
+		// This height-setting is necessitated by		
+		// a bug[?] under IE that echoes the last ~2.2
+		// chars on another line below the titleText div,
+		// which expands the titlebar text---only happens 
+		// under IE6:
+		// TODO: avoid the echoing in the first place:
+		if(navigator.appVersion.indexOf("MSIE 6")>-1){
+			this.titleBar.style.height= (w+4) + "px";							
+			this.titleBarText.style.height = this.titleBar.offsetHeight + "px" ;
 		}
 	}	
 });



Mime
View raw message