* Function: ng_ParentPosition * Determines absolute position to parent object or document. * * Syntax: * int *ng_ParentPosition* (object obj[, object parent]) * * Parameters: * obj - element object * parent - element object * * Returns: * Object with properti
(o, parent)
| 1538 | * Object with properties x and y. |
| 1539 | */ |
| 1540 | function ng_ParentPosition(o, parent) |
| 1541 | { |
| 1542 | var n=o,pn; |
| 1543 | var pos=new Object; |
| 1544 | pos.x=0; |
| 1545 | pos.y=0; |
| 1546 | if(typeof parent === 'undefined') parent=document.body; |
| 1547 | while((n)&&(n!=parent)) |
| 1548 | { |
| 1549 | pn=n.offsetParent; |
| 1550 | pos.x += n.offsetLeft + ng_GetCurrentStylePx(n,'border-left-width'); |
| 1551 | pos.y += n.offsetTop + ng_GetCurrentStylePx(n,'border-top-width'); |
| 1552 | if((pn)&&(pn!=parent)) |
| 1553 | { |
| 1554 | pos.x -= pn.scrollLeft; |
| 1555 | pos.y -= pn.scrollTop; |
| 1556 | } |
| 1557 | if(ngFireFox) |
| 1558 | { |
| 1559 | if((ng_GetCurrentStyle(n,'overflow')!=='auto')||((ngFireFox1x)||(ngFireFox2x))) |
| 1560 | { |
| 1561 | pos.x+=ng_GetCurrentStylePx(n,'border-left-width'); |
| 1562 | pos.y+=ng_GetCurrentStylePx(n,'border-top-width'); |
| 1563 | } |
| 1564 | |
| 1565 | } |
| 1566 | else |
| 1567 | { |
| 1568 | if(ngOpera) |
| 1569 | { |
| 1570 | pos.x -=ng_GetCurrentStylePx(n,'border-left-width'); |
| 1571 | pos.y -=ng_GetCurrentStylePx(n,'border-top-width'); |
| 1572 | } |
| 1573 | } |
| 1574 | n=pn; |
| 1575 | } |
| 1576 | return pos; |
| 1577 | } |
| 1578 | |
| 1579 | |
| 1580 | /** |
no test coverage detected