JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old March 20th, 2004, 06:44 PM
kh44na kh44na is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Posts: 37 kh44na User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Exclamation Javascript Pull Down Menu

Hello there!

I had a question about a pull down menu script I found on the net. I was interested in formatting it slightly. THe menu basically runs off of three pages (menu.html, menu.css, and menu.js)



This is what menu.js looks like:

Code:
var menuTimeout = 300

var menuSections = new Array()
var menuCountHide = new Array()

var menuSectionCnt = 0
var menuBoxCnt = 0

function menuShow(section, elements) {
  for (var i = 0; i < menuSections.length; i++) {
    if (menuSections[i] != section) {
      menuHide(menuSections[i], menuCountNodes(menuSections[i]))
    }
  }
  for (var i = 1; i <= elements; i++) {
    document.getElementById(section + '-' + i).style.visibility = 'visible'
  }
}

function menuHide(section, elements) {
  for (var i = 1; i <= elements; i++) {
    document.getElementById(section + '-' + i).style.visibility = 'hidden'
    document.getElementById(section).style.zIndex = -1
  }
}

function menuTryHide(section, elements, countHide) {
  if (countHide != menuCountHide[section]) {
    return
  }
  menuHide(section, elements)
}

function menuCountNodes(element) {
  ret = 0
  nodes = document.getElementById(element).childNodes.length  
  for (var i = 0; i < nodes; i++) {
    if (document.getElementById(element).childNodes[i].nodeType == 1) {
      ret++
    }
  }
  return ret
}

function menuInitSection(section) {
  var elements = menuCountNodes(section)
  for (var i = 0; i <= elements; i++) {
    var s = (i == 0 ? (section + '-top') : (section + '-' + i))
    if (i == 0) {
      document.getElementById(s).onmouseover = function() {
        menuShow(section, elements)
        menuCountHide[section]++
        for (var ii = 0; ii < menuSections.length; ii++) {
          document.getElementById(section).style.zIndex = 1
          if (menuSections[ii] != section) {
            document.getElementById(menuSections[ii]).style.zIndex = -1
          }
        }
      }
    } else {
      document.getElementById(s).onmouseover = function() {
        menuShow(section, elements)
        menuCountHide[section]++
      }
    }
    document.getElementById(s).onmouseout = function() {
      setTimeout("menuTryHide('" + section + "', " + elements + ", " + menuCountHide[section] + ")", menuTimeout)
    }
  }
}

function menuMakeId(nodes) {
  for (var i = 0; i < nodes.length; i++) {
    switch (nodes[i].className) {
      case 'top':
        menuSectionCnt++
        menuBoxCnt = 0
        nodes[i].id = 'menu-' + menuSectionCnt + '-top'
        break
      case 'section':
        nodes[i].id = 'menu-' + menuSectionCnt
        menuSections[menuSections.length] = nodes[i].id
        break
      case 'box':
        menuBoxCnt++
        nodes[i].id = 'menu-' + menuSectionCnt + '-' + menuBoxCnt
        break
    }
    if (nodes[i].childNodes) {
      menuMakeId(nodes[i].childNodes)
    }
  }
}

function menuInit() {
  menuMakeId(document.getElementById('menu').childNo  des)
  for (var i = 0; i < menuSections.length; i++) {
    menuCountHide[menuSections[i]] = 0
  }
  for (var i = 0; i < menuSections.length; i++) {
    menuInitSection(menuSections[i])
  }
}



Menu.css basically contains various text styles, and formats the background colours, etc (for the actual menu).

The "text" for the category options and subcategories of the menu are embedded directly into menu.html.

Basically, what I was interested in doing is INCREASING the HEIGHT of the menu, but I can't seem to figure out which page to edit, and how to go about doing this.

Perhaps some of the more experienced javascript programmers may have an idea of what do do? If you would like to see the code for the other pages, let me know, and I'll put it in here.

Your help would be GREATLY appreciated. And I would like to thank you in advance.

Reply With Quote
  #2  
Old March 20th, 2004, 10:44 PM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
The CSS file would control all the presentational aspects of the menu. What you need to do is find the class or ID that controls the menu items. Without seeing the whole system, I'd guess the class is called "box".
__________________
DevArticles Moderator
BlueSix - Web Development and Consulting

