1 //2 // Set height of contentPanel3 //4 var y = y-196-50;5 var panel=document.getElementById('contentPanel');6 panel.style.height = y + 'px';7 //8 //9 // Set visibility of child elements in contentPanel10 //11 function findPosY(obj) // Get full top offset12 {13 var curtop = 0;14 if (obj.offsetParent)15 {16 while (obj.offsetParent)17 {18 curtop += obj.offsetTop19 obj = obj.offsetParent;20 }21 }22 else if (obj.y)23 curtop += obj.y;24 return curtop;25 }26 function setVisibility(node, y, panel) {27 var children=node.childNodes;28 for (var i=0; i < children.length; i++) {29 if (children[i].className && (children[i].className == 'toggle' || children[i].className.search('toggle'))) {30 var top=findPosY(children[i])31 var height = children[i].offsetHeight;32 var panelTop = findPosY(panel);33 //alert("<strong class="highlight">offsetTop</strong> = " + top + " <strong class="highlight">offsetHeight</strong> = " + height);34 if ( (top+height) > (y+panelTop) )35 children[i].style.visibility = 'hidden';36 else37 children[i].style.visibility = 'visible';38 }39 else40 setVisibility(children[i], y, panel);41 }42 }43 if (panel.className == 'noScroll') {44 panel.style.overflow = 'hidden';45 setVisibility(panel, y, panel);46 }
Enlace
El enlace para compartir es: