Learn how to use jQuery at the Blog

Marvin Christian Lee « visit

  • Added 5 months ago
  • 336 Lines of Code shown
  • 4 Links of Interest
http://marvinchristianlee.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 Marvin Christian Lee - http://marvinchristianlee.com

/////////////////////////////////////////////////////////////////////////////////////////
// LAVALAMP

(function(a){a.fn.lavaLamp=function(b){b=a.extend({fx:"swing",speed:500,click:function(){return true},startItem:"no",autoReturn:true,returnDelay:0,setOnClick:true,homeTop:0,homeLeft:0,homeWidth:0,homeHeight:0,returnHome:false},b||{});return this.each(function(){var h=location.pathname+location.search+location.hash;var e=new Object;var d;var i;var f;var g;if(b.homeTop||b.homeLeft){f=a('<li class="homeLava selectedLava"></li>').css({left:b.homeLeft,top:b.homeTop,width:b.homeWidth,height:b.homeHeight,position:"absolute"});a(this).prepend(f)}var j=a("li",this);if(b.startItem=="no"){e=a('li a[href$="'+h+'"]',this).parent("li")}if(e.length==0&&b.startItem=="no"&&location.hash){e=a('li a[href$="'+location.hash+'"]',this).parent("li")}if(e.length==0||b.startItem!="no"){if(b.startItem=="no"){b.startItem=0}e=a(j[b.startItem])}g=a("li.selectedLava",this)[0]||a(e).addClass("selectedLava")[0];j.mouseover(function(){if(a(this).hasClass("homeLava")){g=a(this)[0]}c(this)});i=a('<li class="backLava"><div class="leftLava"></div><div class="bottomLava"></div><div class="cornerLava"></div></li>').appendTo(this);a(this).mouseout(function(){if(b.autoReturn){if(b.returnHome&&f){c(f[0])}else{if(b.returnDelay){if(d){clearTimeout(d)}d=setTimeout(c,b.returnDelay+b.speed)}else{c()}}}});j.click(function(k){if(b.setOnClick){a(g).removeClass("selectedLava");a(this).addClass("selectedLava");g=this}return b.click.apply(this,[k,this])});if(b.homeTop||b.homeLeft){i.css({left:b.homeLeft,top:b.homeTop,width:b.homeWidth,height:b.homeHeight})}else{i.css({left:g.offsetLeft,top:g.offsetTop,width:g.offsetWidth,height:g.offsetHeight})}function c(k){if(!k){k=g}var m=0,l=0;if(!a.browser.msie){m=(i.outerWidth()-i.innerWidth())/2;l=(i.outerHeight()-i.innerHeight())/2}i.stop().animate({left:k.offsetLeft-m,top:k.offsetTop-l,width:k.offsetWidth,height:k.offsetHeight},b.speed,b.fx)}})}})(jQuery);


	$(function() {
		$('#menu').lavaLamp({fx: 'swing', speed: 400});
	});
	

//////////////////////////////////////////////////////////////////////////////////////////
// AJAX CONTACT

$(document).ready(function() {
	
	//if submit button is clicked
	$('#submit').click(function () {		
		
		//Get the data from all the fields
		var name = $('input[name=name]');
		var email = $('input[name=email]');
		var website = $('input[name=website]');
		var comment = $('textarea[name=comment]');

		//Simple validation to make sure user entered something
		//If error found, add hightlight class to the text field
		if (name.val()=='') {
			name.addClass('hightlight');
			return false;
		} else name.removeClass('hightlight');
		
		if (email.val()=='') {
			email.addClass('hightlight');
			return false;
		} else email.removeClass('hightlight');
		
		if (comment.val()=='') {
			comment.addClass('hightlight');
			return false;
		} else comment.removeClass('hightlight');
		
		//organize the data properly
		var data = 'name=' + name.val() + '&email=' + email.val() + '&website=' + 
		website.val() + '&comment='  + encodeURIComponent(comment.val());
		
		//disabled all the text fields
		$('.contact-label').attr('disabled','true');
		
		//show the loading sign
		$('.loading').show();
		
		//start the ajax
		$.ajax({
			//this is the php file that processes the data and send mail
			url: "contact.php",	
			
			//GET method is used
			type: "GET",

			//pass the data			
			data: data,		
			
			//Do not cache the page
			cache: false,
			
			//success
			success: function (html) {				
				//if process.php returned 1/true (send mail success)
				if (html==1) {					
					//hide the form
					$('.form').fadeOut('slow');					
					
					//show the success message
					$('.done').fadeIn('slow');
					
				//if process.php returned 0/false (send mail failed)
				} else alert('Sorry, unexpected error. Please try again later.');				
			}		
		});
		
		//cancel the submit button default behaviours
		return false;
	});	
});	

//////////////////////////////////////////////////////////////////////////////////////////
// SLIDESHOW PLUGIN

$(function(){
	$("#slideshow").cycle({"speed":1500,"timeout":5250});
	$("#slideshow_list").cycle({"speed":1500,"timeout":5250,"height":"204px","width":"291px","fx":"scrollDown","cleartype":true});
	$(".featured_list li").css({backgroundColor:'transparent'});
});

//////////////////////////////////////////////////////////////////////////////////////////
// TARGET _BLANK FOR ANCHORS

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

//////////////////////////////////////////////////////////////////////////////////////////
// AJAX CONTENT

$(document).ready(function(){
	//References
	var sections = $("a[rel^=ajax]");
	var loading = $("#loading");
	var content = $("#content");
	var scrollfix =$("html").css({"overflow-y":"scroll"});
	
	//Manage click events
	sections.click(function(){
		//show the loading bar
		showLoading();
		//load selected section
		switch(this.id){

			case "one":
				content.slideUp("slow",function(){
                    $.ajax({
					url :"/news/index.html",
					success:function(html){
						content.html(html).slideDown("slow");
						hideLoading();
						}
					})
				})
                break;
			case "two":
				content.slideUp("slow",function(){
                    $.ajax({
					url :"/news/index.html",
					success:function(html){
						content.html(html).slideDown("slow");
						hideLoading();
						}
					})
				})
                break;
			default:
				//hide loading bar if there is no selected section
				hideLoading();
				break;
		}
	});

	//show loading bar
	function showLoading(){
		loading
			.css({visibility:"visible"})
			.css({opacity:"1"})
			.css({display:"block"})
		;
	}
	//hide loading bar
	function hideLoading(){
		loading.fadeTo(2500, 0);
	};
});


//////////////////////////////////////////////////////////////////////////////////////////
// SIFR


var gothamMedium = {src: '/swf/gotham-medium.swf'};
var gothamLight = {src: '/swf/gotham-light.swf'};
var gothamBook = {src: '/swf/gotham-book.swf'};

sIFR.activate(gothamMedium);
sIFR.activate(gothamLight); 
sIFR.activate(gothamBook); 

sIFR.replace(gothamMedium, {
  selector: '.heading_title, .heading_title2',
  css: [
      '.sIFR-root { kerning:true; font-size:26px;letter-spacing:0; width:100%; font-weight:normal; color:#FFFFFF; z-index: 0 }'
      ],
  wmode: 'transparent'
});

sIFR.replace(gothamLight, {
  selector: '#page_sub.resume .table_title',
  css: [
      '.sIFR-root { kerning:true; font-size:16px; text-transform:uppercase; width:100%; font-weight:normal; color:#FFFFFF; z-index: 0 }'
      ],
  wmode: 'transparent'
});

sIFR.replace(gothamBook, {
  selector: '.heading_subtitle',
  css: [
      '.sIFR-root { kerning:true; font-size:16px; text-transform:uppercase; width:100%; font-weight:normal; color:#FFFFFF; z-index: 0 }'
      ],
  wmode: 'transparent'
});


