Learn how to use jQuery at the Blog

Engage Interactive « visit

  • Added 8 months ago
  • 376 Lines of Code shown
  • 5 Links of Interest
http://engageinteractive.co.uk
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 Engage Interactive - http://engageinteractive.co.uk

//AJAX IMAGES

function cancel_anims()
{
	 $('#work_a_images').cycle('pause');
	 $('#work_b_images').cycle('pause');
	 $('#work_c_images').cycle('pause');
	 $('#work_d_images').cycle('pause');
	 $('#work_e_images').cycle('pause');
	 $('#work_f_images').cycle('pause');
	 $('#work_g_images').cycle('pause');
	 $('#work_h_images').cycle('pause');
	 $('#work_i_images').cycle('pause');
}
$(document).ready(function(){

	$('ul.primary').show().css({opacity:0}).animate({opacity:1}, 1000);
	
	$('.next_prev a').click(function(){
		hashPos = $(this).attr('href').indexOf("#");
		theItem = $(this).attr('href').substr(hashPos + 1);
		workImages(theItem)
	});
	$('.work_nav a').click(function(){
		hashPos = $(this).attr('href').indexOf("#");
		theItem = $(this).attr('href').substr(hashPos + 1);
		workImages(theItem)
	});
	$('.selected a').click(function(){
		hashPos = $(this).attr('href').indexOf("#");
		theItem = $(this).attr('href').substr(hashPos + 1);
		workImages(theItem)
	});
	$('.work a').click(function(){
		hashPos = $(this).attr('href').indexOf("#");
		theItem = $(this).attr('href').substr(hashPos + 1);
		workImages(theItem)
	});
	
	function workImages(whichWork){
		$('a[href = #work]').addClass('scrolling');
		if($('#'+whichWork+' ul.sequence').children('li').attr('class') == 'loading'){
			$('#'+whichWork+'_images').load('includes/'+whichWork+'_images.php',{},function(){
				cancel_anims();
				$('#'+whichWork+'_images').cycle('resume');
				$('#'+whichWork+'_images').cycle({
				fx:    'fade', 
				speed:  2000,
				timeout:  900
				});
			});
		}
	}
	
});

// SLIDING FUNCTIONS

jQuery(function( $ ){
				
	//Easing equation for panel
	jQuery.easing.easeOutQuart = function (x, t, b, c, d) {
		return -c * ((t=t/d-1)*t*t*t - 1) + b;
	};
	
	/**
	 * Most jQuery.localScroll's settings, actually belong to jQuery.ScrollTo, check it's demo for an example of each option.
	 * @see http://www.freewebs.com/flesler/jQuery.ScrollTo/
	 * You can use EVERY single setting of jQuery.ScrollTo, in the settings hash you send to jQuery.LocalScroll.
	 */
	
	var target = $('#content').get(0);//the scrolled div
	
	/**
	 * restart the scroll position to ( 0, 0 ) (Firefox doesn't reset it)
	 * could use $(target).scrollTo( 0, {axis:'xy'));
	 * but this needs to be quick(synchronous), to reset before $.localScroll.hash() begins
	 */
	target.scrollLeft = target.scrollTop = 0;
	
	//scroll initially if there's a hash (#something) in the url 
	$.localScroll.hash({
		target: target, //could be a selector or a jQuery object too.
		axis:'xy',//the default is 'y'
		queue:true,
		duration:1500
	});
	
	var $last = $([]);//save the last link
	
	/**
	 * NOTE: In the former version of the demo, I called $('#navigation').localScroll()
	 * Now I want to also affect the >> and << links, so I'll use $.localScroll() instead
	 */
	$.localScroll({
		target: target, //could be a selector or a jQuery object too.
		axis:'xy',//the default is 'y'
		queue:true,
		duration:1300,
		easing:'easeOutQuart',
		hash:false,	
		onBefore:function( e, anchor, $target ){//'this' is the clicked link
			$last.removeClass('scrolling');
			$last = $(this).addClass('scrolling');
		}
	});
});
		
// FORM VALIDATION
       
$(document).ready(function() { 
	$('#validation').hide();
	$('#confirmation').hide();
    var options = { 
        target:        '#confirmation',   // target element(s) to be updated with server response 
        beforeSubmit:  validate,  // pre-submit callback 
        success:       function() { 
        	$('#validation').fadeOut('slow');
        	$('#commentForm').fadeOut('slow');
            $('#confirmation').fadeIn('slow'); 
        }  
    }; 
    $('#commentForm').ajaxForm(options); 
}); 
 
