<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Tutorialzine</title>
	
	<link>http://tutorialzine.com</link>
	<description>PHP MySQL jQuery CSS Tutorials, Resources and Freebies</description>
	<lastBuildDate>Tue, 09 Mar 2010 22:58:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Tutorialzine" /><feedburner:info uri="tutorialzine" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>Tutorialzine</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>Making a Mosaic Slideshow With jQuery &amp; CSS</title>
		<link>http://feedproxy.google.com/~r/Tutorialzine/~3/0GM-mbwkGBs/</link>
		<comments>http://tutorialzine.com/2010/03/mosaic-slideshow-jquery-css/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 22:58:03 +0000</pubDate>
		<dc:creator>Martin Angelov</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://tutorialzine.com/?p=763</guid>
		<description><![CDATA[Today we are making a jQuery &#038; CSS mosaic gallery, which will feature an interesting tile transition effect when moving from one slide to another.]]></description>
			<content:encoded><![CDATA[<p>When designing a product page, it is often necessary to present a number of images in a succession, also known as a slideshow. With the raise of the jQuery library and its numerous plugins, there is an abundance of ready-made solutions which address this problem. However, to make a lasting impression to your visitors, you need to present them with something they have not seen before.</p>
<p>Today we are making a jQuery &amp; CSS mosaic gallery. Mosaic, because it will feature an interesting tile transition effect when moving from one slide to another.</p>
<h3>Step 1 &#8211; XHTML</h3>
<p>The mosaic effect of the slideshow is achieved by dividing the original image into smaller parts. These tiles, which contain parts of the image, are sequentially hidden from view, which causes the effect. The markup of the slideshow is pretty straightforward. It consists of the main slideshow container element (<strong>#mosaic-slideshow</strong>), a left and right arrow for previous and next transition and the mosaic-slide div, which is inserted by jQuery at run-time.</p>
<h4>demo.html</h4>
<pre class="brush:html">&lt;div id="mosaic-slideshow"&gt;
	&lt;div class="arrow left"&gt;&lt;/div&gt;
	&lt;div class="arrow right"&gt;&lt;/div&gt;

	&lt;div class="mosaic-slide" style="z-index: 10;"&gt;

		&lt;!-- The mosaic-slide div and the tiles are generated by jQuery --&gt;
		&lt;div class="tile" style="..."&gt;&lt;/div&gt;
		&lt;div class="tile" style="..."&gt;&lt;/div&gt;
		&lt;div class="tile" style="..."&gt;&lt;/div&gt;
		&lt;div class="tile" style="..."&gt;&lt;/div&gt;

	&lt;/div&gt;
&lt;/div&gt;</pre>
<p>The div with the <strong>mosaic-slide</strong> class name is added to the page by jQuery after the<strong> transition()</strong> JavaScript function is executed (we will come back to this in the third step). Inside it you can see the <strong>tile </strong>divs. There are a total of 56 such divs, each of which has a 60px by 60px portion of the slide image set as its background.</p>
<div id="attachment_766" class="wp-caption alignnone" style="width: 630px"><a href="http://tutorialzine.com/wp-content/uploads/2010/03/i1.jpg"><img class="size-full wp-image-766" title="Mosaic Slideshow" src="http://tutorialzine.com/wp-content/uploads/2010/03/i1.jpg" alt="Mosaic Slideshow" width="620" height="460" /></a><p class="wp-caption-text">Mosaic Slideshow</p></div>
<h3>Step 2 &#8211; CSS</h3>
<p>To make this effect work (and most importantly look good), we have to add a few lines of CSS. Only the code directly used by the gallery is shown here. You can see the code that styles the rest of the demonstration page in <strong>styles.css</strong>.</p>
<h4>styles.css &#8211; Part 1</h4>
<pre class="brush:css">#mosaic-slideshow{
	/* The slideshow container div */
	height:500px;
	margin:0 auto;
	position:relative;
	width:670px;
}

.mosaic-slide{
	/* This class is shared between all the slides */
	left:80px;
	position:absolute;
	top:25px;

	border:10px solid #555;

	/* CSS3 rounded corners */
	-moz-border-radius:20px;
	-webkit-border-radius:20px;
	border-radius:20px;
}

.tile{
	/* The individual tiles */
	height:60px;
	width:60px;
	float:left;
	border:1px solid #555;
	border-width:0 1px 1px 0;
	background-color:#555;
}
</pre>
<p>The slideshow is contained inside the div with an ID of <strong>mosaic-slideshow</strong> (or #mosaic-slideshow, if we refer to it in a form of a CSS / jQuery selector).  There can be only one such div in the page, hence the use of an ID attribute.</p>
<p>However there can be more than one <strong>mosaic-slide</strong> divs in the page. The effect itself is achieved by stacking two slides on top of each other and hiding the tiles of the first one to reveal the ones of the second. This is why we are using a class name instead of an ID.</p>
<p>Some of the more interesting rules presented here are the three CSS3 rules for rounded corners. As the CSS3 standard is still a work in progress, browsers don&#8217;t support the regular <strong>border-radius </strong>property yet (except for the new 10.50 version of Opera), and need vendor-specific prefixes to recognize it. The<strong> -moz-</strong> prefix is used by Firefox, and <strong>-webkit-</strong> is used by Safari and Chrome.</p>
<h4>styles.css &#8211; Part 2</h4>
<pre class="brush:css">.arrow{
	/* The prev/next arrows */
	width:35px;
	height:70px;
	background:url("img/arrows.png") no-repeat;
	position:absolute;
	cursor:pointer;
	top:50%;
	margin-top:-35px;
}

.arrow.left{
	left:15px;
	background-position:center top;
}

.arrow.left:hover{
	background-position:center -70px;
}

.arrow.right{
	right:15px;
	background-position:center -140px;
}

.arrow.right:hover{
	background-position:center -210px;
}

.clear{
	/* This class clears the floats */
	clear:both;
}</pre>
<p>The <strong>arrow</strong> class is shared by the previous and next arrows. They do need individual styling in addition to this common rule, so we add it after this. We are also using a CSS sprite as the background for the arrow divs. It contains a regular and hover state for both arrows, which spares us from having to use four individual images.</p>
<blockquote><p>&#8220;<strong>CSS spriting</strong>&#8221; is a widespread technique used by web designers. It allows the designer to join multiple smaller images into a single larger one, called a sprite, which is downloaded faster and saves the web server from multiple download requests. After this, the designer can use the CSS background property in conjunction with setting the elements to a fixed size, to show only the part of the sprite image that they need.</p></blockquote>
<div id="attachment_767" class="wp-caption alignnone" style="width: 630px"><a href="http://tutorialzine.com/wp-content/uploads/2010/03/i2.jpg"><img class="size-full wp-image-767" title="Mosaic Slideshow" src="http://tutorialzine.com/wp-content/uploads/2010/03/i2.jpg" alt="Mosaic Slideshow" width="620" height="260" /></a><p class="wp-caption-text">Mosaic Slideshow</p></div>
<h3>Step 3 &#8211; jQuery</h3>
<p>After including the jQuery library to the page, we can move on to creating the script that will make the slideshow tick. To achieve the mosaic effect, the script defines 4 functions:</p>
<ul>
<li><strong>transition()</strong> &#8211; this function makes an animated transition between the currently shown slide, and a new one specified by the id parameter. It works by positioning the new slide we want to show, below the current one, and then hiding the current one one tile at a time;</li>
<li><strong>generateGrid()</strong> &#8211; this function is used by transition() to generate a grid of tiles. Each tile contains a part of the slide image as its background;</li>
<li><strong>next()</strong> &#8211; detects which the next slide is and runs the transition() function with its index;</li>
<li><strong>prev()</strong> &#8211; analogous to next().</li>
</ul>
<h4>script.js &#8211; Part 1</h4>
<pre class="brush:js">/* The slide images are contained in the slides array. */
var slides = new Array('img/slide_1.jpg',
					   'img/slide_2.jpg',
					   'img/slide_3.jpg',
					   'img/slide_4.jpg',
					   'img/slide_5.jpg');

$(document).ready(function(){
	/* This code is executed after the DOM has been completely loaded */

	$('.arrow.left').click(function(){
		prev();

		/* Clearing the autoadvance if we click one of the arrows */
		clearInterval(auto);
	});

	$('.arrow.right').click(function(){
		next();
		clearInterval(auto);
	});

	/* Preloading all the slide images: */

	for(var i=0;i&lt;slides.length;i++)
	{
		(new Image()).src=slides[i];
	}

	/* Showing the first one on page load: */
	transition(1);

	/* Setting auto-advance every 10 seconds */

	var auto;

	auto=setInterval(function(){
		next();
	},10*1000);
});</pre>
<p>The <strong>$(document).ready()</strong> method is executed once the page has finished loading. This will ensure that all the divs and other elements are accessible to the script. Inside it we bind a function for the click event on the previous and next arrows, preload all the images, show the first slide (otherwise the slideshow would be empty) and set up the auto-advance interval.</p>
<h4>script.js &#8211; Part 2</h4>
<pre class="brush:js">var current = {};
function transition(id)
{
	/* This function shows the slide specified by the id. */

	if(!slides[id-1]) return false;

	if(current.id)
	{
		/* If the slide we want to show is currently shown: */
		if(current.id == id) return false;

		/* Moving the current slide layer to the top: */
		current.layer.css('z-index',10);

		/* Removing all other slide layers that are positioned below */
		$('.mosaic-slide').not(current.layer).remove();
	}

	/* Creating a new slide and filling it with generateGrid: */
	var newLayer = $('&lt;div class="mosaic-slide"&gt;').html(generateGrid({rows:7,cols:8,image:slides[id-1]}));

	/* Moving it behind the current slide: */
	newLayer.css('z-index',1);

	$('#mosaic-slideshow').append(newLayer);

	if(current.layer)
	{
		/* Hiding each tile of the current slide, exposing the new slide: */
		$('.tile',current.layer).each(function(i){
			var tile = $(this);
			setTimeout(function(){
				tile.css('visibility','hidden');
			},i*10);
		})
	}

	/* Adding the current id and newLayer element to the current object: */
	current.id = id;
	current.layer = newLayer;
}
</pre>
<p>The transition function uses the global <strong>current</strong> object to store the id of the currently shown slide, and a reference to the current slide div. This is later used to remove leftover slides and prevent a transition from occurring if the same slide as the currently active one is to be shown.</p>
<p>Notice how we use the each method on line 31 to loop through the tiles of the current slide and schedule them to be hidden in <strong>i*10 milliseconds</strong> in the future. As <strong>i</strong> is incremented for every tile, this mean that they are hidden 10 milliseconds apart from one another.</p>
<div id="attachment_768" class="wp-caption alignnone" style="width: 630px"><a href="http://tutorialzine.com/wp-content/uploads/2010/03/i31.png"><img class="size-full wp-image-768" title="Slide Transition" src="http://tutorialzine.com/wp-content/uploads/2010/03/i31.png" alt="Slide Transition" width="620" height="460" /></a><p class="wp-caption-text">Slide Transition</p></div>
<h4>script.js – Part 3</h4>
<pre class="brush:js">function next()
{
	if(current.id)
	{
		transition(current.id%slides.length+1);
	}
}

function prev()
{
	if(current.id)
	{
		transition((current.id+(slides.length-2))%slides.length+1);
	}

}

/* Width and height of the tiles in pixels: */
var tabwidth=60, tabheight=60;

function generateGrid(param)
{
	/* This function generates the tile grid, with each tile containing a part of the slide image */

	/* Creating an empty jQuery object: */
	var elem = $([]),tmp;

	for(var i=0;i&lt;param.rows;i++)
	{
		for(var j=0;j&lt;param.cols;j++)
		{
			tmp = $('&lt;div&gt;', {
					"class":"tile",
					"css":{
						"background":'#555 url('+param.image+') no-repeat '+(-j*tabwidth)+'px '+(-i*tabheight)+'px'
					}
			});

			/* Adding the tile to the jQuery object: */
			elem = elem.add(tmp);
		}

		/* Adding a clearing element at the end of each line. This will clearly divide the divs into rows: */
		elem = elem.add('&lt;div class="clear"&gt;&lt;/div&gt;');
	}

	return elem;
}</pre>
<p>The parameter passed to <strong>generateGrid()</strong> is an object containing the rows and the columns we want to be generated, as well as the image to be set as the background of the tiles. While generating the tiles, the background image is offset according to the current position of the tile in the row and in the column. Finally the tile is added to an empty jQuery object which is returned at the end.</p>
<p><strong>With this the mosaic slideshow is complete!</strong></p>
<h3>Wrapping it up</h3>
<p>Today we created a slideshow with an animated mosaic transition effect. You can modify it to include a different number of rows and columns or change the way slides are changed entirely.</p>
<p><strong>What do you think? How would you use this slideshow?</strong></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=0GM-mbwkGBs:fbY3IRJyoYE:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=0GM-mbwkGBs:fbY3IRJyoYE:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=0GM-mbwkGBs:fbY3IRJyoYE:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=0GM-mbwkGBs:fbY3IRJyoYE:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=0GM-mbwkGBs:fbY3IRJyoYE:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=0GM-mbwkGBs:fbY3IRJyoYE:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=0GM-mbwkGBs:fbY3IRJyoYE:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=0GM-mbwkGBs:fbY3IRJyoYE:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=0GM-mbwkGBs:fbY3IRJyoYE:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=0GM-mbwkGBs:fbY3IRJyoYE:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Tutorialzine/~4/0GM-mbwkGBs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tutorialzine.com/2010/03/mosaic-slideshow-jquery-css/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://tutorialzine.com/2010/03/mosaic-slideshow-jquery-css/</feedburner:origLink></item>
		<item>
		<title>MicroTut: Centering a Div Both Horizontally And Vertically</title>
		<link>http://feedproxy.google.com/~r/Tutorialzine/~3/cbm8i950hMk/</link>
		<comments>http://tutorialzine.com/2010/03/centering-div-vertically-and-horizontally/#comments</comments>
		<pubDate>Fri, 05 Mar 2010 17:27:57 +0000</pubDate>
		<dc:creator>Martin Angelov</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[MicroTuts]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://tutorialzine.com/?p=741</guid>
		<description><![CDATA[In this MicroTut, we are going to take a look at a couple of ways to center a div both horizontally and vertically with pure CSS. A jQuery method is also presented.]]></description>
			<content:encoded><![CDATA[<p>While building web page layouts, you&#8217;ve probably been faced with a situation where you need to center a div both horizontally and vertically with pure CSS. There are more than a few ways to achieve this, and in this MicroTut I am going to show you my favorite involving CSS and jQuery.</p>
<p>But first, the basics:</p>
<h3>Horizontal centering with CSS</h3>
<p>It is as easy as applying a margin to a div:</p>
<pre class="brush:css">.className{
	margin:0 auto;
	width:200px;
	height:200px;
}
</pre>
<p>To center a div only horizontally, you need to specify a width, and an <strong>auto</strong> value for the <strong>left and right margins</strong> (you do remember the shorthand declarations in CSS don&#8217;t you?). This method works on block level elements (divs, paragraphs, h1, etc). To apply it to inline elements (like hyperlinks and images), you need to apply one additional rule &#8211; <strong>display:block</strong>.</p>
<h3>Horizontal and vertical centering with CSS</h3>
<p>Center a div both horizontally and vertically with CSS is a bit more tricky. You need to know the dimensions of the div beforehand.</p>
<pre class="brush:css">.className{
	width:300px;
	height:200px;
	position:absolute;
	left:50%;
	top:50%;
	margin:-100px 0 0 -150px;
}
</pre>
<p>By positioning the element <strong>absolutely</strong>, we can detach it from its surroundings and specify its position in relation to the browser window. Offsetting the div by <strong>50%</strong> from the left and the top part of the window, you have its upper-left corner precisely at the center of the page. The only thing we are left to do is to move the div to the <strong>left</strong> and to the <strong>top</strong> with <strong>half</strong> its width and height with a negative margin, to have it perfectly centered.</p>
<h3>Horizontal and vertical centering with jQuery</h3>
<p>As mentioned earlier &#8211; the CSS method only works with divs with fixed dimensions. This is where jQuery comes into play:</p>
<pre class="brush:js">$(window).resize(function(){

	$('.className').css({
		position:'absolute',
		left: ($(window).width() - $('.className').outerWidth())/2,
		top: ($(window).height() - $('.className').outerHeight())/2
	});

});

// To initially run the function:
$(window).resize();
</pre>
<p>The functionality is inserted into a <strong>$(window).resize()</strong> statement, which is executed every time the window is resized by the user. We use <strong>outerWidth()</strong> and <strong>outerHeight()</strong>, because unlike from the regular <strong>width()</strong> and <strong>height()</strong>, they add the padding and the border width to the returned size. Lastly, we simulate a resize event to kick center the div on page load.</p>
<p>The benefit of using this method, is that you do not need to know how big the div is. The main disadvantage is that it will only work with JavaScript turned on. This however makes it perfect for rich user interfaces (such as facebook&#8217;s).</p>
<p><strong>Be sure to share your favorite methods in the comment section.</strong></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=cbm8i950hMk:IJKMgN--nbA:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=cbm8i950hMk:IJKMgN--nbA:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=cbm8i950hMk:IJKMgN--nbA:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=cbm8i950hMk:IJKMgN--nbA:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=cbm8i950hMk:IJKMgN--nbA:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=cbm8i950hMk:IJKMgN--nbA:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=cbm8i950hMk:IJKMgN--nbA:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=cbm8i950hMk:IJKMgN--nbA:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=cbm8i950hMk:IJKMgN--nbA:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=cbm8i950hMk:IJKMgN--nbA:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Tutorialzine/~4/cbm8i950hMk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tutorialzine.com/2010/03/centering-div-vertically-and-horizontally/feed/</wfw:commentRss>
		<slash:comments>16</slash:comments>
		<feedburner:origLink>http://tutorialzine.com/2010/03/centering-div-vertically-and-horizontally/</feedburner:origLink></item>
		<item>
		<title>“Who Is Online” Widget With PHP, MySQL &amp; jQuery</title>
		<link>http://feedproxy.google.com/~r/Tutorialzine/~3/vnBj9LFMVBk/</link>
		<comments>http://tutorialzine.com/2010/03/who-is-online-widget-php-mysql-jquery/#comments</comments>
		<pubDate>Tue, 02 Mar 2010 22:37:22 +0000</pubDate>
		<dc:creator>Martin Angelov</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://tutorialzine.com/?p=744</guid>
		<description><![CDATA[We are making a "Who is online" widget with PHP, MySQL &#038; jQuery. It will display the number of visitors, currently viewing your site, and a list of countries they are from in a slide out panel.]]></description>
			<content:encoded><![CDATA[<p>For this week&#8217;s tutorial, we are taking a look at our ever-so-interesting inbox. It all started with a letter from one of our readers a couple of weeks ago:</p>
<blockquote><p>My boss is always coming into my office asking me to install things on our client&#8217;s sites. One of the items that&#8217;s been coming up more and more is &#8220;How can we tell who&#8217;s currently online?&#8221;  So, the next time you need a tutorial idea, there you go &#8211; a php/mysql/jquery &#8216;online users&#8217; widget. Oh, and a geomap of each visitor would be super rad too.</p>
<p>Thanks for everything you guys do,<br />
Taylor</p></blockquote>
<p>Taylor, we are always happy when we receive good tutorial ideas, so today we are doing just that &#8211; a &#8220;<strong>Who is online</strong>&#8221; widget with PHP, MySQL &amp; jQuery. It will display the number of visitors, currently viewing your site, and thanks to <a href="http://www.hostip.info/" target="_blank">Hostip&#8217;s free IP to location API</a>, it will even be able to detect the country your visitors are from and display it in a slide out panel.</p>
<h3>Step 1 &#8211; XHTML</h3>
<p>As usual, we start off with the XHTML part. The code presented here might not look like much, but it is all that we need to show off all the work that has been done by the backend. The widget features a slick slide-out panel with all the geolocation data, shown on mouse over.</p>
<h4>demo.html</h4>
<pre class="brush:html">&lt;div class="onlineWidget"&gt;

&lt;div class="panel"&gt;

	&lt;!-- Fetched with AJAX: --&gt;

	&lt;div class="geoRow"&gt;
	&lt;div class="flag"&gt;&lt;img src="who-is-online/img/famfamfam-countryflags/us.gif" width="16" height="11"&gt;&lt;/div&gt;
	&lt;div class="country" title="UNITED STATES"&gt;UNITED STATES&lt;/div&gt;
	&lt;div class="people"&gt;2&lt;/div&gt;
	&lt;/div&gt;

	&lt;div class="geoRow"&gt;
	&lt;div class="flag"&gt;&lt;img src="who-is-online/img/famfamfam-countryflags/uk.gif" width="16" height="11"&gt;&lt;/div&gt;
	&lt;div class="country" title="UNITED KINGDOM"&gt;UNITED KINGDOM&lt;/div&gt;
	&lt;div class="people"&gt;1&lt;/div&gt;
	&lt;/div&gt;

&lt;/div&gt;

&lt;div class="count"&gt;8&lt;/div&gt;
&lt;div class="label"&gt;online&lt;/div&gt;
&lt;div class="arrow"&gt;&lt;/div&gt;
&lt;/div&gt;
</pre>
<p>As you may see from the markup above, the main container div &#8211; &#8220;<strong>onlineWidget</strong>&#8221; contains the slide-out panel (the div with class name &#8220;<strong>panel</strong>&#8220;), the total number of people online (the &#8220;<strong>count</strong>&#8221; div), the &#8220;<strong>online</strong>&#8221; label and the green arrow to the right.</p>
<div id="attachment_750" class="wp-caption alignnone" style="width: 630px"><a href="http://tutorialzine.com/wp-content/uploads/2010/03/i1.png"><img class="size-full wp-image-750" title="Geolocation-enabled Who Is Online Widget" src="http://tutorialzine.com/wp-content/uploads/2010/03/i1.png" alt="Geolocation-enabled Who Is Online Widget" width="620" height="460" /></a><p class="wp-caption-text">Geolocation-enabled Who Is Online Widget</p></div>
<p>The panel div is dynamically filled by AJAX with the countries with the most visitors currently online. The default content of this div is a rotating gif preloader, which is replaced with the geo data once the AJAX request is complete (usually in less than a second). We will come back to this in a moment.</p>
<h3>Step 2 &#8211; The Database</h3>
<p>Unlike the usual routine, here we are going to take a look at how the database is structured, as it is fundamental to the rest of the script.</p>
<p>All of the widget data is stored into the <strong>tz_who_is_online</strong> table. It consists of six fields (or columns). The first one &#8211; ID, is a standard primary key / auto increment field. After this is the IP field which stores the visitor&#8217;s IP address (converted to a integer beforehand with the <strong>ip2long</strong> PHP function).</p>
<p>After this are three fields fetched by Hostip&#8217;s API -<strong> Country, CountryCode</strong> and <strong>City</strong>. The widget is not using the city field at this point, but it is good to have in case somebody wants to implement it. Last is the <strong>DT</strong> timestamp field, which is updated on every page load and enables us to track who is online (users without a page load in the last 10 minutes have probably left the site).</p>
<div id="attachment_749" class="wp-caption alignnone" style="width: 630px"><a href="http://tutorialzine.com/wp-content/uploads/2010/03/i3.png"><img class="size-full wp-image-749" title="Table Structure Of tz_who_is_online" src="http://tutorialzine.com/wp-content/uploads/2010/03/i3.png" alt="Table Structure Of tz_who_is_online" width="620" height="260" /></a><p class="wp-caption-text">Table Structure Of tz_who_is_online</p></div>
<h3>Step 3 &#8211; CSS</h3>
<p>The widget is (almost) image free, and is only styled with CSS. Lets take a look at the styling, as defined in <strong>styles.css</strong>. The code is divided in two parts, so it is easier to follow.</p>
<h4>who-is-online/styles.css &#8211; Part 1</h4>
<pre class="brush:css">.onlineWidget,.panel{

	/* Styling the widget and the sliding panel at once */

	background-color:#F9F9F9;
	border:2px solid #FFFFFF;
	height:25px;
	padding:4px 8px;
	position:relative;
	width:130px;

	cursor:pointer;

	/* CSS3 rules for rounded corners, box and text shadows: */

	-moz-border-radius:6px;
	-webkit-border-radius:6px;
	border-radius:6px;

	-moz-box-shadow:0 0 3px #CCCCCC;
	-webkit-box-shadow:0 0 3px #CCCCCC;
	box-shadow:0 0 3px #CCCCCC;

	text-shadow:0 2px 0 white;
}

.onlineWidget:hover{
	background-color:#fcfcfc;
}

.onlineWidget:hover .arrow{
	/* Changing the background image for the green arrow on hover: */
	background-position:bottom center;
}

.count{
	/* The total number of people online div */

	color:#777777;
	float:left;
	font-size:26px;
	font-weight:bold;
	margin-top:-3px;
	text-align:center;
	width:30px;
}

.label{
	/* The online label */

	float:left;
	font-size:10px;
	padding:7px 0 0 7px;
	text-transform:uppercase;
}</pre>
<p>In the first step above, you can see that we style the <strong>widget</strong> and the <strong>slide-out panel</strong> at once. This is to ensure that they have consistent styling which is easy to change later on. Some rules are unique to the panel, however, so we include a individually targeted set of rules in the second part of the code.</p>
<p>We also define the hover state and style the <strong>label</strong> and <strong>count</strong> divs.</p>
<h4>who-is-online/styles.css &#8211; Part 2</h4>
<pre class="brush:css">.arrow{
	/* The green arrow on the right */

	background:url(img/arrow.png) no-repeat top center;
	position:absolute;
	right:6px;

	width:25px;
	height:25px;
}

.panel{
	/* The slideout panel */

	position:absolute;
	cursor:default;

	bottom:50px;
	left:0;
	height:auto;
	display:none;
	margin:-2px;
	z-index:1000;
}

.preloader{
	/* The rotating gif preloader image */
	display:block;
	margin:10px auto;
}

.geoRow{
	/* The div that contains each country */

	height:16px;
	overflow:hidden;
	padding:2px 0;
}

.flag{
	float:left;
	margin:0 4px;
}

.country, .people{
	float:left;
	font-size:10px;
	padding:2px;
}

.country{
	width:85px;
	overflow:hidden;
}

.people{
	font-weight:bold;
}</pre>
<p>In the second part of the file, we style the how the geolocation data that is presented in the slide-out panel, after jQuery fetches it from the back-end. With this we can continue with the next step.</p>
<div id="attachment_751" class="wp-caption alignnone" style="width: 630px"><a href="http://tutorialzine.com/wp-content/uploads/2010/03/i2.png"><img class="size-full wp-image-751" title="CSS3 &amp; jQuery Front End" src="http://tutorialzine.com/wp-content/uploads/2010/03/i2.png" alt="CSS3 &amp; jQuery Front End" width="620" height="260" /></a><p class="wp-caption-text">CSS3 &amp; jQuery Front End</p></div>
<h3>Step 4 &#8211; PHP</h3>
<p>This is where the magic happens. PHP has to keep the database of online users up to date and fetch IP-to-location data from <strong>Hostip&#8217;s API</strong>. This is later cached for future use in a cookie on the visitors PC.</p>
<h4>who-is-online/online.php</h4>
<pre class="brush:php">require "connect.php";
require "functions.php";

// We don't want web bots altering our stats:
if(is_bot()) die();

$stringIp = $_SERVER['REMOTE_ADDR'];
$intIp = ip2long($stringIp);

// Checking wheter the visitor is already marked as being online:
$inDB = mysql_query("SELECT 1 FROM tz_who_is_online WHERE ip=".$intIp);

if(!mysql_num_rows($inDB))
{
	// This user is not in the database, so we must fetch
	// the geoip data and insert it into the online table:

	if($_COOKIE['geoData'])
	{
		// A "geoData" cookie has been previously set by the script, so we will use it

		// Always escape any user input, including cookies:
		list($city,$countryName,$countryAbbrev) = explode('|',mysql_real_escape_string(strip_tags($_COOKIE['geoData'])));
	}
	else
	{
		// Making an API call to Hostip:

		$xml = file_get_contents('http://api.hostip.info/?ip='.$stringIp);

		$city = get_tag('gml:name',$xml);
		$city = $city[1];

		$countryName = get_tag('countryName',$xml);
		$countryName = $countryName[0];

		$countryAbbrev = get_tag('countryAbbrev',$xml);
		$countryAbbrev = $countryAbbrev[0];

		// Setting a cookie with the data, which is set to expire in a month:
		setcookie('geoData',$city.'|'.$countryName.'|'.$countryAbbrev, time()+60*60*24*30);
	}

	$countryName = str_replace('(Unknown Country?)','UNKNOWN',$countryName);

	mysql_query("	INSERT INTO tz_who_is_online (ip,city,country,countrycode)
					VALUES(".$intIp.",'".$city."','".$countryName."', '".$countryAbbrev."')");
}
else
{
	// If the visitor is already online, just update the dt value of the row:
	mysql_query("UPDATE tz_who_is_online SET dt=NOW() WHERE ip=".$intIp);
}

// Removing entries not updated in the last 10 minutes:
mysql_query("DELETE FROM tz_who_is_online WHERE dt&lt;SUBTIME(NOW(),'0 0:10:0')");

// Counting all the online visitors:
list($totalOnline) = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM tz_who_is_online"));

// Outputting the number as plain text:
echo $totalOnline;</pre>
<p>This PHP script is initially called by jQuery in order to populate the count div with the current number of people online. Behind the scenes, however, this script writes the visitor&#8217;s IP to the database and resolves their IP-to-location data.</p>
<p>This is the best strategy in organizing the back-end, as we keep the calls to the API (which are quite time expensive) distributed to each user as they visit the site for the first time.</p>
<p>The other alternative would be to store only the IPs of the visitors and queue the geolocation data once the panel is shown. This would mean to resolve a huge number of IPs simultaneously, which would make the script unresponsive and get us black-listed from the API. Totally not cool.</p>
<p>You can queue the Hostip&#8217;s API by opening a connection to a URL similar to this: <strong>http://api.hostip.info/?ip=128.128.128.128</strong>. It returns a valid XML response, which contains all sorts of data, including a <strong>country </strong>and <strong>city </strong>name associated with the IP, country <strong>abbreviation </strong>and even <strong>absolute coordinates</strong>. We are fetching this data with the PHP <strong>file_get_contents()</strong> function and extracting the bits of information we need.</p>
<h4>who-is-online/geodata.php</h4>
<pre class="brush:php">require "connect.php";
require "functions.php";

// We don't want web bots accessing this page:
if(is_bot()) die();

// Selecting the top 15 countries with the most visitors:
$result = mysql_query("	SELECT countryCode,country, COUNT(*) AS total
						FROM tz_who_is_online
						GROUP BY countryCode
						ORDER BY total DESC
						LIMIT 15");

while($row=mysql_fetch_assoc($result))
{
	echo '
	&lt;div class="geoRow"&gt;
		&lt;div class="flag"&gt;&lt;img src="who-is-online/img/famfamfam-countryflags/'.strtolower($row['countryCode']).'.gif" width="16" height="11" /&gt;&lt;/div&gt;
		&lt;div class="country" title="'.htmlspecialchars($row['country']).'"&gt;'.$row['country'].'&lt;/div&gt;
		&lt;div class="people"&gt;'.$row['total'].'&lt;/div&gt;
	&lt;/div&gt;
	';
}
</pre>
<p><strong>Geodata.php</strong> is fetched by jQuery to populate the slide-out panel with location data. This file basically queues the database with a <strong>GROUP BY</strong> query, which groups the individual users by country and orders the resulting rows in a descending order, with the most popular countries at the top.</p>
<p>For the flag icons, we are using the <a href="http://www.famfamfam.com/lab/icons/flags/" target="_blank">famfamfam flag icon set</a>, which is released as public domain. A great thing about the Hostip API, is that it returns the country code in a standard two letter format, which is also shared by the famfamfam icon set. This means that in the while loop, it is really easy to find the appropriate flag to show, by just lowering the case of the country abbreviation stored in the database and adding a <strong>gif</strong> extension.</p>
<h3>Step 5 &#8211; jQuery</h3>
<p>JavaScript manages the AJAX requests and slides the panel. This would be a daunting task with pure JS alone, which is why we are using the newest version of the jQuery library.</p>
<p>Now lets take a look at what the code looks like.</p>
<h4>who-is-online/widget.js</h4>
<pre class="brush:js">$(document).ready(function(){
	// This function is executed once the document is loaded

	// Caching the jQuery selectors:
	var count = $('.onlineWidget .count');
	var panel = $('.onlineWidget .panel');
	var timeout;

	// Loading the number of users online into the count div with the load AJAX method:
	count.load('who-is-online/online.php');

	$('.onlineWidget').hover(
		function(){
			// Setting a custom 'open' event on the sliding panel:

			clearTimeout(timeout);
			timeout = setTimeout(function(){panel.trigger('open');},500);
		},
		function(){
			// Custom 'close' event:

			clearTimeout(timeout);
			timeout = setTimeout(function(){panel.trigger('close');},500);
		}
	);

	var loaded=false;	// A flag which prevents multiple AJAX calls to geodata.php;

	// Binding functions to custom events:

	panel.bind('open',function(){
		panel.slideDown(function(){
			if(!loaded)
			{
				// Loading the countries and the flags
				// once the sliding panel is shown:

				panel.load('who-is-online/geodata.php');
				loaded=true;
			}
		});
	}).bind('close',function(){
		panel.slideUp();
	});

});</pre>
<p>You might be a bit perplexed with the use of <strong>setTimeout </strong>in the menu. This is done, so we have a bit of delay between the hovering of the mouse and the actual opening of the slide-out panel. This way, unintentional movements of the mouse cursor over the widget won&#8217;t fire the open event, and once opened, will not <strong>close</strong> it immediately once the mouse leaves it.</p>
<p><strong>With this our widget is ready!</strong></p>
<h3>Setting up the demo</h3>
<p>At this point you probably want to grab the widget and put it on your site. To make it work, you need to execute the SQL code found in <strong>table.sql</strong> in the download archive. It will create the <strong>tz_who_is_online</strong> table in your database, which is used by the widget. Later you need to upload the files to your server and include <strong>widget.js</strong> to the head section of your page (along with the jQuery  library). After this you have to fill your MySQL login details in <strong>connect.php</strong> and finally add the markup from <strong>demo.html</strong> to your web page.</p>
<h3>Conclusion</h3>
<p>Having access to real time data on your site userbase is a dream to any webmaster. Tools like Google Analytics give a great perspective on your site&#8217;s reach, but lack the real time feel a simple widget like this can provide.</p>
<p><strong>What do you think? How would you modify this code?</strong></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=vnBj9LFMVBk:2Uw_ud0YYHo:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=vnBj9LFMVBk:2Uw_ud0YYHo:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=vnBj9LFMVBk:2Uw_ud0YYHo:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=vnBj9LFMVBk:2Uw_ud0YYHo:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=vnBj9LFMVBk:2Uw_ud0YYHo:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=vnBj9LFMVBk:2Uw_ud0YYHo:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=vnBj9LFMVBk:2Uw_ud0YYHo:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=vnBj9LFMVBk:2Uw_ud0YYHo:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=vnBj9LFMVBk:2Uw_ud0YYHo:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=vnBj9LFMVBk:2Uw_ud0YYHo:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Tutorialzine/~4/vnBj9LFMVBk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tutorialzine.com/2010/03/who-is-online-widget-php-mysql-jquery/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
		<feedburner:origLink>http://tutorialzine.com/2010/03/who-is-online-widget-php-mysql-jquery/</feedburner:origLink></item>
		<item>
		<title>MicroTut: The jQuery Hover Method</title>
		<link>http://feedproxy.google.com/~r/Tutorialzine/~3/4VcFiqjx-5E/</link>
		<comments>http://tutorialzine.com/2010/02/the-jquery-hover-method/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 20:23:43 +0000</pubDate>
		<dc:creator>Martin Angelov</dc:creator>
				<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://tutorialzine.com/?p=732</guid>
		<description><![CDATA[When building a navigation menu, or any other jQuery script, it is often necessary to have a robust method with which to define a mouse over and mouse out state. This is where the hover() method comes along.]]></description>
			<content:encoded><![CDATA[<p>When building a navigation menu, or any other jQuery script, it is often necessary to have a robust method with which to define a mouse over and mouse out state. This is where the <strong>hover()</strong> method comes along. Here is how it is used:</p>
<pre class="brush:js">$('.selectorClass').hover(
function(){
	$(this).stop().fadeTo('slow',0.4);
},
function(){
	$(this).stop().fadeTo('slow',1);
});
</pre>
<p>This assigns the first function to be executed when the mouse moves above the elements on the page, which share the <strong>selectorClass</strong> class name, and the second one is executed when the mouse moves away.</p>
<p>You can use &#8220;<strong>this&#8221;</strong> inside of the functions, to access the element that triggered the event.</p>
<p>Hover actually binds the first function to the <strong>mouseenter</strong> event, and the second one to <strong>mouseleave</strong>, so you could alternatively write this:</p>
<pre class="brush:js">$('.selectorClass').mouseenter(function(){
	$(this).stop().fadeTo('slow',0.4);
}).mouseleave(function(){
	$(this).stop().fadeTo('slow',1);
});
</pre>
<p>As of <strong>version 1.4</strong> of jQuery, it is now possible to pass a single function to hover, which will be called on both mouseenter and mouseleave. This way you can shorten your code even more by writing only one function:</p>
<pre class="brush:js">$('.selectorClass').hover(function(){
	this.check = this.check || 1;
	$(this).stop().fadeTo('slow',this.check++%2==0 ? 1 : 0.4);
});
</pre>
<p>The example above increments <strong>this.check</strong> every time the function is run. Depending on whether the number is even or not, it chooses the opacity level to pass to <strong>fadeTo()</strong> (1 being completely visible).</p>
<p>This is also a great place to use the jQuery toggle functions like <strong>.slideToggle()</strong> and <strong>.toggleClass()</strong>.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=4VcFiqjx-5E:JxyHOg9Wg90:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=4VcFiqjx-5E:JxyHOg9Wg90:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=4VcFiqjx-5E:JxyHOg9Wg90:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=4VcFiqjx-5E:JxyHOg9Wg90:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=4VcFiqjx-5E:JxyHOg9Wg90:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=4VcFiqjx-5E:JxyHOg9Wg90:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=4VcFiqjx-5E:JxyHOg9Wg90:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=4VcFiqjx-5E:JxyHOg9Wg90:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=4VcFiqjx-5E:JxyHOg9Wg90:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=4VcFiqjx-5E:JxyHOg9Wg90:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Tutorialzine/~4/4VcFiqjx-5E" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tutorialzine.com/2010/02/the-jquery-hover-method/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		<feedburner:origLink>http://tutorialzine.com/2010/02/the-jquery-hover-method/</feedburner:origLink></item>
		<item>
		<title>PHP &amp; MySQL File Download Counter</title>
		<link>http://feedproxy.google.com/~r/Tutorialzine/~3/3cczr6gT3A8/</link>
		<comments>http://tutorialzine.com/2010/02/php-mysql-download-counter/#comments</comments>
		<pubDate>Sun, 21 Feb 2010 15:51:53 +0000</pubDate>
		<dc:creator>Martin Angelov</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://tutorialzine.com/?p=717</guid>
		<description><![CDATA[It has been a while since we've done a proper PHP &#038; MySQL tutorial here, at Tutorialzine, so today we are creating a simple yet robust file download tracker.]]></description>
			<content:encoded><![CDATA[<p>It has been a while since we&#8217;ve done a proper PHP &amp; MySQL tutorial here, at Tutorialzine, so today we are creating a simple, yet robust, file download tracker.</p>
<p>Each file will have a corresponding row in the database, where the total number of downloads is saved. PHP will update the MySQL database and redirect the visitors to the appropriate files.</p>
<p>To track the number of downloads, you just need to upload your files to the <strong>files</strong> folder, and use a special URL to access them.</p>
<h3>Step 1 &#8211; XHTML</h3>
<p>The first step is to lay down the XHTML markup of the tracker.  It is pretty straightforward &#8211; we have the <strong>file-manager</strong> div, which contains an <strong>unordered list</strong> with each file as a <strong>li</strong> element.</p>
<p>The files, that are going to be tracked, are put into the <strong>files</strong> folder in the script root directory (you can see how the file structure is organized in  the demonstration zip file). PHP then loops through all the files and adds each one as a separate <strong>li</strong> element to the unordered list.</p>
<h4>demo.php</h4>
<pre class="brush:html">&lt;div id="file-manager"&gt;

	&lt;ul class="manager"&gt;

		&lt;!-- The LI items are generated by php --&gt;
		&lt;li&gt;&lt;a href="download.php?file=photoShoot-1.0.zip"&gt;photoShoot-1.0.zip
			&lt;span class="download-count" title="Times Downloaded"&gt;0&lt;/span&gt; &lt;span class="download-label"&gt;download&lt;/span&gt;&lt;/a&gt;
		&lt;/li&gt;
	&lt;/ul&gt;

&lt;/div&gt;
</pre>
<p>Notice the <strong>href </strong>attribute of the hyperlink &#8211; it passes  the name of the file as a parameter to <strong>download.php</strong>. This is where the download tracking happens, as you will see in a moment.</p>
<p>You are not limited to this interface in order to provide  download tracking &#8211; you can just post the links to <strong>download.php</strong> in your  blog posts or site pages, and all downloads will be correctly tracked.</p>
<div id="attachment_721" class="wp-caption alignnone" style="width: 630px"><a href="http://tutorialzine.com/wp-content/uploads/2010/02/i11.png"><img class="size-full wp-image-721" title="Download Counter Interface" src="http://tutorialzine.com/wp-content/uploads/2010/02/i11.png" alt="Download Counter Interface" width="620" height="460" /></a><p class="wp-caption-text">Download Counter Interface</p></div>
<h3>Step 2 &#8211; CSS</h3>
<p>With the XHTML markup in place, we can now concentrate on the presentation side of script. The CSS rules below target the <strong>file-manager</strong> div by <strong>id</strong> (with the <strong>hash symbol</strong>), as it is present only once in the page, and the rest of the elements by <strong>class names</strong>.</p>
<h4>styles.css</h4>
<pre class="brush:css">#file-manager{
	background-color:#EEE;
	border:1px solid #DDD;
	margin:50px auto;
	padding:10px;
	width:400px;
}

ul.manager li{
	background:url("img/bg_gradient.gif") repeat-x center bottom #F5F5F5;
	border:1px solid #DDD;
	border-top-color:#FFF;

	list-style:none;
	position:relative;
}

ul.manager li a{
	display:block;
	padding:8px;
}

ul.manager li a:hover .download-label{
	/* When a list is hovered over, show the download green text inside it: */
	display:block;
}

span.download-label{
	background-color:#64B126;
	border:1px solid #4E9416;
	color:white;
	display:none;
	font-size:10px;
	padding:2px 4px;
	position:absolute;
	right:8px;
	text-decoration:none;
	text-shadow:0 0 1px #315D0D;
	top:6px;

	/* CSS3 Rounded Corners */

	-moz-border-radius:3px;
	-webkit-border-radius:3px;
	border-radius:3px;
}

span.download-count{
	color:#999;
	font-size:10px;
	padding:3px 5px;
	position:absolute;
	text-decoration:none;
}</pre>
<p>The interesting part here is that the download label is hidden by default with <strong>display:none</strong>. It is shown with <strong>display:block</strong> only when we are hovering over its parent <strong>&lt;a&gt;</strong> element, and thus the right label is shown without a need for using JavaScript. A bit of <strong>CSS3 </strong>is also used as well to round the corners of the download label.</p>
<div id="attachment_722" class="wp-caption alignnone" style="width: 630px"><a href="http://tutorialzine.com/wp-content/uploads/2010/02/i21.png"><img class="size-full wp-image-722" title="Hover State With CSS" src="http://tutorialzine.com/wp-content/uploads/2010/02/i21.png" alt="Hover State With CSS" width="620" height="260" /></a><p class="wp-caption-text">Hover State With CSS</p></div>
<h3>Step 3 &#8211; PHP</h3>
<p>As mentioned earlier, PHP loops through the <strong>files</strong> folder, and outputs each file as a <strong>li</strong> element in the unordered list. Now lets take a closer look at how this happens.</p>
<h4>demo.php &#8211; Top Section</h4>
<pre class="brush:php">// Error reporting:
error_reporting(E_ALL^E_NOTICE);

// Including the DB connection file:
require 'connect.php';

$extension='';
$files_array = array();

/* Opening the thumbnail directory and looping through all the thumbs: */

$dir_handle = @opendir($directory) or die("There is an error with your file directory!");

while ($file = readdir($dir_handle))
{
	/* Skipping the system files: */
	if($file{0}=='.') continue;

	/* end() returns the last element of the array generated by the explode() function: */
	$extension = strtolower(end(explode('.',$file)));

	/* Skipping the php files: */
	if($extension == 'php') continue;

	$files_array[]=$file;
}

/* Sorting the files alphabetically */
sort($files_array,SORT_STRING);

$file_downloads=array();

$result = mysql_query("SELECT * FROM download_manager");

if(mysql_num_rows($result))
while($row=mysql_fetch_assoc($result))
{
	/* 	The key of the $file_downloads array will be the name of the file,
		and will contain the number of downloads: */

	$file_downloads[$row['filename']]=$row['downloads'];
}</pre>
<p>Notice how we are selecting all the rows from the <strong>download_manager </strong>table with <strong>mysql_query()</strong>, and later adding them to the <strong>$file_downloads</strong> array with the filename as a key to the number of downloads. This way, later in the code, we can write <strong>$file_downloads['archive.zip']</strong>, and output how many times this file has been downloaded.</p>
<p>You can see the code we use to generate the <strong>li</strong> items below.</p>
<h4>demo.php &#8211; Mid Section</h4>
<pre class="brush:php">foreach($files_array as $key=&gt;$val)
{
	echo '&lt;li&gt;&lt;a href="download.php?file='.urlencode($val).'"&gt;'.$val.'
		&lt;span class="download-count" title="Times Downloaded"&gt;'.(int)$file_downloads[$val].'&lt;/span&gt; &lt;span class="download-label"&gt;download&lt;/span&gt;&lt;/a&gt;
	&lt;/li&gt;';
}
</pre>
<p>It is simple as that &#8211; a <strong>foreach </strong>loop on the <strong>$files_array</strong> array, and an echo statement which prints all the markup to the page.</p>
<p>Now lets take a closer look at how exactly are the downloads tracked.</p>
<h4>download.php</h4>
<pre class="brush:php">// Error reporting:
error_reporting(E_ALL^E_NOTICE);

// Including the connection file:
require('connect.php');

if(!$_GET['file']) error('Missing parameter!');
if($_GET['file']{0}=='.') error('Wrong file!');

if(file_exists($directory.'/'.$_GET['file']))
{
	/* If the visitor is not a search engine, count the downoad: */
	if(!is_bot())
	mysql_query("	INSERT INTO download_manager SET filename='".mysql_real_escape_string($_GET['file'])."'
					ON DUPLICATE KEY UPDATE downloads=downloads+1");

	header("Location: ".$directory."/".$_GET['file']);
	exit;
}
else error("This file does not exist!");

/* Helper functions: */

function error($str)
{
	die($str);
}

function is_bot()
{
	/* This function will check whether the visitor is a search engine robot */

	$botlist = array("Teoma", "alexa", "froogle", "Gigabot", "inktomi",
	"looksmart", "URL_Spider_SQL", "Firefly", "NationalDirectory",
	"Ask Jeeves", "TECNOSEEK", "InfoSeek", "WebFindBot", "girafabot",
	"crawler", "www.galaxy.com", "Googlebot", "Scooter", "Slurp",
	"msnbot", "appie", "FAST", "WebBug", "Spade", "ZyBorg", "rabaz",
	"Baiduspider", "Feedfetcher-Google", "TechnoratiSnoop", "Rankivabot",
	"Mediapartners-Google", "Sogou web spider", "WebAlta Crawler","TweetmemeBot",
	"Butterfly","Twitturls","Me.dium","Twiceler");

	foreach($botlist as $bot)
	{
		if(strpos($_SERVER['HTTP_USER_AGENT'],$bot)!==false)
		return true;	// Is a bot
	}

	return false;	// Not a bot
}
</pre>
<p>It is important to check if, by any chance, the visitor is a search engine robot scanning your links and not a real person. Robots are a good thing, as they get you included in services like Google Search, but in a situation such as this, can skew your download statistics. This is why the database row is updated only after the visitor passes the <strong>is_bot()</strong> validation.</p>
<h3>Step 4 &#8211; MySQL</h3>
<p>As mentioned in the previous step, the download count is stored as a row in the <strong>download_manager</strong> table in your MySQL database. First, lets explain how this particular query works:</p>
<h4>download.php</h4>
<pre class="brush:sql">INSERT INTO download_manager SET filename='filename.doc'
ON DUPLICATE KEY UPDATE downloads=downloads+1</pre>
<p>It tells MySQL to insert a new row in the <strong>download_manager</strong> table, and set the <strong>filename</strong> field of the row to the value of the requested file for download. However, the <strong>filename</strong> field is defined as a <strong>unique index</strong> in the table. This means that a row can be inserted only once, otherwise a <strong>duplicate key error</strong> will occur.</p>
<p>This is where the second part of the query kicks in &#8211; <strong>ON DUPLICATE KEY UPDATE</strong> will tell MySQL to increment the downloads column by one if the file already exists in the database.</p>
<p>This way new files will be automatically inserted in the database the first time they are downloaded.</p>
<div id="attachment_727" class="wp-caption alignnone" style="width: 630px"><a href="http://tutorialzine.com/wp-content/uploads/2010/02/i31.png"><img class="size-full wp-image-727" title="Structure of the download_manager Table" src="http://tutorialzine.com/wp-content/uploads/2010/02/i31.png" alt="Structure of the download_manager Table" width="620" height="260" /></a><p class="wp-caption-text">Structure of the download_manager Table</p></div>
<h3>Step 5 &#8211; jQuery</h3>
<p>To make the download tracking feel almost like real-time, it will be a nice addition to update the counter next to the file name once the user initiates the download. Otherwise they would have to initiate a page refresh so that new stats for the counter are shown.</p>
<p>We will achieve this with a little jQuery trick:</p>
<h4>script.js</h4>
<pre class="brush:js">$(document).ready(function(){
	/* This code is executed after the DOM has been completely loaded */

	$('ul.manager a').click(function(){

		var countSpan = $('.download-count',this);
		countSpan.text( parseInt(countSpan.text())+1);
	});
});
</pre>
<p>We just assign a click handler to the links that point to the files, and every time one of them is clicked, we increment the number inside of the counter span tag.</p>
<h3>Step 6 &#8211; htaccess</h3>
<p>There is one more thing we need to do, before we call it a day. What <strong>download.php</strong> does is to  redirect the visitor to the requested file that was passed as a parameter. However you may have noticed that, for certain file types, the default browser behavior is to open them directly. We want to initiate a download instead. This is achieved with a couple of lines inside of a <strong>.htacess</strong> file, found in the <strong>files</strong> directory:</p>
<pre class="brush:plain">&lt;Files *.*&gt;
ForceType application/octet-stream
&lt;/Files&gt;
</pre>
<p><strong>With this our File Download Counter is complete!</strong></p>
<h3>Conclusion</h3>
<p>To run the demo on your own server, you will need to recreate the <strong>download_manager</strong> table in a MySQL database you have access to. You can find the needed <strong>SQL</strong> code that will create the table for you in <strong>table.sql</strong>, which you can find in the download archive.</p>
<p>After this, just add your login details for the database (as provided by your webhost) to <strong>configuration.php</strong>.</p>
<p><strong>What do you think? How would you improve this example?</strong></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=3cczr6gT3A8:EG5F98qiXY4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=3cczr6gT3A8:EG5F98qiXY4:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=3cczr6gT3A8:EG5F98qiXY4:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=3cczr6gT3A8:EG5F98qiXY4:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=3cczr6gT3A8:EG5F98qiXY4:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=3cczr6gT3A8:EG5F98qiXY4:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=3cczr6gT3A8:EG5F98qiXY4:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=3cczr6gT3A8:EG5F98qiXY4:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=3cczr6gT3A8:EG5F98qiXY4:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=3cczr6gT3A8:EG5F98qiXY4:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Tutorialzine/~4/3cczr6gT3A8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tutorialzine.com/2010/02/php-mysql-download-counter/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		<feedburner:origLink>http://tutorialzine.com/2010/02/php-mysql-download-counter/</feedburner:origLink></item>
		<item>
		<title>Coding a CSS3 &amp; HTML5 One-Page Website Template</title>
		<link>http://feedproxy.google.com/~r/Tutorialzine/~3/y7bBsejKDeM/</link>
		<comments>http://tutorialzine.com/2010/02/html5-css3-website-template/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 17:21:41 +0000</pubDate>
		<dc:creator>Martin Angelov</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://tutorialzine.com/?p=669</guid>
		<description><![CDATA[Here we are using the new version of HTML - the fundamental language of the web, to make a web template, using some of the new features brought by CSS3 and jQuery with the scrollTo plug-in.]]></description>
			<content:encoded><![CDATA[<p>Web development is an area in which you have to keep up with the latest technologies and techniques, so that you are at the top of your game.  And no wonder &#8211; this is an area which changes with an amazing pace. What is the standard now will be obsolete in just a couple of years.</p>
<p>But changes do not come from nowhere. The early adopters are already using what we are going to use day-to-day a few years from now. One of these technologies is <strong>HTML5</strong> &#8211; the new version of the fundamental language of the web.</p>
<p>Today we are making a <strong>HTML5</strong> web template, using some of the new features brought by CSS3 and jQuery, with the <strong>scrollTo</strong> <a href="http://demos.flesler.com/jquery/scrollTo/" target="_blank">plug-in</a>. As HTML5 is still a work in progress, you can optionally download a <strong>XHTML version </strong>of the template <a href="/2010/02/free-xhtml-css3-website-template/" target="_blank">here</a>.</p>
<h3>Step 1 &#8211; The Design</h3>
<p>Every design process starts with an initial idea which you later build upon. At this stage, designers usually go with programs such as Photoshop, to work on the details and see how it will all fit together.</p>
<div id="attachment_672" class="wp-caption alignnone" style="width: 630px"><a href="http://tutorialzine.com/wp-content/uploads/2010/02/i1.png"><img class="size-full wp-image-672" title="Photoshop Design" src="http://tutorialzine.com/wp-content/uploads/2010/02/i1.png" alt="Photoshop Design" width="620" height="460" /></a><p class="wp-caption-text">Photoshop Design</p></div>
<p>After this, the design is hand coded with HTML and CSS going hand by hand, moving from designing the background, colors and fonts, to detail work on the content section.</p>
<h3>Step 2 &#8211; HTML</h3>
<p>It is a good time to note, that <strong>HTML5</strong> is still a work in progress. It will remain so probably till around <strong>2022</strong> (I am absolutely serious about this). However some parts of the standard are complete, and can be used <strong>today</strong>.</p>
<p>In this tutorial, we are using a few of the tags introduced with this new version of HTML:</p>
<ul>
<li><strong>header</strong> &#8211; wraps your page header;</li>
<li><strong>footer</strong> &#8211; wraps your page footer;</li>
<li><strong>section</strong> &#8211; groups content into sections (e.g. main area, sidebar etc);</li>
<li><strong>article</strong> &#8211; separates the individual articles from the rest of the page;</li>
<li><strong>nav</strong> &#8211; contains your navigation menu;</li>
<li><strong>figure</strong> &#8211; usually contains an image used as an illustration for your article.</li>
</ul>
<p>These are used exactly as you would use normal divs. With the difference being that these tags organize your page semantically. In other words, you can present your content in such a way, that the subject matter of your page can be more easily determined. As a result services, such as search engines, will bring you more targeted visitors and thus boost your revenue (and theirs actually).</p>
<p>However, there are some <strong>implications</strong> in using HTML5 today. One of the most notable is the IE family of browsers, which does not support these tags (it can be fixed with a simple JavaScript include file though). This is why you should base your decision for moving to HTML5 on your site&#8217;s audience. And just for this purpose, we are releasing a <a href="/2010/02/free-xhtml-css3-website-template/" target="_blank">pure XHTML version</a> of this template as well.</p>
<h4>template.html &#8211; Head section</h4>
<pre class="brush:html">&lt;!DOCTYPE html&gt; &lt;!-- The new doctype --&gt;

&lt;html&gt;
&lt;head&gt;

	&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt;

	&lt;title&gt;Coding A CSS3 &amp;amp; HTML5 One Page Template | Tutorialzine demo&lt;/title&gt;

	&lt;link rel="stylesheet" type="text/css" href="styles.css" /&gt;

	&lt;!-- Internet Explorer HTML5 enabling script: --&gt;

	&lt;!--[if IE]&gt;
		&lt;script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"&gt;&lt;/script&gt;
		&lt;style type="text/css"&gt;

			.clear {
				zoom: 1;
				display: block;
			}

		&lt;/style&gt;

	&lt;![endif]--&gt;

&lt;/head&gt;
</pre>
<p>You can notice the new <strong>&lt;DOCTYPE&gt;</strong> at line one, which tells the browser that the page is created with the HTML5 standard. It is also much shorter and easier to remember than older doctypes.</p>
<p>After specifying the encoding of the document and the title, we move on to including a special JS file that will enable Internet Explorer (any version) to render HTML5 tags properly. Again, this means that if a visitor is using IE and has <strong>JavaScript disabled</strong>, the page is going to show all <strong>messed up</strong>. This is why, depending on your audience, you should consider the regular XHTML version of this template, which works in <strong>any browser</strong> and is <a href="/2010/02/free-xhtml-css3-website-template/" target="_blank">released free for all of our readers here</a>.</p>
<h4>template.html &#8211; Body Section</h4>
<pre class="brush:html">&lt;body&gt;

	&lt;section id="page"&gt; &lt;!-- Defining the #page section with the section tag --&gt;

	&lt;header&gt; &lt;!-- Defining the header section of the page with the appropriate tag --&gt;

		&lt;h1&gt;Your Logo&lt;/h1&gt;

		&lt;h3&gt;and a fancy slogan&lt;/h3&gt;

		&lt;nav class="clear"&gt; &lt;!-- The nav link semantically marks your main site navigation --&gt;

			&lt;ul&gt;

				&lt;li&gt;&lt;a href="#article1"&gt;Photoshoot&lt;/a&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href="#article2"&gt;Sweet Tabs&lt;/a&gt;&lt;/li&gt;
				&lt;li&gt;&lt;a href="#article3"&gt;Navigation Menu&lt;/a&gt;&lt;/li&gt;

			&lt;/ul&gt;

		&lt;/nav&gt;

	&lt;/header&gt;
</pre>
<p>Here we use the new <strong>section</strong> tags, which divide your page into separate semantic sections. Outermost is the <strong>#page section</strong> which is set to a width of <strong>960px</strong> in the style sheet (a fairly standard width with older computer displays in mind). After this comes the header tag and the navigation tag.</p>
<p>Notice the <strong>href</strong> attributes of the links &#8211; the part after the hash symbol <strong>#</strong> corresponds to the <strong>ID</strong> of the <strong>article</strong> we want to scroll to.</p>
<h4>template.html &#8211; Article</h4>
<pre class="brush:html">	&lt;!-- Article 1 start --&gt;

	&lt;div class="line"&gt;&lt;/div&gt;  &lt;!-- Dividing line --&gt;

	&lt;article id="article1"&gt; &lt;!-- The new article tag. The id is supplied so it can be scrolled into view. --&gt;

		&lt;h2&gt;Photoshoot Effect&lt;/h2&gt;

		&lt;div class="line"&gt;&lt;/div&gt;

		&lt;div class="articleBody clear"&gt;

			&lt;figure&gt; &lt;!-- The figure tag marks data (usually an image) that is part of the article --&gt;

				&lt;a href="http://tutorialzine.com/2010/02/photo-shoot-css-jquery/"&gt;
					&lt;img src="http://tutorialzine.com/img/featured/641.jpg" width="620" height="340" /&gt;&lt;/a&gt;

			&lt;/figure&gt;

			&lt;p&gt;In this tutorial, we are creating a photo shoot effect with our just-released PhotoShoot jQuery plug-in. With it you can convert a regular div on the page into a photo shooting stage simulating a camera-like feel.&lt;/p&gt;

			&lt;p&gt;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer luctus quam quis .... &lt;/p&gt;

		&lt;/div&gt;

	&lt;/article&gt;

	&lt;!-- Article 1 end --&gt;
</pre>
<p>The markup above is shared between all of the articles. First is the dividing line (the best solution semantically would be an <strong>&lt;hr&gt;</strong> line, which in HTML5 has the added role of a logical dividing element, but unfortunately it is impossible to style in a cross-browser fashion, so we will stick with a <strong>DIV</strong>). After this we have the new <strong>article</strong> tag, with an <strong>unique ID</strong>, which is used by the navigation to<strong> scroll the page</strong>.</p>
<p>Inside we have the title of the article, two paragraphs and the new <strong>figure</strong> tag, which marks the use of images in the article.</p>
<h4>template.html &#8211; Footer</h4>
<pre class="brush:html">		&lt;footer&gt; &lt;!-- Marking the footer section --&gt;

			&lt;div class="line"&gt;&lt;/div&gt;

			&lt;p&gt;Copyright 2010 - YourSite.com&lt;/p&gt; &lt;!-- Change the copyright notice --&gt;
			&lt;a href="#" class="up"&gt;Go UP&lt;/a&gt;
			&lt;a href="http://tutorialzine.com/" class="by"&gt;Template by Tutorialzine&lt;/a&gt;

		&lt;/footer&gt;

	&lt;/section&gt; &lt;!-- Closing the #page section --&gt;

	&lt;!-- JavaScript Includes --&gt;

	&lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"&gt;&lt;/script&gt;
	&lt;script src="jquery.scrollTo-1.4.2/jquery.scrollTo-min.js"&gt;&lt;/script&gt;
	&lt;script src="script.js"&gt;&lt;/script&gt;

	&lt;/body&gt;

&lt;/html&gt;
</pre>
<p>Lastly, we have the <strong>footer</strong> tag, which does exactly what you expect it to do. At the bottom of the page are the rest of the JavaScript  includes, which add the <strong>jQuery library</strong> and the <strong>scrollTo</strong> plug-in, which we are going to use in the next steps.</p>
<div id="attachment_673" class="wp-caption alignnone" style="width: 630px"><a href="http://tutorialzine.com/wp-content/uploads/2010/02/i2.png"><img class="size-full wp-image-673" title="HTML5 CSS3 Website Template" src="http://tutorialzine.com/wp-content/uploads/2010/02/i2.png" alt="HTML5 CSS3 Website Template" width="620" height="460" /></a><p class="wp-caption-text">An HTML5 &amp; CSS3 Website Template</p></div>
<h3>Step 3 &#8211; CSS</h3>
<p>As we are using HTML5, we have to take some extra measures with the styling. The tags that this new version of HTML introduces, are not yet provided with a default styling. This is however easily fixed with a couple of lines of CSS code and the page works and looks as it is supposed to:</p>
<h4>styles.css &#8211; Part 1</h4>
<pre class="brush:css">header,footer,
article,section,
hgroup,nav,
figure{
	/* Giving a display value to the HTML5 rendered elements: */
	display:block;
}

article .line{
	/* The dividing line inside of the article is darker: */
	background-color:#15242a;
	border-bottom-color:#204656;
	margin:1.3em 0;
}

footer .line{
	margin:2em 0;
}

nav{
	background:url(img/gradient_light.jpg) repeat-x 50% 50% #f8f8f8;
	padding:0 5px;
	position:absolute;
	right:0;
	top:4em;

	border:1px solid #FCFCFC;

	-moz-box-shadow:0 1px 1px #333333;
	-webkit-box-shadow:0 1px 1px #333333;
	box-shadow:0 1px 1px #333333;
}

nav ul li{
	display:inline;
}

nav ul li a,
nav ul li a:visited{
	color:#565656;
	display:block;
	float:left;
	font-size:1.25em;
	font-weight:bold;
	margin:5px 2px;
	padding:7px 10px 4px;
	text-shadow:0 1px 1px white;
	text-transform:uppercase;
}

nav ul li a:hover{
	text-decoration:none;
	background-color:#f0f0f0;
}

nav, article, nav ul li a,figure{
	/* Applying CSS3 rounded corners: */
	-moz-border-radius:10px;
	-webkit-border-radius:10px;
	border-radius:10px;
}
</pre>
<p>We basically need to set the <strong>display</strong> value of the new tags to <strong>block</strong>, as you can see from the first couple of lines. After this we can style them as we would do with regular divs.</p>
<p>We style the horizontal lines, the articles, and the navigation buttons, with the latter organized as an unordered list inside of the <strong>nav</strong> tag. At the bottom we assign the <strong>border-radius</strong> property for four different types of elements of once, which saves a lot of code.</p>
<h4>styles.css &#8211; Part 2</h4>
<pre class="brush:css">/* Article styles: */

#page{
	width:960px;
	margin:0 auto;
	position:relative;
}

article{
	background-color:#213E4A;
	margin:3em 0;
	padding:20px;

	text-shadow:0 2px 0 black;
}

figure{
	border:3px solid #142830;
	float:right;
	height:300px;
	margin-left:15px;
	overflow:hidden;
	width:500px;
}

figure:hover{
	-moz-box-shadow:0 0 2px #4D7788;
	-webkit-box-shadow:0 0 2px #4D7788;
	box-shadow:0 0 2px #4D7788;
}

figure img{
	margin-left:-60px;
}

/* Footer styling: */

footer{
	margin-bottom:30px;
	text-align:center;
	font-size:0.825em;
}

footer p{
	margin-bottom:-2.5em;
	position:relative;
}

footer a,footer a:visited{
	color:#cccccc;
	background-color:#213e4a;
	display:block;
	padding:2px 4px;
	z-index:100;
	position:relative;
}

footer a:hover{
	text-decoration:none;
	background-color:#142830;
}

footer a.by{
	float:left;

}

footer a.up{
	float:right;
}
</pre>
<p>In the second part of the code, we apply more detailed styling to the elements. A <strong>width</strong> for the <strong>page</strong> section, a <strong>hover</strong> property for the <strong>figure</strong> tag and styles for the links inside of the footer. There are also a few styles that are not included here, but you can see them in <strong>styles.css</strong>.</p>
<p>Now lets continue with the next step.</p>
<div id="attachment_674" class="wp-caption alignnone" style="width: 630px"><a href="http://tutorialzine.com/wp-content/uploads/2010/02/i3.png"><img class="size-full wp-image-674" title="Structure Of The Page" src="http://tutorialzine.com/wp-content/uploads/2010/02/i3.png" alt="Structure Of The Page" width="620" height="460" /></a><p class="wp-caption-text">Structure Of The Page - HTML5 Tags</p></div>
<h3>Step 4 &#8211; jQuery</h3>
<p>To enhance the template, we will create a smooth scrolling effect once a navigation link has been clicked, using the <strong>scrollTo</strong> jQuery plug-in that we included in the page earlier. To make it work we just need to loop through the links in the navigation bar (and the UP link in the footer) and assign an onclick event which will trigger the <strong>$.srollTo()</strong> function, which is defined by the plug-in.</p>
<h4>script.js</h4>
<pre class="brush:js">$(document).ready(function(){
	/* This code is executed after the DOM has been completely loaded */

	$('nav a,footer a.up').click(function(e){

		// If a link has been clicked, scroll the page to the link's hash target:

		$.scrollTo( this.hash || 0, 1500);
		e.preventDefault();
	});

});
</pre>
<p><strong><em>With this our template is complete!</em></strong></p>
<h3>Wrapping it up</h3>
<p>In this tutorial, we leveraged the new semantic features provided by HTML5, to design and code a one-page web template. You can use it for free both personally and commercially, providing you leave the back link intact.</p>
<p>If you like this tutorial, be sure to check out <a href="http://twitter.com/Tutorialzine">our twitter stream</a> as well, where we share the latest and greatest design and development links.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=y7bBsejKDeM:XyzY2JSWjI4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=y7bBsejKDeM:XyzY2JSWjI4:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=y7bBsejKDeM:XyzY2JSWjI4:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=y7bBsejKDeM:XyzY2JSWjI4:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=y7bBsejKDeM:XyzY2JSWjI4:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=y7bBsejKDeM:XyzY2JSWjI4:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=y7bBsejKDeM:XyzY2JSWjI4:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=y7bBsejKDeM:XyzY2JSWjI4:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=y7bBsejKDeM:XyzY2JSWjI4:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=y7bBsejKDeM:XyzY2JSWjI4:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Tutorialzine/~4/y7bBsejKDeM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tutorialzine.com/2010/02/html5-css3-website-template/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		<feedburner:origLink>http://tutorialzine.com/2010/02/html5-css3-website-template/</feedburner:origLink></item>
		<item>
		<title>Free XHTML &amp; CSS3 One-Page Template</title>
		<link>http://feedproxy.google.com/~r/Tutorialzine/~3/Bx0ZlW99eZU/</link>
		<comments>http://tutorialzine.com/2010/02/free-xhtml-css3-website-template/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 17:21:20 +0000</pubDate>
		<dc:creator>Martin Angelov</dc:creator>
				<category><![CDATA[Templates]]></category>

		<guid isPermaLink="false">http://tutorialzine.com/?p=676</guid>
		<description><![CDATA[A free one-page template for our readers. It is compatible with all browser versions, SEO friendly, and features a sleek jQuery scroll effect. Perfect for those cases when you need something up fast.]]></description>
			<content:encoded><![CDATA[<p>In response to <a href="/2010/02/html5-css3-website-template/" target="_blank">this week&#8217;s tutorial</a>, where we are creating a HTML5 &amp; CSS3 template, here is the pure XHTML version. It is compatible with all browser versions, SEO friendly, and features a sleek jQuery scroll effect. Perfect for those cases when you need something up fast.</p>
<p>It is easily modifiable and the code is properly commented.</p>
<h3>Installation</h3>
<p>Just download it from the button above, extract it from the archive, and upload it to your server.</p>
<h3>License</h3>
<p>Free for personal and commercial use, as long as you keep the link at the bottom.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=Bx0ZlW99eZU:XFI5TPv4oGw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=Bx0ZlW99eZU:XFI5TPv4oGw:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=Bx0ZlW99eZU:XFI5TPv4oGw:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=Bx0ZlW99eZU:XFI5TPv4oGw:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=Bx0ZlW99eZU:XFI5TPv4oGw:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=Bx0ZlW99eZU:XFI5TPv4oGw:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=Bx0ZlW99eZU:XFI5TPv4oGw:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=Bx0ZlW99eZU:XFI5TPv4oGw:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=Bx0ZlW99eZU:XFI5TPv4oGw:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=Bx0ZlW99eZU:XFI5TPv4oGw:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Tutorialzine/~4/Bx0ZlW99eZU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tutorialzine.com/2010/02/free-xhtml-css3-website-template/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<feedburner:origLink>http://tutorialzine.com/2010/02/free-xhtml-css3-website-template/</feedburner:origLink></item>
		<item>
		<title>Making a Sleek Feed Widget With YQL, jQuery &amp; CSS3</title>
		<link>http://feedproxy.google.com/~r/Tutorialzine/~3/MhmMn_gWjSg/</link>
		<comments>http://tutorialzine.com/2010/02/feed-widget-jquery-css-yql/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 16:08:21 +0000</pubDate>
		<dc:creator>Martin Angelov</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://tutorialzine.com/?p=661</guid>
		<description><![CDATA[We are making a sleek feed widget, that will fetch any feed and display it in your blog sidebar. You can set it up to show the latest posts from the different categories of your blog, your latest stumbles, or even people mentioning you on twitter.]]></description>
			<content:encoded><![CDATA[<p>You will be surprised at how much data is made available on the web through RSS or ATOM feeds &#8211; twitter searches, your latest diggs, Google Search alerts, your own blog categories and so much more. You just have to look for that orange icon and you&#8217;ll surely find a lot more precious data, just waiting to be put into use.</p>
<p>Today we are making a <strong>sleek feed widget</strong>, that will fetch any feed and display it in your blog sidebar. You can set it up to show the latest posts from the different categories of your blog, your latest stumbles, or even people mentioning you on twitter.</p>
<p><em>So go ahead, <strong>download the demo archive from the button above</strong>, and keep on reading..</em></p>
<h2>Problem Solving</h2>
<p>Before stepping into development, we have to clarify for ourselves what we are aiming for, discuss some potential problems, and their solutions.</p>
<h4>Problem 1 &#8211; Fetching Feeds</h4>
<p>The widget is entirely front-end based, so we have to find a way to fetch the feeds directly with JavaScript. AJAX is a great technology, but there are security restrictions that limit it to fetching data only from the current domain. This means we cannot access feeds directly and display them.</p>
<p>This is where <strong>YQL</strong> comes along. It fetches the feed we want, and makes it available to our script as a regular <strong>JSON</strong> object that we can later loop and print to the page.</p>
<blockquote><p>YQL is a free <strong>API</strong> service from Yahoo, with which you can do much more than just download feeds. It acts as a gateway between you and other API&#8217;s and lets you manipulate them with a quick to learn SQL-like syntax (hence the name).</p>
<p><span class="small">You can reed more about it in <a href="http://net.tutsplus.com/tutorials/other/an-api-for-the-web-learning-yql/" target="_blank">this tutorial on nettuts</a>, or go to the official <a href="http://developer.yahoo.com/yql/" target="_blank">YQL page</a>.</span></p></blockquote>
<p>Setting up YQL to work is tricky though (we have to dynamically include a <strong>&lt;script&gt;</strong> tag to the head section of the page, like we did in the <a href="http://tutorialzine.com/2009/10/jquery-twitter-ticker/">Twitter Ticker tutorial</a> few months back). Luckily, jQuery provides a method for just this purpose &#8211; <strong>getJSON</strong>. It does everything behind the scenes, so we don&#8217;t have to worry about the implementation.</p>
<h4>Problem 2 &#8211; Different Feed Formats</h4>
<p>As with everything else, feeds are available in a number of formats &#8211;  <strong>RSS1, RSS2</strong> and <strong>ATOM</strong>. They all have their differences and present a  challenge, because our code has to be able to loop through the results returned by <strong>YQL</strong> and successfully display the entries.</p>
<p>The solution to this is to move the functionality that displays the feeds in a separate function and use a number of logical <strong>OR</strong>-s ( || ) throughout the code. It works with all the feeds that I tested it with, but you could easily make your own version of the function for special cases (for example displaying Flickr streams with a thumbnail).</p>
<h4>Problem 3 &#8211; Insufficient Space</h4>
<p>This is more of a layout problem actually, but is quite an important one. Given the limited width of the blog sidebar area, it becomes evident that it is impossible to display more than a couple of tabs simultaneously, if we go with the regular horizontal placement. So the best option is to have them show in a sleek drop down, which can store all the feeds one could possibly want.</p>
<p><em>With those issues addressed, we can now move on to development.</em></p>
<h3>Step 1 &#8211; XHTML</h3>
<p>The first part of the tutorial consists of laying down the XHTML structure for the feed widget. The snippet below (extracted from <strong>demo.html</strong> in the download archive) is everything you need to show the widget on your page (apart from the CSS and jQuery files, covered in the later steps).</p>
<h4>demo.html</h4>
<pre class="brush:html">&lt;div id="feedWidget"&gt;

	&lt;div id="activeTab"&gt;
		&lt;!-- The name of the current tab is inserted here --&gt;
	&lt;/div&gt;

	&lt;div class="line"&gt;&lt;/div&gt;

	&lt;div id="tabContent"&gt;
		&lt;!-- The feed items are inserted here --&gt;
	&lt;/div&gt;

&lt;/div&gt;
</pre>
<p>As the widget is entirely dependent on JavaScript to function, there is little point in providing a fallback solution. The best we can do is to entirely hide it from view if JS is disabled. This is why the <strong>feedWidget</strong> div is hidden with <strong>display:non</strong>e in the stylesheet file, and shown with jQuery&#8217;s <strong>show()</strong> method in <strong>script.js</strong> (which will be run only if JS is available).</p>
<p>Now lets move to the next step.</p>
<div id="attachment_664" class="wp-caption alignnone" style="width: 630px"><a href="http://tutorialzine.com/wp-content/uploads/2010/02/i11.jpg"><img class="size-full wp-image-664" title="Feed Widget With jQuery, CSS3 &amp; YQL" src="http://tutorialzine.com/wp-content/uploads/2010/02/i11.jpg" alt="Feed Widget With jQuery, CSS3 &amp; YQL" width="620" height="460" /></a><p class="wp-caption-text">Feed Widget With jQuery, CSS3 &amp; YQL</p></div>
<h3>Step 2 &#8211; CSS</h3>
<p>The styling of the widget is defined in <strong>styles.css</strong>. Only the styles that are directly used by the widget are included here. You can view the rest of the CSS declarations that define the looks of the page itself in that file.</p>
<h4>styles.css &#8211; Part 1</h4>
<pre class="brush:css">#feedWidget{
	background:url(img/bg.png) repeat-x #47525c;
	border:2px solid #48535e;
	margin:0 auto;
	width:200px;
	padding:5px;
	position:relative;

	/* Remains hidden if JS is not enabled: */
	display:none;
	z-index:20;
}

#activeTab.hover,.dropDownList{
	background:url(img/drop_arrow.png) no-repeat 95% 50% #47525c;
	border:1px solid #38434d;

	margin:-1px;

	cursor:pointer;

	/* CSS3 round corners: */
	-moz-border-radius:5px;
	-webkit-border-radius:5px;
	border-radius:5px;

}

#activeTab,.dropDownList div{
	color:white;
	cursor:pointer;
	font-size:20px;
	margin:0 2px 0 0;
	padding:5px;

	text-shadow:0 1px 1px black;
}

.line{
	height:1px;
	overflow:hidden;
	background-color:#2b353d;
	border-bottom:1px solid #687581;
	margin:10px 0;
}</pre>
<p>Notice that we define a special hover class for the <strong>#activeTab</strong> div, instead of the regular <strong>:hover</strong> pseudo-class. This is because the hover style should only be applied if there is more than one tab to be shown, which is impossible to determine with CSS alone. This is why we apply it with JS.</p>
<p>The <strong>dropDownList</strong> shares a number of properties with the <strong>hover</strong> class of the <strong>#activeTab</strong> div. The most effective way to write the CSS is to group those two together, and later individually apply only those rules that differ, as you can see in the snippet below:</p>
<h4>styles.css &#8211; Part 2</h4>
<pre class="brush:css">.dropDownList{
	background-image:none;
	position:absolute;

	border-top:none;
	padding:5px;

	/* We reset the roundness of the top corners, inherited by a previous rule: */

	-moz-border-radius-topleft: 0;
	-moz-border-radius-topright: 0;
	-webkit-border-top-left-radius: 0;
	-webkit-border-top-right-radius: 0;
	border-top-left-radius: 0;
	border-top-right-radius: 0;
}

.dropDownList div:hover{
	background-color:#505e6b;
}

#tabContent div{
	/* The feed entry divs */

	background-color:#EEEEEE;
	color:#555555;
	font-size:10px;
	margin-bottom:10px;
	padding:5px;
	position:relative;

	-moz-border-radius:5px;
	-webkit-border-radius:5px;
	border-radius:5px;

	/* CSS3 box shadow: */
	-moz-box-shadow:0 1px 1px black;
	-webkit-box-shadow:0 1px 1px black;
	box-shadow:0 1px 1px black;
}
</pre>
<p>We apply a number of CSS3 rules here: <strong>border-radius</strong> for pure CSS rounded corners and <strong>box-shadow</strong> for adding a drop shadow below the feed items. They are provided with the -<strong>moz</strong>- and -<strong>webkit</strong>- vendor prefixes, because the regular version is not yet supported in any browser (but we supply it as well for future-proofing).</p>
<div id="attachment_665" class="wp-caption alignnone" style="width: 630px"><a href="http://tutorialzine.com/wp-content/uploads/2010/02/i31.jpg"><img class="size-full wp-image-665" title="The Dropdown" src="http://tutorialzine.com/wp-content/uploads/2010/02/i31.jpg" alt="The Dropdown" width="620" height="260" /></a><p class="wp-caption-text">The Dropdown</p></div>
<h3>Step 3 &#8211; jQuery</h3>
<p>After including the jQuery library into the page, it is now possible to leverage the methods it provides and build some complex interactions that would otherwise be impossible (or at least would take too much development resources).  The JavaScript code is located in <strong>scripts.js</strong> in the demo files.</p>
<h4>script.js &#8211; Part 1</h4>
<pre class="brush:js">/* Configuration: */

var tabs = {
	"@tutorialzine" : {
		"feed"		: "http://twitter.com/statuses/user_timeline/67315866.rss",
		"function"	: twitter
	},

	"Latest Tutorials": {
		"feed"		: "http://feeds.feedburner.com/Tutorialzine",
		"function"	: rss
	},

	"Smashing Mag": {
		"feed"		: "http://rss1.smashingmagazine.com/feed/",
		"function"	: rss
	},

	"Script &amp; Style" : {
		"feed"		: "http://feeds2.feedburner.com/ScriptAndStyle",
		"function"	: rss
	}
}

$(document).ready(function(){
	/* This code is executed after the DOM has been completely loaded */

	/* Counting the tabs: */
	var totalTabs=0;
	$.each(tabs,function(){totalTabs++;})

	$('#feedWidget').show().mouseleave(function(){

		/* If the cursor left the widet, hide the drop down list: */
		$('.dropDownList').remove();
		$('#activeTab').removeClass('hover');

	}).mouseenter(function(){

		if(totalTabs&gt;1) $('#activeTab').addClass('hover');

	});

	$('#activeTab').click(showDropDown);

	/* Using the live method to bind an event, because the .dropDownList does not exist yet: */

	$('.dropDownList div').live('click',function(){

 		/* Calling the showDropDown function, when the drop down is already shown, will hide it: */
		showDropDown();
		showTab($(this).text());
	});

	/* Showing one of the tabs on load: */

	showTab('@tutorialzine');
});
</pre>
<p>Notice the <strong>tabs</strong> object. It contains the declarations of the different feeds we want to use, along with a function that handles the output of those feeds to the page. The name of the property (before the colon) is inserted as a tab name, and when passed to the <strong>showTab()</strong> function, shows the contents of this feed inside the widget. This is how we load the &#8216;<strong>@tutorialzine</strong>&#8216; tweets on page load.</p>
<h4>script.js &#8211; Part 2</h4>
<pre class="brush:js">function showTab(key)
{
	var obj = tabs[key];
	if(!obj) return false;

	var stage = $('#tabContent');

	/* Forming the query: */
	var query = "select * from feed where url='"+obj.feed+"' LIMIT 5";

	/* Forming the URL to YQL: */
	var url = "http://query.yahooapis.com/v1/public/yql?q="+encodeURIComponent(query)+"&amp;format=json&amp;callback=?";

	$.getJSON(url,function(data){

		stage.empty();

		/* item exists in RSS and entry in ATOM feeds: */

		$.each(data.query.results.item || data.query.results.entry,function(){

			try{
				/* Trying to call the user provided function, "this" the rest of the feed data: */
				stage.append(obj['function'](this));

			}
			catch(e){
				/* Notifying users if there are any problems with their handler functions: */
				var f_name =obj['function'].toString().match(/function\s+(\w+)\(/i);
				if(f_name) f_name = f_name[1];

				stage.append('&lt;div&gt;There is a problem with your '+f_name+ ' function&lt;/div&gt;');
				return false;
			}
		})

	});

	$('#activeTab').text(key);
}

function showDropDown()
{
	if(totalTabs&lt;2) return false;

	if($('#feedWidget .dropDownList').length)
	{
	/* If the drop down is already shown, hide it: */

	$('.dropDownList').slideUp('fast',function(){ $(this).remove(); })

	return false;

	}

	var activeTab = $('#activeTab');

	var offsetTop = (activeTab.offset().top - $('#feedWidget').offset().top )+activeTab.outerHeight() - 5;

	/* Creating the drop down div on the fly: */

	var dropDown = $('&lt;div&gt;').addClass('dropDownList').css({

		'top'	: offsetTop,
		'width'	: activeTab.width()

	}).hide().appendTo('#feedWidget')

	$.each(tabs,function(j){

		/* Populating the div with the tabs that are not currently shown: */
		if(j==activeTab.text()) return true;

		$('&lt;div&gt;').text(j).appendTo(dropDown);
	})

	dropDown.slideDown('fast');

}
</pre>
<p>The <strong>showTab</strong> function takes a tab name as a parameter and displays it in the widget, after forming the corresponding <strong>YQL</strong> URL, and fetching it with the <strong>getJSON()</strong> method. After this, the response is looped with <strong>$.each</strong> and the function that was provided in the tab definition is called.</p>
<p>You can additionally switch the active tab from outside the widget code, by calling <strong>showTab()</strong> with a different tab name (and thus creating custom controls for the widget).</p>
<h4>script.js &#8211; Part 3</h4>
<pre class="brush:js">function twitter(item)
{
	/* Formats the tweets, by turning hashtags, mentions an URLS into proper hyperlinks: */

	return $('&lt;div&gt;').html(
		formatString(item.description || item.title)+
		' &lt;a href="'+(item.link || item.origLink)+'" target="_blank"&gt;[tweet]&lt;/a&gt;'
	);
}

function rss(item)
{
	return $('&lt;div&gt;').html(
		formatString(item.title.content || item.title)+
		' &lt;a href="'+(item.origLink || item.link[0].href || item.link)+'" target="_blank"&gt;[read]&lt;/a&gt;'
	);
}

function formatString(str)
{
	/* This function was taken from our Twitter Ticker tutorial - http://tutorialzine.com/2009/10/jquery-twitter-ticker/ */

	str = str.replace(/&lt;[^&gt;]+&gt;/ig,'');
	str=' '+str;
	str = str.replace(/((ftp|https?):\/\/([-\w\.]+)+(:\d+)?(\/([\w/_\.]*(\?\S+)?)?)?)/gm,'&lt;a href="$1" target="_blank"&gt;$1&lt;/a&gt;');
	str = str.replace(/([^\w])\@([\w\-]+)/gm,'$1@&lt;a href="http://twitter.com/$2" target="_blank"&gt;$2&lt;/a&gt;');
	str = str.replace(/([^\w])\#([\w\-]+)/gm,'$1&lt;a href="http://twitter.com/search?q=%23$2" target="_blank"&gt;#$2&lt;/a&gt;');
	return str;
}
</pre>
<p>In the last part of the code, we have the two functions &#8211; <strong>twitter</strong> and <strong>rss</strong>. These take an object passed from the <strong>$.each</strong> loop in <strong>showTab()</strong> and find their way to the link and title of the feed item, depending on whether it is RSS or ATOM.</p>
<p>You can create your own functions and include them in the <strong>tabs</strong> object. This way you can expand the functionality for feeds that are not limited to text. It is only important that you return the results as a <strong>&#8216;&lt;div&gt;&#8230;.&lt;/div&gt;&#8217;</strong> string.</p>
<p><strong>With this our Sleek Feed Widget is complete!</strong></p>
<h3>To Wrap It Up</h3>
<p>You are free to use and build upon the widget any way you see fit. The code is easy to modify and you can quickly implement all sorts of functionality.</p>
<p>If you liked this tutorial, be sure to <a href="http://twitter.com/Tutorialzine" target="_blank">follow us on twitter</a> for the latest and greatest web dev resources on the web.</p>
<p><strong>What do you think? How would you modify this code?</strong></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=MhmMn_gWjSg:JertWW152B4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=MhmMn_gWjSg:JertWW152B4:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=MhmMn_gWjSg:JertWW152B4:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=MhmMn_gWjSg:JertWW152B4:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=MhmMn_gWjSg:JertWW152B4:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=MhmMn_gWjSg:JertWW152B4:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=MhmMn_gWjSg:JertWW152B4:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=MhmMn_gWjSg:JertWW152B4:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=MhmMn_gWjSg:JertWW152B4:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=MhmMn_gWjSg:JertWW152B4:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Tutorialzine/~4/MhmMn_gWjSg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tutorialzine.com/2010/02/feed-widget-jquery-css-yql/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		<feedburner:origLink>http://tutorialzine.com/2010/02/feed-widget-jquery-css-yql/</feedburner:origLink></item>
		<item>
		<title>Making a Photoshoot Effect With jQuery &amp; CSS</title>
		<link>http://feedproxy.google.com/~r/Tutorialzine/~3/81g_gBbeqZI/</link>
		<comments>http://tutorialzine.com/2010/02/photo-shoot-css-jquery/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 18:16:11 +0000</pubDate>
		<dc:creator>Martin Angelov</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://tutorialzine.com/?p=641</guid>
		<description><![CDATA[We are creating a photo shoot effect with our just-released PhotoShoot jQuery plug-in. With it you can convert a regular div on the page into a photo shooting stage simulating a camera-like feel.]]></description>
			<content:encoded><![CDATA[<p>Often, in your design or development tasks, you are presented with challenges that require a different approach than just plunging head over heels in coding. Research and experiments are a vital part of this process.</p>
<p>This is why this week&#8217;s tutorial is structured in a slightly different manner than usual. First we are presented with the main problems faced and their solutions, and after this we get round to building upon it.</p>
<p>We are creating a photo shoot effect with our just-released <a href="http://tutorialzine.com/2010/02/jquery-photoshoot-plugin/" target="_blank">PhotoShoot jQuery plug-in</a>. With it you can convert a regular div on the page into a photo shooting stage simulating a camera-like feel. Using this plug-in, we give visitors the ability to take shots of the background image.</p>
<p>Before starting with the tutorial, I would suggest you download the zip archive from the buttons above.</p>
<h3>Problem 1 &#8211; Blurring the image</h3>
<p>JavaScript does not support blurring an image directly. For example, there is <strong>no such thing</strong> as document.getElemetById(&#8216;image&#8217;).style.blur=2, no matter how useful it would&#8217;ve been.</p>
<p>The technique I&#8217;ve used and incorporated into the plug-in is actually quite simple &#8211; it just stacks up a bunch of divs, each holding the image as a background and whose opacity is lowered, one on top of the other. Those divs&#8217; positions are off by a few pixels at random, so you end up with a blurred effect.</p>
<blockquote><p>There is however a newer alternative to this technique, which I hope to implement in a future version of the plugin. It is achieved via the <strong>canvas</strong> HTML5 element, which allows low-level modifications of an image inside of the canvas. Unfortunately, canvas is not yet supported by a large portion of the currently used browsers, so a combination of the techniques would have to be used.</p></blockquote>
<h3>Problem 2 &#8211; Hiding the cursor</h3>
<p>CSS does not provide a way for hiding the cursor from view. E.g. you <strong>cannot</strong> specify a CSS rule like <strong>cursor : none</strong>. There is a neat workaround  though. CSS gives you the ability to specify a custom cursor in a <strong>.cur</strong> file with the <strong>css:url()</strong> rule. These files support transparency, so you just need to make a completely transparent cursor and assign it to the area in which you wish the cursor to be hidden.</p>
<p>Unfortunately Google Chrome has issues with completely blank cursors, so a special version has to be tailored which contains one white pixel (still better than nothing).</p>
<p>Another trouble maker is Opera, which does not support custom cursors altogether. There are no workarounds. It is not that much of a big deal though, everything else runs fine in Opera.</p>
<h3>Problem 3 &#8211; No support for masks</h3>
<p>A solution to this problem is to use the background property of the viewfinder div to display the original image. By specifying a negative top and left margin and updating it on every mouse move, we can give users  the impression that the viewfinder clears up the blurring of the scenery below.</p>
<blockquote><p>Masking is the process in which only a part of an image or shape is shown, with the rest clipped away. In the case of this tutorial, a mask would&#8217;ve given us the ability to have a regular version of the image above the blurred one, and mask it, so that only the part that intersects with the viewfinder is shown and thus giving us the impression that it un-blurs the image below.</p></blockquote>
<p>The solutions to these problems are implemented in the plug-in for us, which lifts a lot of the development burden and we can start building upon it.</p>
<h3>Step 1 &#8211; XHTML</h3>
<p>As most of the work is handled by the PhotoShoot jQuery plug-in, our work is reduced to only provide a div that is going to be transformed into a photo shooting stage (we still have to pass a configuration object holding the image we want displayed, along with a few other options though).</p>
<h4>demo.html</h4>
<pre class="brush:html">&lt;div id="main"&gt;

&lt;!-- The plugin automatically inserts the needed markup here --&gt;

&lt;/div&gt;
</pre>
<p>You can have this div anywhere on your page. You&#8217;ll need to specify a fixed width and height in the stylesheet in order for this to work properly. After the page loads and the plug-in is initialized, additional code is inserted into this div.</p>
<h4>demo.html</h4>
<pre class="brush:html">&lt;div id="main"&gt;

&lt;div class="blur" style="......"&gt;&lt;/div&gt;
&lt;div class="blur" style="......"&gt;&lt;/div&gt;
&lt;!--  8 more blur divs --&gt;

&lt;div class="overlay" style="opacity: 0.2;"&gt;&lt;/div&gt;

&lt;div style="......" class="viewFinder"&gt;
&lt;img src="photoShoot/viewfinder.png" width="300" height="200"&gt;
&lt;/div&gt;

&lt;!-- Additional html for the shots is inserted here. Not part of the plug-in.  --&gt;

&lt;/div&gt;
</pre>
<p>A whole lot has changed here. As mentioned earlier, the blur effect is achieved by stacking transparent divs on top of each other &#8211; the <strong>blur</strong> divs. After this is the overlay div, which darkens the layers below it, according to the opacity option passed to the plug-in.</p>
<p>Finally we have the viewfinder, which follows the mouse movements on the area and has the non-blurred version of the image as its background.</p>
<p>To ensure maximum flexibility, the plug-in provides a way to execute a user-defined function when a click occurs. This is exactly what we use to simulate a camera flash and to insert a new shot in the album div, which is not part of the plug-in.</p>
<div id="attachment_644" class="wp-caption alignnone" style="width: 630px"><a href="http://tutorialzine.com/wp-content/uploads/2010/02/i1.jpg"><img class="size-full wp-image-644" title="A PhotoShoot Effect With Pure jQuery &amp; CSS" src="http://tutorialzine.com/wp-content/uploads/2010/02/i1.jpg" alt="A PhotoShoot Effect With Pure jQuery &amp; CSS" width="620" height="460" /></a><p class="wp-caption-text">A PhotoShoot Effect With Pure jQuery &amp; CSS</p></div>
<h3>Step 2 &#8211; CSS</h3>
<p>The plug-in comes with its own stylesheet (<strong>photoShoot/jquery.photoShoot-1.0.css</strong> in the demo files) which defines the look of the photo shoot components, so we are only left with styling the rest of the page.</p>
<h4>styles.css</h4>
<pre class="brush:css">#main{
	/* This div is converted to a photoShoot stage by the Photo Shoot plug-in */
	margin:0 auto;
	width:960px;
	height:600px;
}

.shot{
	/* These contain a scaled down version of the background image: */

	border:3px solid #FCFCFC;
	float:right;
	position:relative;
	margin-left:10px;
	overflow:hidden;

	/* Adding a CSS3 shadow below the shots: */

	-moz-box-shadow:0 0 2px black;
	-webkit-box-shadow:0 0 2px black;
	box-shadow:0 0 2px black;
}

.shot img{
	display:block;
}

.album{
	/* This div holds the shots */
	bottom:50px;
	height:110px;
	overflow:hidden;
	position:absolute;
	right:20px;
	width:490px;
}

.album .slide{
	/* The slide div is contained in album  */
	width:700px;
	height:110px;
	position:relative;
	left:-210px;
}
</pre>
<p>Each shot is dynamically inserted by our own custom <strong>shoot</strong> function when a click event occurs (as you will see in the next step of the tutorial). The shots are basically a scaled down version of the background image (this means that the image is downloaded once and used multiple times), which are offset to the top and bottom, according to the position of the viewfinder in the moment the event occurred.</p>
<p>The <strong>album</strong> and <strong>slide</strong> divs are added by our own jQuery script (not by the plug-in). The principle here is that the slide div is larger than its parent, the album div, and the shot is slid to the left when inserted, but more on that in a moment.</p>
<div id="attachment_645" class="wp-caption alignnone" style="width: 630px"><a href="http://tutorialzine.com/wp-content/uploads/2010/02/i2.jpg"><img class="size-full wp-image-645" title="The shots" src="http://tutorialzine.com/wp-content/uploads/2010/02/i2.jpg" alt="The shots" width="620" height="260" /></a><p class="wp-caption-text">The shots</p></div>
<h3>Step 3 &#8211; jQuery</h3>
<p>The photoShoot plug-in itself will not be discussed here as you can read more about it on its <a href="http://tutorialzine.com/2010/02/jquery-photoshoot-plugin/" target="_blank">official page</a>. We do need, however, some additional jQuery code which:</p>
<ul>
<li>Inserts the <strong>.album</strong> to the <strong>#main</strong> div;</li>
<li>Chooses a random flickr image from an array to be fed to the plug-in;</li>
<li>Creates the options object;</li>
<li>Defines a custom <strong>shot</strong> function which is called on mouse click by the plug-in;</li>
<li>Calls the plug-in with the .<strong>photoshoot()</strong> method.</li>
</ul>
<h4>script.js</h4>
<pre class="brush:js">$(document).ready(function(){

	// This code is executed after the DOM has been completely loaded

	// Assigning the jQuery object to a variable for speed:
	var main = $('#main');

	// Setting the width of the photoshoot area to
	// 1024 px or the width of the document - whichever is smallest:

	main.width(Math.min(1024,$(document).width()));

	// Creating an array with four possible backgrounds and their sizes:
	var pics = new Array(
				{ url:'http://farm4.static.flickr.com/3595/3405361333_77f2a5e731_b.jpg', size:{x:1024,y:677}},
				{ url:'http://farm4.static.flickr.com/3028/2753126743_4249a4e948_b.jpg', size:{x:1024,y:768}},
				{ url:'http://farm4.static.flickr.com/3641/3595250019_5a1237899a_b.jpg', size:{x:1024,y:768}},
				{ url:'http://farm3.static.flickr.com/2592/4018062274_1f7f23597d_o.jpg', size:{x:1158,y:756}}
	);

	// Choosing a random picture to be passed to the PhotoShoot jQuery plug-in:
	var bg = pics[parseInt(Math.random()*4)];

	// Creating an options object (try tweeking the variables):
	var opts = {
		image		:	bg.url,
		onClick		:	shoot,
		opacity		:	0.8,
		blurLevel	:	4
	}

	// Calling the photoShoot plug-in and converting the #main div to a photo shoot stage:
	main.photoShoot(opts);

	// Adding the album holder to the stage:
	$('&lt;div class="album"&gt;').html('&lt;div class="slide" /&gt;').appendTo(main);

	// Our own shoot function (it is passed as onClick to the options array above):
	function shoot(position){
		// This function is called by the plug-in when the button is pressed

		// Setting the overlay's div to white will create the illusion of a camera flash:
		main.find('.overlay').css('background-color','white');

		// The flash will last for 100 milliseconds (a tenth of the second):
		setTimeout(function(){main.find('.overlay').css('background-color','')},100);

		// Creating a new shot image:
		var newShot = $('&lt;div class="shot"&gt;').width(150).height(100);
		newShot.append( $('&lt;img src="'+bg.url+'" width="'+(bg.size.x/2)+'" height="'+(bg.size.y/2)+'" /&gt;').css('margin',-position.top*0.5+'px 0 0 -'+position.left*0.5+'px') );

		// Removing the fourth shot (the count starts from 0):
		$('.shot').eq(3).remove();

		// Adding the newly created shot to the album div, but moved 160px to the right.
		// We start an animation to slide it in view:

		newShot.css('margin-right',-160).prependTo('.album .slide').animate({marginRight:0},'slow');
	}
});
</pre>
<p>Each time you click the area, a new shot is added to the <strong>slide</strong> div with a negative margin to the right. After this an animation starts, which slides it in view and pushes the other shots to the left, hiding the leftmost one.</p>
<p>It is important to remove the shots that are not visible with the <strong>remove</strong>() method. This way we prevent cluttering of the DOM with unneeded elements.</p>
<div id="attachment_646" class="wp-caption alignnone" style="width: 630px"><a href="http://tutorialzine.com/wp-content/uploads/2010/02/i3.jpg"><img class="size-full wp-image-646" title="The jQuery Animation" src="http://tutorialzine.com/wp-content/uploads/2010/02/i3.jpg" alt="The jQuery Animation" width="620" height="260" /></a><p class="wp-caption-text">The jQuery Animation</p></div>
<p><strong>With this our Photoshoot effect is complete!</strong></p>
<h3>Conclusion</h3>
<p>Today we used a problem solving approach to create photo shoot effect with pure CSS and JavaScript. You can freely use the techniques demonstrated here and build upon the code. There are many possible uses especially in navigation systems and promotional sites.</p>
<p>If you liked this tutorial, be sure to <a href="http://twitter.com/Tutorialzine" target="_blank">follow us on twitter</a> for the latest web development news and links.</p>
<p>A big thanks goes to <a href="http://www.flickr.com/photos/haglundc/3405361333/" target="_blank">haglundc</a> for the <a href="http://www.flickr.com/photos/haglundc/3405361333/" target="_blank">landscape photo</a> used throughout this tutorial.</p>
<p><strong>What do you think? How would you use it?</strong></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=81g_gBbeqZI:Sappdv4go3M:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=81g_gBbeqZI:Sappdv4go3M:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=81g_gBbeqZI:Sappdv4go3M:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=81g_gBbeqZI:Sappdv4go3M:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=81g_gBbeqZI:Sappdv4go3M:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=81g_gBbeqZI:Sappdv4go3M:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=81g_gBbeqZI:Sappdv4go3M:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=81g_gBbeqZI:Sappdv4go3M:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=81g_gBbeqZI:Sappdv4go3M:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=81g_gBbeqZI:Sappdv4go3M:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Tutorialzine/~4/81g_gBbeqZI" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tutorialzine.com/2010/02/photo-shoot-css-jquery/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		<feedburner:origLink>http://tutorialzine.com/2010/02/photo-shoot-css-jquery/</feedburner:origLink></item>
		<item>
		<title>jQuery PhotoShoot Plugin 1.0</title>
		<link>http://feedproxy.google.com/~r/Tutorialzine/~3/vDT2lYy6bDk/</link>
		<comments>http://tutorialzine.com/2010/02/jquery-photoshoot-plugin/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 18:15:44 +0000</pubDate>
		<dc:creator>Martin Angelov</dc:creator>
				<category><![CDATA[Plugins]]></category>

		<guid isPermaLink="false">http://tutorialzine.com/?p=649</guid>
		<description><![CDATA[The jQuery PhotoShoot plugin gives you the ability to convert any div on your web page into a complete photo shooting effect.]]></description>
			<content:encoded><![CDATA[<p>The jQuery PhotoShoot plugin gives you the ability to convert any div on your web page into a photo shooting effect, complete with a view finder. You can check out the demonstration above, or a <a href="http://tutorialzine.com/2010/02/photo-shoot-css-jquery/" target="_blank">nice tutorial on how to use it here</a>.</p>
<h3>Usage</h3>
<p>First, you need to upload the plug-in to your server (it would be best to keep the folder structure intact), and include the stylesheet and js file to the page where you want it to show.</p>
<pre class="brush:html">&lt;link rel="stylesheet" type="text/css" href="photoShoot/jquery.photoShoot-1.0.css" /&gt;

&lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="photoShoot/jquery.photoShoot-1.0.js"&gt;&lt;/script&gt;
</pre>
<p>The plug-in depends on version 1.3.2 of jQuery, but will work fine with newer versions as well.</p>
<p>After this you can convert any div on your page by calling the <strong>.photoShoot()</strong> method and passing a configuration object.</p>
<pre class="brush:js">document.ready(function(){

	var config = {
		image : 'picture.jpg',
	}

	$('#selector').photoShoot(config)
});
</pre>
<p>You can pass additional parameters with the config object, according to the table below.</p>
<h3>Parameters</h3>
<p>The following parameters are supported:</p>
<table class="fancy-table" border="0" cellspacing="2" cellpadding="5">
<caption> Supported Parameters<br />
</caption>
<tbody>
<tr>
<th width="70">Parameter</th>
<th width="93">Default Value</th>
<th width="413">Description</th>
</tr>
<tr>
<td>image</td>
<td>&#8220;&#8221;</td>
<td>Required parameter. Specify the URL of the image to be shown.</td>
</tr>
<tr>
<td>blurLevel</td>
<td>4</td>
<td>The higher the blur level, the more blurred the image.</td>
</tr>
<tr>
<td>opacity</td>
<td>0.92</td>
<td>The lower the opacity, the darker the background behind the viewfinder.</td>
</tr>
<tr>
<td>viewFinder</td>
<td>{ width:300, height:200, img:&#8221; }</td>
<td>Expects an object with the properties width, height and img. With it you can change the size and png graphic of the view finder. If no img is provided, the default one is shown.</td>
</tr>
<tr>
<td>onClick</td>
<td>function(){}</td>
<td>Expects the name of the function that is going to be executed on click. An object is passed as a parameter. See below.</td>
</tr>
</tbody>
</table>
<h3>The onClick function</h3>
<p>You can provide your function to be executed when a click occurs. An <strong>object</strong> containing the location (left and top) of the viewfinder, relative to the background, is passed as the only <strong>parameter</strong>. Here is how it works:</p>
<pre class="brush:js">document.ready(function(){

	var config = {
		image	: 'picture.jpg',
		blurLevel	: 6,
		opacity	: 0.8,
		onClick	: alertPosition
	}

	function alertPosition(param){
		alert("The viewfinder is located at: "+param.left+"x"+param.top);
	}

	$('#selector').photoShoot(config)
});</pre>
<h3>License</h3>
<p>The plugin is distributed under an MIT license.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=vDT2lYy6bDk:uLevO7bZ3Nw:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=vDT2lYy6bDk:uLevO7bZ3Nw:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=vDT2lYy6bDk:uLevO7bZ3Nw:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=vDT2lYy6bDk:uLevO7bZ3Nw:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=vDT2lYy6bDk:uLevO7bZ3Nw:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=vDT2lYy6bDk:uLevO7bZ3Nw:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=vDT2lYy6bDk:uLevO7bZ3Nw:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=vDT2lYy6bDk:uLevO7bZ3Nw:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=vDT2lYy6bDk:uLevO7bZ3Nw:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=vDT2lYy6bDk:uLevO7bZ3Nw:qj6IDK7rITs"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?d=qj6IDK7rITs" border="0"></img></a>
</div><img src="http://feeds.feedburner.com/~r/Tutorialzine/~4/vDT2lYy6bDk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tutorialzine.com/2010/02/jquery-photoshoot-plugin/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		<feedburner:origLink>http://tutorialzine.com/2010/02/jquery-photoshoot-plugin/</feedburner:origLink></item>
	</channel>
</rss>
