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/03/20 21:11:15 UTC

svn commit: r520596 - /incubator/xap/trunk/samples/WebContent/examples/widgets/src-js/AttributeTester.js

Author: mturyn
Date: Tue Mar 20 14:11:14 2007
New Revision: 520596

URL: http://svn.apache.org/viewvc?view=rev&rev=520596
Log:
Altered so that border panel example won't put in new panels with the same colours and borderless, which made me incorrectly think that the center panel was expanding, rather than that a new panel was being added.

Modified:
    incubator/xap/trunk/samples/WebContent/examples/widgets/src-js/AttributeTester.js

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=520596&r1=520595&r2=520596
==============================================================================
--- incubator/xap/trunk/samples/WebContent/examples/widgets/src-js/AttributeTester.js (original)
+++ incubator/xap/trunk/samples/WebContent/examples/widgets/src-js/AttributeTester.js Tue Mar 20 14:11:14 2007
@@ -183,17 +183,45 @@
 	
 }
 
+AttributeTester.randomDarkColorString = function(){
+	var result="rgb(" ;
+	var channels = 3 ;
+	while(channels--){
+		result += (32 + Math.round(Math.random()*64))+"," ;
+	}
+	result = result.replace(/,$/,")") ;
+	return result ;
+}
 
-		
+// Used to tell how many times we've replace a panel:
+AttributeTester.prototype.panels = {e:0,n:0,w:0,s:0,c:0} ;		
 
 AttributeTester.prototype.addBorderComponent = function( parent, borderPosition ){
 alert("add border component");
 	var newElement = parent.ownerDocument.createElement("freePane","http://openxal.org/ui");
-	newElement.setAttribute("backgroundColor","yellow");
+	// Increase the odds that this won't match the colour of a panel right next to
+	// it, which can lead to believing that the center panel has grown horizontally	
+	// or vertically to take over an edge panel's space:
+	newElement.setAttribute("backgroundColor",AttributeTester.randomDarkColorString() );
 	newElement.setAttribute("borderPosition", borderPosition);
 	newElement.setAttribute("width","30px");
 	newElement.setAttribute("height","30px");
+	// Borders help avoid confusion:
+	newElement.setAttribute("borderStyle","dashed");	
+	newElement.setAttribute("borderWidth","1px");
+	newElement.setAttribute("borderColor","silver");	
 	newElement.setAttribute("id", borderPosition);
+	
+	// Create a label so we can tell how many times we've
+	// replace this panel:
+	label = parent.ownerDocument.createElement("label","http://openxal.org/ui");
+	label.setAttribute("text",borderPosition[0]+"."+ (++this.panels[borderPosition[0]]) ) ;
+	label.setAttribute("width","20px") ;	
+	label.setAttribute("height","20px") ;
+	label.setAttribute("x","1px") ;	
+	label.setAttribute("y","1px") ;	
+	label.setAttribute("backgroundColor","white") ;		
+	newElement.appendChild(label) ;
 	parent.appendChild(newElement);
 	alert("New dom node = " + parent.toXml());
 }