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/02/01 21:13:44 UTC

svn commit: r502360 - /incubator/xap/trunk/codebase/src/xap/bridges/xap/XapComboBoxBridge.js

Author: mturyn
Date: Thu Feb  1 13:13:43 2007
New Revision: 502360

URL: http://svn.apache.org/viewvc?view=rev&rev=502360
Log:
https://issues.apache.org/jira/browse/XAP-290

Fixes initial width problem for a combo box under IE6 when there is no width specified:  redrawing the select solves the problem created when the select is inserted into a 0-by-0 div.

Also fixed bug so that combo box widths will predominate over list box widths (and heights, except under IE6, where they're unsettable).

Modified:
    incubator/xap/trunk/codebase/src/xap/bridges/xap/XapComboBoxBridge.js

Modified: incubator/xap/trunk/codebase/src/xap/bridges/xap/XapComboBoxBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/bridges/xap/XapComboBoxBridge.js?view=diff&rev=502360&r1=502359&r2=502360
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/bridges/xap/XapComboBoxBridge.js (original)
+++ incubator/xap/trunk/codebase/src/xap/bridges/xap/XapComboBoxBridge.js Thu Feb  1 13:13:43 2007
@@ -77,8 +77,9 @@
 		dojo.event.disconnect(this._childHandler,"onChange",this,"onChange") ;
 		dojo.event.disconnect(this._childHandler,"onKeyDown",this,"onKeyDown") ;
 		dojo.event.disconnect(this._childHandler,"onMouseUp",this,"onMouseUp") ;
-		dojo.event.disconnect(childHandler,"childAdded",this,"listboxAddedOrRemovedChild") ;
-		dojo.event.disconnect(childHandler,"revalue",this,"revalue") ;		dojo.event.disconnect(childHandler,"removeChild",this,"listboxAddedOrRemovedChild") ;
+		dojo.event.disconnect(this._childHandler,"childAdded",this,"listboxAddedOrRemovedChild") ;
+		dojo.event.disconnect(this._childHandler,"revalue",this,"revalue") ;
+		dojo.event.disconnect(this._childHandler,"removeChild",this,"listboxAddedOrRemovedChild") ;
 	}
 
 	childHandler.isChildOfComboBox = true;
@@ -97,8 +98,18 @@
 	
 	this._childListbox.trimSuperUnarySelectedOptions()	
 
+
 	this.getPeer().addChild(this._childListbox);
 	
+	
+	// Make select box assume its natural width: 
+	this._childListbox.refreshSelectBox()	
+	// Now reset it to something else, if th
+	// tag attributes so demand:
+	this.setInitialBox() ;
+
+		
+	
 	// Fixes height not right on initial display bug in Firefox:
 	//---can't do anything about IE heights:
 	var desiredHeight = this.getElement().getAttribute("height") ;
@@ -108,6 +119,8 @@
 		this._childListbox.select.style.height = "100%" ;
 	}
 
+	
+
 
 	// Notice events in the child:
 	dojo.event.connect(this._childHandler,"onChange",this,"onChange") ;
@@ -121,6 +134,47 @@
 }
 
 
+
+xap.bridges.xap.XapComboBoxBridge.prototype.setInitialBox = function(){
+	var desiredLBHeight = this._childHandler.getElement().getAttribute("height");
+	var desiredCBHeight = this.getElement().getAttribute("height") ;
+	// For the case when there's a listbox height but no combobbox height:
+	var desiredHeight = desiredLBHeight ;
+	if( desiredCBHeight ){
+		desiredHeight = desiredCBHeight ;
+	}	
+	// If there's an explicit height:
+	if( desiredHeight ){
+		// Fixes height not right on initial display bug in Firefox:
+		//---can't do anything about IE heights:	
+		this.setHeightAttribute("1px") ;
+		this.setHeightAttribute( desiredHeight ) ;	
+		this._childListbox.select.style.height = desiredHeight ;
+		
+		this.getElement().setAttribute("height",desiredHeight) ;		
+		
+	}
+
+	var desiredLBWidth = this._childHandler.getElement().getAttribute("width");	
+	var desiredCBWidth = this.getElement().getAttribute("width") ;
+	// For the case when there's a listbox width but no combobox width:
+	var desiredWidth = desiredLBWidth ;
+	if( desiredCBWidth ){
+		desiredWidth = desiredCBWidth ;
+	}
+
+	// If there's an explicit width:
+	if( desiredWidth){
+		this.getRootDomNode().style.width = desiredWidth ;
+		this._childListbox.select.style.width = desiredWidth ;
+		
+		this._childHandler.getElement().setAttribute("width",desiredWidth) ;		
+		this.getElement().setAttribute("width",desiredWidth) ;		
+		
+	}
+}
+
+
 xap.bridges.xap.XapComboBoxBridge.prototype.listboxAddedOrRemovedChild  = function(anEvent){
 	// These should be two strings, since the child 
 	// should be a single-valued list box.
@@ -196,9 +250,7 @@
 xap.bridges.xap.XapComboBoxBridge.prototype.setBorderWidthAttribute = function(value){
 	this.getPeer().setBorderWidth( value ) ;
 }
-xap.bridges.xap.XapComboBoxBridge.prototype.setVisibleAttribute = function(value){
-	this.getPeer().setVisible( value ) ;
-}
+
 xap.bridges.xap.XapComboBoxBridge.prototype.setXAttribute = function(value){
 	this.getPeer().setX( value ) ;
 }
@@ -211,12 +263,6 @@
 }
 
 
-xap.bridges.xap.XapComboBoxBridge.prototype.setXAttribute = function(value){
-	this.getPeer().setX( value ) ;
-}
-xap.bridges.xap.XapComboBoxBridge.prototype.setYAttribute = function(value){
-	this.getPeer().setY( value ) ;
-}
 
 
 xap.bridges.xap.XapComboBoxBridge.prototype.setDisabledAttribute = function(pszValue){