incubator-xap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmarga...@apache.org
Subject svn commit: r533195 - /incubator/xap/trunk/codebase/src/xap/bridges/dojo/TableBridge.js
Date Fri, 27 Apr 2007 19:25:45 GMT
Author: jmargaris
Date: Fri Apr 27 12:25:45 2007
New Revision: 533195

URL: http://svn.apache.org/viewvc?view=rev&rev=533195
Log:
For Michael Mikhaylov: http://issues.apache.org/jira/browse/XAP-404

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

Modified: incubator/xap/trunk/codebase/src/xap/bridges/dojo/TableBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/bridges/dojo/TableBridge.js?view=diff&rev=533195&r1=533194&r2=533195
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/bridges/dojo/TableBridge.js (original)
+++ incubator/xap/trunk/codebase/src/xap/bridges/dojo/TableBridge.js Fri Apr 27 12:25:45 2007
@@ -27,6 +27,7 @@
 
 Xap.require("xap.bridges.dojo.DojoWidgetBridge");
 Xap.require("xap.widgets.dojo.TreeTable"); 
+Xap.require("xap.util.CssUtils"); 
 
 
  
@@ -38,13 +39,10 @@
  
 xap.bridges.dojo.TableBridge= function() {
 	xap.bridges.dojo.DojoWidgetBridge.call(this);
-}
+};
 
 
-Xap.setupClassAsSubclassOf(
-				"xap.bridges.dojo.TableBridge",
-				"xap.bridges.dojo.DojoWidgetBridge"						
-);
+Xap.setupClassAsSubclassOf("xap.bridges.dojo.TableBridge", "xap.bridges.dojo.DojoWidgetBridge");
 
 
 
@@ -53,18 +51,22 @@
 	dojo.event.connect(this.getPeer(), "onActivateRow",this,"onActivateRow");	
 	dojo.event.connect(this.getPeer(), "onSelectRow",this,"onSelectRow");	
 	dojo.event.connect(this.getPeer(), "onDeselectRow",this,"onDeselectRow");
