Team:TU Delft/header2

From 2010.igem.org

(Difference between revisions)
Line 38: Line 38:
$(function() {
$(function() {
-
// Initialize history plugin.
+
});
-
$.history.init(pageload);
+
-
+
-
// set onlick event for menu buttons
+
-
$("a.menu_button").click(function(){
+
-
//
+
-
var hash = this.href;
+
-
hash = hash.replace(/^.*#/, '');
+
-
// moves to a new page.
+
-
// pageload is called at once.
+
-
$.history.load(hash);
+
-
return false;
+
-
});
+
-
  // setup hovering
+
function pageload(hash) {
-
  var btnCssClassSelected = "menu_button_" + page + "_sel";
+
-
  btn.hover(function() {
+
-
    if (page != activePage)
+
-
      btn.addClass(btnCssClassSelected);
+
-
  }, function() {
+
-
    if (page != activePage)
+
-
      btn.removeClass(btnCssClassSelected);
+
-
  });
+
-
 
+
-
  btn.addClass("button_pointer");
+
-
  if (page == activePage) btn.addClass("menu_button_"+activePage+"_sel");
+
 +
// hash doesn't contain the first # character.
 +
if(hash) {
 +
var url = wgServer + "/Team:TU_Delft/" +hash+ "?action=render";
 +
$.get(url, function(data) {
 +
$("#load").html(data).fadeIn(200);
 +
rewriteLinks($("#load"));
});
});
 +
} else {
 +
// start page
 +
$("#load").empty();
 +
}
 +
}
 +
function rewriteLinks(elem) {
 +
 +
$("a", elem).each(function(){
 +
 +
var isFound = $( this ).attr( 'href' ).toString().search( new RegExp( /Team:TU_Delft/i ) );
 +
 +
if(isFound > 0) {
 +
this.href = this.href.replace("Team:TU_Delft/", wgPageName+ "#");
 +
}
 +
 +
});

Revision as of 13:53, 21 July 2010