Opened 15 years ago

Closed 14 years ago

#274 closed defect (fixed)

xinha_config.width and height without px

Reported by: guenole Owned by: gogo
Priority: normal Milestone:
Component: Xinha Core Version:
Severity: normal Keywords:
Cc:

Description

When we specifies this :

       xinha_config = new HTMLArea.Config();
       xinha_config.width  = 640;
       xinha_config.height = 420;

It works in IE but not in Firefox (last version 1.0.4)

Change History (8)

comment:1 Changed 15 years ago by niko

try using "640px"

comment:2 Changed 15 years ago by gogo

  • Resolution set to worksforme
  • Status changed from new to closed

Indeed, it's important with the new table-based-framework that the dimensions include the suffix.

comment:3 Changed 15 years ago by niko

  • Resolution worksforme deleted
  • Status changed from closed to reopened
  • Summary changed from xinha_config.width and height in Firefox to xinha_config.width and height without px

wouldn't it be possilbe to check if width is an integer and add px then?

this would by very important imho, several people had this problem allready

comment:4 Changed 15 years ago by niko

...and backwards-compatibility with htmlarea would be kind of broken too...

comment:5 Changed 15 years ago by mokhet

I think this patch (in HTMLArea.prototype.initSize) can do the job. But probably more to do if the same kind of behavior is needed for panel dimensions.

Index: htmlarea.js
===================================================================
--- htmlarea.js	(revision 186)
+++ htmlarea.js	(working copy)
@@ -1400,7 +1400,7 @@
 
       default :
       {
-        width = this.config.width;
+        width = parseInt(this.config.width, 10) + 'px';
       }
       break;
     }
@@ -1415,7 +1415,7 @@
 
       default :
       {
-        height = this.config.height;
+        height = parseInt(this.config.height, 10) + 'px';
       }
       break;
     }
@@ -5313,4 +5313,4 @@
   }
 }
 
-HTMLArea.init();
+HTMLArea.init();
\ No newline at end of file

comment:6 Changed 15 years ago by gogo

No that patch is incorrect. If somebody supplied config.width = '100%' it would become 100px, likewise for '50em', or '20cm' etc...

comment:7 Changed 15 years ago by mokhet

ah yes true, didnt though about other units. I think this one should be better.

Index: htmlarea.js
===================================================================
--- htmlarea.js	(revision 186)
+++ htmlarea.js	(working copy)
@@ -1401,6 +1401,10 @@
       default :
       {
         width = this.config.width;
+        if ((typeof width == 'number') || ((typeof width == 'string') && (/^[0-9]+$/.test(width))))
+        {
+          width = width + 'px';
+        }
       }
       break;
     }
@@ -1416,6 +1420,10 @@
       default :
       {
         height = this.config.height;
+        if ((typeof height == 'number') || ((typeof height == 'string') && (/^[0-9]+$/.test(height))))
+        {
+          height = height + 'px';
+        }
       }
       break;
     }

comment:8 Changed 14 years ago by gogo

  • Resolution set to fixed
  • Status changed from reopened to closed

Applid something suitable in changeset:417

Note: See TracTickets for help on using tickets.