Learn how to use jQuery at the Blog

TEDx Bucharest « visit

  • Added 5 months ago
  • 161 Lines of Code shown
  • 1 Links of Interest
http://tedxbucharest.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 TEDx Bucharest - http://tedxbucharest.com

$(document).keydown( function( e ) { 
	if( e.which == 27) {  // escape, close box 
		$('#ted_more').html('more');
		$('#ted_more').removeClass('ted_close')
		$('#details').css('display','none').remove();
		$('.details_wing').css('display','none').remove();
	}
}); 

var pages = 1;
var sel_page = 1;
var page_loading = 0;

function load_effect(){
	$('#videos div').mouseenter(function(){
		if ($(this).hasClass('box3'))
			$(this).children('a').children('strong').css('background','transparent');
		else
			$(this).children('a').children('strong').css('background','#000000');

		$(this).children('a').children('strong').stop().animate({'backgroundColor':'#f70000'},300);
	});
	$('#videos div').mouseleave(function(){
		if ($(this).hasClass('box3')){
			$(this).children('a').children('strong').append('<em class="bg">&nbsp;</em>');
			$(this).children('a').children('strong').css({'background':'transparent'});
			$(this).children('a').children('strong').stop();
			$(this).children('a').children('strong').children('em.bg').animate({'opacity':'0'},300,function(){
				$(this).remove();
			});
		}
		else
			$(this).children('a').children('strong').stop().animate({'backgroundColor':'#000000'},300);

	});
}

function display_talks(){
	var cc = $('#videos').children().size();
	$('#videos a img').css({"display":"none"});
	$('#videos a img').each(function(){
		if ($(this)[0].complete){
			$(this).fadeIn();
		}
		else{
			$(this).load(function(){
				$(this).fadeIn();
			});
		}
	});
	if ($('body').hasClass('large')){
		$('#videos').children().css({'top':'5px','left':'483px'});
		if ($("#video1").length > 0) $('#video1').animate({'top':'5px','left':'643px'},function(){ if (cc==1) page_loading = 0;});
		if ($("#video2").length > 0) $('#video2').animate({'top':'5px','left':'323px'},function(){ if (cc==2) page_loading = 0;});
		if ($("#video3").length > 0) $('#video3').animate({'top':'165px','left':'163px'},function(){ if (cc==3) page_loading = 0;});
		if ($("#video4").length > 0) $('#video4').animate({'top':'5px','left':'963px'},function(){ if (cc==4) page_loading = 0;});
		if ($("#video5").length > 0) $('#video5').animate({'top':'5px','left':'3px'},function(){ if (cc==5) page_loading = 0;});
		if ($("#video6").length > 0) $('#video6').animate({'top':'5px','left':'163px'},function(){ if (cc==6) page_loading = 0;});	
		if ($("#video7").length > 0) $('#video7').animate({'top':'165px','left':'3px'},function(){ if (cc==7) page_loading = 0;});	
		if ($("#video8").length > 0) $('#video8').animate({'top':'165px','left':'963px'},function(){ if (cc==8) page_loading = 0;});	
		if ($("#video9").length > 0) $('#video9').animate({'top':'165px','left':'1123px'},function(){ if (cc==9) page_loading = 0;});
		page_loading = 0;	
	}
	else{
		$('#videos').children().css({'top':'5px','left':'323px'});
		if ($("#video1").length > 0) $('#video1').animate({'top':'5px','left':'483px'},function(){ if (cc==1) page_loading = 0;});
		if ($("#video2").length > 0) $('#video2').animate({'top':'5px','left':'163px'},function(){ if (cc==2) page_loading = 0;});
		if ($("#video3").length > 0) $('#video3').animate({'top':'165px','left':'3px'},function(){ if (cc==3) page_loading = 0;});
		if ($("#video4").length > 0) $('#video4').animate({'top':'5px','left':'3px'},function(){ if (cc==4) page_loading = 0;});
		if ($("#video5").length > 0) $('#video5').animate({'top':'5px','left':'803px'},function(){ if (cc==5) page_loading = 0;});
		if ($("#video6").length > 0) $('#video6').animate({'top':'165px','left':'803px'},function(){ if (cc==6) page_loading = 0;});	
	}
	load_effect();
}

$(document).ready(function(){

	$('#videos').addClass('isjs');
	var ww = $(window).width();
	var is_large = 0;
	if (ww>=1600){
		is_large = 1;
		$('body').addClass('large');
		$('#videos').html('');
		page_loading = 1;
		$('#videos').load('scripts/get_talks.php',{type:is_large},function(){
			display_talks();
		});			
	}
	else{
		display_talks();
	}

	CountBack(gsecs); 	

	$.get('scripts/get_pages.php',{type:is_large},function(data){
		pages = data;
	});


	$('#videos a').live('click',function(){
		if (page_loading==0){
			var id = $(this).attr('id');
			var my_id = id.replace('talk_','');
			$('#content').append('<div id="details"></div>');
			$('#content_left').append('<div class="details_wing">&nbsp;</div>');
			$('#content_right').append('<div class="details_wing">&nbsp;</div>');
			$('#details').load('scripts/get_talk.php',{id:my_id},function(){
				$('#details').css({'display':'block'});
				$('.details_wing').css({'display':'block'});
				$('#ted_logo').css({'z-index':'1500'});
				$('#ted_more').html('close');
				$('#ted_more').addClass('ted_close')
				$('#ted_more').css({'z-index':'1500'});		
			});
		}
		return false;
	});

	$('#ted_logo a').click(function(){
		if ($('#tedx').is(':visible'))
			$('#ted_logo a').removeClass('sel');
		else
			$('#ted_logo a').addClass('sel');
		$('#tedx').toggle();
		
		return false;
	});

	$('a#ted_more').live('click',function(){
		if ($(this).hasClass('ted_close')){
			$('#ted_more').html('more');
			$('#ted_more').removeClass('ted_close')
			$('#details').css('display','none').remove();		
			$('.details_wing').css('display','none').remove();
		}
		else{
			if (page_loading==0){
				page_loading = 1;
				var cc = $('#videos').children().size();
				var c = 0;
				$('#videos').children().each(function(){
					c++;
					if (c==cc){
						$(this).fadeOut(function(){
							var next_page = (sel_page+1<=pages)?sel_page+1:1;
							$('#videos').load('scripts/get_talks.php',{p:next_page,type:is_large},function(){
								display_talks();
								sel_page = next_page;
							});			
						});
					}
					else{
						$(this).fadeOut();
					}
				});
			}
		}
		return false;
	});
});