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 2006/11/19 22:02:24 UTC

svn commit: r476941 - /incubator/xap/trunk/src/xap/widgets/Label.js

Author: mturyn
Date: Sun Nov 19 14:02:24 2006
New Revision: 476941

URL: http://svn.apache.org/viewvc?view=rev&rev=476941
Log:
BUG: Image height/width setting wouldn't handle values with "px" in.  Found in <button/>, also a problem in <label/>.
REFERENCE: http://issues.apache.org/jira/browse/XAP-151
FIX: Image height and width setting now use img.setAttribute(), works better than 
setting img.height/img.width.

Modified:
    incubator/xap/trunk/src/xap/widgets/Label.js

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=476941&r1=476940&r2=476941
==============================================================================
--- incubator/xap/trunk/src/xap/widgets/Label.js (original)
+++ incubator/xap/trunk/src/xap/widgets/Label.js Sun Nov 19 14:02:24 2006
@@ -23,6 +23,8 @@
 
 Xap.provide("xap.widgets.Label");
 
+Xap.require("xap.xml.XmlTokens") ;
+
 xap.widgets.Label = function() {
 	// create label structure
 	this.table = document.createElement("table");
@@ -30,7 +32,7 @@
 	this.table.cellPadding = "0px";
 	this.table.cellSpacing = "0px";
 	this.td = document.createElement("td");
-	this.td.style.textAlign="left";
+	this.td.style.textAlign=xap.xml.XmlTokens.LEFT ;
 	this.td.style.width="100%";
 	this.td.style.height="100%";
 	this.br = document.createElement("br");
@@ -50,7 +52,7 @@
 	this.span.style.verticalAlign="middle";
 	this.img = document.createElement("img");
 	this.img.style.verticalAlign="middle";
-	this.img.style.display = "none";
+	this.img.style.display = xap.xml.XmlTokens.NONE ;
 
 	this.td.appendChild(this.img);
 	this.td.appendChild(this.span);
@@ -63,13 +65,13 @@
 	this.text = "";
 	this.imgURL = "";
 	this.imgDisabledURL = "";
-	this.richText = "false";
+	this.richText = xap.xml.XmlTokens.FALSE ;
 	this.textPlacementVertical = "";
 	this.textPlacementHorizontal = "";
 
-	this.setSelectable("false");
-	this.setEnabled("true");
-	this.setAutoWrap("false");
+	this.setSelectable(xap.xml.XmlTokens.FALSE);
+	this.setEnabled(xap.xml.XmlTokens.TRUE);
+	this.setAutoWrap(xap.xml.XmlTokens.FALSE);
 }
 
 xap.widgets.Label.prototype._createHintImg = function(){
@@ -114,7 +116,7 @@
  */
 xap.widgets.Label.prototype._showText = function() {
 	// give it proper text placement
-	if (this.img.style.display != "none") {
+	if (this.img.style.display != xap.xml.XmlTokens.NONE) {
 		if (this.textPlacementHorizontal == "left" || this.textPlacementHorizontal == "right") {
 			var children = this.td.childNodes;
 
@@ -143,7 +145,7 @@
 	
 	this.span.innerHTML = "";
 
-	if (this.richText == "true") {
+	if (this.richText == xap.xml.XmlTokens.TRUE) {
 		this.span.innerHTML = this.text;
 	} else {
 		this.span.appendChild(document.createTextNode(this.text));
@@ -207,7 +209,7 @@
  * @param {boolean} autoWrap if true, the text will be wrapped when necessary, otherwise, no wrap.
  */
 xap.widgets.Label.prototype.setAutoWrap = function(autoWrap) {
-	if (autoWrap == "true") {
+	if (autoWrap == xap.xml.XmlTokens.TRUE) {
 		xap.widgets.styleSet(this.td, {whiteSpace: "normal"});
 	} else {
 		xap.widgets.styleSet(this.td, {whiteSpace: "nowrap"});
@@ -227,7 +229,7 @@
  * @param {int} imgHeight the height of the img.
  */
 xap.widgets.Label.prototype.setImgHeight = function(imgHeight) {
-	this.img.height = imgHeight;
+	this.img.setAttribute(xap.xml.XmlTokens.HEIGHT,imgHeight);
 }
 
 /**
@@ -235,7 +237,7 @@
  * @param {int} imgWidth the width.
  */
 xap.widgets.Label.prototype.setImgWidth = function(imgWidth) {
-	this.img.width = imgWidth;
+	this.img.setAttribute(xap.xml.XmlTokens.WIDTH,imgWidth);
 }
 
 var a = 0;
@@ -244,7 +246,7 @@
  * @param {boolean} seletable if true, user can select the label, otherwise user cannot.
  */
 xap.widgets.Label.prototype.setSelectable = function(selectable) {
-	if (selectable == "true") {
+	if (selectable == xap.xml.XmlTokens.TRUE) {
 		this.td.onmousedown = null;
 		this.td.onselectstart = null;
  	} else {
@@ -258,7 +260,7 @@
  * @param {boolean} enabled if true the label is enabled, otherwise it is disabled.
  */
 xap.widgets.Label.prototype.setEnabled = function(enabled) {
-	this.enabled = enabled == "true";
+	this.enabled = (enabled == xap.xml.XmlTokens.TRUE) ;
 	this._showImg();
 }
 
@@ -275,7 +277,7 @@
 
 			this._showText();
 		} else {
-			this.img.style.display = "none";
+			this.img.style.display = xap.xml.XmlTokens.NONE;
 		}
 	}
 }