Created
July 18, 2009 18:54
-
-
Save alexbeutel/149654 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
This method adds a new menu to the top menu bar | |
string title - The title of the menu | |
hrefs - array of strings that contains the URLs for the menu items | |
links - text to be displayed for the link. if you would like a menu seperator, pass '<hr>' as the string | |
*/ | |
function buildAndInsertMenu(title, hrefs, links) | |
{ | |
var cond = title.replace(" ", "_"); | |
var menu = document.createElement('div'); | |
var html = ""; | |
menu.id = 'fb_menu_'+cond; | |
menu.setAttribute('class', 'fb_menu'); | |
html += "<div class=\"fb_menu_title\"><a href=\"#\" id=\"nav_" + cond +"\">" + title +"</a></div>"; | |
html += "<div id=\"fb_menu_" + cond + "_dropdown\" class=\"fb_menu_dropdown hidden_elem\">"; | |
var i; | |
for(i = 0; i < hrefs.length; i++) | |
{ | |
if (hrefs[i] == null || links[i] == null) | |
continue; | |
if (links[i] == "<hr>") | |
html += "<div class='fb_menu_separator'><hr></div>"; | |
else | |
html += "<div class=\"fb_menu_item\"><a href='" + hrefs[i] + "'>" + links[i] + "</a></div>"; | |
} | |
html += "</div>"; | |
menu.innerHTML = html; | |
if(document.getElementById('fb_menubar_core') != null) | |
document.getElementById('fb_menubar_core').appendChild(menu); | |
var dropdown_id=menu.id+'_dropdown'; | |
var menu_anchor=menu.firstChild.firstChild; | |
if(typeof dropmenu == 'function') | |
dropmenu(menu_anchor).registerHTMLMenu(dropdown_id).addHook('show',bind(new MenuBar('fb_menubar_core'),'_onShowCallback',menu_anchor,menu)).addHook('hide',bind(new MenuBar('fb_menubar_core'),'_onHideCallback',menu_anchor,menu)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment