Template:Tsinghua:Navigation-Script
From 2013.igem.org
(Difference between revisions)
Line 1: | Line 1: | ||
<html> | <html> | ||
<script type="text/javascript"> | <script type="text/javascript"> | ||
- | function | + | function setupMenu(){ |
- | + | //Collapse all submenus | |
- | + | $(".sub-menu").data("collapsed", true) | |
- | + | .hide(); | |
$("h1.firstHeading").remove(); | $("h1.firstHeading").remove(); | ||
$("#p-logo").remove(); | $("#p-logo").remove(); | ||
Line 10: | Line 10: | ||
$("#contentSub").remove(); | $("#contentSub").remove(); | ||
$("#siteSub").remove(); | $("#siteSub").remove(); | ||
+ | } | ||
+ | |||
+ | function setupSectionNavs(){ | ||
+ | $(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(); | ||
+ | }); | ||
+ | }); | ||
} | } | ||
//elem -- the menu-item element | //elem -- the menu-item element | ||
function selectMenu(elem, page_title){ | function selectMenu(elem, page_title){ | ||
- | + | //Deselect all menus | |
- | + | $('.menu-item').removeClass('menu-selected'); | |
- | + | //Deselect all submenu items | |
- | + | $('.sub-menu-item').removeClass('menu-selected'); | |
- | + | //Select menu item | |
- | + | $(elem).addClass('menu-selected'); | |
- | + | //Collapse all other submenus | |
- | + | $('.sub-menu').each(function(){ | |
- | + | if(!$(this).parent().hasClass('menu-selected')){ | |
- | + | $(this).data("collapsed", true).slideUp(); | |
- | + | } | |
- | + | }); | |
- | + | //Change page title | |
- | + | $('#page-title').text(page_title); | |
- | + | //Expand the sub menu | |
- | + | subMenus = elem.getElementsByClassName('sub-menu'); | |
- | + | if(subMenus.length > 0){ | |
- | + | submenu = subMenus[0]; | |
- | + | if($(submenu).data("collapsed")){ | |
- | + | //Expand the sub menu | |
- | + | $(submenu).data("collapsed", false).slideDown(); | |
- | + | }else{ | |
- | + | //Collapse the sub menu | |
- | + | $(submenu).data('collapsed', true).slideUp(); | |
- | + | } | |
- | + | } | |
} | } | ||
//When a sub-menu-item is selected | //When a sub-menu-item is selected | ||
function selectSubMenu(elem, page_title){ | function selectSubMenu(elem, page_title){ | ||
- | + | //Deselect all submenu items | |
- | + | $(".sub-menu-item").removeClass("menu-selected"); | |
- | + | //Select current submenu item | |
- | + | $(elem).addClass("menu-selected"); | |
- | + | //Change page title | |
- | + | $("#page-title").text(page_title); | |
} | } | ||
</script> | </script> | ||
</html> | </html> |
Revision as of 18:28, 26 September 2013