Template:Tsinghua:Navigation-Script

From 2013.igem.org

(Difference between revisions)
Line 2: Line 2:
<script type="text/javascript">
<script type="text/javascript">
function initialize(){
function initialize(){
-
$("h1.firstHeading").remove();
+
$("h1.firstHeading").remove();
     $("#p-logo").remove();
     $("#p-logo").remove();
     $("#search-controls").remove();
     $("#search-controls").remove();
Line 9: Line 9:
}
}
function setupMenu(imenuItem, isubmenuItem){
function setupMenu(imenuItem, isubmenuItem){
-
//Initialize data
+
//Initialize data
-
//Collapse all submenus
+
//Collapse all submenus
-
$(".sub-menu").data("collapsed", true).hide();
+
$(".sub-menu").data("collapsed", true).hide();
-
//Show the selected menu item
+
//Show the selected menu item
-
var menuItem = $($(".menu-item").get(imenuItem));
+
var menuItem = $($(".menu-item").get(imenuItem));
-
menuItem.children(".sub-menu").data("collapsed", false).show();
+
//Select the menu item
-
//Select the menu item and submenu item
+
menuItem.addClass("menu-selected");
-
menuItem.addClass("menu-selected");
+
//Select submenu item
-
if(isubmenuItem >= 0){
+
var submenu = menuItem.children(".sub-menu");
-
  var submenuItem = $($(".sub-menu-item").get(isubmenuItem));
+
var hasSubmenu = (submenu.length > 0);
-
  submenuItem.addClass("menu-selected");
+
if(hasSubmenu){
-
}
+
submenu.data("collapsed", false).show();
-
//Set events
+
var submenuItem = $(submenu.children(".sub-menu-item").get(isubmenuItem));
-
$(".menu-item span").click(function(){
+
submenuItem.addClass("menu-selected");
-
  var submenu = $(this).next();
+
}
-
  var hasSubmenu = (submenu.length > 0);
+
//Set events
-
  var collapsed = true;
+
$(".menu-item span").click(function(){
-
  if(hasSubmenu){
+
var submenu = $(this).next();
-
  collapsed = submenu.data("collapsed");
+
var hasSubmenu = (submenu.length > 0);
-
  }
+
var collapsed = true;
-
  //Select and expand this menu item
+
if(hasSubmenu){
-
  var parentDiv = $(this).parent();
+
collapsed = submenu.data("collapsed");
-
  //Deselect and collapse all other menu items
+
}
-
  $("div.menu-item").not(parentDiv)
+
//Select and expand this menu item
-
  .removeClass("menu-selected")
+
var parentDiv = $(this).parent();
-
  .children(".sub-menu")
+
//Deselect and collapse all other menu items
-
  .data("collapsed", true)
+
$("div.menu-item").not(parentDiv)
-
  .slideUp();
+
.removeClass("menu-selected")
-
  parentDiv.addClass("menu-selected");
+
.children(".sub-menu")
-
  if(hasSubmenu){
+
.data("collapsed", true)
-
  if(collapsed){
+
.slideUp();
-
    submenu.data("collapsed", false).slideDown();
+
parentDiv.addClass("menu-selected");
-
  }else{
+
if(hasSubmenu){
-
    submenu.data("collapsed", true).slideUp();
+
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
+
$("div.sub-menu-item").click(function(){
-
  $(this).addClass("menu-selected");
+
//Deselect other submenu items
-
});
+
$("div.sub-menu-item").removeClass("menu-selected");
 +
//Select this submenu item
 +
$(this).addClass("menu-selected");
 +
});
}
}
function setupSectionNavs(){
function setupSectionNavs(){
-
$(document).ready(function() {
+
$(document).ready(function() {
-
    $("div.section").hide();
+
$("div.section").hide();
-
    $("div.section1").show();
+
$("div.section1").show();
-
    $("#section-nav li").click(function() {
+
$("#section-nav li").click(function() {
-
    $("div.section").hide();
+
$("div.section").hide();
-
    var sectionName = $(this).attr("class");
+
var sectionName = $(this).attr("class");
-
    $("div." + sectionName).show();
+
$("div." + sectionName).show();
-
    });
+
});
-
  });
+
});
}
}
</script>
</script>
</html>
</html>

Revision as of 11:22, 27 September 2013