incubator-xap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mtu...@apache.org
Subject svn commit: r484845 - in /incubator/xap/trunk: WebContent/examples/widgets/listbox.xal src/xap/bridges/xap/ListBoxBridge.js src/xap/bridges/xap/XapComboBoxBridge.js src/xap/widgets/ListBox.js
Date Fri, 08 Dec 2006 23:28:33 GMT
Author: mturyn
Date: Fri Dec  8 15:28:31 2006
New Revision: 484845

URL: http://svn.apache.org/viewvc?view=rev&rev=484845
Log:
Fixed small bugs, cleaned up code a lot (brought full basic attribute setting functionality
to the ListBox peer, rather than puppeteering it from the bridge.)

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

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=484845&r1=484844&r2=484845
==============================================================================
--- incubator/xap/trunk/WebContent/examples/widgets/listbox.xal (original)
+++ incubator/xap/trunk/WebContent/examples/widgets/listbox.xal Fri Dec  8 15:28:31 2006
@@ -15,7 +15,8 @@
 
 				<horizontalBoxPane>
 
-					<listBox id="testComponent" color="green" 				
+					<listBox id="testComponent" color="green" 
+						borderColor="yellow" borderWidth="6px" borderStyle="ridge"									
 						fontWeight="bold" fontSize="18px" 
 						selectionMode="multiRow"  height="200px"
 						onActiveGained="mco:attributeSetter.reportEvent(event)" onActiveLost="mco:attributeSetter.reportEvent(event)"

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=484845&r1=484844&r2=484845
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/xap/ListBoxBridge.js (original)
+++ incubator/xap/trunk/src/xap/bridges/xap/ListBoxBridge.js Fri Dec  8 15:28:31 2006
@@ -54,35 +54,12 @@
 	if(event && event.originalTarget){
 		select = event.originalTarget ;
 	}
+	
+	// These might two arrays, or two strings:
+	var valtext = this.getPeer().getTextValuePairs(select) ; 
 
-	if( select.size == 1 ){
-		var val = select.value ;
-		if( val ){
-			this.writeBackAttribute("value", val) ;	
-			if( select.selectedIndex != -1 ){
-				this.writeBackAttribute("text", 
-						select.options[select.selectedIndex].text
-										 ) ;			
-			} 
-		}
-	} else {
-		// Must step through
-		var arrTexts = new Array(0) ;
-		var arrValues = new Array(0) ;
-		var node = select.firstChild ;
-		var siz = select.size ;
-		while( node  ){
-			if( node.selected ){
-				arrTexts.push(node.text) ;
-				arrValues.push(node.value) ;
-			} else {
-			
-			}
-			node=node.nextSibling ;
-		}
-		this.writeBackAttribute("text",arrTexts) ;
-		this.writeBackAttribute("value",arrValues) ;
-	}
+	this.writeBackAttribute("text", valtext.text ) ;
+	this.writeBackAttribute("value", valtext.value ) ;
 }
 
 // The events associated with list items.
@@ -190,38 +167,27 @@
 	}
 }
 
-xap.bridges.xap.ListBoxBridge.prototype.setWidthAttribute = function(value) {
-	this.getPeer().select.style.width = value;
-}
-
-xap.bridges.xap.ListBoxBridge.prototype.setHeightAttribute = function(value) {
-	this.getPeer().select.style.height = value;
-}
-
-
-
-/* Override Methods */
-
 xap.bridges.xap.ListBoxBridge.prototype.setColorAttribute = function(value){
-	this.getPeer().select.style.color = value ;
+	this.getPeer().setColor( value ) ;
 }
-
 xap.bridges.xap.ListBoxBridge.prototype.setFontFamilyAttribute = function(value){
-	this.getPeer().select.style.fontFamily = value ;
+	this.getPeer().setFontFamily( value ) ;
 }
-
 xap.bridges.xap.ListBoxBridge.prototype.setFontSizeAttribute = function(value){
-	this.getPeer().select.style.fontSize = value ;
+	this.getPeer().setFontSize( value ) ;
 }
-
 xap.bridges.xap.ListBoxBridge.prototype.setFontStyleAttribute = function(value){
-	this.getPeer().select.style.fontStyle = value ;
+	this.getPeer().setFontStyle( value ) ;
 }
-
 xap.bridges.xap.ListBoxBridge.prototype.setFontWeightAttribute = function(value){
-	this.getPeer().select.style.fontWeight = value ;
+	this.getPeer().setFontWeight( value ) ;
+}
+xap.bridges.xap.ListBoxBridge.prototype.setHeightAttribute = function(value) {
+	this.getPeer().setHeight( value ) ;
+}
+xap.bridges.xap.ListBoxBridge.prototype.setWidthAttribute = function(value) {
+	this.getPeer().setWidth( value ) ;
 }
-
 
 
 