//////////////////////////////////////////////////////////////////////////////////////////
// MODAL WINDOW

$(document).ready(function(){
	$(".box_reel li a").attr({"rel": "video"});
	$(".gallery li a").attr({"rel": "gallery"});
	$.fn.colorbox.settings.bgOpacity = "0.90";
	$("a[rel='gallery']").colorbox();
	$("a[rel='video']").colorbox();
	$(".iframe").colorbox({fixedHeight : "80%", fixedWidth : "80%", iframe : true}); 
	$(".links").colorbox();
});

//////////////////////////////////////////////////////////////////////////////////////////
// LOAD BOXES

$(document).ready(function(){
		$('#myblog').load('/index.html div.box_content.myblog');
		$('#featuredwork').load('/index.html #slideshow_list.featuredwork div.box_content');
		$('#socialnetworking').load('/index.html div.box_content.socialnetworking');
		$('#prolinks').load('/news/links.html .prolinks');
});

//////////////////////////////////////////////////////////////////////////////////////////
// TABS GALLERY
$(document).ready(function(){

	$('#page_sub #tabs').tabs({ fx: { opacity: 'toggle' } });

});

//////////////////////////////////////////////////////////////////////////////////////////
// GALLERY

$(document).ready(function() {

	$("#portraits, #production, #misc").each(function(i) {
			$(this).hide();
		setTimeout(function(){
			$("#portraits").slideDown(2000);
		}, 
		500 // interval
		); //close setTimeout
		setTimeout(function(){
			$("#production").slideDown(2000);
		}, 
		1000 // interval
		); //close setTimeout
		setTimeout(function(){
			$("#misc").slideDown(2000);
		}, 
		1500 // interval
		); //close setTimeout
	});// close #page_index #center

	// HOVER FUNCTIONS

	$(".gallery li a img").mouseover(function(){
		$(this).stop().fadeTo("fast", 1);
	 });
	$(".gallery li a img").mouseout(function(){
		$(this).stop().fadeTo("fast",.5);
	 });
	$(".gallery li a img").addClass("thumb_image").attr({width:"130"});
	$(".gallery li").addClass("box_image");
	
	// WRAP IMG FOR IE

	$(".gallery li a").wrap('<div class="thumb-inner"></div>');

});


//////////////////////////////////////////////////////////////////////////////////////////
// REEL

$(document).ready(function(){

	$(".box_reel").each(function(i) {
			$(this).hide();
		setTimeout(function(){
			$(".box_reel").slideDown(2000);
		}, 
		250 // interval
		); //close setTimeout
	});// close #page_index #center

	$("#page_sub #content_left .box_reel li:odd").addClass("end");

	$(".box_reel li img").mouseover(function(){
		$(this).stop().fadeTo("fast", 1);
	 });
	$(".box_reel li img").mouseout(function(){
		$(this).stop().fadeTo("fast",.5);
	 });
	
	$('.box_reel li span:contains(Category)').next().addClass("box_reel_title");
	
});

//////////////////////////////////////////////////////////////////////////////////////////
// BUBBLE

$(document).ready(function(){

	$(".footer a.marioluevanos").hover(function() {
		$(this).next("span").animate({opacity: "show", top: "-65"}, "slow");
	}, function() {
		$(this).next("span").animate({opacity: "hide", top: "-95"}, "fast");
	});


});

//////////////////////////////////////////////////////////////////////////////////////////
// CUSTOM LOAD HOME PAGE & BIO

$(document).ready(function() {
	$("#center.home, #page_sub.bio #slideshow, #page_sub.resume #slideshow").each(function(i) {
			$(this).hide();
		setTimeout(function(){
			$("#center.home").slideDown(2500);
		}, 
		650 // interval
		); //close setTimeout

			$("#page_sub.bio #slideshow").fadeIn(1500);
			$("#page_sub.resume #slideshow").fadeIn(1500);

	});// close #center.home

});