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_sub = $('<ul></ul>'); | ||
- | var _menuItem = [{ 'txt': 'Home', 'link': 'https://2013hs.igem.org/Team:Shenzhen_SFLS' }, | + | var _menuItem = [{ 'txt': 'Home','menu':'menu', 'link': 'https://2013hs.igem.org/Team:Shenzhen_SFLS' }, |
- | { 'txt': 'Team', 'link': 'https://2013hs.igem.org/Team:Shenzhen_SFLS/Team' }, | + | { 'txt': 'Team','menu':'menu', 'link': 'https://2013hs.igem.org/Team:Shenzhen_SFLS/Team' }, |
- | { 'txt': 'Project', 'link': 'https://2013hs.igem.org/Team:Shenzhen_SFLS/Project' }, | + | { 'txt': 'Project','menu':'menu_parent', 'link': 'https://2013hs.igem.org/Team:Shenzhen_SFLS/Project' }, |
- | { 'txt': 'Notebook', 'link': 'https://2013hs.igem.org/Team:Shenzhen_SFLS/Notebook' }, | + | { 'txt': 'Notebook','menu':'menu', 'link': 'https://2013hs.igem.org/Team:Shenzhen_SFLS/Notebook' }, |
- | { 'txt': ' | + | { 'txt': 'Results','menu':'menu', 'link': 'https://2013hs.igem.org/Team:Shenzhen_SFLS/Results' }, |
- | { 'txt': 'Human practices', 'link': 'https://2013hs.igem.org/Team:Shenzhen_SFLS/Human' }]; | + | { 'txt': 'Human practices','menu':'menu', 'link': 'https://2013hs.igem.org/Team:Shenzhen_SFLS/Human' }]; |
for (var i = 0; i < _menuItem.length; i++) { | for (var i = 0; i < _menuItem.length; i++) { | ||
- | $menu_sub.append('<li><a href=' + _menuItem[i].link + '>' + _menuItem[i].txt + '</a></li>'); | + | $menu_sub.append('<li class="' +_menuItem[i].menu+ '"><a href=' + _menuItem[i].link + '>' + _menuItem[i].txt + '</a></li>'); |
} | } | ||
+ | |||
//alert($menu_sub); | //alert($menu_sub); | ||
$('.nav').append($menu_sub); | $('.nav').append($menu_sub); | ||
$('.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 () { | |
- | + | ||
+ | }, function () { | ||
+ | |||
+ | }); | ||
+ | if(_menuItem[_index].menu=='menu') | ||
+ | $('.nav li').eq(_index).addClass('active_select'); | ||
+ | else | ||
+ | $('.nav li').eq(_index).addClass('active_parent_select'); | ||
+ | |||
+ | |||
} | } |
Revision as of 14:29, 21 June 2013
function menu_active(_index) {
var $menu_sub = $('var _menuItem = [{ 'txt': 'Home','menu':'menu', 'link': 'https://2013hs.igem.org/Team:Shenzhen_SFLS' }, { 'txt': 'Team','menu':'menu', 'link': 'https://2013hs.igem.org/Team:Shenzhen_SFLS/Team' }, { 'txt': 'Project','menu':'menu_parent', 'link': 'https://2013hs.igem.org/Team:Shenzhen_SFLS/Project' }, { 'txt': 'Notebook','menu':'menu', 'link': 'https://2013hs.igem.org/Team:Shenzhen_SFLS/Notebook' }, { 'txt': 'Results','menu':'menu', 'link': 'https://2013hs.igem.org/Team:Shenzhen_SFLS/Results' }, { 'txt': 'Human practices','menu':'menu', 'link': 'https://2013hs.igem.org/Team:Shenzhen_SFLS/Human' }];
for (var i = 0; i < _menuItem.length; i++) {$menu_sub.append('