Team:Shenzhen SFLS/comm/javascripts
From 2013hs.igem.org
(Difference between revisions)
(7 intermediate revisions not shown) | |||
Line 1: | Line 1: | ||
- | + | function menu_active(_index) { | |
- | var $menu_sub = $('<ul></ul>'); | + | var $menu = $('<ul></ul>'); |
- | var _menuItem = [{ 'txt': 'Home', 'link': 'https://2013hs.igem.org/Team:Shenzhen_SFLS | + | var $menu_sub=$('<ul class="nav_sub"></ul>');; |
- | + | 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++) { | 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 class="' +_menuItem[i].submenu[j].menu+ '"><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 () { | ||
- | + | if(_menuItem[$(this).index()].menu=='menu') | |
+ | $(this).addClass('active'); | ||
+ | else | ||
+ | $(this).addClass('active_parent'); | ||
}, function () { | }, function () { | ||
- | + | $(this).removeClass('active'); | |
+ | $(this).removeClass('active_parent'); | ||
}); | }); | ||
+ | $('.nav .menu_parent,.nav .active_parent,.nav .active_parent_select').hover( | ||
+ | function () { | ||
+ | $(".nav_sub").slideDown('fast').show(); | ||
+ | }, function () { | ||
+ | $(".nav_sub").slideUp('slow'); | ||
+ | }); | ||
- | + | if(_menuItem[_index].menu=='menu') | |
+ | $('.nav li').siblings().eq(_index).addClass('active_select'); | ||
+ | else | ||
+ | $('.nav li').siblings().eq(_index).addClass('active_parent_select'); | ||
+ | |||
+ | } |
Latest revision as of 18:07, 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=$('