[bugzilla-gnome-org-extensions] IE compat: deal with CSS Object Model difference
- From: Krzesimir Nowak <krnowak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [bugzilla-gnome-org-extensions] IE compat: deal with CSS Object Model difference
- Date: Thu, 20 Nov 2014 22:23:50 +0000 (UTC)
commit 0c0b2b89cecaac7a459470eeaab454e8de4aba97
Author: Owen W. Taylor <otaylor fishsoup net>
Date: Sat Oct 10 23:35:49 2009 -0400
IE compat: deal with CSS Object Model difference
* In IE7 the element.offsetParent chain doesn't necessarily
end at the body.
* When window.innerHeight isn't present, use
document.documentElement.clientHeight. (Right for IE
strict mode which is all we use, quirks mode is different.)
js/splinter.js | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/js/splinter.js b/js/splinter.js
index 4ccd6c5..a232d95 100644
--- a/js/splinter.js
+++ b/js/splinter.js
@@ -520,7 +520,7 @@ function getElementPosition(element) {
var left = element.offsetLeft;
var top = element.offsetTop;
var parent = element.offsetParent;
- while (parent != document.body) {
+ while (parent && parent != document.body) {
left += parent.offsetLeft;
top += parent.offsetTop;
parent = parent.offsetParent;
@@ -530,9 +530,14 @@ function getElementPosition(element) {
}
function scrollToElement(element) {
+ var windowHeight;
+ if ('innerHeight' in window) // Not IE
+ windowHeight = window.innerHeight;
+ else // IE
+ windowHeight = document.documentElement.clientHeight;
var pos = getElementPosition(element);
var yCenter = pos[1] + element.offsetHeight / 2;
- window.scrollTo(0, yCenter - window.innerHeight / 2);
+ window.scrollTo(0, yCenter - windowHeight / 2);
}
function onRowDblClick(e) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]