Web Wiz
Home
Home
Hosting Services
Hosting Services
Knowledgebase
Knowledgebase
Community and Support Forums
Support Forums
Customer Login
Customer Login

  New Posts New Posts RSS Feed - mod for fixing dropdowns when in centered div
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Web Wiz Web Hosting 30 Day Free Trial

Windows Hosting 30 Day Free Trial, with no obligation, on all our Windows Web and Reseller Hosting Packages.

For moreĀ informationĀ see our Windows Hosting 30 Day Free Trial page.

mod for fixing dropdowns when in centered div

 Post Reply Post Reply
Author
odang View Drop Down
Newbie
Newbie


Joined: 02 April 2006
Status: Offline
Points: 22
Post Options Post Options   Thanks (0) Thanks(0)   Quote odang Quote  Post ReplyReply Direct Link To This Post Topic: mod for fixing dropdowns when in centered div
    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;
}


Edited by odang - 22 September 2007 at 10:35pm
Back to Top
iSec View Drop Down
Senior Member
Senior Member
Avatar

Joined: 13 February 2005
Status: Offline
Points: 1099
Post Options Post Options   Thanks (0) Thanks(0)   Quote iSec Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
odang View Drop Down
Newbie
Newbie


Joined: 02 April 2006
Status: Offline
Points: 22
Post Options Post Options   Thanks (0) Thanks(0)   Quote odang Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down



Become a Fan on Facebook Follow us on Twitter Web Wiz on Google+ Community Forums Web Wiz Blogs Web Wiz News
Company Information | Contact Web Wiz | Terms & Conditions | Privacy Policy

Prices exclude VAT unless otherwise stated - $, € prices shown as a guideline only
Web Wiz Ltd, Unit 10E Dawkins Road Ind. Est, Poole, Dorset, UK, BH15 4JD
Copyright ©2001-2012 Web Wiz - All rights reserved