Team:TU Delft/menu test

From 2010.igem.org

(Difference between revisions)
Line 69: Line 69:
<script type="text/javascript">
<script type="text/javascript">
-
function registerButton(btnName) {
+
var pageCache = {};
-
   var btn= $(".menu_button_" + btnName);
+
 
-
   var page = "https://2010.igem.org/Team:TU_Delft/pages/" + btnName + "?action=render";
+
function isUndefined(x) { var u; return x === u; }
-
   btn.click(function() {  
+
 
-
    $("#main_td").load(page);
+
function setupPage(page) {
 +
   var btn= $(".menu_button_" + page);
 +
   var page = "https://2010.igem.org/Team:TU_Delft/pages/" + page + "?action=render";
 +
   btn.click(function() {
 +
    var main_td = $(#main_td");
 +
    main_td.fadeOut(200);
 +
    $.get(page, function(data) {
 +
        main_td.html(data);
 +
        main_td.fadeIn(200);
 +
    });
   });
   });
Line 88: Line 97:
// this runs when page is loaded
// this runs when page is loaded
$(function() {
$(function() {
-
   var buttonList = [ "home", "blog", "competition", "background", "project", "education", "sponsors", "press" ];
+
   var pages = [ "home", "blog", "competition", "background", "project", "education", "sponsors", "press" ];
-
   for(var i in buttonList)   
+
   for(var i in pages{
-
     registerButton(buttonList[i]);
+
     setupPage(pages[i]);
-
});
+
   }
-
 
+
-
/*
+
-
$("#navlist > *").each (function() {
+
-
  // load URL from link element
+
-
  var url = $("*",this).attr("href");
+
-
  var button = $(this);
+
-
 
+
-
  button.click(function() {
+
-
    $("#main_td").load(url + "?action=render");
+
-
//alert(url);
+
-
//    window.location = url;
+
-
   });
+
-
 
+
-
  // setup hovering
+
-
  button.hover(function() {
+
-
    $(this).addClass("button_hover");
+
-
  }, function() {
+
-
    $(this).removeClass("button_hover");
+
-
  });
+
-
 
+
-
  $(this).addClass("button_pointer");
+
});
});
-
});*/
 
</script>
</script>
</html>
</html>

Revision as of 23:01, 4 June 2010