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_sub.append('<li class="' +_menuItem[i].menu+ '"><a href=' + _menuItem[i].link + '>' + _menuItem[i].txt + '</a></li>');
+
$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);
     }
     }
-
+
 
-
    //alert($menu_sub);
+
     $('.nav').append($menu);
-
     $('.nav').append($menu_sub);
+
     $('.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_sub=$('');;
       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=$('
  • </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('
  • <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 li').hover( function () { if(_menuItem[$(this).index()].menu=='menu') $(this).addClass('active'); else $(this).addClass('active_parent'); }, 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').eq(_index).addClass('active_select'); else $('.nav li').eq(_index).addClass('active_parent_select'); }