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/12 22:57:40 UTC
svn commit: r463491 - in /incubator/xap/trunk:
WebContent/examples/widgets/AttributeTester.js
WebContent/examples/widgets/textField.html
WebContent/examples/widgets/textField.xal
src/xap/bridges/dojo/TextFieldBridge.js
Author: mturyn
Date: Thu Oct 12 15:57:39 2006
New Revision: 463491
URL: http://svn.apache.org/viewvc?view=rev&rev=463491
Log:
Added "maxLength", "selectable", "editable" (last two are the same) attributes and testers.
Modified:
incubator/xap/trunk/WebContent/examples/widgets/AttributeTester.js
incubator/xap/trunk/WebContent/examples/widgets/textField.html
incubator/xap/trunk/WebContent/examples/widgets/textField.xal
incubator/xap/trunk/src/xap/bridges/dojo/TextFieldBridge.js
Modified: incubator/xap/trunk/WebContent/examples/widgets/AttributeTester.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/widgets/AttributeTester.js?view=diff&rev=463491&r1=463490&r2=463491
==============================================================================
--- incubator/xap/trunk/WebContent/examples/widgets/AttributeTester.js (original)
+++ incubator/xap/trunk/WebContent/examples/widgets/AttributeTester.js Thu Oct 12 15:57:39 2006
@@ -6,6 +6,17 @@
element.setAttribute(name, value);
}
+AttributeTester.prototype.getAttribute = function(element, name){
+ return element.setAttribute(name);
+}
+
+AttributeTester.prototype.toggleBooleanAttribute = function(element, name){
+ var val = element.getAttribute(name) ;
+ var newVal = (val=="true")?"false":"true" ;
+ element.setAttribute(name, newVal );
+}
+
+
AttributeTester.prototype.reportEvent = function(event){
alert(event);
}
Modified: incubator/xap/trunk/WebContent/examples/widgets/textField.html
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/widgets/textField.html?view=diff&rev=463491&r1=463490&r2=463491
==============================================================================
--- incubator/xap/trunk/WebContent/examples/widgets/textField.html (original)
+++ incubator/xap/trunk/WebContent/examples/widgets/textField.html Thu Oct 12 15:57:39 2006
@@ -3,7 +3,7 @@
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title>Button</title>
+ <title>TextField</title>
<style type="text/css">
<!--
@@ -20,6 +20,16 @@
<script language="JavaScript" type="text/javascript" src="../../xapcore.js"></script>
<script language="JavaScript" type="text/javascript" src="AttributeTester.js"></script>
+
+ <script languag="JavaScript">
+ Xap._sourceRootDir = "../../" ;
+ Xap.addDebuggables(
+ "xap.widgets.dojo.TextField",
+ "xap.bridges.dojo.TextFieldBridge",
+ "xap.bridges.dojo.DojoWidgetBridge"
+ ) ;
+ Xap._loadDebuggables() ;
+ </script>
</head>
Modified: incubator/xap/trunk/WebContent/examples/widgets/textField.xal
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/WebContent/examples/widgets/textField.xal?view=diff&rev=463491&r1=463490&r2=463491
==============================================================================
--- incubator/xap/trunk/WebContent/examples/widgets/textField.xal (original)
+++ incubator/xap/trunk/WebContent/examples/widgets/textField.xal Thu Oct 12 15:57:39 2006
@@ -12,16 +12,42 @@
<xm:modifications xmlns:xm="http://www.openxal.org/xmodify">
<xm:append select="/xal">
- <xal:textField width="200px" text="A text field"
+ <xal:textField width="200px" text="123456789abcdef0" editable="true"
id="testComponent" onEdit="mco:attributeSetter.reportEvent(event)"
/>
- <!-- button specific properties -->
+ <!-- textField specific properties -->
<xal:button width="200px" height="25px"
text="text -> 'some new text'"
onCommand="mco:attributeSetter.setAttribute(testComponent,
'text','some new text')"/>
+
+ <!-- textField specific properties -->
+ <xal:button width="200px" height="25px"
+ text="Limit text to 8 chars"
+ onCommand="mco:attributeSetter.setAttribute(testComponent,
+ 'maxLength','8')"/>
+
+ <!-- textField specific properties -->
+ <xal:button width="200px" height="25px"
+ text="...255 chars."
+ onCommand="mco:attributeSetter.setAttribute(testComponent,
+ 'maxLength','255')"/>
+ <xal:button width="200px" height="25px"
+ text="Selectability ON"
+ onCommand="mco:attributeSetter.setAttribute(testComponent,
+ 'selectable', 'true')"/>
+ <xal:button width="200px" height="25px"
+ text="Selectability OFF"
+ onCommand="mco:attributeSetter.setAttribute(testComponent,
+ 'selectable','false')"/>
+
+ <xal:button width="200px" height="25px"
+ text="Toggle editability"
+ onCommand="mco:attributeSetter.toggleBooleanAttribute(testComponent,
+ 'editable')"/>
+
Modified: incubator/xap/trunk/src/xap/bridges/dojo/TextFieldBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/dojo/TextFieldBridge.js?view=diff&rev=463491&r1=463490&r2=463491
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/dojo/TextFieldBridge.js (original)
+++ incubator/xap/trunk/src/xap/bridges/dojo/TextFieldBridge.js Thu Oct 12 15:57:39 2006
@@ -69,7 +69,7 @@
* No new dynamic attributes
*/
xap.bridges.dojo.TextFieldBridge.prototype.getNewAllowedAttributes = function(){
- return ["text"];
+ return ["text","maxLength","selectable","editable"];
}
xap.bridges.dojo.TextFieldBridge.prototype.setTextAttribute = function( value ){
@@ -83,6 +83,58 @@
clientEvent.text = text;
this.fireEvent("onEdit",null,null,clientEvent);
}
+
+
+xap.bridges.dojo.TextFieldBridge.prototype.setMaxLengthAttribute = function( nMax ){
+ this.getPeer().setMaxLength( nMax ) ;
+
+ // Trim text down, if needed:
+ var text = this.getPeer().getText();
+ if (text && text.length> nMax){
+ text = text.substring(0,nMax) ;
+ this.setTextAttribute(text) ;
+ }
+}
+
+
+xap.bridges.dojo.TextFieldBridge.prototype.getMaxLengthAttribute = function( ){
+ return this.getPeer().getMaxLength() ;
+}
+
+
+xap.bridges.dojo.TextFieldBridge.prototype.setSelectableAttribute = function( bWritable ){
+ this.setEditableAttribute(bWritable) ;
+}
+
+xap.bridges.dojo.TextFieldBridge.prototype.getSelectableAttribute = function( ){
+ return (this.getEditableAttribute()=="false")?"false":"true" ;
+}
+
+xap.bridges.dojo.TextFieldBridge.prototype.setEditableAttribute = function( bWritable ){
+//alert("About to handle setEditableAttribute("+bWritable+").");
+ bWritable = "" + bWritable ;
+ var bReadonly = (bWritable=="false")?"true":"false" ;
+ this.getPeer().setReadOnly( bReadonly ) ;
+ this.writeBackAttribute("editable",bWritable);
+ this.writeBackAttribute("selectable",bWritable);
+
+ // TODO: Move this to css a.s.a.p:
+ if( bReadonly == "true"){
+ this.setBackgroundColorAttribute("#cccccc") ;
+ } else {
+ this.setBackgroundColorAttribute("#ffffee") ;
+ }
+
+}
+
+
+// The peer thinks in terms of "readOnly" or not, we set using the opposite sense,
+// as "editable"=="non-readOnly":
+
+xap.bridges.dojo.TextFieldBridge.prototype.getEditableAttribute = function( ){
+ return ""+ !Boolean(this.getPeer().getReadOnly()) ;
+}
+