PhantomSnake (talk | contribs) mNo edit summary |
PhantomSnake (talk | contribs) mNo edit summary |
||
(18 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
<script type="text/javascript"> | <script type="text/javascript"> | ||
var useFloats = true; | var useFloats = true; | ||
var visible = false; | |||
var lastFloat = ''; | |||
function findRelPosX(obj) { | function findRelPosX(obj) { | ||
Line 32: | Line 34: | ||
if (inobj.offsetParent) { | if (inobj.offsetParent) { | ||
while ( | while (inobj.offsetParent) { | ||
if(inobj.offsetParent == outobj.offsetParent) { | if(inobj.offsetParent == outobj.offsetParent) { | ||
break; | break; | ||
Line 51: | Line 53: | ||
if (inobj.offsetParent) { | if (inobj.offsetParent) { | ||
while ( | while (inobj.offsetParent) { | ||
if(inobj.offsetParent == outobj.offsetParent) { | if(inobj.offsetParent == outobj.offsetParent) { | ||
disty += inobj.offsetTop; | |||
break; | break; | ||
} | } | ||
Line 59: | Line 62: | ||
inobj = inobj.offsetParent; | inobj = inobj.offsetParent; | ||
} | } | ||
disty = outobj.offsetTop - disty; | |||
} else if (inobj.y) { | } else if (inobj.y) { | ||
disty = outobj.y - inobj.y; | disty = outobj.y - inobj.y; | ||
Line 99: | Line 104: | ||
} | } | ||
return curtop; | return curtop; | ||
} | |||
function showFloat(id, index) { | |||
if(lastFloat == id) { } else { | |||
visible = false; | |||
hideFloat(lastFloat); | |||
lastFloat = id; | |||
} | |||
visible = true; | |||
var float = document.getElementById('float' + id); | |||
var floatanchor = document.getElementById('floatanchor' + id); | |||
var link = document.getElementById('floatlink' + id + index); | |||
var linkend = document.getElementById('floatlinkend' + id + index); | |||
float.style.display = 'block'; | |||
var posX = findDistanceX(floatanchor, link) + findRelPosX(floatanchor) + ((findRelPosX(linkend) - findRelPosX(link)) / 2) - 175; | |||
if(posX < 0) { | |||
posX = 12; | |||
} | |||
var posY = findRelPosY(floatanchor) - findDistanceY(floatanchor, link) + 18; | |||
float.style.left = posX + 'px'; | |||
float.style.top = posY + 'px'; | |||
} | |||
function delayedHideFloat(id) { | |||
visible = false; | |||
window.setTimeout('hideFloat(\'' + id + '\')', 200); | |||
} | |||
function hideFloat(id) { | |||
if(visible) { return; } | |||
var float = document.getElementById('float' + id); | |||
if(float) { | |||
float.style.display = 'none'; | |||
} | |||
} | } | ||
</script> | </script> | ||
</plainhtml> | </plainhtml> |
Latest revision as of 14:11, 28 July 2006
<plainhtml>
<script type="text/javascript">
var useFloats = true; var visible = false; var lastFloat = ;
function findRelPosX(obj) { var relleft = 0;
if (obj.offsetParent) { relleft = obj.offsetLeft; } else if (obj.x) { relleft = obj.x; }
return relleft; }
function findRelPosY(obj) { var reltop = 0;
if (obj.offsetParent) { reltop = obj.offsetTop; } else if (obj.y) { reltop = obj.y; }
return reltop; }
function findDistanceX(outobj, inobj) { var distx = 0;
if (inobj.offsetParent) { while (inobj.offsetParent) { if(inobj.offsetParent == outobj.offsetParent) { break; }
distx += inobj.offsetLeft; inobj= inobj.offsetParent; } } else if (inobj.x) { distx = outobj.x - inobj.x; }
return distx; }
function findDistanceY(outobj, inobj) { var disty = 0;
if (inobj.offsetParent) { while (inobj.offsetParent) { if(inobj.offsetParent == outobj.offsetParent) { disty += inobj.offsetTop; break; }
disty += inobj.offsetTop; inobj = inobj.offsetParent; }
disty = outobj.offsetTop - disty; } else if (inobj.y) { disty = outobj.y - inobj.y; }
return disty; }
function findPosX(obj) { var curleft = 0;
if (obj.offsetParent) { while (obj.offsetParent) { curleft += obj.offsetLeft; obj = obj.offsetParent; } } else if (obj.x) { curleft += obj.x; } return curleft; } function findPosY(obj) { var curtop = 0; if (obj.offsetParent) { while (obj.offsetParent) { curtop += obj.offsetTop; obj = obj.offsetParent; } } else if (obj.y) { curtop += obj.y; } return curtop; }
function showFloat(id, index) { if(lastFloat == id) { } else { visible = false; hideFloat(lastFloat); lastFloat = id; } visible = true;
var float = document.getElementById('float' + id); var floatanchor = document.getElementById('floatanchor' + id); var link = document.getElementById('floatlink' + id + index); var linkend = document.getElementById('floatlinkend' + id + index); float.style.display = 'block';
var posX = findDistanceX(floatanchor, link) + findRelPosX(floatanchor) + ((findRelPosX(linkend) - findRelPosX(link)) / 2) - 175; if(posX < 0) { posX = 12; }
var posY = findRelPosY(floatanchor) - findDistanceY(floatanchor, link) + 18;
float.style.left = posX + 'px'; float.style.top = posY + 'px'; } function delayedHideFloat(id) { visible = false; window.setTimeout('hideFloat(\ + id + '\')', 200); } function hideFloat(id) { if(visible) { return; }
var float = document.getElementById('float' + id); if(float) { float.style.display = 'none'; } }
</script>
</plainhtml>