Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Submenu area always visible some way to hide it?

  1. #1
    Join Date
    Nov 2008
    Location
    Phoenix, AZ
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Submenu area always visible some way to hide it?

    1) Script Title: Mouseover Tabs Menu

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...seovertabs.htm

    3) Describe problem:
    Is there a way to hide the SUBmenu area until/unless you hover over the tab? Right now, the submenu area is always visible ... with/without submenu entries .. like http://www.qantas.com.au

    Tanks
    David

  2. #2
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    Remove highlighted:
    Code:
    <li><a href="http://www.javascriptkit.com" rel="gotsubmenu[selected]">JavaScript Kit</a></li>
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

  3. The Following User Says Thank You to rangana For This Useful Post:

    dsmcbride (11-04-2008)

  4. #3
    Join Date
    Nov 2008
    Location
    Phoenix, AZ
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    thanks for the reply .. removing the [selected] still displays the submenu area ... it's is just blank/empty ) but still using the real estate on the page ... what I'd like to have happen is to have the submenu area be visible ONLY when hovering over a menu ...

    Thanks
    David

  5. #4
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Well, the menu you cited on the external site is a little different in that the sub menu DIV is actually absolutely positioned, and overlays the regular contents when it's shown. You can modify this script to behave similarly first by editing mouseovertabs.css with the changes in red:

    Code:
    .tabsmenucontentclass{
    clear: left;
    background: #E8E8E8;
    width: 90%;
    height: 24px;
    padding: 5px;
    border: 1px solid silver;
    position: absolute;
    z-index: 100;
    visibility: hidden;
    }
    This causes the sub menu DIV to be absolutely positioned and initially hidden completely. Then inside mouseovertabs.js, you'll want to add the two lines in red below to complete the change:

    Code:
    showsubmenu:function(linkobj){
    	var tabsmenutree=this.tabsmenutree[linkobj._parentid]
    	this.hidesubmenu(linkobj._parentid)
    	var selected=parseInt(linkobj._pos)
    	tabsmenutree.submenu.style.visibility="visible"
    	tabsmenutree.submenu_divs[selected].style.display="block"
    	this.css(tabsmenutree.tabs[selected], "selected", "add")
    	tabsmenutree.submenu._prevselected=selected
    },
    
    hidesubmenu:function(tabsmenuid){
    	var tabsmenutree=this.tabsmenutree[tabsmenuid]
    	var prevselectedindex=tabsmenutree.submenu._prevselected
    	if (typeof prevselectedindex!="undefined"){
    		tabsmenutree.submenu.style.visibility="hidden"
    		tabsmenutree.submenu_divs[prevselectedindex].style.display="none"
    		this.css(tabsmenutree.tabs[prevselectedindex], "selected", "remove")
    	}
    },
    DD Admin

  6. The Following User Says Thank You to ddadmin For This Useful Post:

    dsmcbride (11-05-2008)

  7. #5
    Join Date
    Nov 2008
    Location
    Phoenix, AZ
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Perfect!!! .. thanks ... is it also possible to again hide the submenu area when the mouse is outside the menu or submenu area?

    Thanks again
    David

  8. #6
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    I was suppose to make a response about this earlier, but ddadmin beat me.

    Anyway, try to remove the changes ddadmin suggested, and add highilighted instead:
    Code:
    this.addEvent(submenu, function(e){
    		submenu.style.display='';
    		mouseovertabsmenu.clearhidetimer(this.hidetimer)
    	}, "mouseover")
    	if (disappearBool==true){
    		this.addEvent(submenu, function(e){ //hide submenu contents when mouse rolls out of submenu DIV
    			if (!mouseovertabsmenu.isContained(this, e)){
    				var cursubmenuobj=this
    				this.hidetimer=setTimeout(function(){mouseovertabsmenu.hidesubmenu(cursubmenuobj._parentid)}, mouseovertabsmenu.disappeardelay)
    			submenu.style.display='none';
    			}
    		}, "mouseout")
    	}
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

  9. #7
    Join Date
    Nov 2008
    Location
    Phoenix, AZ
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    rangana:

    I removed all the changed proposed by DDADMIN (css and js) ... and added the two lines of code you suggested. However a) the submenu are appears when the screen is first loaded -- perhaps this is because of the CSS changes and b) the submenu does not disappear when the mouse is moved off the menu/submenu area ... essentially it appears your suggested changes have no effect

  10. #8
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    Oh, thanks for pointing that out. I forgot to inform you to add highlighted too:
    Code:
    init:function(tabsmenuid, submenuid, disappearBool){
    	this.tabsmenutree[tabsmenuid]={} 
    	this.tabsmenutree[tabsmenuid].tabs=[] //array referencing the active tab links in this menu (ones with a "rel=gotsubmenu" attr)
    	this.tabsmenutree[tabsmenuid].submenu=null //reference submenu DIV for this menu
    	this.tabsmenutree[tabsmenuid].submenu_divs=[] //array referencing the submenu contents (external DIVs with class="tabsmenucontent")
    	var submenu=document.getElementById(submenuid)
    	submenu.style.display='none'; // Hide the SUBMENU
    	submenu._parentid=tabsmenuid
    	this.tabsmenutree[tabsmenuid].submenu=submenu //remember this DIV as menu's submenu container
    	var remoteurl=submenu.getElementsByTagName("a")[0].getAttribute("href")
    	this.ajaxload(tabsmenuid, submenuid, disappearBool, remoteurl)
    }
    ...it hides the submenu on load.

    Hope that fits your desire.
    [/code]
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

  11. #9
    Join Date
    Nov 2008
    Location
    Phoenix, AZ
    Posts
    7
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    rangana:
    yes, now the menu does not come up initially, but unfortunately it also does not display when hovering over the menu choices

    thanks for your help ...i really appreciate it
    david

  12. #10
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    My apologies. Never in my entire life I had been so forgetful as I am now.

    Add highlighted too:
    Code:
    showsubmenu:function(linkobj){
    document.getElementById('mysubmenuarea').style.display='';
    	var tabsmenutree=this.tabsmenutree[linkobj._parentid]
    	this.hidesubmenu(linkobj._parentid)
    	var selected=parseInt(linkobj._pos)
    	tabsmenutree.submenu_divs[selected].style.display="block"
    	this.css(tabsmenutree.tabs[selected], "selected", "add")
    	tabsmenutree.submenu._prevselected=selected
    },
    You could add as many of that as you wish, if you had multiple submenus.

    Hope that was it.

    Let me know if I miss something else.
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •