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/11 09:22:34 UTC
svn commit: r611122 - in /incubator/xap/trunk/codebase/src/xap:
bridges/dojo/ColumnBridge.js bridges/dojo/TableBridge.js
util/UidProvider.js xml/dom/XapElement.js
Author: jmargaris
Date: Fri Jan 11 01:22:34 2008
New Revision: 611122
URL: http://svn.apache.org/viewvc?rev=611122&view=rev
Log:
Fix for https://issues.apache.org/jira/browse/XAP-490,
: in classname was part of the issue
Modified:
incubator/xap/trunk/codebase/src/xap/bridges/dojo/ColumnBridge.js
incubator/xap/trunk/codebase/src/xap/bridges/dojo/TableBridge.js
incubator/xap/trunk/codebase/src/xap/util/UidProvider.js
incubator/xap/trunk/codebase/src/xap/xml/dom/XapElement.js
Modified: incubator/xap/trunk/codebase/src/xap/bridges/dojo/ColumnBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/bridges/dojo/ColumnBridge.js?rev=611122&r1=611121&r2=611122&view=diff
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/bridges/dojo/ColumnBridge.js (original)
+++ incubator/xap/trunk/codebase/src/xap/bridges/dojo/ColumnBridge.js Fri Jan 11 01:22:34 2008
@@ -64,6 +64,39 @@
return this._xapAttributes.concat(this._cssAttributes);
}
+/**
+ * Returns column-specific CSS rule object
+ *
+ */
+xap.bridges.dojo.ColumnBridge.prototype._getLocalCssRule = function() {
+
+ // if we have one, return it right away
+ if(this._localCssRule) { return this._localCssRule; }
+
+ // Create custom CSS class for this column
+ var elementId = this.getElement().getAttribute('id');
+ var localCSSClassName = null;
+
+ if(elementId.indexOf('xap') === 0) {
+ localCSSClassName = elementId.replace('xap','tableColumn');
+ } else {
+ localCSSClassName = 'tableColumn' + elementId;
+ }
+
+ // make it work only for TDs
+ var selector = 'td.' + localCSSClassName;
+
+ // insert an empty rule
+ dojo.html.insertCssRule(selector, ' ');
+ this._localCssRule = xap.util.CssUtils.getCSSRule(selector);
+
+ // save class name on a peer
+ this.getPeer()._localCSSClassName = localCSSClassName;
+
+ // return result
+ return this._localCssRule;
+};
+
/**
This function creates attribute setter and remover functions.
@@ -89,9 +122,7 @@
this[attributeSetterName] = function(value) {
var name = arguments.callee.attributePropertyName;
this['_' + name] = value;
- if(this._localRule !== undefined) {
- this._localRule.style[name] = value;
- }
+ this._getLocalCssRule().style[name] = value;
};
// save attribute name
this[attributeSetterName].attributePropertyName = attributePropertyName;
@@ -100,9 +131,7 @@
this.attributeRemovers[attributePropertyName] = function() {
var name = arguments.callee.attributePropertyName;
delete this['_' + name];
- if(this._localRule !== undefined) {
- this._localRule.style[name] = '';
- }
+ this._getLocalCssRule().style[name] = '';
};
// save attribute name
this.attributeRemovers[attributePropertyName].attributePropertyName = attributePropertyName;
@@ -149,37 +178,29 @@
// set _backgroundImage
xap.bridges.dojo.ColumnBridge.prototype.setBackgroundImageAttribute = function( value ) {
this._backgroundImage = value;
- if(this._localRule !== undefined) {
- this._localRule.style.backgroundImage = 'url(' + value + ')';
- }
+ this._getLocalCssRule().style.backgroundImage = 'url(' + value + ')';
}
// remove _backgroundImage
xap.bridges.dojo.ColumnBridge.prototype.attributeRemovers.backgroundImage = function() {
delete this._backgroundImage;
- if(this._localRule !== undefined) {
- this._localRule.style.backgroundImage = 'url(none)';
- }
+ this._getLocalCssRule().style.backgroundImage = 'url(none)';
}
// set _visible
xap.bridges.dojo.ColumnBridge.prototype.setVisibleAttribute = function( value ) {
this._visible = (value == 'true' || value == 1);
- if(this._localRule !== undefined) {
- this._localRule.style.visibility = (this._visible) ? 'visible' : 'collapse';
- this._localRule.style.display = (this._visible) ? '' : 'none';
- }
+ this._getLocalCssRule().style.visibility = (this._visible) ? 'visible' : 'collapse';
+ this._getLocalCssRule().style.display = (this._visible) ? '' : 'none';
this.getPeer().setVisible(this._visible);
}
// remove _visible
xap.bridges.dojo.ColumnBridge.prototype.attributeRemovers.visible = function() {
delete this._visible;
- if(this._localRule !== undefined) {
- this._localRule.style.visibility = 'visible';
- this._localRule.style.display = '';
- }
+ this._getLocalCssRule().style.visibility = 'visible';
+ this._getLocalCssRule().style.display = '';
this.getPeer().setVisible(true);
}
@@ -199,35 +220,16 @@
xap.bridges.dojo.ColumnBridge.superclass.init.call(this) ;
- /*
- * Create custom CSS class for this column
- */
- var elementId = this.getElement().getAttribute('id');
- var localCSSClassName = null;
-
- if(elementId.indexOf('xap:') != -1) {
- localCSSClassName = elementId.replace('xap:','tableColumn');
- } else {
- localCSSClassName = 'tableColumn' + elementId;
- }
-
- // only for TDs
- var selector = 'td.' + localCSSClassName;
-
- // insert an empty rule
- dojo.html.insertCssRule(selector, ' ');
- this._localRule = xap.util.CssUtils.getCSSRule(selector);
- this.getPeer()._localCSSClassName = localCSSClassName;
-
/**
* Attribute setters are called before init(),
* so we need to assign all attributes here
**/
+ var localStyle = this._getLocalCssRule().style;
for(var n = 0; n < this._cssAttributes.length; n++) {
var attributePropertyName = this._cssAttributes[n];
var value = this['_' + attributePropertyName];
if( value !== undefined ) {
- this._localRule.style[attributePropertyName] = value;
+ localStyle[attributePropertyName] = value;
}
}
@@ -248,16 +250,21 @@
xap.bridges.dojo.ColumnBridge.prototype.unload = function(){
// attempt to destroy global rule instance
- var styleSheet = this._localRule.parentStyleSheet;
- if (styleSheet !== undefined) {
- for(var n = 0; n < styleSheet.length; n++) {
- if(styleSheet[n] == this._localRule) {
- styleSheet.deleteRule(n);
- break;
- }
- }
+ // that does nothing in IE
+ var styleRule = this._localCssRule;
+ if(styleRule) {
+ var styleSheet = styleRule.parentStyleSheet;
+ if (styleSheet !== undefined) {
+ var i = styleSheet.length;
+ while(i) {
+ if(styleSheet[--i] == styleRule) {
+ styleSheet.deleteRule(i);
+ break;
+ }
+ }
+ }
+ delete this._localCssRule;
}
- delete this._localRule;
xap.bridges.dojo.ColumnBridge.superclass.unload.call(this) ;
};
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?rev=611122&r1=611121&r2=611122&view=diff
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/bridges/dojo/TableBridge.js (original)
+++ incubator/xap/trunk/codebase/src/xap/bridges/dojo/TableBridge.js Fri Jan 11 01:22:34 2008
@@ -40,6 +40,7 @@
xap.bridges.dojo.TableBridge= function() {
xap.bridges.dojo.DojoWidgetBridge.call(this);
+ this._localCssRules = {};
};
@@ -70,13 +71,10 @@
xap.bridges.dojo.DojoWidgetBridge.prototype.init.call(this);
-
-
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");
- this._localCssRules = {};
};
Modified: incubator/xap/trunk/codebase/src/xap/util/UidProvider.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/util/UidProvider.js?rev=611122&r1=611121&r2=611122&view=diff
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/util/UidProvider.js (original)
+++ incubator/xap/trunk/codebase/src/xap/util/UidProvider.js Fri Jan 11 01:22:34 2008
@@ -27,7 +27,7 @@
*/
/** @private */
-xap.util.UidProvider.XAP_ID_PREFIX = "xap:";
+xap.util.UidProvider.XAP_ID_PREFIX = "xap";
/** @private */
xap.util.UidProvider.s_count = 0;
Modified: incubator/xap/trunk/codebase/src/xap/xml/dom/XapElement.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/codebase/src/xap/xml/dom/XapElement.js?rev=611122&r1=611121&r2=611122&view=diff
==============================================================================
--- incubator/xap/trunk/codebase/src/xap/xml/dom/XapElement.js (original)
+++ incubator/xap/trunk/codebase/src/xap/xml/dom/XapElement.js Fri Jan 11 01:22:34 2008
@@ -104,7 +104,7 @@
* an end-use assigned one.
*/
xap.xml.dom.XapElement.isGeneratedId = function( id ) {
- return ( id && id.indexOf( xap.util.UidProvider.XAP_ID_PREFIX, 0 ) != -1 );
+ return ( id && id.indexOf( xap.util.UidProvider.XAP_ID_PREFIX, 0 ) === 0 );
};