incubator-xap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mtu...@apache.org
Subject svn commit: r470637 - /incubator/xap/trunk/src/xap/widgets/ListBox.js
Date Fri, 03 Nov 2006 02:21:35 GMT
Author: mturyn
Date: Thu Nov  2 18:21:34 2006
New Revision: 470637

URL: http://svn.apache.org/viewvc?view=rev&rev=470637
Log:
Added mechanisms for keeping official size>=2, so that the listbox doesn't become a dropdown
as it would for size==1.

Modified:
    incubator/xap/trunk/src/xap/widgets/ListBox.js

Modified: incubator/xap/trunk/src/xap/widgets/ListBox.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/widgets/ListBox.js?view=diff&rev=470637&r1=470636&r2=470637
==============================================================================
--- incubator/xap/trunk/src/xap/widgets/ListBox.js (original)
+++ incubator/xap/trunk/src/xap/widgets/ListBox.js Thu Nov  2 18:21:34 2006
@@ -15,15 +15,21 @@
 dojo.inherits(xap.widgets.ListBox, dojo.widget.HtmlWidget);
 
 dojo.lang.extend(xap.widgets.ListBox, {
-		templateString: '<div><form><select dojoAttachPoint="select"></select></form></div>',
+// If size==1, get a combo box, which we don't want, so
+// start with size 2, increment if necessary as we add children:
+		trueSize:0,
+		templateString: '<div><form><select dojoAttachPoint="select" size="2"></select></form></div>',
 		templateCssPath: null,
 		widgetType: "ListBox",
 		isContainer: true,
 		addChild: function(child) { /* elementListItem */
 			
-			this.select.appendChild(child.domNode);
-			
-				//alert('adding an option');
+			this.select.appendChild(child.domNode); 
+			++this.trueSize ;
+			if( trueSize>1){
+				this.select.size = trueSize ;	
+			}
+			//alert('adding an option');
 			
 		},
 		removeChild: function(child) {
@@ -34,7 +40,14 @@
 			var options = this.select.options
 			
 			for (var i = 0; i < options.length; i++) {
-				if (options[i] == child.domNode) options[i] = null;
+				if (options[i] == child.domNode){
+					options[i] = null;
+					// Keep this from turning a list box into a combo box
+					--this.trueSize ;
+					if(this.trueSize > 1){
+						this.select.size = this.trueSize ;
+					}
+				}
 				/* IE doesn't update the page with dom node removal so we have to do this*/
 			}
 			
@@ -44,6 +57,7 @@
 				obj && obj[fn] && obj[fn](param);
 			}
 		}
+		
 		
 	}
 );



Mime
View raw message