diff options
author | Christian Helbling | 2012-11-19 15:09:13 +0000 |
---|---|---|
committer | Christian Helbling | 2012-11-19 15:09:13 +0000 |
commit | 2fe88188ebe73d73473a2f5f8c52b0322c79aff4 (patch) | |
tree | 4e2f583bd092831512916ad614d11444df8ad497 /itjs | |
parent | 8ff4483ee69aafbe1cb62a96d5dcd7ce20138220 (diff) | |
download | itools-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.js | 34 |
1 files changed, 32 insertions, 2 deletions
@@ -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 */ |