function validate(formData, jqForm, options) { 
    
 	$("#validation").html('');
    var form = jqForm[0]; 
    err="";
    if (!form.name.value)
    {
    	err+="<li>Please tell us your name, or we'll just have to call you Bob!</li>";
    }
    if (!form.email.value)
    { 
    	err+="<li>We'll be needing a valid e-mail address or phone number please.</li>";
    }
    if (!form.comment.value) 
    { 
        err+="<li>You forgot to let us know what you wanted! Please complete the big white box.</li>";
    } 
    if (err>'')
    {
    	$("#validation").append("<ul>" + err + "</ul>");
        $("#validation").slideDown();
        return false; 
    }
     
}

$(document).ready(function(){
	
	$("#style_switch").hover(
		function(){
			$(this).children("ul").show();
		},
		function(){
			$(this).children("ul").hide();
		}
	);

	$('.styleswitch').click(function()
	{
		setActiveStyleSheet(this.getAttribute("rel"));
		return false;
	});
	
	setActiveStyleSheet('global');

//Everything from here down is new, can be removed

	$('.primary li a').click(function()
	{
		$(this).addClass('scrolling').siblings('ul').children('li').children('a').removeClass('scrolling');
		$(this).parents('li').children('ul').slideDown();
		$(this).parents('li').siblings('li').children('ul').slideUp();
		$(this).parents('li').siblings('li').children('a').removeClass('scrolling');
	});
	
	$('ul.selected li a').click(function()
	{
		$('.primary li.home a').removeClass('scrolling');
		$('.primary li.work ul').slideDown();
		$('.primary li.work').siblings('li').children('ul').slideUp();
	});
	
	$('.primary li.work a').click(function()
	{
		$(this).next('ul').children('li').children('a').removeClass('scrolling');
	});
	
	$("a[href=#work_a]").click(function(){
		$('.primary li.work ul li a.link_work_a').addClass('scrolling').parents('li').siblings('li').children('a').removeClass('scrolling');
	});
	$("a[href=#work_b]").click(function(){
		$('.primary li.work ul li a.link_work_b').addClass('scrolling').parents('li').siblings('li').children('a').removeClass('scrolling');
	});
	$("a[href=#work_c]").click(function(){
		$('.primary li.work ul li a.link_work_c').addClass('scrolling').parents('li').siblings('li').children('a').removeClass('scrolling');
	});
	$("a[href=#work_d]").click(function(){
		$('.primary li.work ul li a.link_work_d').addClass('scrolling').parents('li').siblings('li').children('a').removeClass('scrolling');
	});
	$("a[href=#work_e]").click(function(){
		$('.primary li.work ul li a.link_work_e').addClass('scrolling').parents('li').siblings('li').children('a').removeClass('scrolling');
	});
	$("a[href=#work_f]").click(function(){
		$('.primary li.work ul li a.link_work_f').addClass('scrolling').parents('li').siblings('li').children('a').removeClass('scrolling');
	});
	$("a[href=#work_g]").click(function(){
		$('.primary li.work ul li a.link_work_g').addClass('scrolling').parents('li').siblings('li').children('a').removeClass('scrolling');
	});
	$("a[href=#work_h]").click(function(){
		$('.primary li.work ul li a.link_work_h').addClass('scrolling').parents('li').siblings('li').children('a').removeClass('scrolling');
	});
	$("a[href=#work_i]").click(function(){
		$('.primary li.work ul li a.link_work_i').addClass('scrolling').parents('li').siblings('li').children('a').removeClass('scrolling');
	});
	
	$("a[href=#about_alex]").click(function(){
		$('.primary li.about ul li a[href=#about_alex]').addClass('scrolling').parents('li').siblings('li').children('a').removeClass('scrolling');
	});
	$("a[href=#about_dave]").click(function(){
		$('.primary li.about ul li a[href=#about_dave]').addClass('scrolling').parents('li').siblings('li').children('a').removeClass('scrolling');
	});
	$("a[href=#about_will]").click(function(){
		$('.primary li.about ul li a[href=#about_will]').addClass('scrolling').parents('li').siblings('li').children('a').removeClass('scrolling');
	});
	
	$('.primary li.home a').addClass('scrolling');
	
	$('h1 a').click(function()
	{
		$('.primary li ul').slideUp();
		$('.primary li.home a').addClass('scrolling').parent('li').siblings('li').children('a').removeClass('scrolling');
	});
	
	$('div#topbar a.button').click(function()
	{
		$('div.clients').slideToggle();
		$(this).toggleClass('panel-down');
	});
	
	$('div.worksection div div.three_col div').hide();
	
	$('div.worksection div div.one_col p.testimonial a').click(function(){
		theTestimonial = $(this).parent('p').parent('div').siblings('div.three_col').children('div');
		if($(theTestimonial).hasClass('active') != true){
			$(theTestimonial).fadeIn('fast');
			$(theTestimonial).addClass('active');
		}else{
			$(theTestimonial).fadeOut('fast');
			$(theTestimonial).removeClass('active');
		}
		if($(this).text() == 'View client testimonial'){
			$(this).text('Hide client testimonial');
		}else{
			$(this).text('View client testimonial');
		}
		return false;
	});
	
	$('.twitter').hover(
		function () {
			$("#latest_tweet").show();
		}, 
		function () {
			$("#latest_tweet").hide();
		}
    );
	
	$("#latest_tweet").hover(
		function () {
			$("#latest_tweet").show();
		}, 
		function () {
			$("#latest_tweet").hide();
		}
    );

	$("#latest_tweet").tweet({
		username: "engagetweet",
		join_text: "auto",
		//avatar_size: 32,
		count: 3,
		auto_join_text_default: "we said:",
		auto_join_text_ed: "we said:",
		auto_join_text_ing: "we were:",
		auto_join_text_reply: "we replied to:",
		auto_join_text_url: "we were checking out:",
		loading_text: "loading tweets..."
	});
	
	theContent = 'undefined';
	
	$('ul.selected li').hover(
		function () {
			theContent = $(this).children('a').attr('title');
			$(this).children('a').removeAttr('title');
			$(this).children('div').remove();
			$(this).prepend("<div><span>"+theContent+"</span><img src='images/template/tooltip_arrow.gif' alt='' /><div>");
			var leftMargin =  '-' + Math.round($(this).children('div').width() / 2) + 'px';
			$(this).children('div').css({marginLeft:leftMargin, opacity:0});
			$(this).children('div').animate({top:'-32px', opacity:1}, 400, 'easeOutQuart');
		}, 
		function () {
			$(this).children('a').attr('title', theContent);
			$(this).children('div').remove();
		}
	);
	
	$('a.internal').click(function(){
		theLink = $(this).attr('href');
		$('#navigation a[href='+theLink+']').addClass('scrolling').siblings('ul').slideDown();
		$('#navigation a[href='+theLink+']').parent('li').siblings('li').children('a').removeClass('scrolling').siblings('ul').slideUp();
	});
	
	$('div#rss_link').hover(
		function () {
			theContent = $(this).children('a').attr('title');
			$(this).children('a').removeAttr('title');
			$(this).children('div').remove();
			$(this).prepend("<div><span>"+theContent+"</span><img src='images/template/tooltip_arrow.gif' alt='' /><div>");
			var leftMargin =  '-' + Math.round($(this).children('div').width() / 2) + 'px';
			$(this).children('div').css({marginLeft:leftMargin, opacity:0});
			$(this).children('div').animate({top:'-32px', opacity:1}, 400, 'easeOutQuart');
		}, 
		function () {
			$(this).children('a').attr('title', theContent);
			$(this).children('div').remove();
		}
	);
	
	//$('div#flash_overlay div').flash({
	//		src: 'flash/flash_advert.swf',
	//		width: 970,
	//		height: 680,
	//		wmode: 'transparent'
	//	},{
	//		update: false
	//	}
	//);
	
//don't delete that thing below though.

});

function openFlash(){
	$('div#flash_overlay').css({width:970, height:680, top:66});
}
function closeFlash(){
	$('div#flash_overlay').css({width:200, height:247, top:499});
}


$(document).ready( function() {
   
    $('a[rel="external"]').click( function() {
        window.open( $(this).attr('href') );
        return false;
    });
   
});

jQuery.extend( jQuery.easing,
{
	
	easeInOutExpo: function (x, t, b, c, d) {
		if (t==0) return b;
		if (t==d) return b+c;
		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
	}

});