Template:Tsinghua:Navigation-Script
From 2013.igem.org
(Difference between revisions)
Andries1990 (Talk | contribs) |
|||
(6 intermediate revisions not shown) | |||
Line 1: | Line 1: | ||
<html> | <html> | ||
<script type="text/javascript"> | <script type="text/javascript"> | ||
- | function | + | function initialize(){ |
- | + | $("h1.firstHeading").remove(); | |
- | + | $("#p-logo").remove(); | |
- | + | $("#search-controls").remove(); | |
- | + | $("#contentSub").remove(); | |
- | + | $("#siteSub").remove(); | |
- | + | ||
- | + | ||
- | + | ||
} | } | ||
- | + | function setupMenu(imenuItem, isubmenuItem){ | |
- | + | //Initialize data | |
- | function | + | //Collapse all submenus |
- | // | + | $(".sub-menu").data("collapsed", true).hide(); |
- | $( | + | //Show the selected menu item |
- | // | + | var menuItem = $($(".menu-item").get(imenuItem)); |
- | $( | + | //Select the menu item |
- | //Select menu item | + | menuItem.addClass("menu-selected"); |
- | + | //Select submenu item | |
- | // | + | var submenu = menuItem.children(".sub-menu"); |
- | + | var hasSubmenu = (submenu.length > 0); | |
- | + | if(hasSubmenu){ | |
- | + | submenu.data("collapsed", false).show(); | |
+ | var submenuItem = $(submenu.children(".sub-menu-item").get(isubmenuItem)); | ||
+ | submenuItem.addClass("menu-selected"); | ||
+ | } | ||
+ | //Set events | ||
+ | $(".menu-item span").click(function(){ | ||
+ | var submenu = $(this).next(); | ||
+ | var hasSubmenu = (submenu.length > 0); | ||
+ | var collapsed = true; | ||
+ | if(hasSubmenu){ | ||
+ | collapsed = submenu.data("collapsed"); | ||
} | } | ||
- | + | //Select and expand this menu item | |
- | + | var parentDiv = $(this).parent(); | |
- | + | //Deselect and collapse all other menu items | |
- | + | $("div.menu-item").not(parentDiv) | |
- | + | .removeClass("menu-selected") | |
- | + | .children(".sub-menu") | |
- | + | .data("collapsed", true) | |
- | + | .slideUp(); | |
- | + | parentDiv.addClass("menu-selected"); | |
- | + | if(hasSubmenu){ | |
- | + | if(collapsed){ | |
- | + | submenu.data("collapsed", false).slideDown(); | |
- | + | }else{ | |
+ | submenu.data("collapsed", true).slideUp(); | ||
+ | } | ||
} | } | ||
- | } | + | }); |
+ | $("div.sub-menu-item").click(function(){ | ||
+ | //Deselect other submenu items | ||
+ | $("div.sub-menu-item").removeClass("menu-selected"); | ||
+ | //Select this submenu item | ||
+ | $(this).addClass("menu-selected"); | ||
+ | }); | ||
} | } | ||
- | + | function setupSectionNavs(){ | |
- | function | + | $(document).ready(function() { |
- | + | $("div.section").hide(); | |
- | + | $("div.section1").show(); | |
- | + | $("#section-nav li").click(function() { | |
- | + | $("div.section").hide(); | |
- | + | var sectionName = $(this).attr("class"); | |
- | + | $("div." + sectionName).show(); | |
+ | }); | ||
+ | }); | ||
} | } | ||
</script> | </script> | ||
</html> | </html> |
Latest revision as of 08:01, 16 July 2014