incubator-xap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mtu...@apache.org
Subject svn commit: r483526 - /incubator/xap/trunk/WebContent/examples/widgets/AttributeTester.js
Date Thu, 07 Dec 2006 16:27:14 GMT
Author: mturyn
Date: Thu Dec  7 08:27:13 2006
New Revision: 483526

URL: http://svn.apache.org/viewvc?view=rev&rev=483526
Log:
1.) Added function to report list/combobox text/value.
2.) Changed list item appending function so that:
     a.) ...each item will have a slightly different text and value
     b.) ...selected or unselected items can be added.
2.) Added function to allow attribute value entry using a carriage return---not necessary,
but a.) convenient, and b.) a good illustration of how to do that sort of thing (keystroke
 filtering).

Modified:
    incubator/xap/trunk/WebContent/examples/widgets/AttributeTester.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=483526&r1=483525&r2=483526
==============================================================================
--- incubator/xap/trunk/WebContent/examples/widgets/AttributeTester.js (original)
+++ incubator/xap/trunk/WebContent/examples/widgets/AttributeTester.js Thu Dec  7 08:27:13
2006
@@ -1,6 +1,6 @@
 AttributeTester = function(){}
 
-// Used in checking MCO reolution:
+// Used in checking MCO resolution:
 AttributeTesterAlias = AttributeTester ;
 
 
@@ -8,10 +8,41 @@
 	element.setAttribute(name, value);
 }
 
+// Hit 'return' in the "value" field, set the attribute:
+AttributeTester.prototype.setAttributeOnCR = function(event,element, name, value){
+	if(event.keyChar=='\r'){
+		this.setAttribute(element,name,value) ;
+	}
+}
+
+
 AttributeTester.prototype.getAttribute = function(element, name){
-	return element.setAttribute(name);
+	return element.getAttribute(name);
+}
+
+AttributeTester.prototype.getAttributeCaption = function(element, name){
+	return "Name: '"+name+"', value: "+element.getAttribute(name)+".";
 }
 
+AttributeTester.prototype.reportTextValueAttributes = function(element){
+	this.reportAttributes(element, ["text", "value"] ) ;
+}
+
+AttributeTester.prototype.reportAttributes = function(element, names){
+	var arr = names ;
+	if(typeof names == "string"){
+		arr = [ names] ;
+	}
+	var attributeValuesString = "Attribute-->value\n";
+	for ( var ii=0; ii<arr.length; ++ii ){
+		attributeValuesString +=   ". . .  "+arr[ii]+"-->"
+									+element.getAttribute(arr[ii])+"\n";
+	}
+	alert(attributeValuesString) ;
+}
+
+
+
 AttributeTester.prototype.toggleBooleanAttribute = function(element, name){
 	var val = element.getAttribute(name) ;
 	var newVal = (val=="true")?"false":"true" ;
@@ -40,7 +71,7 @@
 	    document.body.appendChild(l);   
 	    this._logDiv = l;
 		dojo.event.connect(this._logDiv, "ondblclick",this,"clearLog");	  	    
-	    this._logDiv.innerHTML="[Double-click to clear.]<br/><br/>" ; 		    
+	    this._logDiv.innerHTML="[Double-click to clear.]<br/><br/>" ;        
 	}
 	
 	text = text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g,
'&gt;');
@@ -54,7 +85,20 @@
 	
 }
 
-AttributeTester.prototype.clearLog = function(){
+
+AttributeTester.prototype.clearLog = function(event){
+
+	if( event.layerY && (event.layerY - this._logDiv.scrollTop) < 125){
+
+		if( this._logDiv.style.height=="350px" ){
+			this._logDiv.style.height = "25px" ;
+		} else {
+			this._logDiv.style.height = "350px" ;	
+		}
+
+		return ;
+	}
+
 	if (this._logDiv){
 		this._logDiv.innerHTML = "" ;	
 	}
@@ -62,7 +106,7 @@
 
 
 //IMPORTANT this works if you remove the same thing twice,
-//no error. BEcause we still found element in hashtable?
+//no error. Because we still found element in hashtable?
 AttributeTester.prototype.insertBefore = function( element ){
 alert("insert before");
 	var newElement = element.getOwnerDocument().createElement("freePane","http://openxal.org/ui");
@@ -95,14 +139,18 @@
 	alert("New dom node = " + parent.toXml());
 }
 
-AttributeTester.prototype.appendListItem = function(element) {
+
+AttributeTester.newOptionItemCount=-1;
+AttributeTester.prototype.appendListItem = function(element,selectedP) {
 	alert("append");
 	var newElement = element.getOwnerDocument().createElement("listItem",  "http://openxal.org/ui");
-	newElement.setAttribute("text", "NEW INSERT");
-	newElement.setAttribute("value","NEW VALUE");
-	newElement.setAttribute("selected", "true");
+	var caption="originally " ;
+	caption += ((selectedP)?"selected.":"not selected.") ;
+	newElement.setAttribute("text", ""+(++AttributeTester.newOptionItemCount)+": new text, "
+ caption);
+	newElement.setAttribute("value",""+(AttributeTester.newOptionItemCount)+": new value, "
+ caption);
+	newElement.setAttribute("selected", ""+selectedP);
 	element.appendChild(newElement);
-	alert("New dom node = " + element.toXml());
+	alert("New dom node:\n" + newElement.toXml());
 }
 
 



Mime
View raw message