<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Codrops &#187; draggable</title>
	<atom:link href="http://tympanus.net/codrops/tag/draggable/feed/" rel="self" type="application/rss+xml" />
	<link>http://tympanus.net/codrops</link>
	<description>Useful resources and inspiration for creative minds</description>
	<lastBuildDate>Mon, 06 Feb 2012 07:30:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Draggable Image Boxes Grid</title>
		<link>http://tympanus.net/codrops/2011/10/07/draggable-image-boxes-grid/</link>
		<comments>http://tympanus.net/codrops/2011/10/07/draggable-image-boxes-grid/#comments</comments>
		<pubDate>Fri, 07 Oct 2011 15:22:48 +0000</pubDate>
		<dc:creator>Mary Lou</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[draggable]]></category>
		<category><![CDATA[fullscreen]]></category>
		<category><![CDATA[gallery]]></category>
		<category><![CDATA[images]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[portfolio]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[thumbnails]]></category>

		<guid isPermaLink="false">http://tympanus.net/codrops/?p=6002</guid>
		<description><![CDATA[Today we want to create a template with a fullscreen grid of images and content areas. The idea is to have a draggable grid that shows boxes of thumbnails and menu like items. Once clicked, the thumbnail will expand to the full size image and the menu item box will expand to a fullscreen content area. ]]></description>
			<content:encoded><![CDATA[<p><a href="http://tympanus.net/Tutorials/DraggableImageBoxesGrid/" target="_blank"><img src="http://tympanus.net/codrops/wp-content/uploads/2011/10/DraggableImageBoxesGrid.jpg" alt="Draggable Image Boxes Grid" width="580" height="315" class="aligncenter size-full wp-image-6019" /></a><br />
<a class="demo" href="http://tympanus.net/Tutorials/DraggableImageBoxesGrid/" target="_blank">View demo</a> <a class="download" href="http://tympanus.net/Tutorials/DraggableImageBoxesGrid/DraggableImageBoxesGrid.zip">Download source</a></p>
<p>Today we want to create a template with a fullscreen grid of images and content areas. The idea is to have a draggable grid that shows boxes of thumbnails and menu like items. Once clicked, the thumbnail will expand to the full size image and the menu item box will expand to a fullscreen content area. </p>
<p>The main idea for this template and its effects comes from the beautiful Flash-based website of <a href="http://stephenhamilton.com" target="_blank">Stephen Hamilton</a>.</p>
<p>To make the grid draggable, we used <a href="http://the-taylors.org/jquery.kinetic/" target="_blank">jQuery.kinetic by Dave Taylor</a>. The jQuery plugin allows smooth drag scrolling and it&#8217;s just what we need in our grid.</p>
<p>The beautiful images in the demo are by Ibrahim Iujaz. Check out his <a href="http://www.flickr.com/photos/notsogoodphotography/" target="_blank">Flickr photostream</a>.</p>
<p>So, let&#8217;s begin!<br />
<div id="bsap_1266918" class="bsarocks bsap_af25dfd2f1908889af7a1aa5f4dcbd9e"></div><div style="clear:both;"></div></p>
<h3>The Markup</h3>
<p>The main container will be a div with the class and ID <strong>ib-main-wrapper</strong>. We will add another div element inside since we will need this structure for applying the jQuery.kinetic plugin. Inside of that div which has the class <strong>ib-main</strong>, we will place two types of link elements: the thumbnail links and the content links. The content links are the menu like boxes that will expand to a fullscreen content area: </p>
<pre class="brush:xml">
&lt;div id="ib-main-wrapper" class="ib-main-wrapper"&gt;
	&lt;div class="ib-main"&gt;
		&lt;a href="#"&gt;
			&lt;img src="images/thumbs/1.jpg" data-largesrc="images/large/1.jpg" alt="image01"/&gt;
			&lt;span&gt;Crabbed Age and Youth&lt;/span&gt;
		&lt;/a&gt;
		&lt;a href="#"&gt;
			&lt;img src="images/thumbs/2.jpg" data-largesrc="images/large/2.jpg" alt="image02"/&gt;
			&lt;span&gt;Cannot live together&lt;/span&gt;
		&lt;/a&gt;
		&lt;a href="#" class="ib-content"&gt;
			&lt;div class="ib-teaser"&gt;
				&lt;h2&gt;Welcome &lt;span&gt;Howdy, Stranger&lt;/span&gt;&lt;/h2&gt;
			&lt;/div&gt;
			&lt;div class="ib-content-full"&gt;
				&lt;!-- Some content --&gt;
			&lt;/div&gt;
		&lt;/a&gt;
		...
	&lt;/div&gt;
&lt;/div&gt;
</pre>
<p>The boxes for the content will have the class <strong>ib-content</strong>. The path to the large image for the thumbnails will be saved in the data attribute <strong>data-largesrc</strong>.</p>
<p>For the content and image preview we will use jQuery templates. The template for the large image preview is the following:</p>
<pre class="brush:xml">
&lt;div id="ib-img-preview" class="ib-preview"&gt;
	&lt;img src="${src}" alt="" class="ib-preview-img"/&gt;
	&lt;span class="ib-preview-descr" style="display:none;"&gt;${description}&lt;/span&gt;
	&lt;div class="ib-nav" style="display:none;"&gt;
		&lt;span class="ib-nav-prev"&gt;Previous&lt;/span&gt;
		&lt;span class="ib-nav-next"&gt;Next&lt;/span&gt;
	&lt;/div&gt;
	&lt;span class="ib-close" style="display:none;"&gt;Close Preview&lt;/span&gt;
	&lt;div class="ib-loading-large" style="display:none;"&gt;Loading...&lt;/div&gt;
&lt;/div&gt;
</pre>
<p>We will have the large image, the navigation buttons, a closing cross and a loading element.</p>
<p>The template for the fullscreen content preview looks like this:</p>
<pre class="brush:xml">
&lt;div id="ib-content-preview" class="ib-content-preview"&gt;
	&lt;div class="ib-teaser" style="display:none;"&gt;{{html teaser}}&lt;/div&gt;
	&lt;div class="ib-content-full" style="display:none;"&gt;{{html content}}&lt;/div&gt;
	&lt;span class="ib-close" style="display:none;"&gt;Close Preview&lt;/span&gt;
&lt;/div&gt;
</pre>
<p>Now, let&#8217;s style the grid.</p>
<h3>The CSS</h3>
<p>First, we will style the wrapping container. It will occupy all the page&#8217;s width and we will set the height dynamically to fit the visible area:</p>
<pre class="brush:css">
.ib-main-wrapper{
    width: 100%;
    overflow: hidden;
    margin-top: 40px;
    outline: none;
    /*height dynamic*/
}
</pre>
<p>The main container will have a preset width. We chose this value because we want most visitors to be able to actually drag the grid. If you would set it to less and the user has a larger screen, then the container would be too small:</p>
<pre class="brush:css">
.ib-main{
    position: relative;
    width: 2546px;
}
</pre>
<p>Each box element will be floating and have a background image (for the thumbs) that we&#8217;ll stretch to be a bit larger than the box. We&#8217;ll add a nice transition which will make the background image contract on hover:</p>
<pre class="brush:css">
.ib-main a{
    float: left;
    width: 210px;
    height: 210px;
    position: relative;
    overflow: hidden;
    margin: 0px 0px 2px 2px;
    cursor: move;
    background: #fff url(../images/thumb_bg.jpg) no-repeat center center;
    background-size: 110% 110%;
    -webkit-transition: all 0.2s ease-in-out;
    -moz-transition: all 0.2s ease-in-out;
    -o-transition: all 0.2s ease-in-out;
    -ms-transition: all 0.2s ease-in-out;
    transition: all 0.2s ease-in-out;
}
.ib-main a:hover{
    background-size: 100% 100%;
}
</pre>
<p>The thumbnail will be slightly transparent so that we can see the background image (which is a thick border). We&#8217;ll also add some CSS3 transition here to animate the opacity on hover:</p>
<pre class="brush:css">
.ib-main a img{
    opacity: 0.95;
    -webkit-transition: all 0.2s ease-in-out;
    -moz-transition: all 0.2s ease-in-out;
    -o-transition: all 0.2s ease-in-out;
    -ms-transition: all 0.2s ease-in-out;
    transition: all 0.2s ease-in-out;
}
.ib-main a:hover img{
    opacity: 0.8;
}
</pre>
<p>The description will be positioned absolutely and we&#8217;ll place it out of the box. Then, on hover, we will make it slide in:</p>
<pre class="brush:css">
.ib-main > a > span{
    display: block;
    position: absolute;
    width: 100%;
    height: 20px;
    line-height: 22px;
    text-align: center;
    font-size: 11px;
    bottom: -20px;
    left: 0px;
    text-shadow: 1px 1px 1px rgba(0,0,0,0.4);
    -webkit-transition: all 0.2s ease-in-out;
    -moz-transition: all 0.2s ease-in-out;
    -o-transition: all 0.2s ease-in-out;
    -ms-transition: all 0.2s ease-in-out;
    transition: all 0.2s ease-in-out;
}
.ib-main a:hover > span{
    bottom: 0px;
}
</pre>
<p>When we click on the thumbnail box, we&#8217;ll change the background image in order to show the loading image:</p>
<pre class="brush:css">
.ib-main a.ib-loading,
.ib-main a.ib-loading:hover{
    background: #fff url(../images/ajax-loader.gif) no-repeat center center;
    background-size: 31px 31px;
}
.ib-main a.ib-loading img,
.ib-main a.ib-loading:hover img{
    opacity: 0.5;
}
</pre>
<p>When the thumbnail is in the loading state, we don&#8217;t want to show the description:</p>
<pre class="brush:css">
.ib-main > a.ib-loading > span,
.ib-main a.ib-loading > span{
    display: none;
}
</pre>
<p>Now we&#8217;ll style the content boxes. The background is going to be dark:</p>
<pre class="brush:css">
.ib-content{
    background: #f9f9f9;
}
</pre>
<p>The teaser is the text we&#8217;ll be showing in each content box. On hover we want to animate the background color:</p>
<pre class="brush:css">
.ib-content .ib-teaser{
    text-align: center;
    background: #333;
    width: 100%;
    height: 100%;
    -webkit-transition: all 0.2s ease-in-out;
    -moz-transition: all 0.2s ease-in-out;
    -o-transition: all 0.2s ease-in-out;
    -ms-transition: all 0.2s ease-in-out;
    transition: all 0.2s ease-in-out;
}
.ib-content .ib-teaser:hover{
    background: #000;
}
</pre>
<p>The headline and the subline will have the following style:</p>
<pre class="brush:css">
.ib-teaser h2{
    color: #fff;
    font-size: 26px;
    line-height: 26px;
    padding-top: 40%;
    text-shadow: 1px 0px 2px rgba(0,0,0,0.2);
}
.ib-teaser h2 span{
    text-transform: none;
    font-size: 16px;
    font-family: Georgia, serif;
    font-style: italic;
    display: block;
}
</pre>
<p>When the content area gets expanded, we will show the preview container and it will have an absolute position and a dynamic height:</p>
<pre class="brush:css">
.ib-content-preview{
    position: absolute;
    top: 44px;
    left: 0px;
    background: #000;
    width: 100%;
    /* height dynamic*/
    display: none;
}
</pre>
<p>The text elements will get some styling:</p>
<pre class="brush:css">
.ib-content-preview .ib-teaser h2{
    font-size: 50px;
    padding: 85px 40px 20px 40px;
}
.ib-content-preview .ib-teaser span{
    padding: 20px 0px 0px 5px;
    font-size: 22px;
}
.ib-content-full{
    font-family:'Oswald', serif;
    text-transform: none;
    line-height: 26px;
    margin: 0px 40px;
    border-top: 1px solid #333;
    padding: 20px 0px;
	font-size: 16px;
}
.ib-content-full p{
	padding: 5px 0px;
}
</pre>
<p>The large preview for the thumbnails will also be of absolute position </p>
<pre class="brush:css">
.ib-preview{
    overflow: hidden;
    position: absolute;
    top: 40px;
    display: none;
}
</pre>
<p>The description for the large image will be placed in the bottom left corner. We want big letters:</p>
<pre class="brush:css">
.ib-preview-descr{
    position: absolute;
    bottom: 30px;
    left: 10px;
    z-index: 999;
    font-size: 50px;
    text-shadow: 1px 0px 2px rgba(0,0,0,0.2);
}
</pre>
<p>The image itself will be absolute and the width and height will be set dynamically in the JavaScript:</p>
<pre class="brush:css">
.ib-preview img{
	position: absolute;
}
</pre>
<p>The navigation for the images will be placed on the left and the right side of the screen:</p>
<pre class="brush:css">
.ib-nav span{
	width: 53px;
	height: 87px;
	position: absolute;
	top: 50%;
	margin-top: -43px;
	cursor: pointer;
    text-indent: -9000px;
	opacity: 0.6;
	z-index: 999;
    background: transparent url(../images/nav.png) no-repeat top right;
	right: 10px;
	-webkit-user-select: none;
	-khtml-user-select: none;
	-moz-user-select: none;
	-o-user-select: none;
	user-select: none;
}
.ib-nav span.ib-nav-prev{
	background-position: top left;
	left: 10px;
    right: auto;
}
</pre>
<p>The closing element will be at the top right corner:</p>
<pre class="brush:css">
.ib-close{
	top: 7px;
	right: 7px;
	background: transparent url(../images/close.png) no-repeat center center;
	position: absolute;
	width: 24px;
	height: 24px;
	cursor: pointer;
	opacity: 0.2;
	z-index: 999;
    text-indent: -9000px;
}
.ib-nav span:hover, .ib-close:hover{
	opacity: 1;
}
</pre>
<p>Last, but not least, we&#8217;ll style the loading element for the large image. We&#8217;ll place it in the center of the screen with our 50% and negative margin trick and give it some rounded borders:</p>
<pre class="brush:css">
.ib-loading-large{
    text-indent: -9000px;
    width: 60px;
    height: 60px;
    background: #fff url(../images/ajax-loader.gif) no-repeat center center;
    position: absolute;
    top: 50%;
    left: 50%;
    margin: -30px 0 0 -30px;
    z-index: 999;
    -moz-border-radius: 10px;
    -webkit-border-radius: 10px;
    border-radius: 10px 10px 10px 10px;
    opacity: 0.9;
}
</pre>
<p>And that was all the style. Now, let&#8217;s take a look at the JavaScript.</p>
<h3>The JavaScript</h3>
<p>Let&#8217;s define our template function:</p>
<pre class="brush:js">
var $ibWrapper	= $('#ib-main-wrapper'),

	Template	= (function() {
		...
})();

Template.init();
</pre>
<p>First, we will set some variables and cache some elements:</p>
<pre class="brush:js">
var kinetic_moving				= false,
	// current index of the opened item
	current						= -1,
	// true if the item is being opened / closed
	isAnimating					= false,
	// items on the grid
	$ibItems					= $ibWrapper.find('div.ib-main &gt; a'),
	// image items on the grid
	$ibImgItems					= $ibItems.not('.ib-content'),
	// total image items on the grid
	imgItemsCount				= $ibImgItems.length,
</pre>
<p>The init function will add a class to all the image items and call the jQuery.kinetic plugin and initialize our main events:</p>
<pre class="brush:js">
init						= function() {

		// add a class ib-image to the image items
		$ibImgItems.addClass('ib-image');
		// apply the kinetic plugin to the wrapper
		loadKinetic();
		// load some events
		initEvents();

	},
</pre>
<p><strong>loadKinetic</strong> will set the size of the main wrapper and apply the jQuery.kinetic plugin:</p>
<pre class="brush:js">
loadKinetic					= function() {

	setWrapperSize();

	$ibWrapper.kinetic({
		moved	: function() {

			kinetic_moving = true;

		},
		stopped	: function() {

			kinetic_moving = false;

		}
	});

},
</pre>
<p><strong>setWrapperSize</strong> will set the height of the main wrapper by taking the window height and removing the top bar and the bottom bar (which is our demo header actually):</p>
<pre class="brush:js">
setWrapperSize				= function() {

	var containerMargins	= $('#ib-top').outerHeight(true) + $('#header').outerHeight(true) + parseFloat( $ibItems.css('margin-top') );
	$ibWrapper.css( 'height', $(window).height() - containerMargins )

},
</pre>
<p><strong>initEvents</strong> calls the openItem function when we click on a box (unless we are dragging) and takes care of the resizing when we change the window size:</p>
<pre class="brush:js">
initEvents					= function() {

	// open the item only if not dragging the container
	$ibItems.bind('click.ibTemplate', function( event ) {

		if( !kinetic_moving )
			openItem( $(this) );

		return false;	

	});

	// on window resize, set the wrapper and preview size accordingly
	$(window).bind('resize.ibTemplate', function( event ) {

		setWrapperSize();

		$('#ib-img-preview, #ib-content-preview').css({
			width	: $(window).width(),
			height	: $(window).height()
		})

	});

},
</pre>
<p>When we click on an item, depending on which item we clicked, we&#8217;ll load a full image or a content area:</p>
<pre class="brush:js">
openItem					= function( $item ) {

	if( isAnimating ) return false;

	// if content item
	if( $item.hasClass('ib-content') ) {

		isAnimating	= true;
		current	= $item.index('.ib-content');
		loadContentItem( $item, function() { isAnimating = false; } );

	}
	// if image item
	else {

		isAnimating	= true;
		current	= $item.index('.ib-image');
		loadImgPreview( $item, function() { isAnimating = false; } );

	}

},
</pre>
<p>If we click on a thumbnail, we&#8217;ll load and expand to the respective large image. We will use the jQuery template for the large image preview and set it to the same position like the currently clicked item. Initially having the same size, it will then expand first in width to fit the window and then in height:</p>
<pre class="brush:js">
loadImgPreview				= function( $item, callback ) {

	var largeSrc		= $item.children('img').data('largesrc'),
		description		= $item.children('span').text(),
		largeImageData	= {
			src			: largeSrc,
			description	: description
		};

	// preload large image
	$item.addClass('ib-loading');

	preloadImage( largeSrc, function() {

		$item.removeClass('ib-loading');

		var hasImgPreview	= ( $('#ib-img-preview').length &gt; 0 );

		if( !hasImgPreview )
			$('#previewTmpl').tmpl( largeImageData ).insertAfter( $ibWrapper );
		else
			$('#ib-img-preview').children('img.ib-preview-img').attr( 'src', largeSrc );

		//get dimentions for the image, based on the windows size
		var	dim	= getImageDim( largeSrc );

		$item.removeClass('ib-img-loading');

		//set the returned values and show/animate preview
		$('#ib-img-preview').css({
			width	: $item.width(),
			height	: $item.height(),
			left	: $item.offset().left,
			top		: $item.offset().top
		}).children('img.ib-preview-img').hide().css({
			width	: dim.width,
			height	: dim.height,
			left	: dim.left,
			top		: dim.top
		}).fadeIn( 400 ).end().show().animate({
			width	: $(window).width(),
			left	: 0
		}, 500, 'easeOutExpo', function() {

			$(this).animate({
				height	: $(window).height(),
				top		: 0
			}, 400, function() {

				var $this	= $(this);
				$this.find('span.ib-preview-descr, span.ib-close').show()
				if( imgItemsCount &gt; 1 )
					$this.find('div.ib-nav').show();

				if( callback ) callback.call();

			});

		});

		if( !hasImgPreview )
			initImgPreviewEvents();

	} );

},
</pre>
<p>With the same effect of expanding, we&#8217;ll open a content area, too. Here we have to take care of the text elements:</p>
<pre class="brush:js">
loadContentItem				= function( $item, callback ) {

	var hasContentPreview	= ( $('#ib-content-preview').length &gt; 0 ),
		teaser				= $item.children('div.ib-teaser').html(),
		content				= $item.children('div.ib-content-full').html(),
		contentData			= {
			teaser		: teaser,
			content		: content
		};

	if( !hasContentPreview )
		$('#contentTmpl').tmpl( contentData ).insertAfter( $ibWrapper );

	//set the returned values and show/animate preview
	$('#ib-content-preview').css({
		width	: $item.width(),
		height	: $item.height(),
		left	: $item.offset().left,
		top		: $item.offset().top
	}).show().animate({
		width	: $(window).width(),
		left	: 0
	}, 500, 'easeOutExpo', function() {

		$(this).animate({
			height	: $(window).height(),
			top		: 0
		}, 400, function() {

			var $this	= $(this),
				$teaser	= $this.find('div.ib-teaser'),
				$content= $this.find('div.ib-content-full'),
				$close	= $this.find('span.ib-close');

			if( hasContentPreview ) {
				$teaser.html( teaser )
				$content.html( content )
			}

			$teaser.show();
			$content.show();
			$close.show();

			if( callback ) callback.call();

		});

	});

	if( !hasContentPreview )
		initContentPreviewEvents();	

},
</pre>
<p>A little helper function for preloading images:</p>
<pre class="brush:js">
// preloads an image
preloadImage				= function( src, callback ) {

	$('&lt;img/&gt;').load(function(){

		if( callback ) callback.call();

	}).attr( 'src', src );

},
</pre>
<p>The next function takes care of loading the events for the large image preview : navigation, close button, and window resize:</p>
<pre class="brush:js">
initImgPreviewEvents		= function() {

	var $preview	= $('#ib-img-preview');

	$preview.find('span.ib-nav-prev').bind('click.ibTemplate', function( event ) {

		navigate( 'prev' );

	}).end().find('span.ib-nav-next').bind('click.ibTemplate', function( event ) {

		navigate( 'next' );

	}).end().find('span.ib-close').bind('click.ibTemplate', function( event ) {

		closeImgPreview();

	});

	//resizing the window resizes the preview image
	$(window).bind('resize.ibTemplate', function( event ) {

		var $largeImg	= $preview.children('img.ib-preview-img'),
			dim			= getImageDim( $largeImg.attr('src') );

		$largeImg.css({
			width	: dim.width,
			height	: dim.height,
			left	: dim.left,
			top		: dim.top
		})

	});

},
</pre>
<p>For the content preview we&#8217;ll also have to load the event for the closing functionality:</p>
<pre class="brush:js">
initContentPreviewEvents	= function() {

	$('#ib-content-preview').find('span.ib-close').bind('click.ibTemplate', function( event ) {

		closeContentPreview();

	});

},
</pre>
<p>Next, we&#8217;ll define the function that takes care of navigating through the large images in fullscreen:</p>
<pre class="brush:js">
// navigate the image items in fullscreen mode
navigate					= function( dir ) {

	if( isAnimating ) return false;

	isAnimating		= true;

	var $preview	= $('#ib-img-preview'),
		$loading	= $preview.find('div.ib-loading-large');

	$loading.show();

	if( dir === 'next' ) {

		( current === imgItemsCount - 1 ) ? current	= 0 : ++current;

	}
	else if( dir === 'prev' ) {

		( current === 0 ) ? current	= imgItemsCount - 1 : --current;

	}

	var $item		= $ibImgItems.eq( current ),
		largeSrc	= $item.children('img').data('largesrc'),
		description	= $item.children('span').text();

	preloadImage( largeSrc, function() {

		$loading.hide();

		//get dimentions for the image, based on the windows size
		var	dim	= getImageDim( largeSrc );

		$preview.children('img.ib-preview-img')
						.attr( 'src', largeSrc )
						.css({
			width	: dim.width,
			height	: dim.height,
			left	: dim.left,
			top		: dim.top
						})
						.end()
						.find('span.ib-preview-descr')
						.text( description );

		$ibWrapper.scrollTop( $item.offset().top )
				  .scrollLeft( $item.offset().left );

		isAnimating	= false;

	});

},
</pre>
<p>The following function is for closing the fullscreen image preview:</p>
<pre class="brush:js">

closeImgPreview				= function() {

	if( isAnimating ) return false;

	isAnimating	= true;

	var $item	= $ibImgItems.eq( current );

	$('#ib-img-preview').find('span.ib-preview-descr, div.ib-nav, span.ib-close')
					.hide()
					.end()
					.animate({
						height	: $item.height(),
						top		: $item.offset().top
						}, 500, 'easeOutExpo', function() {

						$(this).animate({
							width	: $item.width(),
							left	: $item.offset().left
							}, 400, function() {

								$(this).fadeOut(function() {isAnimating	= false;});

						} );

					});

},
</pre>
<p>For the content preview we will also need such a function:</p>
<pre class="brush:js">
// closes the fullscreen content item
closeContentPreview			= function() {

	if( isAnimating ) return false;

	isAnimating	= true;

	var $item	= $ibItems.not('.ib-image').eq( current );

	$('#ib-content-preview').find('div.ib-teaser, div.ib-content-full, span.ib-close')
							.hide()
							.end()
							.animate({
								height	: $item.height(),
								top		: $item.offset().top
							}, 500, 'easeOutExpo', function() {

								$(this).animate({
									width	: $item.width(),
									left	: $item.offset().left
								}, 400, function() {

									$(this).fadeOut(function() {isAnimating	= false;});

								} );

							});

},
</pre>
<p><strong>getImageDim</strong> will get the size of an image and make it centered in fullscreen:</p>
<pre class="brush:js">
getImageDim					= function( src ) {

	var img     	= new Image();
	img.src     	= src;

	var w_w	= $(window).width(),
		w_h	= $(window).height(),
		r_w	= w_h / w_w,
		i_w	= img.width,
		i_h	= img.height,
		r_i	= i_h / i_w,
		new_w, new_h,
		new_left, new_top;

	if( r_w &gt; r_i ) {

		new_h	= w_h;
		new_w	= w_h / r_i;

	}
	else {

		new_h	= w_w * r_i;
		new_w	= w_w;

	}

	return {
		width	: new_w,
		height	: new_h,
		left	: (w_w - new_w) / 2,
		top		: (w_h - new_h) / 2
	};

};
</pre>
<p>And that&#8217;s it! I hope you enjoyed making this template with me and find it useful!</p>
<p><a class="demo" href="http://tympanus.net/Tutorials/DraggableImageBoxesGrid/" target="_blank">View demo</a> <a class="download" href="http://tympanus.net/Tutorials/DraggableImageBoxesGrid/DraggableImageBoxesGrid.zip">Download source</a></p>
<div class="googlead"><!-- wp_ad_camp_1 --></div>
]]></content:encoded>
			<wfw:commentRss>http://tympanus.net/codrops/2011/10/07/draggable-image-boxes-grid/feed/</wfw:commentRss>
		<slash:comments>67</slash:comments>
		</item>
		<item>
		<title>Collective: FullCalendar jQuery plugin</title>
		<link>http://tympanus.net/codrops/2011/01/05/collective-fullcalendar-jquery-plugin/</link>
		<comments>http://tympanus.net/codrops/2011/01/05/collective-fullcalendar-jquery-plugin/#comments</comments>
		<pubDate>Wed, 05 Jan 2011 11:53:18 +0000</pubDate>
		<dc:creator>Community</dc:creator>
				<category><![CDATA[Collective]]></category>
		<category><![CDATA[calendar]]></category>
		<category><![CDATA[draggable]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://tympanus.net/codrops/?p=3257</guid>
		<description><![CDATA[FullCalendar is a jQuery plugin that provides a full-sized, drag &#038; drop calendar. It uses AJAX to fetch events on-the-fly for each month and is easily configured to use your own feed format (an extension is provided for Google Calendar). It is visually customizable and exposes hooks for user-triggered events (like clicking or dragging an [...]]]></description>
			<content:encoded><![CDATA[<p><!-- Digg Digg Disabled --></p>
<p><a href="http://arshaw.com/fullcalendar/"><img src="http://tympanus.net/codrops/wp-content/uploads/2011/01/fullcalendar.gif" alt="" title="fullcalendar" width="580" height="328" class="aligncenter size-full wp-image-3258" /></a></p>
<p>FullCalendar is a jQuery plugin that provides a full-sized, drag &#038; drop calendar. It uses AJAX to fetch events on-the-fly for each month and is easily configured to use your own feed format (an extension is provided for Google Calendar). It is visually customizable and exposes hooks for user-triggered events (like clicking or dragging an event). It is open source and dual licensed under the MIT or GPL Version 2 licenses.</p>
<h3>Source</h3>
<p><a href="http://arshaw.com/fullcalendar/">http://arshaw.com/fullcalendar/</a></p>
<h3>Demo</h3>
<p><a href="http://arshaw.com/js/fullcalendar/demos/agenda-views.html" target="_blank">http://arshaw.com/js/fullcalendar/demos/agenda-views.html</a><br />
<br/></p>
<div class="googlead"><!-- wp_ad_camp_1 --></div>
]]></content:encoded>
			<wfw:commentRss>http://tympanus.net/codrops/2011/01/05/collective-fullcalendar-jquery-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Music Portfolio Template with HTML5 and jQuery</title>
		<link>http://tympanus.net/codrops/2010/07/26/music-portfolio-template/</link>
		<comments>http://tympanus.net/codrops/2010/07/26/music-portfolio-template/#comments</comments>
		<pubDate>Mon, 26 Jul 2010 13:30:41 +0000</pubDate>
		<dc:creator>Mary Lou</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[audio]]></category>
		<category><![CDATA[carousel]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[draggable]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[music]]></category>
		<category><![CDATA[portfolio]]></category>
		<category><![CDATA[template]]></category>

		<guid isPermaLink="false">http://tympanus.net/codrops/?p=2659</guid>
		<description><![CDATA[Today we want to share a music portfolio template with you. The idea is to create an artist portfolio with a discography line up and HTML5 audio player jPlayer. The artist albums are shown using the jCarousel plugin and the user can add song samples to the play list and reorder the songs by dragging [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://tympanus.net/Development/MusicPortfolioTemplate/" target="_blank"><img class="aligncenter size-full wp-image-2661" title="musicportfoliotemplate" src="http://tympanus.net/codrops/wp-content/uploads/2010/07/musicportfoliotemplate.jpg" alt="" width="580" height="315" /></a></p>
<p>Today we want to share a music portfolio template with you. The idea is to create an artist portfolio with a discography line up and HTML5 audio player <a href="http://www.happyworm.com/jquery/jplayer/">jPlayer</a>. The artist albums are shown using the <a href="http://sorgalla.com/jcarousel/">jCarousel plugin</a> and the user can add song samples to the play list and reorder the songs by dragging them.</p>
<p>The samples used are from the talented Ivan Chew at <a href="http://ccmixter.org/people/ramblinglibrarian/profile">ccmixter.org</a>. The original images come from <a href="http://www.flickr.com/photos/rickharris/">Rick Harris at Flickr</a>. All the albums are fictitious and are only shown for demonstration purposes. Any resemblance to existing bands or artists are unintended. </p>
<p>We hope you like this template and find it useful!</p>
<p><a class="demo" href="http://tympanus.net/Development/MusicPortfolioTemplate/" target="_blank">View demo</a><a class="download" href="http://tympanus.net/Development/MusicPortfolioTemplate/MusicPortfolioTemplate.zip">Download source</a></p>
<div id="bsap_1266918" class="bsarocks bsap_af25dfd2f1908889af7a1aa5f4dcbd9e"></div><div style="clear:both;"></div>
]]></content:encoded>
			<wfw:commentRss>http://tympanus.net/codrops/2010/07/26/music-portfolio-template/feed/</wfw:commentRss>
		<slash:comments>83</slash:comments>
		</item>
		<item>
		<title>Latest Tweets Tooltip with jQuery</title>
		<link>http://tympanus.net/codrops/2010/07/20/latest-tweets-tooltip/</link>
		<comments>http://tympanus.net/codrops/2010/07/20/latest-tweets-tooltip/#comments</comments>
		<pubDate>Tue, 20 Jul 2010 16:48:47 +0000</pubDate>
		<dc:creator>cody</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[draggable]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[tooltip]]></category>
		<category><![CDATA[twitter]]></category>

		<guid isPermaLink="false">http://tympanus.net/codrops/?p=2636</guid>
		<description><![CDATA[If you have a news website, it might be interesting for you to allow your users to see the latests tweets about a topic. Here is a jQuery plugin for showing the latest tweets about a certain word or phrase. For this plugin we are using the jQuery Twitter Search Plugin. Words or phrases that [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><a href="http://tympanus.net/Development/LatestTweetsTooltip/" target="_blank"><img class="size-full wp-image-2641 aligncenter" title="LatestTweetsTooltip" src="http://tympanus.net/codrops/wp-content/uploads/2010/07/LatestTweetsTooltip.jpg" alt="" width="580" height="315" /></a></p>
<p>If you have a news website, it might be interesting for you to allow your users to see the latests tweets about a topic. Here is a jQuery plugin for showing the latest tweets about a certain word or phrase. </p>
<p>For this plugin we are using the <a href="http://jquery.malsup.com/twitter/">jQuery Twitter Search Plugin</a>.</p>
<p>Words or phrases that you want to be searched for in Twitter, are wrapped with the following span:</p>
<pre class="brush:xml">&lt;span class="twitter_search"&gt;Some search term&lt;/span&gt;</pre>
<p>The popup box that appears can be dragged and resized. Clicking on the cross will make it disappear. The tweets are constantly being loaded in a predefined time span. This loading stops when the user hovers over the tooltip box.</p>
<p>If you want to configure and restyle the tooltip, you will need to have a look at the configurations of the Twitter Search Plugin. Many parameters can be set here, from style to timings.</p>
<p>You can call the plugin like this:</p>
<pre class="brush:js">$(function() {
	$('#article').find('.twitter_search').twitterpopup();
});</pre>
<p>where #article should be replaced by the ID of your container.</p>
<p><a class="demo" href="http://tympanus.net/Development/LatestTweetsTooltip/" target="_blank">View demo</a><a class="download" href="http://tympanus.net/Development/LatestTweetsTooltip/LatestTweetsTooltip.zip">Download source</a></p>
<div id="bsap_1266918" class="bsarocks bsap_af25dfd2f1908889af7a1aa5f4dcbd9e"></div><div style="clear:both;"></div>
]]></content:encoded>
			<wfw:commentRss>http://tympanus.net/codrops/2010/07/20/latest-tweets-tooltip/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Sliding Checkbox Actions Menu with jQuery</title>
		<link>http://tympanus.net/codrops/2010/05/31/sliding-checkbox-actions-menu-with-jquery/</link>
		<comments>http://tympanus.net/codrops/2010/05/31/sliding-checkbox-actions-menu-with-jquery/#comments</comments>
		<pubDate>Mon, 31 May 2010 17:39:35 +0000</pubDate>
		<dc:creator>Mary Lou</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[checkbox]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[draggable]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[menu]]></category>
		<category><![CDATA[sliding]]></category>
		<category><![CDATA[table]]></category>
		<category><![CDATA[usability]]></category>

		<guid isPermaLink="false">http://tympanus.net/codrops/?p=2310</guid>
		<description><![CDATA[View demoDownload source In this tutorial we will create an actions menu with jQuery that appears when checkboxes are selected. This can be a very helpful UI property since we don&#8217;t force the user to scroll to the place where the actions are &#8211; they just appear whenever the user needs them. Additionally, the user [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://tympanus.net/Tutorials/CheckboxActions/" target="_blank"><img src="http://tympanus.net/codrops/wp-content/uploads/2010/05/checkboxActions.jpg" alt="" title="checkboxActions" width="580" height="315" class="aligncenter size-full wp-image-2311" /></a></p>
<p><a class="demo" href="http://tympanus.net/Tutorials/CheckboxActions/" target="_blank">View demo</a><a class="download" href="http://tympanus.net/Tutorials/CheckboxActions/CheckboxActions.zip">Download source</a></p>
<p>In this tutorial we will create an actions menu with jQuery that appears when checkboxes are selected. This can be a very helpful UI property since we don&#8217;t force the user to scroll to the place where the actions are &#8211;  they just appear whenever the user needs them.</p>
<p>Additionally, the user can drag the actions box to the place that is more practical for him, and the box will always follow when the user scrolls the page. It will also show a count of how many checkboxes were selected. </p>
<p>We will use a table as an example. Usually, actions are placed at the top and the bottom of a table, and that&#8217;s OK if the table is not too big. But since we cannot control the size of the user&#8217;s viewport, it is not guaranteed that the actions are close to the users focus. With this solution we make it very easy for the user to perform certain actions on selected items.</p>
<p>This tutorial got inspired by a similar feature in the mobile version of Gmail. If you open your Gmail account in the Safari browser on the iPhone or iPod Touch, you will notice this little helpful menu.</p>
<p>Let&#8217;s get started.</p>
<div id="bsap_1266918" class="bsarocks bsap_af25dfd2f1908889af7a1aa5f4dcbd9e"></div><div style="clear:both;"></div>
<h3>The Markup</h3>
<p>For the markup we will simply create a table with an ID and some checkboxes in the cells:</p>
<pre class="brush:xml">
&lt;table id="mytable"&gt;
	&lt;tr&gt;
		&lt;td class="check"&gt;
			&lt;input id="check_1" name="check_1" type="checkbox" value="1" /&gt;
		&lt;/td&gt;
		&lt;td&gt;Some Content&lt;/td&gt;
	&lt;/tr&gt;
	&lt;tr&gt;
		&lt;td class="check"&gt;
			&lt;input id="check_2" name="check_2" type="checkbox" value="2" /&gt;
		&lt;/td&gt;
		&lt;td&gt;Some Content&lt;/td&gt;
	&lt;/tr&gt;
&lt;/table&gt;
</pre>
<p>For the actions menu we will have the following markup:</p>
<pre class="brush:xml">
&lt;div id="actionsBox" class="actionsBox"&gt;
	&lt;div id="actionsBoxMenu" class="menu"&gt;
		&lt;span id="cntBoxMenu"&gt;&lt;/span&gt;
		&lt;a class="button box_action"&gt;Archive&lt;/a&gt;
		&lt;a class="button box_action"&gt;Delete&lt;/a&gt;
		&lt;a id="toggleBoxMenu" class="open"&gt;&lt;/a&gt;
		&lt;a id="closeBoxMenu" class="button"&gt;X&lt;/a&gt;
	&lt;/div&gt;
	&lt;div class="submenu" style="display:none;"&gt;
		&lt;a class="first box_action"&gt;Move...&lt;/a&gt;
		&lt;a class="box_action"&gt;Mark as read&lt;/a&gt;
		&lt;a class="box_action"&gt;Mark as unread&lt;/a&gt;
		&lt;a class="last box_action"&gt;Spam&lt;/a&gt;
	&lt;/div&gt;
&lt;/div&gt;
</pre>
<p>The div with the class <strong>submenu</strong> will appear when we click on the a with the ID <strong>toggleBoxMenu</strong>. </p>
<h3>The CSS</h3>
<p>In the following we will take a look at the style for the actions box. We will be using a lot of CSS 3 properties, so if you want this to work in ancient browsers, you will have to adapt this tiny menu by using images.</p>
<p>We will want to hide the whole menu initially. So, the actionsBox div will have the following style:</p>
<pre class="brush:css">
.actionsBox{
    font-size:13px;
    font-family:Helvetica,Arial,Verdana;
    font-style:normal;
    left:50%;
    position:absolute;
    top:-50px;
    opacity:0;
    cursor:move;
}
</pre>
<p>The main menu with the buttons will be styled as follows:</p>
<pre class="brush:css">
.actionsBox .menu{
    color:#47708F;
    width:240px;
    line-height:30px;
    text-shadow:1px 1px 0px #fff;
    padding:7px;
    -moz-border-radius:5px;
    -webkit-border-radius:5px;
    border-radius:5px;
    font-weight:bold;
    border:1px solid #D9EAF2;
    background:#e8f4fa;
    background:
        -webkit-gradient(
        linear,
        left bottom,
        left top,
        color-stop(0.58, rgb(217,234,242)),
        color-stop(0.93, rgb(232,244,250))
        );
    background:
        -moz-linear-gradient(
        center bottom,
        rgb(217,234,242) 58%,
        rgb(232,244,250) 93%
        );
    -moz-box-shadow:1px 1px 3px #999;
    -webkit-box-shadow:1px 1px 3px #999;
    box-shadow:1px 1px 3px #999;
}
</pre>
<p>We are making heavily use of CSS3 here: the gradient, the rounded border, the box and text shadow will all create a beautiful effect that will make the use of images needless.<br />
The buttons, which will be link elements, will have the following style:</p>
<pre class="brush:css">
.actionsBox .menu .button{
    padding:4px 7px;
    border:1px solid #D9EAF2;
    cursor:pointer;
    background:#e8f4fa;
    background:
        -webkit-gradient(
        linear,
        left bottom,
        left top,
        color-stop(0.38, rgb(230,243,249)),
        color-stop(0.88, rgb(245,249,250))
        );
    background:
        -moz-linear-gradient(
        center bottom,
        rgb(230,243,249) 38%,
        rgb(245,249,250) 88%
        );
    -moz-border-radius:5px;
    -webkit-border-radius:5px;
    border-radius:5px;
    -moz-box-shadow:0px 1px 0px #f9f9f9;
    -webkit-box-shadow:0px 1px 0px #f9f9f9;
    box-shadow:0px 1px 0px #f9f9f9;
}
</pre>
<p>With the very light box shadow, we are creating a slightly engraved effect. When we hover, we want the element to get a white background:</p>
<pre class="brush:css">
.actionsBox .menu .button:hover{
    background:#fff;
}
</pre>
<p>The span in the menu is for displaying the number of selected checkboxes:</p>
<pre class="brush:css">
.actionsBox .menu span{
    padding:0px 10px;
}
</pre>
<p>The sub menu will not be displayed initially. We will give it a rounded border at its bottom:</p>
<pre class="brush:css">
.actionsBox .submenu{
    display:none;
    width:120px;
    margin-left:100px;
    top:46px;
    right:10px;
    background:#fff;
    border:1px solid #D9EAF2;
    border-top:none;
    -moz-border-radius:0px 0px 10px 10px;
    -webkit-border-bottom-left-radius:10px;
    -webkit-border-bottom-right-radius:10px;
    border-bottom-left-radius:10px;
    border-bottom-right-radius:10px;
    -moz-box-shadow:0px 1px 4px #ddd;
    -webkit-box-shadow:0px 1px 4px #ddd;
    box-shadow:0px 1px 4px #ddd;
}
.actionsBox .submenu a{
    display:block;
    cursor:pointer;
    padding:10px 15px;
    border-top:1px solid #D9EAF2;
}
</pre>
<p>The last item will also have a rounded border at the bottom:</p>
<pre class="brush:css">
.actionsBox .submenu a.last{
    -moz-border-radius:0px 0px 10px 10px;
    -webkit-border-bottom-left-radius:10px;
    -webkit-border-bottom-right-radius:10px;
    border-bottom-left-radius:10px;
    border-bottom-right-radius:10px;
}
</pre>
<p>And the first item will not have a border at the top:</p>
<pre class="brush:css">
.actionsBox .submenu a.first{
    border-top:none;
}
.actionsBox .submenu a:hover{
    background-color:#f9f9f9;
}
</pre>
<p>The open/close item will have the following style:</p>
<pre class="brush:css">
.actionsBox .menu a.open,
.actionsBox .menu a.closed{
    border:1px solid #D9EAF2;
    padding:4px 17px;
    -moz-border-radius:5px;
    -webkit-border-radius:5px;
    border-radius:5px;
    -moz-box-shadow:0px 1px 0px #f9f9f9;
    -webkit-box-shadow:0px 1px 0px #f9f9f9;
    box-shadow:0px 1px 0px #f9f9f9;
    cursor:pointer;
    opacity:0.6;
    margin-right:5px;
}
.actionsBox .menu a.open{
    background:#fff url(../open.png) no-repeat center center;
}
.actionsBox .menu a.closed{
    background:#fff url(../closed.png) no-repeat center center;
}
.actionsBox .menu a.open:hover,
.actionsBox .menu a.closed:hover{
    opacity:1.0;
}
</pre>
<p>And that&#8217;s the style. Of course, you will have to adapt this if you are going to use this in your web application. In IE you can see that the style stays very simple.</p>
<p>Now, let&#8217;s add the jQuery magic!</p>
<h3>The JavaScript</h3>
<p>First, let&#8217;s include the jQuery script and also the jQuery UI script because we are going to make our little menu draggable. </p>
<p>So, the main idea is to have our menu appear whenever the user checks a checkbox. We also want it to disappear when there are no checkboxes selected and we want to make the menu draggable. Additionally, the menu should follow the user when he scrolls the page.</p>
<p>We will also change the class of the table row to &#8220;selected&#8221; whenever we select a checkbox. (You can check out the style for the table and that class in the ZIP file.)</p>
<p>We add the following function:</p>
<pre class="brush:js">
$(function() {
	/* tells us if we dragged the box */
	var dragged = false;

	/* timeout for moving the box when scrolling the window */
	var moveBoxTimeout;

	/* make the actionsBox draggable */
	$('#actionsBox').draggable({
		start: function(event, ui) {
			dragged = true;
		},
		stop: function(event, ui) {
			var $actionsBox = $('#actionsBox');
			/*
			calculate the current distance from the
			window's top until the element;
			this value is going to be used later on,
			to move the box after we scroll
			 */
			$actionsBox.data('distanceTop',parseFloat($actionsBox.css('top'),10) - $(document).scrollTop());
		}
	});

	/*
	when clicking on an input (checkbox),
	change the class of the table row,
	and show the actions box
	 */
	$('#mytable input[type="checkbox"]').bind('click',function(e) {
		var $this = $(this);
		if($this.is(':checked'))
			$this.parents('tr:first').addClass('selected');
		else
			$this.parents('tr:first').removeClass('selected');
		showActionsBox();
	});

	function showActionsBox(){
		/* number of checked inputs */
		var BoxesChecked = $('#mytable input:checked').length;
		/* update the number of checked inputs */
		$('#cntBoxMenu').html(BoxesChecked);
		/*
		if there is at least one selected, show the BoxActions Menu
		otherwise hide it
		 */
		var $actionsBox = $('#actionsBox');
		if(BoxesChecked &gt; 0){
			/*
			if we didn't drag, then the box stays where it is;
			we know that the position is the document's current top
			plus the previous distance that the box had relative
			to the window's top (distanceTop)
			 */
			if(!dragged)
				$actionsBox.stop(true).animate({
					'top': parseInt(15 + $(document).scrollTop()) + 'px',
					'opacity':'1'
				},500);
			else
				$actionsBox.stop(true).animate({
					'top': parseInt($(document).scrollTop() + $actionsBox.data('distanceTop')) + 'px',
					'opacity':'1'
				},500);
		}
		else{
			$actionsBox.stop(true).animate({
				'top': parseInt($(document).scrollTop() - 50) + 'px',
				'opacity':'0'
			},500,function(){
				$(this).css('left','50%');
				dragged = false;
				/* if the submenu was open we hide it again */
				var $toggleBoxMenu = $('#toggleBoxMenu');
				if($toggleBoxMenu.hasClass('closed')){
					$toggleBoxMenu.click();
				}
			});
		}
	}

	/*
	when scrolling, move the box to the right place
	 */
	$(window).scroll(function(){
		clearTimeout(moveBoxTimeout);
		moveBoxTimeout = setTimeout(showActionsBox,500);
	});

	/* open sub box menu for other actions */
	$('#toggleBoxMenu').toggle(
	function(e){
		$(this).addClass('closed').removeClass('open');
		$('#actionsBox .submenu').stop(true,true).slideDown();
	},
	function(e){
		$(this).addClass('open').removeClass('closed');
		$('#actionsBox .submenu').stop(true,true).slideUp();
	}
);

	/*
	close the actions box menu:
	hides it, and then removes the element from the DOM,
	meaning that it will no longer appear
	 */
	$('#closeBoxMenu').bind('click',function(e){
		$('#actionsBox').animate({
			'top':'-50px',
			'opacity':'0'
		},1000,function(){
			$(this).remove();
		});
	});

	/*
	as an example, for all the actions (className:box_action)
	alert the values of the checked inputs
	 */
	$('#actionsBox .box_action').bind('click',function(e){
		var ids = '';
		$('#mytable input:checked').each(function(e,i){
			var $this = $(this);
			ids += 'id : ' + $this.attr('id') + ' , value : ' + $this.val() + '\n';
		});
		alert('checked inputs:\n'+ids);
	});
});
</pre>
<p>The close button will make the actions box disappear completely. You can change that behavior by adapting the function. You might want that the user gets his menu back after he clicks on more checkboxes. </p>
<p>The last function is an example of how to get the values of the checked items. You can adapt this to suit your needs and to process the checked values further.</p>
<p>And that&#8217;s it! I hope you liked it and find it useful!</p>
<p>P.S.: To fully experience what you can do with this, scroll the page, select some checkboxes and drag the menu. You will see how the menu follows you when you scroll the page again. </p>
<p><a class="demo" href="http://tympanus.net/Tutorials/CheckboxActions/" target="_blank">View demo</a><a class="download" href="http://tympanus.net/Tutorials/CheckboxActions/CheckboxActions.zip">Download source</a></p>
<div class="googlead"><!-- wp_ad_camp_1 --></div>
<div class="partner_section_post"><span>Message from Testking</span>Join <a href="http://www.testkingsite.com/cisco/642-902.html">testking 642-902</a> online web design classes to learn web designing . Download the <a href="http://www.testkingsite.com/cisco/642-813.html">testking 642-813</a>  tutorial and expert <a href="http://www.testkingsite.com/microsoft/70-680.html">testking 70-680</a>  guides to learn about jquery plugins in detail.</div>
]]></content:encoded>
			<wfw:commentRss>http://tympanus.net/codrops/2010/05/31/sliding-checkbox-actions-menu-with-jquery/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Interactive Image Vamp up with jQuery, CSS3 and PHP</title>
		<link>http://tympanus.net/codrops/2010/03/22/interactive-image-vamp-up-with-jquery-css3-and-php/</link>
		<comments>http://tympanus.net/codrops/2010/03/22/interactive-image-vamp-up-with-jquery-css3-and-php/#comments</comments>
		<pubDate>Sun, 21 Mar 2010 23:51:22 +0000</pubDate>
		<dc:creator>Mary Lou</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[draggable]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[resize]]></category>
		<category><![CDATA[rotate]]></category>

		<guid isPermaLink="false">http://tympanus.net/codrops/?p=1682</guid>
		<description><![CDATA[View demoDownload source Today we will show you how to create an online application for giving some funny touches to an image. We will be using jQuery and jQuery UI for dragging and resizing little bling elements like mustaches and glasses. With PHP the image and the bling elements will get merged and the end [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://tympanus.net/Tutorials/ImageVampUp/" target="_blank"><img class="aligncenter size-full wp-image-1692" title="imagevampup" src="http://tympanus.net/codrops/wp-content/uploads/2010/03/imagevampup1.png" alt="" width="580" height="362" /></a></p>
<p><a class="demo" href="http://tympanus.net/Tutorials/ImageVampUp/" target="_blank">View demo</a><a class="download" href="http://tympanus.net/Tutorials/ImageVampUp/ImageVampUp.zip">Download source</a></p>
<p>Today we will show you how to create an online application for giving some funny touches to an <a href="http://www.flickr.com/photos/patdavid/4423579562/in/pool-83823859@N00" target="_blank">image</a>. We will be using jQuery and jQuery UI for dragging and resizing little bling elements like mustaches and glasses. With PHP the image and the bling elements will get merged and the end result can be viewed.</p>
<p>Ok, let&#8217;s get started!</p>
<div id="bsap_1266918" class="bsarocks bsap_af25dfd2f1908889af7a1aa5f4dcbd9e"></div><div style="clear:both;"></div>
<h3>The Markup</h3>
<p>The markup is pretty simple: we have a main container with the objects sidebar, the main image and the tools area:</p>
<pre class="brush:xml">&lt;div id="content"&gt;
	&lt;div id="background" class="background"&gt;
		&lt;img id="obj_0" width="640" height="480" src="background.jpg"/&gt;
	&lt;/div&gt;

	&lt;div id="tools"&gt;
	&lt;/div&gt;

	&lt;div id="objects"&gt;
		&lt;div class="obj_item"&gt;
			&lt;img id="obj_1" width="50" class="ui-widget-content" src="elements/bowtie.png" alt="el"/&gt;
		&lt;/div&gt;
		&lt;div class="obj_item"&gt;
			&lt;img id="obj_2" width="50" class="ui-widget-content" src="elements/mus1.png" alt="el"/&gt;
		&lt;/div&gt;
		&lt;div class="obj_item"&gt;
			&lt;img id="obj_3" width="50" class="ui-widget-content" src="elements/beard.png" alt="el"/&gt;
		&lt;/div&gt;
	&lt;/div&gt;

	&lt;a id="submit"&gt;&lt;span&gt;&lt;/span&gt;&lt;/a&gt;

	&lt;form id="jsonform" action="merge.php" method="POST"&gt;
		&lt;input id="jsondata" name="jsondata" type="hidden" value="" autocomplete="off"&gt;&lt;/input&gt;
	&lt;/form&gt;

&lt;/div&gt;
</pre>
<p>The objects sidebar contains all the draggable elements and the tools area will show a list of all the used elements. In each item we will use a slider to allow the rotation of the respective element. We will also provide a delete icon to remove the element.</p>
<h3>The CSS</h3>
<p>Let&#8217;s start with the styling of the content and the image container:</p>
<pre class="brush:css">#content{
    position:relative;
    width:1105px;
    height:500px;
    margin:40px auto 0px auto;
    background-color:#F9F9F9;
    -moz-border-radius:6px;
    -webkit-border-radius:6px;
    border-radius:6px;
    -moz-box-shadow:0px 0px 8px #ccc;
    -webkit-box-shadow:0px 0px 8px #ccc;
    box-shadow:0px 0px 8px #ccc;
}
.background{
    position:absolute;
    width:640px;
    height:480px;
    top:10px;
    left:215px;
    -moz-box-shadow:0px 0px 3px #bbb;
    -webkit-box-shadow:0px 0px 3px #bbb;
    box-shadow:0px 0px 3px #bbb;
}
</pre>
<p>When using CSS3 properties, make sure that you address them in the browser specific way, since not all browsers implement fully CSS3. Once CSS3 becomes a standard, you will also want to make sure to add the &#8220;real&#8221; CSS3 term.</p>
<p>Let&#8217;s take a look at the style for the left sidebar with the draggable bling images:</p>
<pre class="brush:css">#objects{
    width:210px;
    height:486px;
    top:10px;
    left:10px;
    position:absolute;
}
.obj_item{
    width:70px;
    height:70px;
    float:left;
}
</pre>
<p>The obj_item class will wrap around the draggable and resizable image. The next styles are for the right sidebar where we will have all the used bling images listed:</p>
<pre class="brush:css">#tools{
    width:230px;
    top:8px;
    right:10px;
    position:absolute;
    height:420px;
    overflow-y:scroll;
    overflow-x:hidden;
}
.item{
    border:3px solid #fff;
    background-color:#ddd;
    height:60px;
    position:relative;
    margin:2px 5px 2px 2px;
    -moz-border-radius:3px;
    -webkit-border-radius:3px;
    border-radius:3px;
    -moz-box-shadow:0px 0px 2px #999;
    -webkit-box-shadow:0px 0px 2px #999;
    box-shadow:0px 0px 2px #999;
}
</pre>
<p>The item class defines the style for each element that is currently being used in the main image. Inside of that item there will be a thumbnail, a slider for the rotation, and a little button to remove the element:</p>
<pre class="brush:css">.thumb{
    width:50px;
    height:50px;
    margin:5px;
    float:left;
}
.slider{
    float: left;
    width: 115px;
    margin: 30px 0px 0px 5px;
    background-color:#fff;
    height:10px;
    position:relative;
}
.slider span{
    font-size:10px;
    font-weight:normal;
    margin-top:-25px;
    float:left;
}
.slider span.degrees{
    position:absolute;
    right:-22px;
    top:20px;
    width:20px;
    height:20px;
}
.slider .ui-slider-handle {
    width:10px;
    height:20px;
    outline:none;
}
a.remove{
    width:16px;
    height:16px;
    position:absolute;
    top:0px;
    right:0px;
    background:transparent url(../images/cancel.png) no-repeat top left;
    opacity:0.5;
    cursor:pointer;
}
a.remove:hover{
    opacity:1.0;
}
</pre>
<p>The class .ui-slider-handle comes from the jQuery slider and we can adapt it by defining a style in our stylesheet.</p>
<p>Ok, let&#8217;s get to the serious part: the JavaScript!</p>
<h3>The JavaScript</h3>
<p>The functionality of this app is made up of many elements, so will go step by step through the most important parts. The JavaScript code in the index is commented, so that you can as well understand the steps that are not mentioned here.</p>
<p>The element images that are dropped onto the main image will be stored in the following JSON object:</p>
<pre class="brush:js">var data = {
	"images": [
		{"id" : "obj_0" ,"src" : "background.jpg", "width" : "640", "height" : "480"}
	]
};
</pre>
<p>Every time we drop a new image we insert it into the &#8220;images&#8221; array.</p>
<p>The images are resizable and draggable:</p>
<pre class="brush:js">$('#objects img').resizable({
	handles	: 'se',
	stop	: resizestop
}).parent('.ui-wrapper').draggable({
    revert	: 'invalid'
});
</pre>
<p>The background div, where the main image is inserted is droppable. Each time we drop an element into this container we add it to the JSON data object if it is not there already. The most important parameters added are the width, height, top and left. The last two are calculated based on the difference between the absolute top or left of the container and the draggable object.<br />
If the element was already in the JSON data object, meaning that the user keeps dragging it around, we just update the new top and left in the JSON data object. We also set a new z-index to the dropped element, so that the last one dropped always stays on top. Besides adding to the JSON object we also add a new element to the tools sidebar, where we will be able to rotate the corresponding image and also delete it from the container:</p>
<pre class="brush:js">$('#background').droppable({
	accept	: '#objects div', /* accept only draggables from #objects */
	drop	: function(event, ui) {
		var $this 		= $(this);
		++count_dropped_hits;
		var draggable_elem = ui.draggable;
		draggable_elem.css('z-index',count_dropped_hits);
		/* object was dropped : register it */
		var objsrc 		= draggable_elem.find('.ui-widget-content').attr('src');
		var objwidth 	= parseFloat(draggable_elem.css('width'),10);
		var objheight 	= parseFloat(draggable_elem.css('height'),10);

		/* for top and left we decrease the top and left of the droppable element */
		var objtop		= ui.offset.top - $this.offset().top;
		var objleft		= ui.offset.left - $this.offset().left;

		var objid		= draggable_elem.find('.ui-widget-content').attr('id');
		var index 		= exist_object(objid);
		if(index!=-1) { //if exists update top and left
			data.images[index].top 	= objtop;
			data.images[index].left = objleft;
		}
		else{
			/* register new one */
			var newObject = {
				'id' 		: objid,
				'src' 		: objsrc,
				'width' 	: objwidth,
				'height' 	: objheight,
				'top' 		: objtop,
				'left' 		: objleft,
				'rotation'  : '0'
			};
			data.images.push(newObject);
			/* add object to sidebar*/

			$('&lt;div/&gt;',{
				className	:	'item'
			}).append(
				$('&lt;div/&gt;',{
					className	:	'thumb',
					html		:	'&lt;img width="50" class="ui-widget-content" src="'+objsrc+'"&gt;&lt;/img&gt;'
				})
			).append(
				$('&lt;div/&gt;',{
					className	:	'slider',
					html		:	'&lt;span&gt;Rotate&lt;/span&gt;&lt;span class="degrees"&gt;0&lt;/span&gt;'
				})
			).append(
				$('&lt;a/&gt;',{
					className	:	'remove'
				})
			).append(
				$('&lt;input/&gt;',{
					type		:	'hidden',
					value		:	objid		// keeps track of which object is associated
				})
			).appendTo($('#tools'));
			$('.slider').slider({
				orientation	: 'horizontal',
				max			: 180,
				min			: -180,
				value		: 0,
				slide		: function(event, ui) {
					var $this = $(this);
					/* Change the rotation and register that value in data object when it stops */
					draggable_elem.css({
						'-moz-transform':'rotate('+ui.value+'deg)',
						'-webkit-transform':'rotate('+ui.value+'deg)'
					});
					$('.degrees',$this).html(ui.value);
				},
				stop		: function(event, ui) {
					newObject.rotation = ui.value;
				}
			});
		}
	}
});
</pre>
<p>When removing an element from the container, we want to remove it from the sidebar, from the JSON data object and also add it again to the elements list:</p>
<pre class="brush:js">$('.remove',$('#tools')).live('click',function(){
	var $this = $(this);

	/* the element next to this is the input that stores the obj id */
	var objid = $this.next().val();
	/* remove the object from the sidebar */
	$this.parent().remove();
	/* ,from the picture */
	var divwrapper = $('#'+objid).parent().parent();
	$('#'+objid).remove();
	/* add again to the objects list */
	var image_elem 		= $this.parent().find('img');
	var thumb_width 	= image_elem.attr('width');
	var thumb_height 	= image_elem.attr('height');
	var thumb_src 		= image_elem.attr('src');
	$('<img alt="" />',{
		id 			: 	objid,
		src			: 	thumb_src,
		width		:	thumb_width,
		//height		:	thumb_height,
		className	:	'ui-widget-content'
	}).appendTo(divwrapper).resizable({
		handles	: 'se',
		stop	: resizestop
	}).parent('.ui-wrapper').draggable({
		revert: 'invalid'
	});
	/* and unregister it - delete from object data */
	var index = exist_object(objid);
	data.images.remove(index);
});
</pre>
<h3>The PHP</h3>
<p>What we are doing here is getting all the info for each image dropped into the main container, and merging it with the background image. If there was a rotation then we need to make sure we recalculate the top and left, since the PHP imagerotate function is not that friendly and it scales down the image after rotation:</p>
<pre class="brush:php">$res = JSON_decode(stripslashes($_POST['JSONdata']), true);
/* get data */
$count_images 	= count($res['images']);
/* the background image is the first one */
$background 	= $res['images'][0]['src'];
$photo1 		= imagecreatefromjpeg($background);
$foto1W 		= imagesx($photo1);
$foto1H 		= imagesy($photo1);
$photoFrameW 	= $res['images'][0]['width'];
$photoFrameH 	= $res['images'][0]['height'];
$photoFrame 	= imagecreatetruecolor($photoFrameW,$photoFrameH);
imagecopyresampled($photoFrame, $photo1, 0, 0, 0, 0, $photoFrameW, $photoFrameH, $foto1W, $foto1H);

/* the other images */
for($i = 1; $i &lt; $count_images; ++$i){
	$insert 		= $res['images'][$i]['src'];
	$photoFrame2Rotation = (180-$res['images'][$i]['rotation']) + 180;

	$photo2 		= imagecreatefrompng($insert);

	$foto2W 		= imagesx($photo2);
	$foto2H 		= imagesy($photo2);
	$photoFrame2W	= $res['images'][$i]['width'];
	$photoFrame2H 	= $res['images'][$i]['height'];

	$photoFrame2TOP = $res['images'][$i]['top'];
	$photoFrame2LEFT= $res['images'][$i]['left'];

	$photoFrame2 	= imagecreatetruecolor($photoFrame2W,$photoFrame2H);
	$trans_colour 	= imagecolorallocatealpha($photoFrame2, 0, 0, 0, 127);
	imagefill($photoFrame2, 0, 0, $trans_colour);

	imagecopyresampled($photoFrame2, $photo2, 0, 0, 0, 0, $photoFrame2W, $photoFrame2H, $foto2W, $foto2H);

	$photoFrame2 	= imagerotate($photoFrame2,$photoFrame2Rotation, -1,0);
	/*after rotating calculate the difference of new height/width with the one before*/
	$extraTop		=(imagesy($photoFrame2)-$photoFrame2H)/2;
	$extraLeft		=(imagesx($photoFrame2)-$photoFrame2W)/2;

	imagecopy($photoFrame, $photoFrame2,$photoFrame2LEFT-$extraLeft, $photoFrame2TOP-$extraTop, 0, 0, imagesx($photoFrame2), imagesy($photoFrame2));
}
// Set the content type header - in this case image/jpeg
header('Content-type: image/jpeg');
imagejpeg($photoFrame, $targetfile);
imagedestroy($photoFrame);
</pre>
<p>And that&#8217;s it!<br />
Enjoy!</p>
<p><a class="demo" href="http://tympanus.net/Tutorials/ImageVampUp/" target="_blank">View demo</a><a class="download" href="http://tympanus.net/Tutorials/ImageVampUp/ImageVampUp.zip">Download source</a></p>
<p><!-- wp_ad_camp_1 --></p>
<div class="partner_section_post"><span>Message from Testking</span>Become expert designer/developer with our <a href="http://www.testkingsite.com/eccouncil/312-50.html">testking 312-50</a> course. Download the <a href="http://www.testkingsite.com/citrix/1Y0-A08.html">testking 1Y0-A08</a> tutorials and <a href="http://www.testkingsite.com/cisco/642-415.html">testking 642-415</a> video to learn about jquery css3 and php.</div>
]]></content:encoded>
			<wfw:commentRss>http://tympanus.net/codrops/2010/03/22/interactive-image-vamp-up-with-jquery-css3-and-php/feed/</wfw:commentRss>
		<slash:comments>44</slash:comments>
		</item>
		<item>
		<title>jQuery Fancy Draggable Captcha</title>
		<link>http://tympanus.net/codrops/2009/09/08/jquery-fancy-draggable-captcha/</link>
		<comments>http://tympanus.net/codrops/2009/09/08/jquery-fancy-draggable-captcha/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 21:17:31 +0000</pubDate>
		<dc:creator>cody</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[captcha]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSS3]]></category>
		<category><![CDATA[draggable]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[registration]]></category>

		<guid isPermaLink="false">http://tympanus.net/codrops/?p=350</guid>
		<description><![CDATA[Here is a jQuery example for a captcha in a registration form. In order to pass the &#8220;Are you human&#8221; test, the user has to drag the numbers from 1 to 6 into order. Here you can download the source as a ZIP file:  Captcha ZIP DEMO]]></description>
			<content:encoded><![CDATA[<p>Here is a jQuery example for a captcha in a registration form. In order to pass the &#8220;Are you human&#8221; test, the user has to drag the numbers from 1 to 6 into order.</p>
<div id="attachment_351" class="wp-caption alignnone" style="width: 595px"><a href="http://tympanus.net/codrops/wp-content/uploads/2009/09/captcha/captcha.html" target="_blank"><img class="size-full wp-image-351" title="jQuery draggable captcha" src="http://tympanus.net/codrops/wp-content/uploads/2009/09/screenshot.gif" alt="Click to see a demo" width="585" height="189" /></a><p class="wp-caption-text">Click to see a demo</p></div>
<p>Here you can download the source as a ZIP file:  <a href="http://tympanus.net/codrops/wp-content/uploads/2009/09/captcha/captcha.zip">Captcha ZIP</a></p>
<p><a href="http://tympanus.net/codrops/wp-content/uploads/2009/09/captcha/captcha.html" target="_blank">DEMO</a></p>
<p><div id="bsap_1266918" class="bsarocks bsap_af25dfd2f1908889af7a1aa5f4dcbd9e"></div><div style="clear:both;"></div><br />
<br/><br/><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://tympanus.net/codrops/2009/09/08/jquery-fancy-draggable-captcha/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>
<!-- This Quick Cache file was built for (  tympanus.net/codrops/tag/draggable/feed/ ) in 0.27689 seconds, on Feb 8th, 2012 at 5:30 pm UTC. -->
<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on Feb 8th, 2012 at 6:30 pm UTC -->
