Learn how to use jQuery at the Blog

DixonBaxi « visit

  • Added 5 months ago
  • 118 Lines of Code shown
  • 3 Links of Interest
http://dixonbaxi.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 DixonBaxi - http://dixonbaxi.com


// group images into slideshow
// turn video links into flash player
function prepareContent()
{
	// group images into slideshow
	$('.content-group:not(prepared)').each(function(i){
									  
		$(this).addClass('prepared');
				
		var imgs = $(this).find('img');
		if( imgs.length>1 ){ // create a slideshow if multi images
			
			var that = $(this),
				label = that.next(),
				slideshow = new Slideshow().init( that ),
				changeSlideshow = function(dir){
					var n = slideshow.change(dir);
					if(n) label.children('span:eq(1)').html(n.attr('title'));
				};
				
			//slideshow.start();
			$('<div class="slideshow_bts"></div>').appendTo(that)
			.append( $('<img src="'+TEMPLATE_DIR+'/images/arrow-left.png"/>').click(function(e){ e.preventDefault(); $(this).blur(); changeSlideshow(-1) }) )
			.append( $('<img src="'+TEMPLATE_DIR+'/images/arrow-right.png"/>').click(function(e){ e.preventDefault(); $(this).blur(); changeSlideshow(1) }) )
			
			
			label.children('span:eq(1)').html(imgs.eq(0).attr('title'));
		}
		
	});
	
	// show all videos
	$('a.videoPlayer').each(function(i)
	{
		$(this).replaceWith('<div id="videoEmbed'+i+'"></div>');
		
		swfobject.embedSWF(
			TEMPLATE_DIR+"/swf/player.swf", 'videoEmbed'+i,
			"552", "310",
			"10", TEMPLATE_DIR+"/swf/expressInstall.swf",
			{file:$(this).attr('href'), keyframe:$(this).attr('keyframe')}, //xml_source:"xml/playlist.xml"
			{bgcolor:"#000000",allowFullScreen :"true"}
		);
		
	});
		
	
}


// Function to load more content into page
// Check out http://visuelle.co.uk (nice site) or Google Reader

function loadMore(callback)
{
	var //nextpage = 2,
		load = true;
	
	$(".page.nav").empty();
	
	$(window).scroll(function(){
		
		// if more pages available
		if(nextpage <= pages)
		{
			if($(window).scrollTop() == $(document).height() - $(window).height()) // at bottom of page
			{
				if(scroll != 1)
				{
					if(load == true) // whether already loading
					{
						load = false;
						
						// show the loading message
						$('.page.nav').html('Loading more...');
						
						// slow loading msg after 10 secs
						var timeOut = setTimeout(function() {
							$('.page.nav').html('Taking longer than usual...');
						}, 10000);
						
						nexturl = BASE_URL + nextpage;
						if(QUERY) nexturl += QUERY;
						
						//console.log('next:',nexturl);
						$.ajax({
							url: nexturl,
							cache: false,
							success: function(html){
								
								clearTimeout(timeOut);
								load = true;
								
								callback(html);
								
								nextpage ++;
								
								//$(window).scroll(); // try again here
							}
						});
					}
				}
			}
		}
		
		else // no more content
		{
			//log('no more');
			$('.page.nav').html('No more posts');
			$(window).unbind('scroll');
		}
		
	});
	
	$(window).scroll(); // start off, in case page lower than win height

}