Fix for IE in element_pos()
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Wed, 18 Mar 2009 22:09:59 +0000 (22:09 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Wed, 18 Mar 2009 22:09:59 +0000 (22:09 +0000)
js/utils.js

index 25b6e19a70a59b23611ffb509e581bfd6624fca2..f4a4f65cc0f4717af7a14d434325566bf0f018d5 100644 (file)
@@ -275,9 +275,10 @@ function element_pos(e) {
                var offsetParent = e.offsetParent;
                var parentNode = e.parentNode;
 
-               while (offsetParent !== null) {
+               while (offsetParent !== null && offsetParent.style.display != 'none') {
                        res.x += offsetParent.offsetLeft;
                        res.y += offsetParent.offsetTop;
+                       // the second case is for IE6/7 in some doctypes
                        if (offsetParent != document.body && offsetParent != document.documentElement) {
                                res.x -= offsetParent.scrollLeft;
                                res.y -= offsetParent.scrollTop;
@@ -296,6 +297,6 @@ function element_pos(e) {
                }
        }
        // parentNode has style.display set to none
-       if (parentNode!=document.documentElement) return null;
+       if (parentNode != document.documentElement) return null;
        return res;
 }
\ No newline at end of file