Skip to content

Instantly share code, notes, and snippets.

@bernsno
Created October 21, 2009 22:52
Show Gist options
  • Select an option

  • Save bernsno/215553 to your computer and use it in GitHub Desktop.

Select an option

Save bernsno/215553 to your computer and use it in GitHub Desktop.
function showCategory(){ $(this).find("span").animate({top:"0px"}, 200); }
function hideCateogry() { $(this).find("span").animate({top:"30px"}, 200); }
function loadContent(content) { moveAboveTop(); $('#content').load(content,'',showNewContent()); }
function showNewContent() { $('#content').show('normal'); }
function setWindowLocationHash(url) { window.location.hash = url.substr(0,url.length-5); }
function moveAboveTop() {
if ( window.location.hash.length > 0 ){
$("#page-wrap").animate({top:"-180px"}, 200);
}
else {
$("#page-wrap").animate({top:"0px"}, 200);
}
}
$(document).ready(function(){
var hash = window.location.hash.substr(1);
$('#site-nav a').each(function(){
var href = $(this).attr('href');
if( hash == href.substr(0,href.length-5) ){
var toLoad = hash+'.html #content';
$('#content').load(toLoad);
moveAboveTop();
}
});
$("#site-nav ul.image-nav li a").hover(showCategory, hideCateogry);
$("#site-nav a").live("click", function(){
var newUrl = $(this).attr('href');
var newContent = newUrl + ' #content';
setWindowLocationHash(newUrl);
$('#content').hide('fast',loadContent(newContent));
return false;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment