Learn how to use jQuery at the Blog

Position: Absolute « visit

  • Added 7 months ago
  • 171 Lines of Code shown
  • 0 Links of Interest
http://position-absolute.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 Position: Absolute - http://position-absolute.com

/**
 * Common Js
 **/
	
	
  $(document).ready(function() {
  	
  	/* RSS FEEDER  */
  	$(".rssFeeder").css("opacity",0)
  	$(".rssSubscribe").hover(function(){
  		$(".rssFeeder").css("display","block")
  		$(".rssFeeder:not(:animated)").animate({
  			opacity:1,
  			marginLeft:0
  		})
  	},
  	function(){
  		$(".rssFeeder").animate({
  			opacity:0,
  			marginLeft:"-20px"
  		},function(){
  			$(".rssFeeder").css("display","none")
  		})
  	})
  	
  	$(".rssFeeder").hover(function(){
  		$(".rssFeeder").stop()
  	},
  	function(){
  		$(".rssFeeder").animate({
  			opacity:0,
  			marginLeft:"-20px"
  		},function(){
  			$(".rssFeeder").css("display","none")
  		})
  	})
  	
  	
  	
  	/* SNIPPET SEARCH AND SUBMITTION */
  		var selectReset = false
  		var tagsOtherReset = false
  		var allLibrary = ""
  		$("#tags").val("")
  	  $(".tagcloud").css("opacity", 0)	// Search input change color for usability
     
      
      $(".tagBtn").click(function(){   // Show the snippet search Tag Cloud
      	$(this).next().fadeToggle()
      	return false;
      })
      
       $("a#submitSearch").click(function(){
       	
       	submittags = $("#tags").val()
       
       	if( $("select#library option:selected").val()=="all"){
       		submittags += ",all"
       	}
       	 $(this).attr("href", "/tag/"+submittags+"/")
      })
      $("input#tagsOther").blur(function(){
	      	if(tagsOtherReset == false){
	       		tagsBefore = $("#tags").val()
	       		tagsOtherReset = true
	       	}
	 		if(selectReset == true) {
	       		tagsBefore = $("select#library option:selected").val() +","
	       	}
	      	tagsValue = $("#tagsOther").val()
	      	$("#tags").val(tagsBefore + tagsValue) 
      })
      
       $("select#library").blur(function(){
       		
	       	if(selectReset == false){
	       		tagsBefore = $("#tags").val()
	       		selectReset = true
	       	}
	       	if(tagsOtherReset == true) {
	       		tagsBefore = $("#tagsOther").val()
	       	}
	      	 tagsValue = $("select#library option:selected").val() +","
	      	$("#tags").val(tagsValue+tagsBefore) 
      })
        $("#customfields-textfield-1").click(function(){
        	$("#tags").val("all,"+tagsBefore) 
        })
        
     $("img.thumb").each(function(i){
     	if($(this).attr("src")==""){
     		$(this).css("display","none")
     	}
     })
     
  });



/* SMALL FADE AND SLIDE TOGGLE PLUG_IN */
 jQuery.fn.fadeToggle = function(speed, easing, callback) {
 	/* Damn you jQuery opacity:'toggle' that dosen't work!~!!!*/
  
 	if($(this).css("opacity") == 0){
 		this.animate({
 			opacity: 1,
 			height: 'toggle'
 		}, 500, 'swing');
	}else{
		this.animate({
 			opacity: 0,
 			height: 'toggle'
 		}, 500, 'swing');
	}
}; 


function draw() {
	
	
	var boxesCanvas = document.getElementById("boxes-cnvs");
	if (boxesCanvas.getContext) {
		var ctx = boxesCanvas.getContext("2d");
		var h = $("#boxes-cnvs").height();
		var w = $(window).width();
		$("#boxes-cnvs").attr("width",w);
		var color1 = '#193e47';
		var color2 = '#29565c';
		ctx.fillStyle = color1;
		ctx.lineWidth = 1;
		ctx.strokeStyle = color2;

		for ( i=0; i<=270; i++ ) {
		  //randomize values for placement and size
		  var x = Math.random()*w;
		  var y = Math.random()*(Math.random()*.75+.25)*h*.9;
		  var s = 5+Math.random()*Math.random()*Math.random()*100;
		  var theta = Math.random()*3.14;

		  // render boxes on the left
		  ctx.save();
			var x1 = x-w/2;
			ctx.translate( x1, y);
			ctx.rotate(theta);
			ctx.translate(-s/2, -s/2);
			ctx.fillRect(0,0,s,s);
			ctx.strokeRect(0,0,s,s);
		  ctx.restore();

		  // render the same boxes on the right, so it repeats
		  ctx.save();
			var x2 = x+w/2;
			ctx.translate( x2, y);
			ctx.rotate(theta);
			ctx.translate(-s/2, -s/2);
			ctx.fillRect(0,0,s,s);
			ctx.strokeRect(0,0,s,s);
		  ctx.restore();

		}
	}

	
	
}


		
$(function() {
	draw();
})