:: Forum >>

Combo poblem on safari

Hi Alex,

The popup for the combo seems to be misplaced in Safari using the code below on AW 2.5.4.
Do you know of any workarounds ?

Thanks,
Ankur

<html>
<head>
    <script src="runtime/lib/aw.js" type="text/javascript"></script>
    <link href="runtime/styles/system/aw.css" rel="stylesheet">
</head>
<body>

<div style="overflow: scroll; width: 400px; height: 200px; border: 1px solid green;">
<div style="width: 800px; height: 400px; border: 1px solid red;">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ultrices turpis cursus sem porta
<span id="combo1"></span>
</div>
</div>

<script type="text/javascript">
    var itemTextArray = ["Home", "Favorites", "Font size", "Search"];
    var itemImageArray = ["home", "favorites", "fontsize", "search"];
    
    var combo = new AW.UI.Combo;
    combo.setId("combo1");
    combo.setControlText("Combo");
    combo.setControlImage("favorites");
    combo.setItemText(itemTextArray);
    combo.setItemImage(itemImageArray);
    combo.setItemCount(4);
    combo.refresh();
    
</script>
</body>
</html>
Ankur Motreja
Tuesday, July 14, 2009
Here is the patch which should solve this both on Safari4/Chrome and Safari 3 -

if (AW.webkit){
    if (document.documentElement.getBoundingClientRect){ // Safari 4

        AW.getLeft = function(element){
            return element.getBoundingClientRect().left;
        };

        AW.getTop = function(element){
            return element.getBoundingClientRect().top;
        };
    }
    else {

        AW.getLeft = function(element){
            return webkitGetRectangle(element).left - webkitGetScroll(element).left;
        };

        AW.getTop = function(element){
            return webkitGetRectangle(element).top - webkitGetScroll(element).top;
        };

        var webkitGetRectangle = function(e){

            var t = e, x = 0, y = 0;

            function getPos(el){
                if (!el) {
                    return {x:0, y:0};
                }
                if (el == document.body.parentNode){
                    return {x:0, y:0};
                }
                if (el == document.body){
                    return {x:el.offsetLeft, y:el.offsetTop};
                }

                var p = el.offsetParent;

                var pp = getPos(p);

                return {
                    x: el.offsetLeft + pp.x,
                    y: el.offsetTop + pp.y};
            }

            var pp = getPos(e);

            return {
                left: pp.x,
                right: pp.x + e.offsetWidth,
                top: pp.y,
                bottom: pp.y + e.offsetHeight
            };
        };


        var webkitGetScroll = function(e){

            var s = {left: 0, top: 0};

            e = e.parentNode;

            while (e && e !== document.body && e !== document.documentElement){
                s.left += e.scrollLeft;
                s.top += e.scrollTop;
                e = e.parentNode;
            }

            return s;
        };
    }
}
Alex (ActiveWidgets)
Wednesday, July 15, 2009
Thanks Alex.
That works fine.

Thanks,
Ankur
Ankur Motreja
Thursday, July 16, 2009
Fixed in AW 2.5.5 -
http://www.activewidgets.com/general.bugs/2-5-5.html
Alex (ActiveWidgets)
Friday, September 25, 2009

This topic is archived.


Back to support forum

Forum search