summaryrefslogtreecommitdiff
path: root/itjs
diff options
context:
space:
mode:
authorChristian Helbling2012-11-19 15:09:13 +0000
committerChristian Helbling2012-11-19 15:09:13 +0000
commit2fe88188ebe73d73473a2f5f8c52b0322c79aff4 (patch)
tree4e2f583bd092831512916ad614d11444df8ad497 /itjs
parent8ff4483ee69aafbe1cb62a96d5dcd7ce20138220 (diff)
downloaditools-2fe88188ebe73d73473a2f5f8c52b0322c79aff4.tar.gz
itools-2fe88188ebe73d73473a2f5f8c52b0322c79aff4.tar.bz2
itools-2fe88188ebe73d73473a2f5f8c52b0322c79aff4.zip
add code for clients missing getBoundingClientRec - fixes map on Android 1.6 (broken since r45840)
Diffstat (limited to 'itjs')
-rw-r--r--itjs/it.js34
1 files changed, 32 insertions, 2 deletions
diff --git a/itjs/it.js b/itjs/it.js
index b5e1f56..ce154da 100644
--- a/itjs/it.js
+++ b/itjs/it.js
@@ -178,12 +178,42 @@ function it_event_void(evt)
/* Get object pixel position. Based on quirksmode.org's code */
function it_get_obj_x(obj)
{
- return obj.getBoundingClientRect().left + ((window.pageXOffset !== undefined) ? window.pageXOffset : (document.documentElement || document.body.parentNode || document.body).scrollLeft);
+ if("getBoundingClientRect" in obj)
+ return obj.getBoundingClientRect().left + ((window.pageXOffset !== undefined) ? window.pageXOffset : (document.documentElement || document.body.parentNode || document.body).scrollLeft);
+ else
+ {
+ // legacy for Android 1.6
+ var curleft = 0;
+ if (obj.offsetParent)
+ while (obj)
+ {
+ curleft += obj.offsetLeft;
+ obj = obj.offsetParent;
+ }
+ else if (obj.x)
+ curleft += obj.x;
+ return curleft;
+ }
}
function it_get_obj_y(obj)
{
- return obj.getBoundingClientRect().top + ((window.pageYOffset !== undefined) ? window.pageYOffset : (document.documentElement || document.body.parentNode || document.body).scrollTop);
+ if("getBoundingClientRect" in obj)
+ return obj.getBoundingClientRect().top + ((window.pageYOffset !== undefined) ? window.pageYOffset : (document.documentElement || document.body.parentNode || document.body).scrollTop);
+ else
+ {
+ // legacy for Android 1.6
+ var curtop = 0;
+ if (obj.offsetParent)
+ while (obj)
+ {
+ curtop += obj.offsetTop;
+ obj = obj.offsetParent;
+ }
+ else if (obj.y)
+ curtop += obj.y;
+ return curtop;
+ }
}
/* Common accessor for dom elements */