Template:Tsinghua:Navigation-Script
From 2013.igem.org
(Difference between revisions)
(Created page with "<html> <script type="text/javascript"> function start(){ //Collapse all submenus $(".sub-menu").data("collapsed", true) .hide(); $("h1.firstHeading").remove(); ...") |
|||
Line 2: | Line 2: | ||
<script type="text/javascript"> | <script type="text/javascript"> | ||
function start(){ | function start(){ | ||
- | + | //Collapse all submenus | |
- | + | $(".sub-menu").data("collapsed", true) | |
- | + | .hide(); | |
$("h1.firstHeading").remove(); | $("h1.firstHeading").remove(); | ||
$("#p-logo").remove(); | $("#p-logo").remove(); | ||
Line 14: | Line 14: | ||
//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 04:11, 26 September 2013