-	dojo.event.connect(this.getPeer(), "onExpandRow",this,"onExpandRow");	
-}
+	dojo.event.connect(this.getPeer(), "onExpandRow",this,"onExpandRow");
+	
+};
+
 
 xap.bridges.dojo.TableBridge.prototype.getPeerString = function(){
 	return "TreeTable" ;
-}
+};
+
 
 xap.bridges.dojo.TableBridge.prototype.onActivateRow = function( a ){
 	var clientEvent = new xap.session.ClientEvent(this.getElement(), this.getSession());
 	clientEvent.rowId = this.getSelectedRowIds();
 	this.fireEvent("onSelect", null, null, clientEvent);
-}
+};
+
 
 xap.bridges.dojo.TableBridge.prototype.onExpandRow = function( row, expanded ){
 	var handler = this.getUiContentHandler().getHandlerForPeer(row);
@@ -72,13 +74,14 @@
 	var clientEvent = new xap.session.ClientEvent(this.getElement(), this.getSession());
 	clientEvent.rowId = handler.getElement().getAttribute("id");
 	this.fireEvent(expanded?"onExpand":"onCollapse", null, null, clientEvent);
-}
+};
 
 
 xap.bridges.dojo.TableBridge.prototype.onDeselectRow = function( row ){
 	var handler = this.getUiContentHandler().getHandlerForPeer(row);
 	handler.writeBackRemoveAttribute("selected");
-}
+};
+
 
 xap.bridges.dojo.TableBridge.prototype.onSelectRow = function( row ){
 	var handler = this.getUiContentHandler().getHandlerForPeer(row);
@@ -86,7 +89,8 @@
 	var clientEvent = new xap.session.ClientEvent(this.getElement(), this.getSession());
 	clientEvent.rowId = this.getSelectedRowIds();
 	this.fireEvent("onStateChange", null, null, clientEvent);
-}
+};
+
 
 xap.bridges.dojo.TableBridge.prototype.getSelectedRowIds = function(){
 	var s = "";
@@ -94,15 +98,15 @@
 	for (var i=0; i<selectedItems.length; i++){
 		var row = selectedItems[i];
 		var handler = this.getUiContentHandler().getHandlerForPeer(row);
-		if (handler!=null){
-			if (s.length!=0){
-				s+=(',');
+		if (handler){
+			if (s.length !== 0){
+				s += (',');
 			}
-			s+= handler.getElement().getAttribute("id");
+			s += handler.getElement().getAttribute("id");
 		}
 	}
 	return s;
-}
+};
  
 /**
  * 
@@ -116,16 +120,23 @@
  * Dynamic attributes
  */
 xap.bridges.dojo.TableBridge.prototype.getNewAllowedAttributes = function(){
-	return [];
-}	
+	return [
+		"altColor",
+		"altBackgroundColor",
+		"highlightColor",
+		"highlightBackgroundColor",
+		"horizontalLineColor",
+		"verticalLineColor"];
+};
+
 
 xap.bridges.dojo.TableBridge.prototype.setHeightAttribute = function(value){
 	this.getPeer().setHeight (value);
-}
+};
 	
 xap.bridges.dojo.TableBridge.prototype.setWidthAttribute = function(aWidth){
 	this.getPeer().setWidth(aWidth) ;
-}
+};
 
 xap.bridges.dojo.TableBridge.prototype.addChild = function(childHandler, index){
 // TODO: implement "addSelfToTable" methods on child peers
@@ -138,7 +149,8 @@
 	else if (childPeer instanceof xap.widgets.dojo.TableRow){
 		this.getPeer().insertRow(childPeer,-1);
 	}
-}
+};
+
 
 // handler for removing children
 xap.bridges.dojo.TableBridge.prototype.removeChild = function( childHandler ){
@@ -150,5 +162,148 @@
 	else if (childPeer instanceof xap.widgets.dojo.TableRow){
 		this.getPeer().removeRow(childPeer);
 	}
+};
+
+
+//===============================	ATTRIBUTE HELPERS
+
+
+/**
+ *	Returns global CSS rule "." and CSS class name
+ *
+ *	@return CSS rule object
+ */
+xap.bridges.dojo.TableBridge.prototype.getGlobalRule = function(cssClassName) {
+	var globalRule = xap.util.CssUtils.getCSSRule('.' + cssClassName);
+	return globalRule;
 }
