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 start(){
+
function setupMenu(){
-
//Collapse all submenus
+
//Collapse all submenus
-
$(".sub-menu").data("collapsed", true)
+
$(".sub-menu").data("collapsed", true)
-
  .hide();
+
.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
+
//Deselect all menus
-
$('.menu-item').removeClass('menu-selected');
+
$('.menu-item').removeClass('menu-selected');
-
//Deselect all submenu items
+
//Deselect all submenu items
-
$('.sub-menu-item').removeClass('menu-selected');
+
$('.sub-menu-item').removeClass('menu-selected');
-
//Select menu item
+
//Select menu item
-
$(elem).addClass('menu-selected');
+
$(elem).addClass('menu-selected');
-
//Collapse all other submenus
+
//Collapse all other submenus
-
$('.sub-menu').each(function(){
+
$('.sub-menu').each(function(){
-
  if(!$(this).parent().hasClass('menu-selected')){
+
if(!$(this).parent().hasClass('menu-selected')){
-
  $(this).data("collapsed", true).slideUp();
+
$(this).data("collapsed", true).slideUp();
-
  }
+
}
-
});
+
});
-
//Change page title
+
//Change page title
-
$('#page-title').text(page_title);
+
$('#page-title').text(page_title);
-
//Expand the sub menu
+
//Expand the sub menu
-
subMenus = elem.getElementsByClassName('sub-menu');
+
subMenus = elem.getElementsByClassName('sub-menu');
-
if(subMenus.length > 0){
+
if(subMenus.length > 0){
-
  submenu = subMenus[0];
+
submenu = subMenus[0];
-
  if($(submenu).data("collapsed")){
+
if($(submenu).data("collapsed")){
-
  //Expand the sub menu
+
//Expand the sub menu
-
  $(submenu).data("collapsed", false).slideDown();
+
$(submenu).data("collapsed", false).slideDown();
-
  }else{
+
}else{
-
  //Collapse the sub menu
+
//Collapse the sub menu
-
  $(submenu).data('collapsed', true).slideUp();
+
$(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
+
//Deselect all submenu items
-
$(".sub-menu-item").removeClass("menu-selected");
+
$(".sub-menu-item").removeClass("menu-selected");
-
//Select current submenu item
+
//Select current submenu item
-
$(elem).addClass("menu-selected");
+
$(elem).addClass("menu-selected");
-
//Change page title
+
//Change page title
-
$("#page-title").text(page_title);
+
$("#page-title").text(page_title);
}
}
</script>
</script>
</html>
</html>

Revision as of 18:28, 26 September 2013