Modified: incubator/xap/trunk/src/xap/bridges/xap/XapComboBoxBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/xap/XapComboBoxBridge.js?view=diff&rev=484845&r1=484844&r2=484845
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/xap/XapComboBoxBridge.js (original)
+++ incubator/xap/trunk/src/xap/bridges/xap/XapComboBoxBridge.js Fri Dec  8 15:28:31 2006
@@ -55,7 +55,10 @@
 xap.bridges.xap.XapComboBoxBridge.prototype.setHeightAttribute = function(value) {
 	
 	if( !window.netscape ){
-		// nothing can be done:	
+		// nothing more can be done:	
+		if( this.getRootDomNode() ){
+			this.getRootDomNode().style.height = value ;
+		}
 		return ;
 	}
 

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=484845&r1=484844&r2=484845
==============================================================================
--- incubator/xap/trunk/src/xap/widgets/ListBox.js (original)
+++ incubator/xap/trunk/src/xap/widgets/ListBox.js Fri Dec  8 15:28:31 2006
@@ -18,7 +18,11 @@
 // If size==1, get a combo box, which we don't want, so
 // start with size 2, increment if necessary as we add children:
 //(Note:onkeydown, onblur so far is only needed if this is a combobox interior.)
-		templateString: '<div style="border: 0px solid silver"><select dojoAttachPoint="select"
dojoAttachEvent="onkeyup;onchange;onmouseout;onkeydown;onblur;onselect" size="2"></select></div>',
+		templateString: '<div style="border: 0px solid black;margin:0px;padding:0px;align:center;vertical-align:middle">'
+						+'<select dojoAttachPoint="select" '
+							+ 'dojoAttachEvent="onkeyup;onchange;onmouseout;onkeydown;onblur;onselect"' 
+							+ 'style="border: 1px ridge darkgray;margin:0px;padding:0px"'
+							+ 'size="2"></select></div>',
 		templateCssPath: null,
 		widgetType: "ListBox",
 		isContainer: true,
@@ -26,21 +30,22 @@
 		setSelectMultiple:function(tf){
 			this.multiselect = tf ;
 			if(tf){
-				this.domNode.multiple = true ;
+				this.select.multiple = true ;
 			} else {
-				this.domNode.multiple= false ;
+				this.select.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 */
 			
 			this.select.appendChild(child.domNode);
 			//alert('adding an option');
 			if( this.multiselect){
-				++this.domNode.size ;
+				++this.select.size ;
 			}
 			
 		},
@@ -58,7 +63,7 @@
 				/* IE doesn't update the page with dom node removal so we have to do this*/
 				
 			}
-			--this.select.size ;			
+			--this.select.size ;						
 		},
 		setOnStateChange: function(obj, fn, param) {
 			this.select.onchange = function() {
@@ -105,8 +110,9 @@
 		},
 		
 		trimSuperUnarySelectedOptions:function(){
-			var node=this.domNode.firstChild ;
+			var node=this.select ;
 			var foundFirstSelected=false ;
+			node=node.firstChild ;
 			while(node){
 				if( !foundFirstSelected && node.selected){
 					foundFirstSelected = true ;
@@ -116,9 +122,81 @@
 				node = node.nextSibling ;
 			}
 		
+		},
+		getTextValuePairs:function(aSelectNode){
+			var select = aSelectNode ;
+			if( !select ){
+				select = this.select ;
+			}
+			result={text:null, value:null} ;
+			if( !select.multiple ){
+				var val = select.value ;
+				if( val ){
+					result.value = val ;	
+					if( select.selectedIndex != -1 ){
+							result.text 
+								= select.options[select.selectedIndex].text			
+					} 
+				}
+			} else {
+				// Must step through
+				var arrTexts = new Array(0) ;
+				var arrValues = new Array(0) ;
+				var node = select.firstChild ;
+				var siz = select.size ;
+				while( node  ){
+					if( node.selected ){
+						arrTexts.push(node.text) ;
+						arrValues.push(node.value) ;
+					} else {
+					
+					}
+					node=node.nextSibling ;
+				}		
+			result.text = arrTexts ;
+			result.value = arrValues ;
 		}
-	}
+		return result ;
+	} // getTextValuePairs
+}
 );
+
+
+//Avoid "puppetry"---that is, make this widget able to handle things for itself,
+//leaving the bridge class to call these methods---much better if we have to change
+// this class:
+
+xap.widgets.ListBox.prototype.setWidth = function(value) {
+	this.select.style.width = "100%";	
+	this.domNode.style.width = value ;	
+}
+
+xap.widgets.ListBox.prototype.setHeight = function(value) {
+	this.select.style.height = "100%";	
+	this.domNode.style.height = value;		
+}
+
+xap.widgets.ListBox.prototype.setColor = function(value){
+	this.select.style.color = value ;
+}
+
+xap.widgets.ListBox.prototype.setFontFamily = function(value){
+	this.select.style.fontFamily = value ;
+}
+
+xap.widgets.ListBox.prototype.setFontSize = function(value){
+	this.select.style.fontSize = value ;
+}
+
+xap.widgets.ListBox.prototype.setFontStyle = function(value){
+	this.select.style.fontStyle = value ;
+}
+
+xap.widgets.ListBox.prototype.setFontWeight = function(value){
+	this.select.style.fontWeight = value ;
+}
+
+
 
 
 // Maybe use this later:



Mime
View raw message