Reply With Quote
  #3  
Old March 20th, 2004, 10:56 PM
kh44na kh44na is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Posts: 37 kh44na User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Hello!

Thanks for your quick response bud. The css style sheet looks like this, but it doesn't make sense to me as to where I would control the menu's height:

Code:
#menu {
    background : url(gradient.jpg);
}
#menu div.top {
    padding-top: 5px;
    padding-bottom: 6px;
    padding-left: 6px;
    padding-right: 8px;

    width: 100%;
}
#menu div.section {
    position: absolute;
    display: inline;
    z-index: -1;
}
#menu div.box {
    background-color: #CACACA;
    padding-top: 4px;
    padding-bottom: 5px;
    padding-left: 6px;
    padding-right: 6px;
    border-color: #ACACAC;
    border-width: 1px;
    border-style: none none solid none;

    position: relative;
    visibility: hidden;
    width: 100%;
}
#menu a {
    font-family: verdana;
    font-size: 11px;
    color: #464646;
    text-decoration: none;
    white-space: nowrap;
}
#menu a:hover {
    font-family: verdana;
    font-size: 11px;
    color: #464646;
    text-decoration: none;
    white-space: nowrap;
}

Reply With Quote
  #4  
Old March 20th, 2004, 11:06 PM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
Try adding more padding to this rule: "#menu div.box". In fact, remove all their padding attributes and write this: "padding : 6px 6px;" - the first value is the top/bottom padding, the second is the left/right.

Reply With Quote
  #5  
Old March 20th, 2004, 11:19 PM
kh44na kh44na is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Posts: 37 kh44na User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
ok - what should I REMOVE and what should I replace in the code? Sorry, I'm just trying to figure out what you would suggest I do (in order to increase the vertical thickness of this menu)

Reply With Quote
  #6  
Old March 20th, 2004, 11:25 PM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
To change the height of the item, add MORE PADDING to the top/bottom padding values.

Reply With Quote
  #7  
Old March 21st, 2004, 03:56 AM
kh44na kh44na is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Posts: 37 kh44na User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Thank you very much!

The only other small thing is that the increased height has caused the TEXT (for the main category options) to become top aligned. There's too much empty space near the bottom of the menu - Is there a way that I can "middle" align the text that shows up in the #menu div.top ?

(I appreciate your help)

Reply With Quote
  #8  
Old March 21st, 2004, 05:47 AM
stumpy's Avatar
stumpy stumpy is offline
May contain nuts.
Dev Articles Regular (2000 - 2499 posts)
 
Join Date: Aug 2002
Location: Sydney, AU
Posts: 2,058 stumpy User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 8 m 57 sec
Reputation Power: 9
Send a message via ICQ to stumpy Send a message via MSN to stumpy
Can't really do much unless I can see the whole thing running. Can you put the code up somewhere live on the net?

Reply With Quote
  #9  
Old March 21st, 2004, 08:16 AM
kh44na kh44na is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Posts: 37 kh44na User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Absolutely!

http://www.dreamnation.ca/testing/menu/menu.html

That's where the menu is located. As you can see the text for the menu's MAIN CATEGORIES, is at TOP aligned. I want it to be in the middle of the gradient (vertically speaking).

Reply With Quote
  #10  
Old March 28th, 2004, 02:49 PM
Pheifel Pheifel is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Location: Denmark
Posts: 174 Pheifel User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 43 m 46 sec
Reputation Power: 5
Send a message via MSN to Pheifel
try posting the new css style sheet, with the changes on, opossed to the old one, and then let me take a look at it.

or you could give me the exact name of the css style, and i can take it down from your testsite my selvf, and post the changes.

Just now, it lookes to me like, you have changed the wrong variables in the .css style

- Pheifel

Reply With Quote
  #11  
Old March 28th, 2004, 03:22 PM
kh44na kh44na is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Posts: 37 kh44na User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
thanks - but I figured out a solution to my problem quite a while ago.

regards

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingJavaScript Development > Javascript Pull Down Menu


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT