Learn how to use jQuery at the Blog

Icondock « visit

  • Added 10 months ago
  • 231 Lines of Code shown
  • 4 Links of Interest
http://icondock.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 Icondock - http://icondock.com

this.screenshotPreview = function(){	
	/* CONFIG */
		
		xOffset = 37;
		yOffset = 22;
		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result
		
	/* END CONFIG */
	$("a.screenshot").hover(function(e){
		this.t = this.title;
		this.title = "";	
		//var c = (this.t != "") ? "<br/>" + this.t : "";
		//$("body").append("<p id='screenshot'><img src='"+ this.rel +"' alt='url preview' />"+ c +"</p>");								 
		$("body").append("<div id='screenshot'><span></span><img src='"+ this.rel +"' alt='loading image' /></div>");								 
		$("#screenshot")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");						
    },
	function(){
		this.title = this.t;	
		$("#screenshot").remove();
    });	
	$("a.screenshot").mousemove(function(e){
		$("#screenshot")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};



$(document).ready(function(){

	screenshotPreview();

	$('h1').prepend("<span></span>");
	
	$(".set_list .item").hover(function() {
		$(this).parents("li").find(".details").show();
	}, function() {
		$(this).parents("li").find(".details").hide();
	});

	$(".set_list .details").hover(function() {
		$(this).show();
	}, function() {
		$(this).hide();
	});

	$("#menu ul").css({display: "none"}); // Opera Fix
	$("#menu li").hover(function(){
		$(this).find('ul:first').css({visibility: "visible",display: "none"}).show();
		$(this).addClass("current");
		},function(){
			$(this).find('ul:first').css({visibility: "hidden"});
			$(this).removeClass("current");
		});

	$("#dock_list").jCarouselLite({
		btnNext: "#dock .next",
		btnPrev: "#dock .prev",
		visible: 5,
		circular: false,
		mouseWheel: true,
		vertical: true,
		speed: 300
	});    

	$(".feat_list").jCarouselLite({
		btnNext: ".feat_prods .next",
		btnPrev: ".feat_prods .prev",
		visible: 4,
		speed: 300
	});
	
	$('ul.tabnav .tab_btn a').click(function() {
		var curChildIndex = $(this).parent().prevAll().length + 1;
		$(this).parent().parent().children('.current').removeClass('current');
		$(this).parent().addClass('current');
		$(this).parent().parent().next('.tabcontainer').children('.current').fadeOut('fast',function() {
			$(this).removeClass('current');
			$(this).parent().children('div:nth-child('+curChildIndex+')').fadeIn('normal',function() {
				$(this).addClass('current');
			});
		});
		return false;								
	});
	

}); //close doc ready



jQuery(document).ready(
  function() {
  jQuery('#dragdrop_container').slideNews();
  jQuery('.product_image').Draggable(
    {
    ghosting: true,
    revert: true,
    opacity: 0.5,
    zIndex: 20,
    fx: 250,
    onStop: function(element) {
//       console.log("%o was dropped", jQuery(this).attr('id'));
      }
    }
  );
  //item_remover
  jQuery('.draggable_cart_item').Draggable( {
    ghosting: true,
    revert: true,
    opacity: 0.5,
    zIndex: 20,
    fx: 950
    }
  );
  
  jQuery('#dock').Droppable( {
    accept: 'item product_image',
    onDrop: function(drag) {
      form_id = drag.id.replace(/image_/, '');
      submitform(document.getElementById(form_id));
      jQuery(drag).TransferTo({
        to: jQuery(this),
        className: 'transfering',
        duration: '200'
        });
      },
    onHover: function(drag) {
      },
    onOut: function(drag) {
      }
    }
  );
  
  jQuery('#page').Droppable({
    accept: 'dock_item item product_image',
    onDrop: function(drag) {
    drag_and_drop_item_deleter(drag);
      jQuery(drag).TransferTo({
        to: jQuery(this),
        className: 'transfering',
        duration: '200'
      });
    }
  });
  jQuery('#page').Droppable({
    accept: 'draggable_cart_item',
    onDrop: function(drag) {
    drag_and_drop_item_deleter(drag);
      jQuery(drag).TransferTo({
        to: jQuery(this),
        className: 'transfering',
        duration: '200'
      });
    }
  });
  

  jQuery('.draggable_cart_item a.item_remover').click( function() {
    product_id = jQuery(this).parent().attr('id');
	  //console.log("Id = %s;",product_id);
	  drag_and_drop_item_deleter(document.getElementById(product_id));
	  return false;
	});
  }
);
    
var drag_and_drop_cart_ajax=function(results) {
  jQuery('#dock').html(results);
  
  jQuery('.draggable_cart_item a.item_remover').click( function() {
    product_id = jQuery(this).parent().attr('id');
	  //console.log("Id = %s;",product_id);
	  drag_and_drop_item_deleter(document.getElementById(product_id));
	  return false;
    });

	$("#dock_list").jCarouselLite({
		btnNext: "#dock .next",
		btnPrev: "#dock .prev",
		visible: 5,
		circular: false,
		mouseWheel: true,
		vertical: true,
		speed: 300
	});
  
  jQuery('.draggable_cart_item').Draggable({
    ghosting: true,
    revert: true,
    opacity: 0.5,
    zIndex: 20,
    fx: 250
  });
  //jQuery('#dragdrop_container').slideNews();
  jQuery("#dragdrop_spinner").css('display', 'none');
}


function drag_and_drop_cart_updater() {
  jQuery("#dragdrop_spinner").css('display', 'block');
	ajax.post("index.php",drag_and_drop_cart_ajax,"ajax=true&user=true&drag_and_drop_cart=true");

}
    
    
function drag_and_drop_item_deleter(element) {
  element_id = element.id;
  product_id = jQuery("#"+element_id+' form input[name=product_id]').val();
  cart_id = jQuery("#"+element_id+' form input[name=cart_id]').val();
  quantity = jQuery("#"+element_id+' form input[name=quantity]').val();
	//console.log("Product Id = %s; Card Id = %s; Quantity = %s;", product_id, cart_id, quantity);
  if(parseInt(quantity) <= 1) {
    jQuery("#"+element_id).css('display', 'none');
	} else {
		//jQuery("#"+element_id+'_quantity').html("<span>"+(parseInt(quantity) - 1)+"</span>");
	}
  jQuery("#dragdrop_spinner").css('display', 'block');
  ajax.post("index.php",drag_and_drop_cart_ajax,"ajax=true&user=true&drag_and_drop_cart=true&action=delete&product_id="+product_id+"&cart_id="+cart_id);
}
  
  
    function drag_and_drop_hover()
      {
      return false;
      }