Learn how to use jQuery at the Blog

Blaine Robison « visit

  • Added 10 months ago
  • 66 Lines of Code shown
  • 2 Links of Interest
http://blainerobison.net
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 Blaine Robison - http://blainerobison.net

$(document).ready(function(){
	$(document).pngFix();
	//jQuery('a[rel*=facebox]').facebox();
	$("a[rel*=westways]").facebox()
	$("a[rel*=autoheim]").facebox()
	$("a[rel*=andrewholder]").facebox()
	$("a[rel*=mrsrobison]").facebox()
	$("a[rel*=boardworks]").facebox()
	$("a[rel*=surffilms]").facebox()
	$("a[rel*=demolition]").facebox()
	$("a[rel*=ridind]").facebox()
	// Newsletter - partial validation
	$("form#sendEmail").submit(function() {
		// Validate
		var emailFilter		= /^[a-zA-Z0-9._%-]+@[a-zA-Z0-9._%-]+\.[a-zA-Z]{2,4}$/;
		var formError		= "";
		$('.error').remove();
		if ($("#name").val() == "") {
			formError = '<p class="error">Please enter your name.</p>';
		}
		if ($("#email").val() == "") {
			formError += '<p class="error">Please enter your email address.</p>';
		}else if (!(emailFilter.test($("#email").val()))) { 
			formError += '<p class="error">Please enter a valid email address.</p>';
		}
		if (formError) {
			$('#signup-response')
				.append(formError)
				.css('display' , 'block');
			return false;
		}else{
			$('#submit').hide();
			$('#processing').show();
			var dataStr = $("#sendEmail").serialize();
			$.ajax({
				type: "POST",
				url: "assets/scripts/cform-send.php",
				data: dataStr,
				success: function(del){
					$('#error').remove();
					$('#processing').remove();
					$('#signup-response')
						.append('<p id="success">Thanks! Your email has been sent.</p>')
						.fadeIn();
				}
			});
			return false;
		}
	});
	$(".btn-slide").click(function(){
		$("#contact").slideToggle("slow");
		$(this).toggleClass("active"); return false;
	});
	$('#extras').click(function(){
		$('html, body').animate({ 
			scrollTop: $($(this).attr("href"))
			.offset().top }, 1500);
	return false;
	});
	$('#top').click(function(){
		$('html, body').animate({ 
			scrollTop: $($(this).attr("href"))
			.offset().top }, 1500);
	return false;
	});
});