Web Wiz - Green Windows Web Hosting

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

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: 1140
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

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.