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));
-
//Select the menu item
+
//Select the menu item
-
menuItem.addClass("menu-selected");
+
menuItem.addClass("menu-selected");
-
//Select submenu item
+
//Select submenu item
-
var submenu = menuItem.children(".sub-menu");
+
var submenu = menuItem.children(".sub-menu");
-
var hasSubmenu = (submenu.length > 0);
+
var hasSubmenu = (submenu.length > 0);
-
if(hasSubmenu){
+
if(hasSubmenu){
-
submenu.data("collapsed", false).show();
+
  submenu.data("collapsed", false).show();
-
var submenuItem = $(submenu.children(".sub-menu-item").get(isubmenuItem));
+
  var submenuItem = $(submenu.children(".sub-menu-item").get(isubmenuItem));
-
submenuItem.addClass("menu-selected");
+
  submenuItem.addClass("menu-selected");
-
}
+
}
-
//Set events
+
//Set events
-
$(".menu-item span").click(function(){
+
$(".menu-item span").click(function(){
-
var submenu = $(this).next();
+
  var submenu = $(this).next();
-
var hasSubmenu = (submenu.length > 0);
+
  var hasSubmenu = (submenu.length > 0);
-
var collapsed = true;
+
  var collapsed = true;
-
if(hasSubmenu){
+
  if(hasSubmenu){
-
collapsed = submenu.data("collapsed");
+
  collapsed = submenu.data("collapsed");
-
}
+
  }
-
//Select and expand this menu item
+
  //Select and expand this menu item
-
var parentDiv = $(this).parent();
+
  var parentDiv = $(this).parent();
-
//Deselect and collapse all other menu items
+
  //Deselect and collapse all other menu items
-
$("div.menu-item").not(parentDiv)
+
  $("div.menu-item").not(parentDiv)
-
.removeClass("menu-selected")
+
  .removeClass("menu-selected")
-
.children(".sub-menu")
+
  .children(".sub-menu")
-
.data("collapsed", true)
+
  .data("collapsed", true)
-
.slideUp();
+
  .slideUp();
-
parentDiv.addClass("menu-selected");
+
  parentDiv.addClass("menu-selected");
-
if(hasSubmenu){
+
  if(hasSubmenu){
-
if(collapsed){
+
  if(collapsed){
-
submenu.data("collapsed", false).slideDown();
+
    submenu.data("collapsed", false).slideDown();
-
}else{
+
  }else{
-
submenu.data("collapsed", true).slideUp();
+
    submenu.data("collapsed", true).slideUp();
-
}
+
  }
-
}
+
  }
-
});
+
});
-
$("div.sub-menu-item").click(function(){
+
$("div.sub-menu-item").click(function(){
-
//Deselect other submenu items
+
  //Deselect other submenu items
-
$("div.sub-menu-item").removeClass("menu-selected");
+
  $("div.sub-menu-item").removeClass("menu-selected");
-
//Select this submenu item
+
  //Select this submenu item
-
$(this).addClass("menu-selected");
+
  $(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:38, 27 September 2013