Learn how to use jQuery at the Blog

Paramore Redd « visit

  • Added 11 months ago
  • 211 Lines of Code shown
  • 4 Links of Interest
http://paramoreredd.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 Paramore Redd - http://paramoreredd.com

/*
*p|r jQuery Goodies
*Add all common document.ready calls here
*/

var sortClass = '';

$(document).ready(function(){
	// Homepage Carousel
	$("#project-slider-wrap").jCarouselLite({
		btnNext: "#next",
		btnPrev: "#back",
		circular: true,
		easing: "easeInOutQuad",
		speed: 900
	});
		
	$('h2#enews a').click(function(){
		$.scrollTo('#footer', 800, {easing:'easeInOutQuad'});
		return false;
	});

	// Site Wide Tooltips
	$('#related-work a, #peeps-list a, #blog-pagination a, #view-more a').tooltip({
		track: true, 
		delay: 0, 
		fade: 400,
		showURL: false,
		top: 25,
   		left: 0
	});
	
	// IE fixes
	if (jQuery.browser.msie){
		//Remove ALT in IE
		$('#peeps-list a img').removeAttr("alt");
		
		// IE 6 specific fixes
		if(jQuery.browser.version < 7){
			// reset the background for the first item in home page LIs
			$('#project-slider li').css('background-image',$('#project-slider li').eq(1).css('background-image'));
			
			// hide the buttons because the scroll doesn't work right
			$('#next, #back').hide();
			/*
			// reset the arrows because they stay orange when clicked; this fixes that
			$('#next, #back').click(function(){
				$(this).blur();
			});
			/**/
		}
	}

	// US List Page - Hijack links and send to ajax page (checking for js basically)
	var peepURL = "http://paramoreredd.com/us/peep-a/";
	$('#peeps-list a').each(function() {
		$(this).attr("href",peepURL + '#' + this.id);
	});
	
	//Set width and height w/jquery
	$('#work-list-slider, #work-list-slider li.page, #work-list-wrapper').width(960).height(475);

	// reset for FireFox gallery resize (cycle?)
	$('#case-study-gallery img').width(498).height(315).css('display','block');
	$('#project-image img').width(620).height(393).css('display','block');
	
	//Work Project Page Images Cycle	
	$('#project-image').cycle({
		fx: 'scrollHorz',
    	timeout: 0,
	    speed:   500,
		easing: 'easeInOutQuad',
		pager: '#project-cycle-links'
	});
	
	$('#case-study-gallery').cycle({
		fx: 'scrollHorz',
		timeout: 0,
		speed: 500,
		easing: 'easeInOutQuad',
		pager: '#project-cycle-links'
	});
	
	
	// Define the active class, and start rebuilding the HTML for the work items
	$('.sort-list a, #view-case-studies a, #view-all-work a').click(function() {
		if ($(this).hasClass("act") == false){
			// get the selected hash / class
			pageHash = this.hash;
			sortClass = pageHash.replace('#','');

			// set the active tab
			$('ul.column a').removeClass('act');
			$(this).addClass('act');

			if(this.id == 'case-study' || this.id == 'btn-view-all') {
				$('div.sort-list.act').slideUp('fast');
				$('#work-tabs a').removeClass('act');
				if(this.id == 'case-study') $('#view-all-work a').removeClass('act');
				if(this.id == 'btn-view-all') $('#view-case-studies a').removeClass('act');
			} else {
				$('#view-more a').removeClass('act');
			}
			// fade out and callback the function to rebuild the HTML
			$('#work-list-nav').fadeOut('fast');
			$('#work-list-slider').fadeOut('fast',ajaxLoadWork(this.href));
		
		}
		return false;
	});
	
	// Work Ajax...
	var allWorkURL = "http://paramoreredd.com/work/project-ajax/";
	var workURL = allWorkURL + "c/";
	$('.sort-list a, #view-case-studies a, #view-all-work a').each(function() {
		var url = (this.id == 'btn-view-all') ? allWorkURL : workURL + this.id;
		$(this).attr("href",url);
	});
	 
	
	function ajaxLoadWork(url) {
		$('#work-list-wrapper').load(url,fadeInNewWorkList);
	}
	
	function fadeInNewWorkList() {
		$('#work-list-slider').fadeIn('fast');
	}
	
	//Work List Page Tabs
	$('div.sort-list').hide();
	$('div.sort-list:first').addClass('act');

	$("ul#work-tabs a").click(function(){
		var divID = this.hash;
		if ($(this).hasClass("act") == false){
			$('ul#work-tabs a, #view-case-studies a, #view-all-work a').removeClass('act');
			$(this).addClass('act');
			$('div.sort-list.act').slideUp('fast', function() {
				$(this).removeClass('act');
				$(divID).slideDown('slow').addClass('act');
			});
		}
		return false; 
	});
	
	//Blog Comments Live Preivew
	$('#comment-form').one('focus',function() {
		$('#comment').parent().after('<div id="live-preview"></div>');
	});
	var comment = ''; 
	var name = ''; 
	var after = ''; 
	$('#comment').keyup(function() {
		comment = $(this).val();
		name = $('#comment-name').val();
		if(name != '')
		{
			after = '<h3>' + name + ' <span>said</span></h3>';
		}
		$('#tester').html( after );
		comment = comment.replace(/\n/g, "<br />").replace(/\n\n+/g, '<br /><br />').replace(/(<\/?)script/g,"$1noscript");
		finalVar = '<p>Comment Preview</p><div id="preview">' + after + comment + '</div>';
		$('#live-preview').html( finalVar );
	});

	// panels expand/contract
	$("#panel, .panel").toggle(function(){
		if( this.id == "panel" ){ var height_is = "200px"; }
		else{ var height_is = "160px"; }
		$(this).animate({ height: height_is	}, 1000, "easeInQuint");
		$(this).find('h2 a').addClass('act');
		$(this).css('cursor','pointer');
	},function(){
		if( this.id == "panel" ){ var height_is = "36px"; }
		else{ var height_is = "26px"; }
		$(this).animate({ height: height_is }, 1000, "easeInQuint");
		$(this).find('h2 a').removeClass('act');
	});
	
	$("a#next, a#back").attr({ onClick: "return false;" });
	
	//Valid way to open links in new window
	$("a[@rel='external']").click(function(){window.open(this.href); return false;});
	
	
	$('#footer-contact').submit(function(){
		// validation?
		$('#footer-contact').fadeOut('fast', function(){
			$('#footer-contact-sending').fadeIn('fast',function(){
				var act  = $('#footer-contact').attr('action');
				var vars = $('#footer-contact').serialize();
				$.post(
					act,
					vars,
					function(){
						$('#footer-contact-sending').fadeOut('fast',function(){
							$('#footer-contact-thanks').fadeIn('fast');
						});
					}
				);
			});
		});
		return false;
	});
	
	//Show hide input copy
	$("#footer-contact input:text").hint();
	
	$("#awards-btn").click(function() { $("#foot-awards").slideToggle(400); return false; });

});//End document.ready