mod for fixing dropdowns when in centered div
Printed From: Web Wiz Forums
Category: Web Wiz Web App Support Forums
Forum Name: Web Wiz Forums Modifications
Forum Description: Mod's and Add-on's for Web Wiz Forums.
URL: https://forums.webwiz.net/forum_posts.asp?TID=24486
Printed Date: 30 March 2026 at 3:54am Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com
Topic: mod for fixing dropdowns when in centered div
Posted By: odang
Subject: mod for fixing dropdowns when in centered div
Date Posted: 22 September 2007 at 10:34pm
OK, since the dropdown system in the new forum was, in my mind, poorly implemented and still not fixed. Here's an easy mod that only requires a little bit of change to the forum's default_javascript_v9.js file. This way it won't be a hassle to continue to upgrade to newer forum versions. Replace the showDropDown function with the below. You may need to add additional Javascript to the portion labeled //offsets for other dropdowns that aren't aligning correctly.
function showDropDown(parentEle, dropDownEle, dropDownWidth, offSetRight){
parentElement = document.getElementById(parentEle); dropDownElement = document.getElementById(dropDownEle)
//position //dropDownElement.style.left = (getOffsetLeft(parentElement) - offSetRight) + 'px'; //dropDownElement.style.top = (getOffsetTop(parentElement) + parentElement.offsetHeight + 3) + 'px'; //offsets offsetleft=0; if (Left(parentEle,11)=='postOptions'){ offsetleft=150; } if (Left(parentEle,15)=='SearchTopicLink'){ offsetleft=150; } if (Left(parentEle,8)=='modTools'){ offsetleft=150; } if (Left(parentEle,12)=='topicOptions'){ offsetleft=150; }
dropDownElement.style.left = getY(parentEle, 'left')+offsetleft+'px'; //dropDownElement.style.top = (getY(parentEle, 'top')+40)+'px';
dropDownElement.style.top = (getOffsetTop(parentElement) + parentElement.offsetHeight -100) + 'px';
//width dropDownElement.style.width = dropDownWidth + 'px';
//display hideDropDown(); dropDownElement.style.visibility = 'visible';
//Event Listener to hide drop down if(document.addEventListener){ // Mozilla, Netscape, Firefox document.addEventListener('mouseup', hideDropDown, false); } else { // IE document.onmouseup = hideDropDown; } }
function Left(str, n){ if (n <= 0) return ""; else if (n > String(str).length) return str; else return String(str).substring(0,n); } function Right(str, n){ if (n <= 0) return ""; else if (n > String(str).length) return str; else { var iLen = String(str).length; return String(str).substring(iLen, iLen - n); } }
function getY( oElement, opos ) { var iReturnValue = 0; elementid=document.getElementById(oElement) while( elementid != null ){ if (opos=="top"){ iReturnValue += elementid.offsetTop; }else{ iReturnValue += elementid.offsetLeft; } //elementid = elementid.offsetParent; elementid=null; } //alert(opos+" - "+iReturnValue); return iReturnValue; }
|
Replies:
Posted By: iSec
Date Posted: 23 September 2007 at 12:12am
What does this specifically fix? Do you have a demo where we can test it?
------------- "When it gets dark enough, you can see the stars"
-Charles A. Beard
|
Posted By: odang
Date Posted: 23 September 2007 at 9:59am
|
if you have your forum centered withing Div tags verses tables, the the dropdowns don't appear in the correct spots. This is the fix for it. If your dropdowns (calendar, search, topic options, post options...) are appearing off point then you will potentially want to use this.
|
|