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 2007/04/19 03:05:52 UTC
svn commit: r530245 - in
/incubator/xap/trunk/samples/WebContent/examples/widgets:
includes/standardButtons.xal src-js/AttributeTester.js
Author: mturyn
Date: Wed Apr 18 20:05:51 2007
New Revision: 530245
URL: http://svn.apache.org/viewvc?view=rev&rev=530245
Log:
Replaced textfield for evaluation of JS code with a textarea field (double-click to toggle its height); return of eval'd code is now logged.
Modified:
incubator/xap/trunk/samples/WebContent/examples/widgets/includes/standardButtons.xal
incubator/xap/trunk/samples/WebContent/examples/widgets/src-js/AttributeTester.js
Modified: incubator/xap/trunk/samples/WebContent/examples/widgets/includes/standardButtons.xal
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/samples/WebContent/examples/widgets/includes/standardButtons.xal?view=diff&rev=530245&r1=530244&r2=530245
==============================================================================
--- incubator/xap/trunk/samples/WebContent/examples/widgets/includes/standardButtons.xal (original)
+++ incubator/xap/trunk/samples/WebContent/examples/widgets/includes/standardButtons.xal Wed Apr 18 20:05:51 2007
@@ -73,7 +73,7 @@
<radioButton group="width" width="75px" text="100px"
onSelect="mco:attributeSetter.setAttribute(testComponent, this.group, this.text)"
onCreate="mco:SmokeTests.addAttributeTest(this.group, this.text, this)"/>
- <radioButton group="width" width="75px" text="300px"
+ <radioButton group="width" width="75px" text="450px"
onSelect="mco:attributeSetter.setAttribute(testComponent, this.group, this.text)"
onCreate="mco:SmokeTests.addAttributeTest(this.group, this.text, this)"/>
<radioButton group="width" width="75px" text="25%"
@@ -283,8 +283,14 @@
<label width="400px" autoWrap="true"
text="Execute javascript with the field below. Type it in and hit 'Go.'"/>
<horizontalBoxPane>
- <textField id="codeSnippet" width="200px"/>
- <button text="Go!" onCommand="mco:attributeSetter.evalCode(codeSnippet.text)" width="50px"
+ <textArea id="codeSnippet"
+ width="400px" height="25px"
+ onKeyDown="mco:attributeSetter.evalCodeOnCR(event,codeSnippet)"
+ onDoubleClick="mco:attributeSetter.toggleSize(event,codeSnippet)"
+ >
+ </textArea>
+ <button text="Go!" onCommand="mco:attributeSetter.evalCode(codeSnippet.text)" width="50px"
+
height="22px"/>
</horizontalBoxPane>
Modified: incubator/xap/trunk/samples/WebContent/examples/widgets/src-js/AttributeTester.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/samples/WebContent/examples/widgets/src-js/AttributeTester.js?view=diff&rev=530245&r1=530244&r2=530245
==============================================================================
--- incubator/xap/trunk/samples/WebContent/examples/widgets/src-js/AttributeTester.js (original)
+++ incubator/xap/trunk/samples/WebContent/examples/widgets/src-js/AttributeTester.js Wed Apr 18 20:05:51 2007
@@ -91,19 +91,42 @@
// Hit 'return' in the "value" field, set the attribute:
AttributeTester.prototype.setAttributeOnCR = function(event,element, name, value){
- if(event.keyChar=='\r'){
+ if(event.keyChar=='\r'||event.keyCode==13){
this.setAttribute(element,name,value) ;
}
}
-AttributeTester.prototype.evalCodeOnCR = function(event,code){
- if(event.keyChar=='\r'){
- this.evalCode(code) ;
+AttributeTester.prototype.evalCodeOnCR = function(event,element){
+ if(event.keyChar=='\r'||event.keyCode==13){
+ var docHandler = event.session.getUiDocumentHandler();
+ var bridge = docHandler._elementsToBridges.get(element) ;
+ this.log(eval(bridge.getPeer().getText())) ;
+ } else if (event.keyCode==9){
+ // Allow indentation.
+ var docHandler = event.session.getUiDocumentHandler();
+ var bridge = docHandler._elementsToBridges.get(element) ;
+ var peer = bridge.getPeer() ;
+ var text = peer.getText() ;
+ peer.setText(text + "\t") ;
+ bridge.stopEvent(event.htmlEvent);
}
}
+AttributeTester.prototype.toggleSize = function(event,element){
+ var docHandler = event.session.getUiDocumentHandler();
+ var bridge = docHandler._elementsToBridges.get(element) ;
+ var peer = bridge.getPeer() ;
+ if(peer.domNode.offsetHeight<50){
+ bridge.setHeightAttribute("250px") ;
+ } else {
+ bridge.setHeightAttribute("25px") ;
+ }
+}
+
+
+
AttributeTester.prototype.evalCode = function(code){
- eval(code);
+ this.log(eval(code));
}