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 jm...@apache.org on 2008/01/21 04:22:08 UTC

svn commit: r613755 - /incubator/xap/trunk/codebase/src/xap/bridges/dojo/CellBridge.js

Author: jmargaris
Date: Sun Jan 20 20:22:08 2008
New Revision: 613755

URL: http://svn.apache.org/viewvc?rev=613755&view=rev
Log:
https://issues.apache.org/jira/browse/XAP-552

Modified:
    incubator/xap/trunk/codebase/src/xap/bridges/dojo/CellBridge.js

Modified: incubator/xap/trunk/codebase/src/xap/bridges/dojo/CellBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/bridges/dojo/CellBridge.js?rev=613755&r1=613754&r2=613755&view=diff
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/bridges/dojo/CellBridge.js (original)
+++ incubator/xap/trunk/codebase/src/xap/bridges/dojo/CellBridge.js Sun Jan 20 20:22:08 2008
@@ -26,27 +26,40 @@
 	this._cellInfo._text = "";
 }
 
+
 Xap.setupClassAsSubclassOf("xap.bridges.dojo.CellBridge", "xap.bridges.basic.AbstractWidgetBridge");
 
 
 
 xap.bridges.dojo.CellBridge.prototype.obtainPeer = function() {
+	this._image = document.createElement("img");
+	this._image.style.visibility = 'hidden';
+	this._text = document.createTextNode("");
 	this._domNode = document.createElement("span");
+	this._domNode.appendChild(this._image);
+	this._domNode.appendChild(this._text);
 	return this._domNode;
 }
 
 
 xap.bridges.dojo.CellBridge.prototype.getRootDomNode = function() {
-	return this._domNode
-}	
+	return this._domNode;
+}
+
+
+/** getCellInfo implementation for use by row bridge */
+xap.bridges.dojo.CellBridge.prototype.getCellInfo = function() {
+    return this._cellInfo;
+}
 
 
 xap.bridges.dojo.CellBridge.prototype.getNewAllowedAttributes = function() {
-	return ["text", "image", "backgroundColor", "horizontalAlignment", "sortValue"];
-}	
+	return ["text", "image", "backgroundColor", "horizontalAlignment", "verticalAlignment", "sortValue",
+	"imageHeight", "imageWidth", "horizontalTextToImagePlacement", "verticalTextToImagePlacement"];
+}
 
 xap.bridges.dojo.CellBridge.prototype.setTextAttribute = function(text) {
-	this._domNode.innerHTML = text;
+	this._text.data = text;
 	this._cellInfo._text = text;
 }
 
@@ -55,47 +68,92 @@
     this._cellInfo._sortValue = text;
 }
 
-
-xap.bridges.dojo.CellBridge.prototype.setImageAttribute = function(text) {
-	/*
-	TODO
-	*/
+xap.bridges.dojo.CellBridge.prototype.setImageAttribute = function(url) {
+	if(url) {
+		this._image.src = url;
+		this._image.style.visibility = 'visible';
+	} else {
+		this._image.src = '';
+		this._image.style.visibility = 'hidden';
+	}
 }
 
 /** XML attribute set method for "backgroundColor" */
 xap.bridges.dojo.CellBridge.prototype.setBackgroundColorAttribute = function(value){
-	// we need to set the attribute of our parent since we're only a lowly span
-	this._domNode.style.backgroundColor = value;
-	if ( this._domNode.parentNode && this._domNode.parentNode.style )
-		this._domNode.parentNode.style.backgroundColor = value ;
+	if ( this._domNode.parentNode && this._domNode.parentNode.style ) {
+		this._domNode.parentNode.style.backgroundColor = value;
+	}
 }
 
 /** XML attribute set method for "horizontalAlignment" */
 xap.bridges.dojo.CellBridge.prototype.setHorizontalAlignmentAttribute = function(value){
 	// we need to set the attribute of our parent since we're only a lowly span
 	this._domNode.style.textAlign = value;
-	if ( this._domNode.parentNode )
-		this._domNode.parentNode.align = value ;
+	if ( this._domNode.parentNode ) {
+		this._domNode.parentNode.align = value;
+	}
 }
-xap.bridges.dojo.CellBridge.prototype.setAlignVerticalAttribute = function(value){
-	// we need to set the attribute of our parent since we're only a lowly span 
-	/*
-	TODO: implement vertical alignment
-	*/
+
+xap.bridges.dojo.CellBridge.prototype.setVerticalAlignmentAttribute = function(value){
+	var parent = this._domNode.parentNode;
+	if ( parent && parent.style ) {
+		parent.style.verticalAlign = value ;
+	} else {
+		// reschedule for later
+		dojo.lang.setTimeout(this, arguments.callee, 0, value);	
+	}
 }
 
+
 xap.bridges.dojo.CellBridge.prototype.resetSize = function(){
     // NO-OP for optimization
-};
+}
+
 
 // overrides AbstractWidgetBridge
 xap.bridges.dojo.CellBridge.prototype.setCursorAttribute = function(value){
-	if ( this._domNode.parentNode !== undefined) {
-		this._domNode.parentNode.style.cursor = value ;
+	var parent = this._domNode.parentNode;
+	if ( parent && parent.style ) {
+		parent.style.cursor = value ;
+	} else {
+		// reschedule for later
+		dojo.lang.setTimeout(this, arguments.callee, 0, value);	
 	}
-};
+}
 
-/** getCellInfo implementation for use by row bridge */
-xap.bridges.dojo.CellBridge.prototype.getCellInfo = function() {
-    return this._cellInfo;
+
+xap.bridges.dojo.CellBridge.prototype.setHorizontalTextToImagePlacementAttribute = function(alignment) {
+	if('left' == alignment && this._domNode.firstChild == this._text) {
+		this._domNode.removeChild(this._text);
+		this._domNode.appendChild(this._text);
+	}
+	
+	if('right' == alignment && this._domNode.firstChild == this._image) {
+		this._domNode.removeChild(this._image);
+		this._domNode.appendChild(this._image);
+	}
+	
+}
+
+
+xap.bridges.dojo.CellBridge.prototype.setVerticalTextToImagePlacementAttribute = function(alignment) {
+	this._image.style.verticalAlign = alignment;
+}
+
+
+/**
+ * Set the height for the img.
+ * @param {int} imgHeight the height of the img.
+ */
+xap.bridges.dojo.CellBridge.prototype.setImageHeightAttribute = function(imgHeight) {
+	this._image.style.height = imgHeight;
+}
+
+
+/**
+ * Set the width for the img.
+ * @param {int} imgWidth the width.
+ */
+xap.bridges.dojo.CellBridge.prototype.setImageWidthAttribute = function(imgWidth) {
+	this._image.style.width = imgWidth;
 }