Fixed bug with grid element position calculation in firefox - firefox uses fractional height values internally but returns them rounded when using offsetHeight - using getComputedStyle when using firefox fixed the issue.

This commit is contained in:
Andreas Stöckel 2011-03-30 20:52:02 +00:00
parent 3111c74eda
commit a726d95d0b
2 changed files with 41 additions and 10 deletions

View File

@ -615,14 +615,24 @@ egwGridViewContainer.prototype.setPosition = function(_top)
/** /**
* Returns the height of the container in pixels and zero if the element is not * Returns the height of the container in pixels and zero if the element is not
* visible. The height is clamped to positive values. * visible. The height is clamped to positive values.
* The browser switch is placed at this position as the getHeight function is one
* of the mostly called functions in the whole grid code and should stay
* quite fast.
*/ */
if ($.browser.mozilla)
{
egwGridViewContainer.prototype.getHeight = function() egwGridViewContainer.prototype.getHeight = function()
{ {
if (this.visible && this.parentNode) if (this.visible && this.parentNode)
{ {
if (this.height === false && this.assumedHeight === false) if (this.height === false && this.assumedHeight === false)
{ {
this.height = this.parentNode.outerHeight(); // Firefox sometimes provides fractional pixel values - we are
// forced to use those - we can obtain the fractional pixel height
// by using the window.getComputedStyle function
var styleHeightStr =
getComputedStyle(this.parentNode.context, null).getPropertyValue("height");
this.height = parseFloat(styleHeightStr.substr(0, styleHeightStr.length - 2));
} }
return this.height !== false ? this.height : this.assumedHeight; return this.height !== false ? this.height : this.assumedHeight;
@ -632,6 +642,26 @@ egwGridViewContainer.prototype.getHeight = function()
return 0; return 0;
} }
} }
}
else
{
egwGridViewContainer.prototype.getHeight = function()
{
if (this.visible && this.parentNode)
{
if (this.height === false && this.assumedHeight === false)
{
this.height = this.parentNode.context.offsetHeight;
}
return this.height !== false ? this.height : this.assumedHeight;
}
else
{
return 0;
}
}
}
egwGridViewContainer.prototype.invalidateHeightCache = function() egwGridViewContainer.prototype.invalidateHeightCache = function()
{ {

View File

@ -4,6 +4,8 @@
<title>Grid Test</title> <title>Grid Test</title>
<!-- Basic action stuff --> <!-- Basic action stuff -->
<script src="js/jquery.js"></script>
<script src="../egw_action.js"></script> <script src="../egw_action.js"></script>
<script src="../egw_action_common.js"></script> <script src="../egw_action_common.js"></script>
@ -22,7 +24,6 @@
<script src="../egw_grid.js"></script> <script src="../egw_grid.js"></script>
<script src="../egw_stylesheet.js"></script> <script src="../egw_stylesheet.js"></script>
<script src="js/jquery.js"></script>
<link rel="stylesheet" href="grid.css"/> <link rel="stylesheet" href="grid.css"/>
<link rel="stylesheet" href="skins/dhtmlxmenu_egw.css"/> <link rel="stylesheet" href="skins/dhtmlxmenu_egw.css"/>
</head> </head>
@ -237,7 +238,7 @@
"entryType": EGW_DATA_TYPE_RANGE, "entryType": EGW_DATA_TYPE_RANGE,
"prefix": "root_elem_", "prefix": "root_elem_",
"canHaveChildren": true, "canHaveChildren": true,
"count": 10 "count": 1000
} }
] ]
); );