Learn how to use jQuery at the Blog

Uber Stealth « visit

  • Added 7 months ago
  • 98 Lines of Code shown
  • 2 Links of Interest
http://uberstealth.com
This is my Source Code and I don't want to show it here
View Source Code only (as overlay)
// That code snippet belongs to Uber Stealth - http://uberstealth.com

$(document).ready(function(){
	
	$('#content').wrap('<div id="content-wrapper"></div>');
	
	$('#main-image-container').wrap('<div id="image-wrapper"></div>');
	
	function pageload(hash) {
		// hash doesn't contain the first # character.
		if(hash) {
			// restore ajax loaded state
			$("#content-wrapper").load(hash + " #content", '', function(){
			
				$('#content-wrapper').show('normal');

				$("#image-wrapper").load(hash + " #main-image-container", '', function(){

					$('#image-wrapper').fadeIn();
					
					if(hash == 'installations'){

						//Activate FancyBox

						$("#gallery-items a").fancybox({
						});	

					}

				});
				
				$('#load').fadeOut('normal');
			});			
		}
	}
	
	// Initialize history plugin.
	// The callback is called at once by present location.hash. 
	$.historyInit(pageload);
	
	// set onlick event for buttons
	$("#navigation a").click(function(){
		
		$('#main-image-container').cycle('pause');
		
		var hash = this.href;
		hash = hash.replace(/^.*#/, '');
		// moves to a new page. 
		// pageload is called at once.
		$('#content-wrapper').hide('fast',function(){$.historyLoad(hash)});
		
		$('#image-wrapper').fadeOut();
		
		$('#load').remove();
		$('#header').append('<span id="load">LOADING...</span>');
		$('#load').fadeIn('normal');
		
		return false;
	});
	
	
	/* Slide show stuff in here */
	var stack = [];
	
	for (var i = 0; i < slideshowimages.length; i++) { 
	    var img = new Image(); 
	    img.src = slideshowimages[i];
		img.setAttribute("height",'100%');
	    $(img).bind('load', function() { 
	        stack.push(this); 
	    }); 
	}  

	// start slideshow
	$('#main-image-container').cycle({
		fx: 		'fade', 
	    speed:    	'slow',
        before:     onBefore
	});
   	// add images to slideshow 
   	function onBefore(curr, next, opts) { 
    	if (opts.addSlide) // <-- important! 
        	while(stack.length) 
   				opts.addSlide(stack.pop());  
	};
	
});

$(function(){
	$('#navigation a')
		.css( {backgroundPosition: "0px -99px"} )
		.mouseover(function(){
			$(this).stop().animate({backgroundPosition:"(0px 0px)"}, {duration:450});
		})
		.mouseout(function(){
			$(this).stop().animate({backgroundPosition:"(0px -99px)"}, {duration:200, complete:function(){
				$(this).css({backgroundPosition: "0px -99px"})
			}})
		})
});