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 2006/10/19 21:34:43 UTC

svn commit: r465901 - in /incubator/xap/trunk: WebContent/examples/widgets/tabPane.html WebContent/examples/widgets/tabPane.xal src/xap/bridges/dojo/TabBridge.js

Author: mturyn
Date: Thu Oct 19 14:34:43 2006
New Revision: 465901

URL: http://svn.apache.org/viewvc?view=rev&rev=465901
Log:
Added detection and event-firing for onStateChange event, added selected() function.  

Added another tab to the example (the only way I can tell which colour means 'selected'.)

Improved layout of buttons in example--gave them x/width attributes to position them within that free panel.

Modified:
    incubator/xap/trunk/WebContent/examples/widgets/tabPane.html
    incubator/xap/trunk/WebContent/examples/widgets/tabPane.xal
    incubator/xap/trunk/src/xap/bridges/dojo/TabBridge.js

Modified: incubator/xap/trunk/WebContent/examples/widgets/tabPane.html
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/widgets/tabPane.html?view=diff&rev=465901&r1=465900&r2=465901
==============================================================================
--- incubator/xap/trunk/WebContent/examples/widgets/tabPane.html (original)
+++ incubator/xap/trunk/WebContent/examples/widgets/tabPane.html Thu Oct 19 14:34:43 2006
@@ -3,7 +3,7 @@
 <html>
 <head>
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
-    <title>Button</title>
+    <title>Tab pane</title>
 
 	<style type="text/css">
       <!--

Modified: incubator/xap/trunk/WebContent/examples/widgets/tabPane.xal
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/widgets/tabPane.xal?view=diff&rev=465901&r1=465900&r2=465901
==============================================================================
--- incubator/xap/trunk/WebContent/examples/widgets/tabPane.xal (original)
+++ incubator/xap/trunk/WebContent/examples/widgets/tabPane.xal Thu Oct 19 14:34:43 2006
@@ -14,28 +14,54 @@
 	
 		<xal:tabPane width="200px" height="100px"
 		id="testComponent" >
-			<xal:tab text="Tab1" id="tab1"  onSelect="mco:attributeSetter.reportEvent(event)">
-				<xal:button text="button1"/>
-				<xal:button text="button2"/>
-				<xal:button text="button3"/>
+			<xal:tab text="Tab1" id="tab1" 
+				onSelect="mco:attributeSetter.reportEvent(event)" 
+				onStateChange="mco:attributeSetter.reportEvent(event)" 
+				backgroundColor="#FFEEFF"
+			>
+				<xal:button text="button1" x="0px" width="25%"/>
+				<xal:button text="button2" x="30%" width="25%"/>
+				<xal:button text="button3" x="60%" width="25%"/>/>
 			</xal:tab>
-			<xal:tab text="Tab2" id="tab2" onSelect="mco:attributeSetter.reportEvent(event)">
-				<xal:button text="buttonA"/>
-				<xal:button text="buttonB"/>
-				<xal:button text="buttonC"/>
+			<xal:tab text="Tab2" id="tab2" 
+				onSelect="mco:attributeSetter.reportEvent(event)" 
+				onStateChange="mco:attributeSetter.reportEvent(event)" 
+				backgroundColor="#FFFFEE"				
+			>
+				<xal:button text="buttonA" x="0px" width="25%"/>
+				<xal:button text="buttonB" x="30%" width="25%"/>
+				<xal:button text="buttonC" x="60%" width="25%"/>/>
 			</xal:tab>
+			<xal:tab text="Tab3" id="tab3" 
+				onSelect="mco:attributeSetter.reportEvent(event)" 
+				onStateChange="mco:attributeSetter.reportEvent(event)" 
+				backgroundColor="#EEFFFF"				
+			>
+				<xal:button text="buttonI" x="0px" width="25%"/>
+				<xal:button text="buttonII" x="30%" width="25%"/>
+				<xal:button text="buttonIII" x="60%" width="25%"/>/>
+			</xal:tab>			
+			
 		</xal:tabPane>
 		
 		
 		<xal:button width="200px" height="25px" 
 			text="selected(tab1)-> 'true'"
+			backgroundColor="#FFeeFF"
 			onCommand="mco:attributeSetter.setAttribute(tab1,
 				'selected' ,'true')"/>
 			
 		<xal:button width="200px" height="25px" 
 			text="selected(tab2)-> 'true'"
+			backgroundColor="#FFFFee"
 			onCommand="mco:attributeSetter.setAttribute(tab2,
 				'selected' ,'true')"/>
+				
+		<xal:button width="200px" height="25px" 
+			text="selected(tab3)-> 'true'"
+			backgroundColor="#eeFFFF"
+			onCommand="mco:attributeSetter.setAttribute(tab3,
+				'selected' ,'true')"/>				
 				
 		<!--standard test things -->
 		

Modified: incubator/xap/trunk/src/xap/bridges/dojo/TabBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/dojo/TabBridge.js?view=diff&rev=465901&r1=465900&r2=465901
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/TabBridge.js (original)
+++ incubator/xap/trunk/src/xap/bridges/dojo/TabBridge.js Thu Oct 19 14:34:43 2006
@@ -56,8 +56,11 @@
 	var parentHandler = this.getUiContentHandler().getHandlerForElement( parentElement );
 	this._tabContainer =  parentHandler.getPeer();
 	
+	this._wasSelected = 
+			(this._tabContainer.selectedTabWidget == this.getPeer()) ;
+	
 	//add listener last so we don't fire for the initial set
-	dojo.event.connect(this._tabContainer, "selectTab",this,"onSelect");	
+	dojo.event.connect(this._tabContainer, "selectTab",this,"onSelect");		
 }
 
 xap.bridges.dojo.TabBridge.prototype.unload = function(){
@@ -65,19 +68,29 @@
 }
 
 xap.bridges.dojo.TabBridge.prototype.onSelect = function(){
+	var isSelectedNow =  this.selected() ;
+	
+	// A change is a change, regardless of the direction:
+	if( isSelectedNow == !this._wasSelected ){ // This is not what was
+		this.fireEvent("onStateChange") ;	
+	}	
 	
-	if (this._tabContainer.selectedTabWidget == this.getPeer() && !this._wasSelected){
+	if ( isSelectedNow && !this._wasSelected){
 		this.writeBackAttribute("selected","true");
-		this.fireEvent("onSelect");
+		this.fireEvent("onSelect");			
 		this._wasSelected = true;
 	}
 	else{
-		this.writeBackRemoveAttribute("selected");
-		this._wasSelected = false;
-	}
+		this.writeBackRemoveAttribute("selected");	
+		this._wasSelected = false;	
+	}	
+	
 }
 
 
+
+
+
 xap.bridges.dojo.TabBridge.prototype.getPeerString = function(){
     return "FreePanel" ;
 }
@@ -109,5 +122,9 @@
 		this._tabContainer.selectTab(this.getPeer());
 	}
 }	
+
+xap.bridges.dojo.TabBridge.prototype.selected = function(){
+	return ( this._tabContainer.selectedTabWidget == this.getPeer() ) ;
+}