drifterz28
4/3/2013 - 4:18 PM

Working on a simple page loader

Working on a simple page loader

var currentSite = location.hostname,
    container = '#bodycontent',
    insertIn = '#bodycontent';

if (history.pushState) {
	$('#container').on('click','a',function(e){
		var click_link = $(this).attr('href');
		// internal link check
		if(click_link.indexOf(currentSite) === -1 && click_link.indexOf("http") > 0){
			//return;
		}
		$('body,html').animate({
			scrollTop: 0
		}, 200);
		
		$(container).slideUp(500,function(){
			$('body, a').css('cursor', 'wait');
			$(this).empty();
			if(window.history && window.history.pushState){
				window.history.pushState('Herbalist', $(this).text(), click_link);
			}
			$(container).load(click_link+' '+insertIn,function(){
				$(container).slideDown();
				$('body').css('cursor', 'inherit');
				$('a').css('cursor', 'pointer');
				e.preventDefault(); // prevent default only if this is done.
			});	
		});
	});
}