Skip to content

Instantly share code, notes, and snippets.

@clarkf
Created January 31, 2011 11:45
Show Gist options
  • Save clarkf/803936 to your computer and use it in GitHub Desktop.
Save clarkf/803936 to your computer and use it in GitHub Desktop.
// script.js
$(document).ready(function(){
var $def = $('.projects').find('dl dd');
$def.hide();
var defBox = $('#def-box');
$('.projects').hover(function(){
//defBox.fadeToggle(800);
defBox.html('<p> Hover over my recent work to see a description <p>');
});
$('dt').hover(function(){
// defBox.hide();
var $data = $(this).next('dd').html();
defBox.html($data);
},function(){
defBox.html();
});
// Check for hash value in URL
var hash = window.location.hash.substr(1);
//Check to ensure that a link with href == hash is on the page
if ($('a[href="' + hash + '"]').length) {
//Load the page.
var toLoad = hash + '.php #main-content';
$('#main-content').load(toLoad);
}
$('nav ul li a').click(function(){
var goingTo = $(this).attr('href');
goingTo = goingTo.substring(goingTo.lastIndexOf('/') + 1);
if (window.location.hash.substring(1) === goingTo) return false;
var toLoad = $(this).attr('href')+' #main-content';
$('#main-content').hide('fast',loadContent);
$('#load').remove();
$('#wrapper').append('<span id="load">LOADING...</span>');
$('#load').fadeIn('normal');
window.location.hash = goingTo;
function loadContent() {
$('#main-content').load(toLoad,'',showNewContent)
}
function showNewContent() {
$('#main-content').show('normal',hideLoader);
}
function hideLoader() {
$('#load').fadeOut('normal');
}
return false;
});
}); // end jQuery
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment