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 2006/12/11 06:01:10 UTC
svn commit: r485519 - in /incubator/xap/trunk/src/xap:
bridges/xap/LabelBridge.js widgets/Label.js
Author: jmargaris
Date: Sun Dec 10 22:01:09 2006
New Revision: 485519
URL: http://svn.apache.org/viewvc?view=rev&rev=485519
Log:
separate class to do proper padding with that works
across different browsers better
Modified:
incubator/xap/trunk/src/xap/bridges/xap/LabelBridge.js
incubator/xap/trunk/src/xap/widgets/Label.js
Modified: incubator/xap/trunk/src/xap/bridges/xap/LabelBridge.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/bridges/xap/LabelBridge.js?view=diff&rev=485519&r1=485518&r2=485519
==============================================================================
--- incubator/xap/trunk/src/xap/bridges/xap/LabelBridge.js (original)
+++ incubator/xap/trunk/src/xap/bridges/xap/LabelBridge.js Sun Dec 10 22:01:09 2006
@@ -18,6 +18,7 @@
Xap.provide("xap.bridges.xap.LabelBridge");
Xap.require("xap.bridges.basic.AbstractWidgetBridge");
Xap.require("xap.widgets.Label");
+Xap.require("dojo.html");
xap.bridges.xap.LabelBridge = function() {
xap.bridges.basic.AbstractWidgetBridge.call(this);
@@ -25,14 +26,39 @@
Xap.setupClassAsSubclassOf("xap.bridges.xap.LabelBridge", "xap.bridges.basic.AbstractWidgetBridge");
+xap.bridges.xap.LabelBridge.prototype.init = function() {
+ xap.bridges.basic.AbstractWidgetBridge.prototype.init.call(this);
+ var innerContent = this.getPeer().getLabelContents();
+ dojo.html.addClass(innerContent,this.getContentClassName());
+}
+
xap.bridges.xap.LabelBridge.prototype.obtainPeer = function() {
- this.setPeer(new xap.widgets.Label());
+ this.setPeer(new xap.widgets.Label());
}
xap.bridges.xap.LabelBridge.prototype.getRootDomNode = function() {
return this.getPeer()._rootDomNode;
}
+
+xap.bridges.xap.LabelBridge.prototype.getContentClassName = function( ) {
+ var nodeName = this.getElement().nodeName;
+ nodeName = "xap" + nodeName.substring(0,1).toUpperCase() + nodeName.substring(1) + "Contents";
+ return nodeName;
+}
+
+xap.bridges.xap.LabelBridge.prototype.addStyleState = function(stateName){
+ xap.bridges.basic.AbstractWidgetBridge.prototype.addStyleState.call(this,stateName);
+ var innerContent = this.getPeer().getLabelContents();
+ dojo.html.addClass(innerContent,this.getContentClassName()+stateName);
+}
+
+xap.bridges.xap.LabelBridge.prototype.removeStyleState = function(stateName){
+ xap.bridges.basic.AbstractWidgetBridge.prototype.removeStyleState.call(this,stateName);
+ var innerContent = this.getPeer().getLabelContents();
+ dojo.html.removeClass(innerContent,this.getContentClassName()+stateName);
+}
+
xap.bridges.xap.LabelBridge.prototype.getNewAllowedAttributes = function() {
return ["alignHorizontal", "alignVertical", "autoWrap", "image",
"backgroundImage", "disabledImage", "imageHeight", "imageWidth", "richText",
@@ -101,4 +127,12 @@
xap.bridges.xap.LabelBridge.prototype.setTextPlacementVerticalAttribute = function(alignment) {
this.getPeer().setTextPlacementVertical(alignment);
+}
+
+/**
+ * Overridden to set it on the inner div instead of the outer table,
+ * seems to work better.
+ */
+xap.bridges.xap.LabelBridge.prototype.setPaddingAttribute = function(value){
+ this.getPeer().style.padding = value ;
}
Modified: incubator/xap/trunk/src/xap/widgets/Label.js
URL: http://svn.apache.org/viewvc/incubator/xap/trunk/src/xap/widgets/Label.js?view=diff&rev=485519&r1=485518&r2=485519
==============================================================================
--- incubator/xap/trunk/src/xap/widgets/Label.js (original)
+++ incubator/xap/trunk/src/xap/widgets/Label.js Sun Dec 10 22:01:09 2006
@@ -48,14 +48,18 @@
this.table.appendChild(tbody);
tbody.appendChild(tr);
tr.appendChild(this.td);
+
+ this.div = document.createElement("div");
+ this.td.appendChild(this.div);
+
this.span = document.createElement("span");
this.span.style.verticalAlign="middle";
this.img = document.createElement("img");
this.img.style.verticalAlign="middle";
this.img.style.display = xap.xml.XmlTokens.NONE ;
- this.td.appendChild(this.img);
- this.td.appendChild(this.span);
+ this.div.appendChild(this.img);
+ this.div.appendChild(this.span);
xap.widgets.styleSet(this.td, {width:"100%", height: "100%"});
@@ -78,11 +82,15 @@
if (!this.hintImg ){
this.hintImg = document.createElement("span");
this.hintImg.style.verticalAlign="middle";
- this.td.appendChild(this.hintImg);
+ this.div.appendChild(this.hintImg);
this.hintImg.innerHTML = " "
}
}
+xap.widgets.Label.prototype.getLabelContents = function(){
+ return this.div;
+}
+
xap.widgets.styleSet = function(el, properties) {
var style = el.style;
@@ -118,28 +126,28 @@
// give it proper text placement
if (this.img.style.display != xap.xml.XmlTokens.NONE) {
if (this.textPlacementHorizontal == "left" || this.textPlacementHorizontal == "right") {
- var children = this.td.childNodes;
+ var children = this.div.childNodes;
for (var i = 0; i < children.length; i++) {
var node = children[i];
if (node.nodeType == 1 && node.nodeName == "br") {
- this.td.removeChild(node);
+ this.div.removeChild(node);
}
}
if (this.textPlacementHorizontal == "left") {
- this.td.insertBefore(this.span, this.img);
+ this.div.insertBefore(this.span, this.img);
} else if(this.textPlacementHorizontal == "right") {
- this.td.insertBefore(this.img, this.span);
+ this.div.insertBefore(this.img, this.span);
}
}
if (this.textPlacementVertical == "bottom") {
- this.td.insertBefore(this.img, this.span);
- this.td.insertBefore(this.br, this.span);
+ this.div.insertBefore(this.img, this.span);
+ this.div.insertBefore(this.br, this.span);
} else if (this.textPlacementVertical == "top") {
- this.td.insertBefore(this.span, this.img);
- this.td.insertBefore(this.br, this.img);
+ this.div.insertBefore(this.span, this.img);
+ this.div.insertBefore(this.br, this.img);
}
}