Team:Shenzhen SFLS/comm/javascripts
From 2013hs.igem.org
(Difference between revisions)
Line 1: | Line 1: | ||
function menu_active(_index) { | function menu_active(_index) { | ||
- | var $menu_sub = $('<ul></ul>'); | + | var $menu = $('<ul></ul>'); |
- | var _menuItem = [{ 'txt': 'Home','menu':'menu', 'link': 'https://2013hs.igem.org/Team:Shenzhen_SFLS' }, | + | var $menu_sub=$('<ul class="nav_sub"></ul>');; |
- | { 'txt': 'Team','menu':'menu', 'link': 'https://2013hs.igem.org/Team:Shenzhen_SFLS/Team' }, | + | var $menu_context; |
- | { 'txt': 'Project','menu':'menu_parent', 'link': 'https://2013hs.igem.org/Team:Shenzhen_SFLS/Project' }, | + | var _menuItem = [{ 'txt': 'Home','menu':'menu', 'link': 'https://2013hs.igem.org/Team:Shenzhen_SFLS','submenu':[] }, |
- | { 'txt': 'Notebook','menu':'menu', 'link': 'https://2013hs.igem.org/Team:Shenzhen_SFLS/Notebook' }, | + | { 'txt': 'Team','menu':'menu', 'link': 'https://2013hs.igem.org/Team:Shenzhen_SFLS/Team','submenu':[] }, |
- | { 'txt': 'Results','menu':'menu', 'link': 'https://2013hs.igem.org/Team:Shenzhen_SFLS/Results' }, | + | { 'txt': 'Project','menu':'menu_parent', 'link': 'https://2013hs.igem.org/Team:Shenzhen_SFLS/Project', |
- | { 'txt': 'Human practices','menu':'menu', 'link': 'https://2013hs.igem.org/Team:Shenzhen_SFLS/Human' }]; | + | 'submenu':[{'txt': 'biosafety','menu':'menu', 'link': 'https://2013hs.igem.org/Team:Shenzhen_SFLS/Biosafety'}] }, |
+ | { 'txt': 'Notebook','menu':'menu', 'link': 'https://2013hs.igem.org/Team:Shenzhen_SFLS/Notebook','submenu':[] }, | ||
+ | { 'txt': 'Results','menu':'menu', 'link': 'https://2013hs.igem.org/Team:Shenzhen_SFLS/Results' ,'submenu':[]}, | ||
+ | { 'txt': 'Human practices','menu':'menu', 'link': 'https://2013hs.igem.org/Team:Shenzhen_SFLS/Human' ,'submenu':[]}]; | ||
for (var i = 0; i < _menuItem.length; i++) { | for (var i = 0; i < _menuItem.length; i++) { | ||
- | + | $menu_context=$('<li class="' +_menuItem[i].menu+ '"></li>'); | |
+ | $menu_context.append('<a href=' + _menuItem[i].link + '>' + _menuItem[i].txt + '</a>'); | ||
+ | if(_menuItem[i].submenu.length>0){ | ||
+ | for(var j=0;j<_menuItem[i].submenu.length;j++){ | ||
+ | $menu_sub.append('<li><a href=' + _menuItem[i].submenu[j].link + '>' + _menuItem[i].submenu[j].txt + '</a></li>'); | ||
+ | } | ||
+ | $menu_context.append($menu_sub); | ||
+ | } | ||
+ | $menu.append($menu_context); | ||
} | } | ||
- | + | ||
- | + | $('.nav').append($menu); | |
- | $('.nav').append($ | + | |
$('.nav li').hover( | $('.nav li').hover( | ||
function () { | function () { | ||
Line 28: | Line 38: | ||
$('.nav .menu_parent,.nav .active_parent,.nav .active_parent_select').hover( | $('.nav .menu_parent,.nav .active_parent,.nav .active_parent_select').hover( | ||
function () { | function () { | ||
- | + | $(".nav_sub").slideDown('fast').show(); | |
}, function () { | }, function () { | ||
- | + | $(".nav_sub").slideUp('slow'); | |
}); | }); | ||
if(_menuItem[_index].menu=='menu') | if(_menuItem[_index].menu=='menu') |
Revision as of 16:35, 21 June 2013
function menu_active(_index) {
var $menu = $('var $menu_context; var _menuItem = [{ 'txt': 'Home','menu':'menu', 'link': 'https://2013hs.igem.org/Team:Shenzhen_SFLS','submenu':[] }, { 'txt': 'Team','menu':'menu', 'link': 'https://2013hs.igem.org/Team:Shenzhen_SFLS/Team','submenu':[] }, { 'txt': 'Project','menu':'menu_parent', 'link': 'https://2013hs.igem.org/Team:Shenzhen_SFLS/Project',
'submenu':[{'txt': 'biosafety','menu':'menu', 'link': 'https://2013hs.igem.org/Team:Shenzhen_SFLS/Biosafety'}] },
{ 'txt': 'Notebook','menu':'menu', 'link': 'https://2013hs.igem.org/Team:Shenzhen_SFLS/Notebook','submenu':[] }, { 'txt': 'Results','menu':'menu', 'link': 'https://2013hs.igem.org/Team:Shenzhen_SFLS/Results' ,'submenu':[]}, { 'txt': 'Human practices','menu':'menu', 'link': 'https://2013hs.igem.org/Team:Shenzhen_SFLS/Human' ,'submenu':[]}];
for (var i = 0; i < _menuItem.length; i++) {$menu_context=$('