incubator-xap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mtu...@apache.org
Subject svn commit: r483649 - in /incubator/xap/trunk: WebContent/examples/widgets/listbox.html WebContent/examples/widgets/listbox.xal src/xap/bridges/xap/ListBoxBridge.js src/xap/widgets/ListBox.js
Date Thu, 07 Dec 2006 20:31:47 GMT
Author: mturyn
Date: Thu Dec  7 12:31:46 2006
New Revision: 483649

URL: http://svn.apache.org/viewvc?view=rev&rev=483649
Log:
Fixed multiple selection en/disabling.  Now trims all but first selected options if one foes
from multiple to single selectability.

Fixed test page---wasn't even _trying_ to set multiple, was just selecting the first option.

Modified:
    incubator/xap/trunk/WebContent/examples/widgets/listbox.html
    incubator/xap/trunk/WebContent/examples/widgets/listbox.xal
    incubator/xap/trunk/src/xap/bridges/xap/ListBoxBridge.js
    incubator/xap/trunk/src/xap/widgets/ListBox.js

Modified: incubator/xap/trunk/WebContent/examples/widgets/listbox.html
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/widgets/listbox.html?view=diff&rev=483649&r1=483648&r2=483649
==============================================================================
--- incubator/xap/trunk/WebContent/examples/widgets/listbox.html (original)
+++ incubator/xap/trunk/WebContent/examples/widgets/listbox.html Thu Dec  7 12:31:46 2006
@@ -31,6 +31,7 @@
 	
 
 	<script language="JavaScript" type="text/javascript" src="../../xapcore.js"></script>
+	<script language="JavaScript" type="text/javascript" src="AttributeTester.js"></script>
     
     <script language="JavaScript">  
 	<!-- must do this before we load the actual application: -->    

Modified: incubator/xap/trunk/WebContent/examples/widgets/listbox.xal
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/widgets/listbox.xal?view=diff&rev=483649&r1=483648&r2=483649
==============================================================================
--- incubator/xap/trunk/WebContent/examples/widgets/listbox.xal (original)
+++ incubator/xap/trunk/WebContent/examples/widgets/listbox.xal Thu Dec  7 12:31:46 2006
@@ -15,8 +15,7 @@
 
 				<horizontalBoxPane>
 
-					<listBox id="testComponent" color="green" 
-tooltip="{mco:attributeSetter.getAttributeCaption(this,'value')}"				
+					<listBox id="testComponent" color="green" 				
 						fontWeight="bold" fontSize="18px" 
 						selectionMode="multiRow"  height="200px"
 						onActiveGained="mco:attributeSetter.reportEvent(event)" onActiveLost="mco:attributeSetter.reportEvent(event)"
@@ -39,7 +38,8 @@
 
 					<button width="200px" height="50px" alignHorizontal="center" alignVertical="center"
text="Insert a NEW Option" onCommand="mco:attributeSetter.appendListItem(testComponent)" />
 
-					<button width="200px" height="50px" alignHorizontal="center" alignVertical="center"
text="Multiselect" onCommand="mco:attributeSetter.setAttribute(testOption1, 'selected', 'true')"
/>
+					<button width="200px" height="50px" alignHorizontal="center" alignVertical="center"
text="Multiselect on" onCommand="mco:attributeSetter.setAttribute(testComponent, 'selectionMode',
'multiRow')" />
+					<button width="200px" height="50px" alignHorizontal="center" alignVertical="center"
text="Multiselect off" onCommand="mco:attributeSetter.setAttribute(testComponent, 'selectionMode',
'single')" />					
 					
 					<button width="200px" height="50px" alignHorizontal="center" alignVertical="center"
text="Selected text/value" onCommand="mco:attributeSetter.reportTextValueAttributes(testComponent)"
/>
 

Modified: incubator/xap/trunk/src/xap/bridges/xap/ListBoxBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/xap/ListBoxBridge.js?view=diff&rev=483649&r1=483648&r2=483649
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/xap/ListBoxBridge.js (original)
+++ incubator/xap/trunk/src/xap/bridges/xap/ListBoxBridge.js Thu Dec  7 12:31:46 2006
@@ -49,7 +49,11 @@
 
 xap.bridges.xap.ListBoxBridge.prototype.onChange = function(event){
 
+	// Default:
 	var select = this.getPeer().select ;
+	if(event && event.originalTarget){
+		select = event.originalTarget ;
+	}
 
 	if( select.size == 1 ){
 		var val = select.value ;
@@ -141,9 +145,7 @@
 	// We should always use "onChange" to reset values
 	// to make sure values are propagated upwards if this
 	// is pwned by a ComboBoxBridge
-	var event = { originalTarget: this.getPeer().select } ;
-	
-	this.onChange( event ) ;
+	this.onChange( null ) ;
 
 }
 
@@ -183,6 +185,8 @@
 	} else {
 		this.getPeer().setSelectMultiple(false);
 		this.writeBackAttribute("selectionMode","single") ;		
+		// We might have trimmed nodes at this point, so set an onChange
+		this.onChange(null);
 	}
 }
 

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=483649&r1=483648&r2=483649
==============================================================================
--- incubator/xap/trunk/src/xap/widgets/ListBox.js (original)
+++ incubator/xap/trunk/src/xap/widgets/ListBox.js Thu Dec  7 12:31:46 2006
@@ -26,9 +26,13 @@
 		setSelectMultiple:function(tf){
 			this.multiselect = tf ;
 			if(tf){
-				this.domNode.size=this.domNode.options.size ;
+				this.domNode.multiple = true ;
 			} else {
-				this.domNode.size = 1 ;
+				this.domNode.multiple= false ;
+				// If more than one is selected at this point,
+				// keep the first (faute de mieux) and deselect
+				// the rest:
+				this.trimSuperUnarySelectedOptions() ;
 			}
 		},
 		addChild: function(child) { /* elementListItem */
@@ -98,10 +102,21 @@
 			
 		numberOfOptions:function(){
 			return this.select.options.length ;			
-		}		
-
+		},
 		
+		trimSuperUnarySelectedOptions:function(){
+			var node=this.domNode.firstChild ;
+			var foundFirstSelected=false ;
+			while(node){
+				if( !foundFirstSelected && node.selected){
+					foundFirstSelected = true ;
+				} else {
+					node.selected = false ;
+				}
+				node = node.nextSibling ;
+			}
 		
+		}
 	}
 );
 



Mime
View raw message