+
+
+/**
+ *	Returns local CSS rule by combining element id and CSS class name
+ *
+ *	@return CSS rule object
+ */
+xap.bridges.dojo.TableBridge.prototype.getLocalRule = function(cssClassName) {
+	var id = this.getRootDomNode().getAttribute('id');
+	var selector = 'div#' + id + ' .' + cssClassName;
+	var localRule = xap.util.CssUtils.getCSSRule(selector);
+	if(!localRule) {
+			// create local rule
+			var globalRule = this.getGlobalRule(cssClassName);
+			dojo.html.insertCssRule(selector, globalRule.style.cssText);
+			localRule = xap.util.CssUtils.getCSSRule(selector);
+	}
+	return localRule;
+}
+
+
+//===============================	ATTRIBUTE SETTERS
+
+
+/** XML attribute set method for "altColor" */
+xap.bridges.dojo.TableBridge.prototype.setAltColorAttribute = function(value) {
+	var cssClassName = this.getPeer()._alternateRowClass;
+	var localRule = this.getLocalRule(cssClassName);
+	localRule.style.color = value;
+	// create local selected row class to prevent override
+	this.getLocalRule(this.getPeer()._selectedRowClass);
+};
+
+/** XML attribute remove method for "altColor" */
+xap.bridges.dojo.TableBridge.prototype.attributeRemovers.altColor = function() {
+	var cssClassName = this.getPeer()._alternateRowClass;
+	var localRule = this.getLocalRule(cssClassName);
+	if(localRule) {	localRule.style.color = null; } 
+};
+
+//==
+
+/** XML attribute set method for "altBackgroundColor" */
+xap.bridges.dojo.TableBridge.prototype.setAltBackgroundColorAttribute = function(value) {
+	var cssClassName = this.getPeer()._alternateRowClass;
+	var localRule = this.getLocalRule(cssClassName);
+	localRule.style.backgroundColor = value;
+	// create local selected row class to prevent override
+	this.getLocalRule(this.getPeer()._selectedRowClass);
+};
+
+/** XML attribute remove method for "altBackgroundColor" */
+xap.bridges.dojo.TableBridge.prototype.attributeRemovers.altBackgroundColor = function()
{
+	var cssClassName = this.getPeer()._alternateRowClass;
+	var localRule = this.getLocalRule(cssClassName);
+	if(localRule) {	localRule.style.backgroundColor = null; } 
+};
+
+
+//==
+
+/** XML attribute set method for "highlightColor" */
+xap.bridges.dojo.TableBridge.prototype.setHighlightColorAttribute = function(value) {
+	var cssClassName = this.getPeer()._selectedRowClass;
+	var localRule = this.getLocalRule(cssClassName);
+	localRule.style.color = value;
+};
+
+/** XML attribute remove method for "highlightColor" */
+xap.bridges.dojo.TableBridge.prototype.attributeRemovers.highlightColor = function() {
+	var cssClassName = this.getPeer()._selectedRowClass;
+	var localRule = this.getLocalRule(cssClassName);
+	if(localRule) {	localRule.style.color = null; } 
+};
+
+
+//==
+
+
+/** XML attribute set method for "highlightBackgroundColor" */
+xap.bridges.dojo.TableBridge.prototype.setHighlightBackgroundColorAttribute = function(value)
{
+	var cssClassName = this.getPeer()._selectedRowClass;
+	var localRule = this.getLocalRule(cssClassName);
+	localRule.style.backgroundColor = value;
+};
+
+/** XML attribute remove method for "highlightBackgroundColor" */
+xap.bridges.dojo.TableBridge.prototype.attributeRemovers.highlightBackgroundColor = function()
{
+	var cssClassName = this.getPeer()._selectedRowClass;
+	var localRule = this.getLocalRule(cssClassName);
+	if(localRule) {	localRule.style.backgroundColor = null; } 
+};
+
+
+
+//==
+
+
+/** XML attribute set method for "horizontalLineColor" */
+xap.bridges.dojo.TableBridge.prototype.setHorizontalLineColorAttribute = function(value)
{
+	var cssClassName = this.getPeer()._tableCellClass;
+	var localRule = this.getLocalRule(cssClassName);
+	localRule.style.borderBottomColor = value;
+};
+
+/** XML attribute remove method for "horizontalLineColor" */
+xap.bridges.dojo.TableBridge.prototype.attributeRemovers.horizontalLineColor = function()
{
+	var cssClassName = this.getPeer()._tableCellClass;
+	var localRule = this.getLocalRule(cssClassName);
+	if(localRule) {	localRule.style.borderBottomColor = null; } 
+};
+
+
+//==
+
+
+/** XML attribute set method for "verticalLineColor" */
+xap.bridges.dojo.TableBridge.prototype.setVerticalLineColorAttribute = function(value) {
+	var cssClassName = this.getPeer()._tableCellClass;
+	var localRule = this.getLocalRule(cssClassName);
+	localRule.style.borderRightColor = value;
+};
+
+/** XML attribute remove method for "verticalLineColor" */
+xap.bridges.dojo.TableBridge.prototype.attributeRemovers.verticalLineColor = function() {
+	var cssClassName = this.getPeer()._tableCellClass;
+	var localRule = this.getLocalRule(cssClassName);
+	if(localRule) {	localRule.style.borderRightColor = null; } 
+};
 



Mime
View raw message