Learn how to use jQuery at the Blog

AspiredMind « visit

  • Added 10 months ago
  • 142 Lines of Code shown
  • 3 Links of Interest
http://aspiredmind.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 AspiredMind - http://aspiredmind.com

var isIE    = !!(navigator.userAgent.toLowerCase().indexOf('msie') >= 0 && document.all);
var isOpera = !!(window.opera && document.getElementById);
var isMoz   = (!isIE && !isOpera);
var ini_top;
var zIndex = 50;
var $j = jQuery.noConflict();

function showme(id) {
    id = '#' + id;

    if ($j(id).css('position') != 'absolute') {
        $j(id).css('position', 'absolute');
        $j(id).css('left', 0);
        $j(id).css('top', $j('#fakeBody').get(0).offsetHeight + 2 + 'px');
        ini_top = $j('#fakeBody').get(0).offsetHeight + 2;
    }

    if (parseInt($j(id).css('height')) > 1){
        new_height = 1;
        new_top = ini_top;
    }else{
        $j(id).css('z-index', ++zIndex);
        new_height = $j(id + ' > .content').get(0).offsetHeight;
        if (!isMoz) new_height += 35;
        new_top = parseInt($j(id).css('top')) - new_height;
    }

    $j(id).animate(
        {height: new_height + 'px', top: new_top + 'px'},
        1000
    );

}

function down(id){
    id = '#' + id;
    $j(id).animate
    (
        {height: '0px', top: ini_top + 'px'},
        1000
    );
}
$j(document).ready(function () {
    $j('.error').hide();
	$j('.input-txt').css({backgroundColor:"#000"});
	$j('.input-txt').focus(function(){
		$j(this).css({backgroundColor:"#ffff00", color:"#000"});
	});
	$j('.input-txt').blur(function(){
		$j(this).css({backgroundColor:"#000", color:"#ffff00"});
		$j("label#name_error").fadeOut("slow");
		$j("label#email_error").fadeOut("slow");
		$j("label#details_error").fadeOut("slow");
	});

	$j("input#submit_button").click(function() {
	    $j('.error').hide();
		var name = $j("input#name").val();
		if (name == "") {
			//$j("label#name_error").show();
			$j("label#name_error").fadeIn("slow");
			$j("input#name").focus();
			return false;
		}
		var email = $j("input#email").val();
		if (email == "") {
			$j("label#email_error").show();
			$j("input#email").focus();
			return false;
		} else {
			if( !IsEmail(email) ) {
				$j("label#email_error").show();
				$j("input#email").focus();
				return false;
			}
		}
		
		var details = $j("textarea#details").val();
		if (details == "") {
			$j("label#details_error").show();
			$j("textarea#details").focus();
			return false;
		}
		var copy = $j('#copy').attr('checked')?1:0;
		$j('#submit_button').attr("disabled", "true");
		var dataString = 'name='+ name + '&email=' + email + '&details=' + details + '&copy=' + copy;

		$j.ajax({
			type: "POST",
			url: "bin/process.php",
			data: dataString,
			success: function() {
				$j('#contact_form').html("<div id='message'></div>");
				$j('#message').html("<h2>thank you!</h2>")
				.append("<p>your message has been forwarded to <strong>sayhello[at]aspiredmind.com</strong></p><p>we will be in touch soon.</p>")
				.hide()
				.fadeIn(1500, function() {
					$j('#message').append("<img id='checkmark' src='images/button_ok.png' />");
				});
			}
		});
		
		return false;
	});

});

function IsEmail(email) {
	var regex = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (regex.test(email)) return true; else return false;
}  



jQuery.easing.easeOutQuart = function (x, t, b, c, d) {
	return -c * ((t=t/d-1)*t*t*t - 1) + b;
};

jQuery(function( $ ){
	$('#webworks_gallery').serialScroll({
		target:'#sections',
		items:'li', // Selector to the items ( relative to the matched elements, '#sections' in this case )
		prev:'div.prev',// Selector to the 'prev' button (absolute!, meaning it's relative to the document)
		next:'div.next',// Selector to the 'next' button (absolute too)
		axis:'xy',// The default is 'y' scroll on both ways
		navigation:'#navigation li a',
		duration:1000,// Length of the animation (if you scroll 2 axes and use queue, then each axis take half this time)
		force:true, // Force a scroll to the element specified by 'start' (some browsers don't reset on refreshes)
		cycle:true, //don't pull back once you reach the end
		easing:'easeOutQuart', //use this easing equation for a funny effect
		
		onBefore:function( e, elem, $pane, $items, pos ){
			e.preventDefault();
			if( this.blur )
				this.blur();
		},
		onAfter:function( elem ){
			//'this' is the element being scrolled ($pane) not jqueryfied
		}
	});

});