incubator-xap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmarga...@apache.org
Subject svn commit: r485946 - in /incubator/xap/trunk: WebContent/examples/widgets/textArea.xal src/xap/bridges/dojo/TextAreaBridge.js
Date Mon, 11 Dec 2006 23:51:47 GMT
Author: jmargaris
Date: Mon Dec 11 15:51:47 2006
New Revision: 485946

URL: http://svn.apache.org/viewvc?view=rev&rev=485946
Log:
now accepting child text node

Modified:
    incubator/xap/trunk/WebContent/examples/widgets/textArea.xal
    incubator/xap/trunk/src/xap/bridges/dojo/TextAreaBridge.js

Modified: incubator/xap/trunk/WebContent/examples/widgets/textArea.xal
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/widgets/textArea.xal?view=diff&rev=485946&r1=485945&r2=485946
==============================================================================
--- incubator/xap/trunk/WebContent/examples/widgets/textArea.xal (original)
+++ incubator/xap/trunk/WebContent/examples/widgets/textArea.xal Mon Dec 11 15:51:47 2006
@@ -42,7 +42,7 @@
 	<xm:modifications>
 		<xm:append select="/ui">
 				<xal:textArea width="200px" 
-					text="This is some text" id="testComponent"
+					id="testComponent"
 					alignHorizontal="right" alignVertical="center"
 					onActiveGained="mco:attributeSetter.reportEvent(event)"
 					onActiveLost="mco:attributeSetter.reportEvent(event)"
@@ -62,7 +62,7 @@
 					onMouseOut="mco:attributeSetter.reportEvent(event)"
 					onMouseOver="mco:attributeSetter.reportEvent(event)"
 					onMouseUp="mco:attributeSetter.reportEvent(event)"
-					onTextChange="mco:attributeSetter.reportEvent(event)"/>			
+					onTextChange="mco:attributeSetter.reportEvent(event)">this is some text in a text
area</xal:textArea>			
 			<horizontalBoxPane>
 				<verticalBoxPane>
 					<!-- button specific properties -->

Modified: incubator/xap/trunk/src/xap/bridges/dojo/TextAreaBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/dojo/TextAreaBridge.js?view=diff&rev=485946&r1=485945&r2=485946
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/TextAreaBridge.js (original)
+++ incubator/xap/trunk/src/xap/bridges/dojo/TextAreaBridge.js Mon Dec 11 15:51:47 2006
@@ -26,6 +26,8 @@
 Xap.require("xap.bridges.dojo.TextFieldBridge");
 Xap.require("xap.widgets.dojo.TextArea"); 
 Xap.require("xap.session.ClientEvent"); 
+Xap.require("xap.taghandling.AbstractTagImpl");
+Xap.require("xap.xml.dom.events.StructureChangeEvent");
 
  /**
  * @fileoverview
@@ -49,7 +51,55 @@
 xap.bridges.dojo.TextAreaBridge.prototype.init = function() {
 	xap.bridges.dojo.TextFieldBridge.prototype.init.call(this);	
 	dojo.event.connect(this.getPeer(), "onselect",this,"onSelect");	
-	dojo.event.connect(this.getPeer(), "onmousedown",this,"onMousedown");			
+	dojo.event.connect(this.getPeer(), "onmousedown",this,"onMousedown");
+	
+	//parse initial children has the children add themselves to the parent
+	//but that doesn't work well for plain old text/html children without any
+	//handlers, so look for a child here
+	var childNodes = this.getElement().childNodes;
+	if (!xap.taghandling.AbstractTagImpl.TAIL_RECURSION){
+		for (var i = 0; i<childNodes.length;i++){
+			if (childNodes[i].nodeType==google.DOM_TEXT_NODE){
+				this.childAdded(new xap.xml.dom.events.StructureChangeEvent( 
+					this.getElement(),childNodes[i], -1 ));
+			}
+		}
+	}			
+}
+
+
+//TODO make this ONLY work and not the text attribute??
+//right now both will work which is odd...
+xap.bridges.dojo.TextAreaBridge.prototype.childAdded = function( e ) {
+	var childElement = e.getChange();
+	
+	//this only handles the first child particularly well
+	if (childElement.nodeType==google.DOM_TEXT_NODE){
+		this.setTextAttribute(childElement.nodeValue);
+	}
+}
+
+
+xap.bridges.dojo.TextAreaBridge.prototype.onTextChange = function( event ){
+	var text = this.getPeer().getText() ;
+	// When text field size is limited, get a keyup even if there's been no 
+	// change, so we'll have to check that there has been:
+	if ( text != this.lastText ){
+		this.lastText = text ;
+		var clientEvent = new xap.session.ClientEvent(this.getElement(),this.getSession());
+		clientEvent.text = text;
+		clientEvent.originalEvent = event ;
+		this.lastKeyCode = event.keyCode ;
+		
+		//TODO stop writing back the attribute and ONLY do the dom node	
+		this.writeBackAttribute(xap.xml.XmlTokens.TEXT,text);
+		
+		//TODO this is really slow to do this every time, maybe we should do it
+		//only when we NEED to have it ready, for example before we fire an event
+		//that we know the user is listening for or when we blur
+		this.writeBackTextNode(text);
+		this.fireEvent("onTextChange",null,null,clientEvent);
+	}
 }
 
 xap.bridges.dojo.TextAreaBridge.prototype.getPeerString = function(){



Mime
View raw message