From 2fe88188ebe73d73473a2f5f8c52b0322c79aff4 Mon Sep 17 00:00:00 2001 From: Christian Helbling Date: Mon, 19 Nov 2012 15:09:13 +0000 Subject: add code for clients missing getBoundingClientRec - fixes map on Android 1.6 (broken since r45840) --- itjs/it.js | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'itjs/it.js') 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 */ -- cgit v1.2.3