<?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>Web Development Tutorials &amp; Resources</description>
	<lastBuildDate>Mon, 14 May 2012 09:13:18 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<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>How to use Geolocation and Yahoo’s APIs to build a simple weather webapp</title>
		<link>http://feedproxy.google.com/~r/Tutorialzine/~3/WE9Ji7e9_mo/</link>
		<comments>http://tutorialzine.com/2012/05/weather-forecast-geolocation-jquery/#comments</comments>
		<pubDate>Mon, 14 May 2012 09:13:18 +0000</pubDate>
		<dc:creator>Martin Angelov</dc:creator>
				<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://tutorialzine.com/?p=1985</guid>
		<description><![CDATA[<div><a href="http://tutorialzine.com/2012/05/weather-forecast-geolocation-jquery/"><img src="http://cdn.tutorialzine.com/img/featured/1985.jpg" /></a></div> Today we will be using the HTML5 Geolocation API to present the user with a personalized weather forecast.]]></description>
			<content:encoded><![CDATA[<div><a href="http://tutorialzine.com/2012/05/weather-forecast-geolocation-jquery/"><img src="http://cdn.tutorialzine.com/img/featured/1985.jpg" /></a></div> <p>Today we will be using the HTML5 geolocation API to present the user with a personalized weather forecast. Using jQuery, we will issue AJAX request to two of Yahoo&#8217;s popular APIs to obtain additional geographical information and a weather forecast. This example also makes use of the wonderful <a href="http://adamwhitcroft.com/climacons/" target="_blank">climacons icon set</a>.</p>
<h3>Obtaining an Application Key</h3>
<p>Yahoo provides a <a href="http://developer.yahoo.com/everything.html" target="_blank">large collection of useful APIs</a> that are free for developers to use. The requirement is that you register your application with through their <a href="https://developer.apps.yahoo.com/dashboard/createKey.html" target="_blank">developer dashboard</a>. The registration is simple and straightforward, and as a result you obtain an application id (look for it under the title of your application). You are going to need this later in the tutorial, but first let&#8217;s see how everything would work together.</p>
<h3>The Idea</h3>
<p>Here is what we need to do in order to display our weather forecast:</p>
<ul>
<li>First we&#8217;ll use the <em>Geolocation API</em> supported by modern browsers. The API will prompt the user to authorize location access and will return a set of GPS coordinates;</li>
<li>Next, we will issue a request to Yahoo&#8217;s <a href="http://developer.yahoo.com/geo/placefinder/" target="_blank">PlaceFinder API</a>, passing the above coordinates. This will give us the name of the city and country, and a <strong>woeid</strong> &#8211; a special ID used to identify the city in weather forecasts;</li>
<li>Finally, we will issue a request to Yahoo&#8217;s <a href="http://developer.yahoo.com/weather/" target="_blank">Weather API</a> with that woeid. This will give us current weather conditions, as well as a forecast for the rest of the current and the next day.</li>
</ul>
<p>Great! We are now ready for the HTML.</p>
<div id="attachment_1996" class="wp-caption alignnone" style="width: 630px"><a href="http://demo.tutorialzine.com/2012/05/weather-forecast-geolocation-jquery/"><img class="size-full wp-image-1996" title="Weather Forecast Web App" src="http://cdn.tutorialzine.com/wp-content/uploads/2012/05/jquery-geolocation-weather-app.jpg" alt="Weather Forecast Web App" width="620" height="460" /></a><p class="wp-caption-text">Weather Forecast Web App</p></div>
<h3>The HTML</h3>
<p>We will start with a blank HTML5 document, and we will add a reference to our stylesheet to the head section, along with two fonts from <a href="http://www.google.com/webfonts" target="_blank">Google&#8217;s Webfonts</a> library. In the body we will add a h1 header and markup for the weather forecast slider.</p>
<h4>index.html</h4>
<pre class="brush:html">&lt;!DOCTYPE html&gt;
&lt;html&gt;
    &lt;head&gt;
        &lt;meta charset="utf-8" /&gt;
        &lt;title&gt;Weather Forecast with jQuery &amp;amp; Yahoo APIs | Tutorialzine Demo&lt;/title&gt;

        &lt;!-- The stylesheet --&gt;
        &lt;link rel="stylesheet" href="assets/css/styles.css" /&gt;

        &lt;!-- Google Fonts --&gt;
        &lt;link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Playball|Open+Sans+Condensed:300,700" /&gt;

        &lt;!--[if lt IE 9]&gt;
          &lt;script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"&gt;&lt;/script&gt;
        &lt;![endif]--&gt;
    &lt;/head&gt;

    &lt;body&gt;

		&lt;header&gt;
			&lt;h1&gt;Weather Forecast&lt;/h1&gt;
		&lt;/header&gt;

        &lt;div id="weather"&gt;

        	&lt;ul id="scroller"&gt;
        		&lt;!-- The forecast items will go here --&gt;
        	&lt;/ul&gt;

        	&lt;a href="#" class="arrow previous"&gt;Previous&lt;/a&gt;
        	&lt;a href="#" class="arrow next"&gt;Next&lt;/a&gt;

        &lt;/div&gt;

        &lt;p class="location"&gt;&lt;/p&gt;

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

        &lt;!-- JavaScript includes - jQuery, turn.js and our own script.js --&gt;
		&lt;script src="http://code.jquery.com/jquery-1.7.2.min.js"&gt;&lt;/script&gt;
		&lt;script src="assets/js/script.js"&gt;&lt;/script&gt;

    &lt;/body&gt;
&lt;/html&gt;</pre>
<p>Before the closing body tag we are adding the latest version of jQuery and our script.js file, which we are discussing in the following sections.</p>
<h3>The JavaScript</h3>
<p>The first step is to define two configuration variables in <strong>/assets/js/script.js</strong>:</p>
<pre class="brush:js">var APPID = '';	// Your Yahoo Application ID
var DEG = 'c';	// c for celsius, f for fahrenheit</pre>
<p>These are passed as parameters with the AJAX requests for the location and weather APIs as you will see in a moment.</p>
<p>Following the outline in the idea section, we should now look into using the <em>HTML5 Geolocation API</em> to obtain a set of GPS coordinates. This API is supported by all new browsers including IE9 and mobile devices. To use it, we need to test whether the global navigator object has a <strong>geolocation</strong> property. If it does, we call its <strong>getCurrentPosition</strong> method passing two event handling functions for success and failure. Here is the relevant code from <strong>script.js</strong> that does this:</p>
<pre class="brush:js">// Does this browser support geolocation?
if (navigator.geolocation) {
	navigator.geolocation.getCurrentPosition(locationSuccess, locationError);
}
else{
	showError("Your browser does not support Geolocation!");
}

function locationSuccess(position) {
	var lat = position.coords.latitude;
	var lon = position.coords.longitude;

	// We will make further requests to Yahoo's APIs here
}

function locationError(error){
	switch(error.code) {
		case error.TIMEOUT:
			showError("A timeout occured! Please try again!");
			break;
		case error.POSITION_UNAVAILABLE:
			showError('We can\'t detect your location. Sorry!');
			break;
		case error.PERMISSION_DENIED:
			showError('Please allow geolocation access for this to work.');
			break;
		case error.UNKNOWN_ERROR:
			showError('An unknown error occured!');
			break;
	}

}

function showError(msg){
	weatherDiv.addClass('error').html(msg);
}</pre>
<p>The <strong>locationSuccess</strong> function is where we will be issuing requests to Yahoo&#8217;s APIs in a moment. The <strong>locationError</strong> function is passed an error object with the specific reason for the error condition. We will use a <strong>showError</strong> helper function to display the error messages on the screen.</p>
<p>The full version of <em>locationSuccess</em> follows:</p>
<pre class="brush:js">function locationSuccess(position) {
	var lat = position.coords.latitude;
	var lon = position.coords.longitude;

	// Yahoo's PlaceFinder API http://developer.yahoo.com/geo/placefinder/
	// We are passing the R gflag for reverse geocoding (coordinates to place name)
	var geoAPI = 'http://where.yahooapis.com/geocode?location='+lat+','+lon+'&amp;flags=J&amp;gflags=R&amp;appid='+APPID;

	// Forming the query for Yahoo's weather forecasting API with YQL
	// http://developer.yahoo.com/weather/

	var wsql = 'select * from weather.forecast where woeid=WID and u="'+DEG+'"',
		weatherYQL = 'http://query.yahooapis.com/v1/public/yql?q='+encodeURIComponent(wsql)+'&amp;format=json&amp;callback=?',
		code, city, results, woeid;

	// Issue a cross-domain AJAX request (CORS) to the GEO service.
	// Not supported in Opera and IE.
	$.getJSON(geoAPI, function(r){

		if(r.ResultSet.Found == 1){

			results = r.ResultSet.Results;
			city = results[0].city;
			code = results[0].statecode || results[0].countrycode;

			// This is the city identifier for the weather API
			woeid = results[0].woeid;

			// Make a weather API request (it is JSONP, so CORS is not an issue):
			$.getJSON(weatherYQL.replace('WID',woeid), function(r){

				if(r.query.count == 1){

					// Create the weather items in the #scroller UL

					var item = r.query.results.channel.item.condition;
					addWeather(item.code, "Now", item.text + ' &lt;b&gt;'+item.temp+'°'+DEG+'&lt;/b&gt;');

					for (var i=0;i&lt;2;i++){
						item = r.query.results.channel.item.forecast[i];
						addWeather(
							item.code,
							item.day +' &lt;b&gt;'+item.date.replace('\d+$','')+'&lt;/b&gt;',
							item.text + ' &lt;b&gt;'+item.low+'°'+DEG+' / '+item.high+'°'+DEG+'&lt;/b&gt;'
						);
					}

					// Add the location to the page
					location.html(city+', &lt;b&gt;'+code+'&lt;/b&gt;');

					weatherDiv.addClass('loaded');

					// Set the slider to the first slide
					showSlide(0);

				}
				else {
					showError("Error retrieving weather data!");
				}
			});

		}

	}).error(function(){
		showError("Your browser does not support CORS requests!");
	});

}</pre>
<p>The PlaceFinder API returns its results as plain JSON. But as it is on a different domain, only browsers that support CORS (cross origin resource sharing) will be able to retrieve it. Most major browsers that support geolocation also support CORS, with the exception of IE9 and Opera, which means that this example won&#8217;t work there.</p>
<p>Another thing to consider is that the weather API returns only two days of forecasts, which somewhat limits the utility of our web app, but unfortunately there is no way around it.</p>
<blockquote class="note"><p>We are only using the Weather API for temperature data, but it provides additional information that you might find useful. You can play with the API and browse the responses in the <a href="http://developer.yahoo.com/yql/console/?q=show%20tables&amp;env=store://datatables.org/alltableswithkeys#h=select%20*%20from%20weather.forecast%20where%20woeid%3D2502265" target="_blank">YQL console</a>.</p></blockquote>
<p>After we retrieve the weather data, we call the <strong>addWeather</strong> function, which creates a new LI item in the <em>#scroller</em> unordered list.</p>
<pre class="brush:js">function addWeather(code, day, condition){

	var markup = '&lt;li&gt;'+
		'&lt;img src="assets/img/icons/'+ weatherIconMap[code] +'.png" /&gt;'+
		' &lt;p class="day"&gt;'+ day +'&lt;/p&gt; &lt;p class="cond"&gt;'+ condition +
		'&lt;/p&gt;&lt;/li&gt;';

	scroller.append(markup);
}</pre>
<p>Now we need to listen for clicks on the previous / next arrows, so we can offset the slider to reveal the correct day of the forecast.</p>
<pre class="brush:js">	/* Handling the previous / next arrows */

	var currentSlide = 0;
	weatherDiv.find('a.previous').click(function(e){
		e.preventDefault();
		showSlide(currentSlide-1);
	});

	weatherDiv.find('a.next').click(function(e){
		e.preventDefault();
		showSlide(currentSlide+1);
	});

	function showSlide(i){
		var items = scroller.find('li');

		// Exit if the requested item does not exist,
		// or the scroller is currently being animated
		if (i &gt;= items.length || i &lt; 0 || scroller.is(':animated')){
			return false;
		}

		// The first/last classes hide the left/right arrow with CSS
		weatherDiv.removeClass('first last');

		if(i == 0){
			weatherDiv.addClass('first');
		}
		else if (i == items.length-1){
			weatherDiv.addClass('last');
		}

		scroller.animate({left:(-i*100)+'%'}, function(){
			currentSlide = i;
		});
	}</pre>
<p><strong>With this our simple weather web app is complete!</strong> You can see everything together in <em>/assets/js/script.js</em>. We won't be discussing the styling here, but you can read through <em>/assets/css/styles.css</em> yourself.</p>
<h3>Done!</h3>
<p>In this example you learned how to use the HTML5 geolocation with Yahoo's Weather and Places APIs to present a location-aware weather forecast. It works on most modern web browsers and mobile devices.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=WE9Ji7e9_mo:cSfOze2YRR4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=WE9Ji7e9_mo:cSfOze2YRR4:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=WE9Ji7e9_mo:cSfOze2YRR4:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=WE9Ji7e9_mo:cSfOze2YRR4:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=WE9Ji7e9_mo:cSfOze2YRR4:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=WE9Ji7e9_mo:cSfOze2YRR4:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=WE9Ji7e9_mo:cSfOze2YRR4:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=WE9Ji7e9_mo:cSfOze2YRR4:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=WE9Ji7e9_mo:cSfOze2YRR4:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=WE9Ji7e9_mo:cSfOze2YRR4: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/WE9Ji7e9_mo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tutorialzine.com/2012/05/weather-forecast-geolocation-jquery/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		<feedburner:origLink>http://tutorialzine.com/2012/05/weather-forecast-geolocation-jquery/</feedburner:origLink></item>
		<item>
		<title>4Teamplates Winners</title>
		<link>http://feedproxy.google.com/~r/Tutorialzine/~3/BNnyBYmpmrw/</link>
		<comments>http://tutorialzine.com/2012/05/4teamplates-winners/#comments</comments>
		<pubDate>Mon, 07 May 2012 14:32:03 +0000</pubDate>
		<dc:creator>Martin Angelov</dc:creator>
				<category><![CDATA[Tzine]]></category>

		<guid isPermaLink="false">http://tutorialzine.com/?p=1979</guid>
		<description><![CDATA[<div><a href="http://tutorialzine.com/2012/05/4teamplates-winners/"><img src="http://cdn.tutorialzine.com/img/featured/1979.jpg" /></a></div> Announcing the winners for the 4Templates giveaway.]]></description>
			<content:encoded><![CDATA[<div><a href="http://tutorialzine.com/2012/05/4teamplates-winners/"><img src="http://cdn.tutorialzine.com/img/featured/1979.jpg" /></a></div> <p>Nearly two weeks ago, you participated in a <a href="http://tutorialzine.com/2012/04/4templates-giveaway/">giveaway for $50 credit at 4Templates</a>. Now is time to draw the winners!</p>
<p>And they are:</p>
<p><em><strong>Alejandro Carrillo</strong></em> and <em><strong>Patschi</strong></em></p>
<p>They have been contacted and will receive their prizes shortly. Congratulations!</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=BNnyBYmpmrw:x83WnNX-5QA:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=BNnyBYmpmrw:x83WnNX-5QA:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=BNnyBYmpmrw:x83WnNX-5QA:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=BNnyBYmpmrw:x83WnNX-5QA:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=BNnyBYmpmrw:x83WnNX-5QA:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=BNnyBYmpmrw:x83WnNX-5QA:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=BNnyBYmpmrw:x83WnNX-5QA:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=BNnyBYmpmrw:x83WnNX-5QA:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=BNnyBYmpmrw:x83WnNX-5QA:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=BNnyBYmpmrw:x83WnNX-5QA: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/BNnyBYmpmrw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tutorialzine.com/2012/05/4teamplates-winners/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://tutorialzine.com/2012/05/4teamplates-winners/</feedburner:origLink></item>
		<item>
		<title>TouchTouch – A Touch Optimized Gallery Plugin</title>
		<link>http://feedproxy.google.com/~r/Tutorialzine/~3/XUm_1HZtTiU/</link>
		<comments>http://tutorialzine.com/2012/04/mobile-touch-gallery/#comments</comments>
		<pubDate>Thu, 26 Apr 2012 22:01:23 +0000</pubDate>
		<dc:creator>Martin Angelov</dc:creator>
				<category><![CDATA[Plugins]]></category>

		<guid isPermaLink="false">http://tutorialzine.com/?p=1966</guid>
		<description><![CDATA[<div><a href="http://tutorialzine.com/2012/04/mobile-touch-gallery/"><img src="http://cdn.tutorialzine.com/img/featured/1966.jpg" /></a></div> TouchTouch is a jQuery plugin that makes it easy to display a set of photos on your site as a touch-optimized photo gallery.]]></description>
			<content:encoded><![CDATA[<div><a href="http://tutorialzine.com/2012/04/mobile-touch-gallery/"><img src="http://cdn.tutorialzine.com/img/featured/1966.jpg" /></a></div> <p>I want to share a little experiment with Tutorialzine readers &#8211; TouchTouch. It is a jQuery plugin that turns a collection of photos on a webpage into a touch-friendly mobile gallery. It works on all major browsers (except for IE7 and below) and most importantly is specifically designed with iOS and Android in mind.</p>
<h3>Highlights</h3>
<ul>
<li>Smooth CSS3 animations and transitions;</li>
<li>A responsive CSS interface that fills the screen and responds to changes in device orientation;</li>
<li>Preloads photos only when they are needed;</li>
<li>Supports swiping through photos;</li>
<li>Displays onscreen arrows and listens for arrow key presses on desktop browsers;</li>
</ul>
<p>TouchTouch relies entirely on CSS3 for animations, which means that transitions are extra smooth on mobile devices (naturally, this also means that you won&#8217;t see any on older browsers). Using some clever CSS, the interface automatically adjusts to the size and orientation of the device, with photos growing to fill the available screen estate (test it by resizing your browser window). And with the help of jQuery, going through photos is done by swiping left or right.</p>
<p>On the desktop, you get that same responsive interface and smooth animations. Browsing the gallery there is done either with the onscreen arrows, or the arrow keys on the keyboard.</p>
<div id="attachment_1973" class="wp-caption alignnone" style="width: 630px"><a href="http://demo.tutorialzine.com/2012/04/mobile-touch-gallery/"><img class="size-full wp-image-1973" title="jQuery touch-optimized gallery" src="http://cdn.tutorialzine.com/wp-content/uploads/2012/04/touch-gallery-jquery-plugin.jpg" alt="jQuery touch-optimized gallery" width="620" height="400" /></a><p class="wp-caption-text">jQuery touch-optimized gallery</p></div>
<h3>How to use</h3>
<p>Using it is simple. Drop the <strong>touchTouch</strong> folder (you can find it in the download under <em>assets/</em>) somewhere in your website folder tree. After this, include <strong>touchTouch/touchTouch.css</strong> in your &lt;head&gt;, and <strong>touchTouch.jquery.js</strong> right after the jQuery library. The script depends on <strong>jQuery 1.7</strong> or above.</p>
<p>After you do all of this, simply call the gallery as a regular jQuery plugin:</p>
<pre class="brush:js">$(function(){

	// Initialize the gallery
	$('#thumbs a').touchTouch();

});</pre>
<p>You must pass anchor elements which point to images in their href attributes for the gallery to work. In addition to conveying which images are to be displayed in the gallery, this also provides a graceful fallback in case JavaScript is not available.</p>
<p>Following Tutorialzine&#8217;s tradition of releasing quality resources for developers, the gallery source code is extensively commented and released on <a href="https://github.com/martinaglv/touchTouch" target="_blank">Github</a>.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=XUm_1HZtTiU:P9FxAdJdJVg:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=XUm_1HZtTiU:P9FxAdJdJVg:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=XUm_1HZtTiU:P9FxAdJdJVg:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=XUm_1HZtTiU:P9FxAdJdJVg:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=XUm_1HZtTiU:P9FxAdJdJVg:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=XUm_1HZtTiU:P9FxAdJdJVg:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=XUm_1HZtTiU:P9FxAdJdJVg:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=XUm_1HZtTiU:P9FxAdJdJVg:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=XUm_1HZtTiU:P9FxAdJdJVg:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=XUm_1HZtTiU:P9FxAdJdJVg: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/XUm_1HZtTiU" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tutorialzine.com/2012/04/mobile-touch-gallery/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		<feedburner:origLink>http://tutorialzine.com/2012/04/mobile-touch-gallery/</feedburner:origLink></item>
		<item>
		<title>Win a $50 Credit From 4Templates!</title>
		<link>http://feedproxy.google.com/~r/Tutorialzine/~3/ZRdEQhAyVhg/</link>
		<comments>http://tutorialzine.com/2012/04/4templates-giveaway/#comments</comments>
		<pubDate>Tue, 24 Apr 2012 21:21:16 +0000</pubDate>
		<dc:creator>Martin Angelov</dc:creator>
				<category><![CDATA[Tzine]]></category>

		<guid isPermaLink="false">http://tutorialzine.com/?p=1960</guid>
		<description><![CDATA[<div><a href="http://tutorialzine.com/2012/04/4templates-giveaway/"><img src="http://cdn.tutorialzine.com/img/featured/1960.jpg" /></a></div> Our friends at 4Templates are offering a prize for two lucky Tutorialzine readers.]]></description>
			<content:encoded><![CDATA[<div><a href="http://tutorialzine.com/2012/04/4templates-giveaway/"><img src="http://cdn.tutorialzine.com/img/featured/1960.jpg" /></a></div> <p><a href="http://4templates.com/">4Temlates.com</a> has hundreds of awesome website templates and WordPress themes with amazing graphics, standards compliant XHTML and CSS code, PSD files, and great tech support whenever you need it. And with pricing $25 or below, you’ll always find something that works great no matter the project or budget.</p>
<p>Today two of you will have a chance to win <strong>$50</strong> in credit for their online store! You can use it to download any themes you wish.</p>
<h3>How to win?</h3>
<ul>
<li>Follow <a href="http:/twitter.com/4templates" target="_blank">@4Templates</a> on Twitter.</li>
<li><a href="https://twitter.com/share?text=Win+a+$50+credit+at+@4Templates!&amp;url=http://tutorialzine.com/2012/04/4templates-giveaway/&amp;via=tutorialzine" target="_blank">Tweet this article</a> and leave a comment below.</li>
</ul>
<p><span style="text-decoration: line-through;"><em>The winners will be announced on May 7th 2012 in a follow-up post.</em></span> <em><a href="http://tutorialzine.com/2012/05/4teamplates-winners/">Announced!</a></em></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=ZRdEQhAyVhg:Y_-TwzA6ziM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=ZRdEQhAyVhg:Y_-TwzA6ziM:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=ZRdEQhAyVhg:Y_-TwzA6ziM:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=ZRdEQhAyVhg:Y_-TwzA6ziM:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=ZRdEQhAyVhg:Y_-TwzA6ziM:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=ZRdEQhAyVhg:Y_-TwzA6ziM:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=ZRdEQhAyVhg:Y_-TwzA6ziM:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=ZRdEQhAyVhg:Y_-TwzA6ziM:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=ZRdEQhAyVhg:Y_-TwzA6ziM:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=ZRdEQhAyVhg:Y_-TwzA6ziM: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/ZRdEQhAyVhg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tutorialzine.com/2012/04/4templates-giveaway/feed/</wfw:commentRss>
		<slash:comments>43</slash:comments>
		<feedburner:origLink>http://tutorialzine.com/2012/04/4templates-giveaway/</feedburner:origLink></item>
		<item>
		<title>5 Lightweight jQuery Alternatives for Mobile Development</title>
		<link>http://feedproxy.google.com/~r/Tutorialzine/~3/2_Fl3JkwJVg/</link>
		<comments>http://tutorialzine.com/2012/04/5-lightweight-jquery-alternatives/#comments</comments>
		<pubDate>Tue, 17 Apr 2012 09:38:05 +0000</pubDate>
		<dc:creator>Martin Angelov</dc:creator>
				<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://tutorialzine.com/?p=1942</guid>
		<description><![CDATA[<div><a href="http://tutorialzine.com/2012/04/5-lightweight-jquery-alternatives/"><img src="http://cdn.tutorialzine.com/img/featured/1942.jpg" /></a></div> Sometimes jQuery is not the smart choice. Learn about 5 alternatives here.]]></description>
			<content:encoded><![CDATA[<div><a href="http://tutorialzine.com/2012/04/5-lightweight-jquery-alternatives/"><img src="http://cdn.tutorialzine.com/img/featured/1942.jpg" /></a></div> <p>We all love jQuery. This site is even dedicated to building beautiful examples that use the library. But there are situations in which jQuery is not the smart choice. If you are using it only for simple DOM manipulation or an AJAX request or two, why slow down your page load times and introduce an additional dependency?</p>
<p>The problem is more severe on mobile devices. You see, although we include jQuery via a CDN like Google&#8217;s, it is still not free &#8211; downloading it and parsing it still takes time. The very thing that made jQuery popular &#8211; perfect cross browser support, also makes it too bulky for use on mobile devices. After all, why would you need your mobile website to support old IE versions if it is meant to be viewed only on iOS and Android?</p>
<h3>Getting Lean</h3>
<p>There are additional problems to be solved. jQuery&#8217;s approach to animations for instance is to modify the css style properties of an element in small intervals. This works fine on the desktop, but performs poorly on mobile devices. Pure CSS animations on the other hand (that use transitions and @keyframes) are hardware accelerated and smooth.</p>
<p>This means that a whole new approach must be taken for building mobile websites. Fortunately, there are five libraries that can help us with that.</p>
<h4>Zepto.js</h4>
<div id="attachment_1948" class="wp-caption alignnone" style="width: 630px"><a href="http://zeptojs.com/"><img class="size-full wp-image-1948" title="Zepto.js" src="http://cdn.tutorialzine.com/wp-content/uploads/2012/04/zepto.jpg" alt="Zepto.js" width="620" height="260" /></a><p class="wp-caption-text">Zepto.js</p></div>
<p>This is the most feature-rich library out there that is specifically designed for iOS and Android (both using the webkit engine). It retains nearly all of jQuery&#8217;s functionality in 8kb (instead of jQuery&#8217;s 32) and adds support for touch events (including pinch to zoom) and pure CSS animations. It takes a modular approach &#8211; you only add the components that you need for an even leaner library.</p>
<p><a href="http://zeptojs.com/" target="_blank">Site</a> | <a href="https://github.com/madrobby/zepto" target="_blank">Github</a></p>
<h4>Snack.js</h4>
<div id="attachment_1949" class="wp-caption alignnone" style="width: 630px"><a href="http://snackjs.com/"><img class="size-full wp-image-1949" title="Snack.js" src="http://cdn.tutorialzine.com/wp-content/uploads/2012/04/snack.jpg" alt="Snack.js" width="620" height="260" /></a><p class="wp-caption-text">Snack.js</p></div>
<p>Snack is a small and simple JavaScript library. Though ideal for small projects, it&#8217;s got enough in it to build complex, cross-browser web apps. It takes a different approach than Zepto in that it breaks away from the jQuery API but at 3kb is half the size. You will have to handle animations yourself with this one.</p>
<p><a href="http://snackjs.com/" target="_blank">Site</a> | <a href="https://github.com/rpflorence/snack" target="_blank">Github</a></p>
<h4>$dom</h4>
<div id="attachment_1950" class="wp-caption alignnone" style="width: 630px"><a href="https://github.com/julienw/dollardom/"><img class="size-full wp-image-1950" title="$dom" src="http://cdn.tutorialzine.com/wp-content/uploads/2012/04/dollardom.jpg" alt="$dom" width="620" height="260" /></a><p class="wp-caption-text">$dom</p></div>
<p>$dom is even smaller &#8211; at 2kb it packs quite a punch. It keeps cross-browser compatibility and even handles animations (albeit taking jQuery&#8217;s approach with a timeout), but omits functionality like array manipulation functions and AJAX. The perfect use case for this library is when building responsive websites, which can be viewed on smartphones, tablets and desktops.</p>
<p><a href="https://github.com/julienw/dollardom/" target="_blank">Github</a></p>
<h4>xui.js</h4>
<div id="attachment_1951" class="wp-caption alignnone" style="width: 630px"><a href="http://xuijs.com/"><img class="size-full wp-image-1951" title="xui.js" src="http://cdn.tutorialzine.com/wp-content/uploads/2012/04/xui.jpg" alt="xui.js" width="620" height="260" /></a><p class="wp-caption-text">xui.js</p></div>
<p>At 4kb XUI is a small framework for authoring HTML5 mobile web applications. It works across all of the devices in the mobile landscape and even has special builds for webkit, ie mobile and blackberry browser. It supports touch events and even has a jQuery compatibility plugin.</p>
<p><a href="http://xuijs.com/" target="_blank">Site</a> | <a href="https://github.com/xui/xui" target="_blank">Github</a></p>
<h4>140medley</h4>
<div id="attachment_1952" class="wp-caption alignnone" style="width: 630px"><a href="https://github.com/honza/140medley"><img class="size-full wp-image-1952" title="140medley" src="http://cdn.tutorialzine.com/wp-content/uploads/2012/04/140medley.jpg" alt="140medley" width="620" height="260" /></a><p class="wp-caption-text">140medley</p></div>
<p>You can&#8217;t go more micro than 140medley. This 0.5kb collection of functionality was inspired by the <a href="http://140byt.es/">140bytes</a> contest, where participants create tweet-sized JavaScript snippets. It supports templates, events and even AJAX. This is pro territory only, as the only documentation provided is through comments in the cryptic source code.</p>
<p><a href="https://github.com/honza/140medley" target="_blank">Github</a></p>
<h3>Conclusion</h3>
<p>These are only some of the exciting new frameworks that are out there. But it isn&#8217;t enough to have an awesome name or site &#8211; the community is what makes or breaks an open source project. So if you find something interesting that is worth your time, make sure to spread the word about it.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=2_Fl3JkwJVg:nWL-wLbDddM:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=2_Fl3JkwJVg:nWL-wLbDddM:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=2_Fl3JkwJVg:nWL-wLbDddM:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=2_Fl3JkwJVg:nWL-wLbDddM:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=2_Fl3JkwJVg:nWL-wLbDddM:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=2_Fl3JkwJVg:nWL-wLbDddM:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=2_Fl3JkwJVg:nWL-wLbDddM:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=2_Fl3JkwJVg:nWL-wLbDddM:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=2_Fl3JkwJVg:nWL-wLbDddM:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=2_Fl3JkwJVg:nWL-wLbDddM: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/2_Fl3JkwJVg" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tutorialzine.com/2012/04/5-lightweight-jquery-alternatives/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<feedburner:origLink>http://tutorialzine.com/2012/04/5-lightweight-jquery-alternatives/</feedburner:origLink></item>
		<item>
		<title>Timeline Portfolio</title>
		<link>http://feedproxy.google.com/~r/Tutorialzine/~3/qvnuiMAbgB8/</link>
		<comments>http://tutorialzine.com/2012/04/timeline-portfolio/#comments</comments>
		<pubDate>Mon, 02 Apr 2012 08:16:09 +0000</pubDate>
		<dc:creator>Martin Angelov</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://tutorialzine.com/?p=1920</guid>
		<description><![CDATA[<div><a href="http://tutorialzine.com/2012/04/timeline-portfolio/"><img src="http://cdn.tutorialzine.com/img/featured/1920.jpg" /></a></div> This time we will be using the Timeline jQuery plugin as a dark themed portfolio in which you can showcase projects and important events in your career.]]></description>
			<content:encoded><![CDATA[<div><a href="http://tutorialzine.com/2012/04/timeline-portfolio/"><img src="http://cdn.tutorialzine.com/img/featured/1920.jpg" /></a></div> <p><a href="http://timeline.verite.co/" target="_blank">Timeline</a> is a jQuery plugin specialized in showing a chronological series of events. You can embed all kinds of media including tweets, videos and maps, and associate them with a date. With some design tweaks, this will make it perfect for a portfolio in which you showcase your work and interests.</p>
<h3>The HTML</h3>
<p>Timeline comes with a light colored theme by default. It is perfectly usable and in most cases would be exactly what you need. However, for our portfolio, a dark design would be a better fit, so we will customize it to our liking.</p>
<p>First, let&#8217;s look at the basic layout of the page:</p>
<h4>index.html</h4>
<pre class="brush:html">&lt;!DOCTYPE html&gt;
&lt;html&gt;
    &lt;head&gt;
        &lt;meta charset="utf-8" /&gt;
        &lt;title&gt;Timeline Portfolio | Tutorialzine Demo&lt;/title&gt;

        &lt;!-- The default timeline stylesheet --&gt;
        &lt;link rel="stylesheet" href="assets/css/timeline.css" /&gt;
        &lt;!-- Our customizations to the theme --&gt;
        &lt;link rel="stylesheet" href="assets/css/styles.css" /&gt;

		&lt;!-- Google Fonts --&gt;
        &lt;link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Dancing+Script|Antic+Slab" /&gt;

        &lt;!--[if lt IE 9]&gt;
          &lt;script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"&gt;&lt;/script&gt;
        &lt;![endif]--&gt;
    &lt;/head&gt;

    &lt;body&gt;

		&lt;div id="timeline"&gt;
			&lt;!-- Timeline will generate additional markup here --&gt;
		&lt;/div&gt;

        &lt;!-- JavaScript includes - jQuery, turn.js and our own script.js --&gt;
		&lt;script src="http://code.jquery.com/jquery-1.7.1.min.js"&gt;&lt;/script&gt;
		&lt;script src="assets/js/timeline-min.js"&gt;&lt;/script&gt;
		&lt;script src="assets/js/script.js"&gt;&lt;/script&gt;

    &lt;/body&gt;
&lt;/html&gt;</pre>
<p>In the head section, we have the plugin&#8217;s stylesheet &#8211; timeline.css, and styles.css, which will hold our customizations. In the footer we have the jQuery library, timeline plugin and <strong>script.js</strong> which initializes it.</p>
<p>When we call the plugin, it will search for a div on your page with the ID of <strong>timeline</strong>. Inside it, it will inserts all the markup it needs to present the timeline:</p>
<pre class="brush:html">&lt;div class="container main" id="timeline"&gt;
	&lt;div class="feature slider" style="overflow-y: hidden;"&gt;
		&lt;div class="slider-container-mask slider-container slider-item-container"&gt;

			&lt;!-- The divs below are the events of the timeline --&gt;

			&lt;div class="slider-item content"&gt;
				&lt;div class="text container"&gt;

					&lt;h2 class="start"&gt;Johnny B Goode&lt;/h2&gt;
					&lt;p&gt;&lt;em&gt;&lt;span class="c1"&gt;Designer&lt;/span&gt; &amp;amp; &lt;span class=
					"c2"&gt;Developer&lt;/span&gt;&lt;/em&gt;&lt;/p&gt;

				&lt;/div&gt;

				&lt;div class="media media-wrapper media-container"&gt;
					&lt;!-- Images or other media go here --&gt;
				&lt;/div&gt;
			&lt;/div&gt;

			&lt;div class="slider-item content content-container"&gt;
				&lt;div class="text container"&gt;

					&lt;h2 class="date"&gt;March 2009&lt;/h2&gt;
					&lt;h3&gt;My first experiment in time-lapse photography&lt;/h3&gt;
					&lt;p&gt;Nature at its finest in this video.&lt;/p&gt;

				&lt;/div&gt;

				&lt;div class="media media-wrapper media-container"&gt;
					&lt;!-- Images or other media go here --&gt;
				&lt;/div&gt;
			&lt;/div&gt;

			&lt;!-- More items go here --&gt;
		&lt;/div&gt;

        &lt;!-- Next arrow --&gt;
		&lt;div class="nav-next nav-container"&gt;
			&lt;div class="icon"&gt;&lt;/div&gt;
			&lt;div class="date"&gt;March 2010&lt;/div&gt;
			&lt;div class="title"&gt;Logo Design for a pet shop&lt;/div&gt;
		&lt;/div&gt;

        &lt;!-- Previous arrow --&gt;
		&lt;div class="nav-previous nav-container"&gt;
			&lt;div class="icon"&gt;&lt;/div&gt;
			&lt;div class="date"&gt;July 2009&lt;/div&gt;
			&lt;div class="title"&gt;Another time-lapse experiment&lt;/div&gt;
		&lt;/div&gt;
	&lt;/div&gt;

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

			&lt;!-- The navigation items go here (the tooltips in the bottom)
                one for each of the events --&gt;

			&lt;div class="time"&gt;
				&lt;!-- The timeline numbers go here --&gt;
			&lt;/div&gt;
		&lt;/div&gt;

		&lt;div class="timenav-background"&gt;
			&lt;div class="timenav-line" style="left: 633px;"&gt;&lt;/div&gt;

			&lt;div class="timenav-interval-background top-highlight"&gt;&lt;/div&gt;
		&lt;/div&gt;

		&lt;div class="toolbar" style="top: 27px;"&gt;
			&lt;div class="back-home icon" title="Return to Title"&gt;&lt;/div&gt;
			&lt;div class="zoom-in icon" title="Expand Timeline"&gt;&lt;/div&gt;
			&lt;div class="zoom-out icon" data-original-title="Contract Timeline"&gt;&lt;/div&gt;
		&lt;/div&gt;
	&lt;/div&gt;
&lt;/div&gt;</pre>
<p>As we will be modifying the CSS of the timeline, the fragment above will give you a better idea of the customizations. Note that we won&#8217;t be recreating the plugin&#8217;s stylesheet from scratch, we will only be overriding some of the rules in our own css file. This has the benefit of making future updates to the plugin straightforward, not to mention that it will be much easier.</p>
<div id="attachment_1931" class="wp-caption alignnone" style="width: 630px"><a href="http://demo.tutorialzine.com/2012/04/timeline-portfolio/"><img class="size-full wp-image-1931" title="Timeline Portfolio with jQuery" src="http://cdn.tutorialzine.com/wp-content/uploads/2012/03/timeline-portfolio-jquery.jpg" alt="Timeline Portfolio with jQuery" width="620" height="460" /></a><p class="wp-caption-text">Timeline Portfolio with jQuery</p></div>
<p>Writing the CSS by looking at the markup alone would be a tough undertaking, given that our rules must have <a href="http://css-tricks.com/specifics-on-css-specificity/" target="_blank">precedence</a> over the ones used in <em>timeline.css</em>. Fortunately, there is a much easier way, as you will see in the CSS section of this tutorial.</p>
<h3>The jQuery</h3>
<p>To initialize the plugin, we need to call the VMM.Timeline() method on document ready:</p>
<pre class="brush:js">$(function(){

	var timeline = new VMM.Timeline();
	timeline.init("data.json");

});</pre>
<p>The init method takes single argument &#8211; the data source. It can either be a json file like above, or a Google spreadsheet (reminiscent of our <a title="Dynamic FAQ Section w/ jQuery, YQL &amp; Google Docs" href="http://tutorialzine.com/2010/08/dynamic-faq-jquery-yql-google-docs/">Spredsheet Powered FAQ Tutorial</a>).</p>
<blockquote class="note"><p>For more information on the supported data sources, see the <a href="http://timeline.verite.co/#fileformat" target="_blank">documentation on the plugin&#8217;s site</a>, or browse the data.json file in the zip download for this tutorial.</p></blockquote>
<h3>The CSS</h3>
<p>I used Firebug&#8217;s HTML Inspector to get the right selectors for the elements that we are about to customize. In the HTML tab, it is easy to see what rules have been applied to each element by <em>timeline.css</em>. To override them, I copied the same selectors to <em>styles.css</em> which is where our modifications will take place. On several occurrences, however, I have used the <strong>!important</strong> flag to make my work easier.</p>
<p>All the customizations you see below override only a handful of CSS styles. The rest are inherited by the default stylesheet.<strong> Let&#8217;s begin!</strong></p>
<p>The first thing we will do in <strong>styles.css</strong>, after styling the page itself, is to change the backgrounds of the timeline:</p>
<pre class="brush:css">#timeline{
	background:none;
}

/* The individual events in the slider */
.slider .slider-container-mask .slider-container{
	background:none;
}

/* Setting a custom background image */
#timeline div.navigation{
    background: url('../img/timeline_bg.jpg') repeat;
    border-top:none;
}</pre>
<div id="attachment_1932" class="wp-caption alignnone" style="width: 630px"><a href="http://demo.tutorialzine.com/2012/04/timeline-portfolio/"><img class="size-full wp-image-1932" title="Timeline Navigation with a CSS 3D Effect" src="http://cdn.tutorialzine.com/wp-content/uploads/2012/03/a-css-3d-effect.jpg" alt="Timeline Navigation with a CSS 3D Effect" width="620" height="260" /></a><p class="wp-caption-text">Timeline Navigation with a CSS 3D Effect</p></div>
<p>To create the 3D effect of the timeline navigation, we will need to use additional elements. But the Timeline plugin doesn&#8217;t include such in its markup. An easy solution is to use <strong>:before</strong> / <strong>:after</strong> pseudo elements. The :after element is the darker top part and it uses a linear gradient to enhance the effect.</p>
<pre class="brush:css">#timeline div.navigation:before{
	position:absolute;
	content:'';
	height:40px;
	width:100%;
	left:0;
	top:-40px;
	background: url('../img/timeline_bg.jpg') repeat;
}

#timeline div.navigation:after{
	position:absolute;
	content:'';
	height:10px;
	width:100%;
	left:0;
	top:-40px;
	background:repeat-x;

	background-image: linear-gradient(bottom, #434446 0%, #363839 100%);
	background-image: -o-linear-gradient(bottom, #434446 0%, #363839 100%);
	background-image: -moz-linear-gradient(bottom, #434446 0%, #363839 100%);
	background-image: -webkit-linear-gradient(bottom, #434446 0%, #363839 100%);
	background-image: -ms-linear-gradient(bottom, #434446 0%, #363839 100%);
}</pre>
<p>Then we add a dark background to the timeline navigation (the section with the small clickable tooltips that represent the events):</p>
<pre class="brush:css">#timeline div.timenav-background{
 	background-color:rgba(0,0,0,0.4) !important;

}

#timeline .navigation .timenav-background .timenav-interval-background{
	background:none;
}

#timeline .top-highlight{
	background-color:transparent !important;
}</pre>
<p>Later we style the zoom-in / zoom-out buttons and toolbar:</p>
<pre class="brush:css">#timeline .toolbar{
	border:none !important;
	background-color: #202222 !important;
}

#timeline .toolbar div{
	border:none !important;
}</pre>
<p>The numeric scale at the bottom comes next:</p>
<pre class="brush:css">#timeline .navigation .timenav .time .time-interval-minor .minor{
	margin-left:-1px;
}

#timeline .navigation .timenav .time .time-interval div{
	color: #CCCCCC;
}</pre>
<p>The previous and next arrows:</p>
<pre class="brush:css">.slider .nav-previous .icon {
	background: url("timeline.png") no-repeat scroll 0 -293px transparent;
}

.slider .nav-previous,.slider .nav-next{
	font-family:'Segoe UI',sans-serif;
}

.slider .nav-next .icon {
	background: url("timeline.png") no-repeat scroll 72px -221px transparent;
	width: 70px !important;
}

.slider .nav-next:hover .icon{
	position:relative;
	right:-5px;
}

.slider .nav-previous:hover, .slider .nav-next:hover {
    color: #666;
    cursor: pointer;
}

#timeline .thumbnail {
	border: medium none;
}</pre>
<p>The loading screen:</p>
<pre class="brush:css">#timeline .feedback {
	background-color: #222222;
	box-shadow: 0 0 30px rgba(0, 0, 0, 0.2) inset;
	border:none;
}

#timeline .feedback div{
	color: #AAAAAA;
	font-size: 14px !important;
	font-weight: normal;
}</pre>
<p>Then we move on to the slides:</p>
<pre class="brush:css">#timeline .slider-item h2,
#timeline .slider-item h3{
	font-family:'Antic Slab','Segoe UI',sans-serif;
}

#timeline .slider-item h2{
	color:#fff;
}

#timeline .slider-item p{
	font-family:'Segoe UI',sans-serif;
}

#timeline .slider-item img,
#timeline .slider-item iframe{
	border:none;
}</pre>
<p>Finally, we will customize the appearance of the front page. I am using <strong>nth-child(1)</strong> to target only the first slider-item, which contains the name and description of the timeline which have been defined in the JSON data source.</p>
<pre class="brush:css">/* Customizing the first slide - the cover */

#timeline .slider-item:nth-child(1) h2{
	font:normal 70px/1 'Antic Slab','Segoe UI',sans-serif;
	background:rgba(0,0,0,0.3);
	white-space: nowrap;
	padding:10px 5px 5px 20px;
	position:relative;
	right:-60px;
	z-index:10;
}

#timeline .slider-item:nth-child(1) p i{
	font:normal normal 40px 'Dancing Script','Segoe UI',sans-serif;
	background:rgba(0,0,0,0.3);
	white-space: nowrap;
	padding:5px 20px;
	position:relative;
	right:-60px;
	z-index:10;
}

#timeline .slider-item:nth-child(1) p .c1{
	color:#1bdff0;
}

#timeline .slider-item:nth-child(1) p .c2{
	color:#c92fe6;
}

#timeline .slider-item:nth-child(1) .media-container {
	left: -30px;
	position: relative;
	z-index: 1;
}

#timeline .slider-item:nth-child(1) .credit{
	text-align: center;
}</pre>
<p>The only thing left is to open up <em>timeline.psd</em> that is bundled with the download of the plugin, and change the color of some of the icons in photoshop. I have included the necessary files in the zip download for this tutorial. With this our timeline portfolio is complete!</p>
<h3>Done!</h3>
<p>You can use this portfolio to display not only your recent projects, but also interests and important moments of your career. Share your thoughts and suggestions in the comment section.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=qvnuiMAbgB8:v0WEJKa3yIs:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=qvnuiMAbgB8:v0WEJKa3yIs:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=qvnuiMAbgB8:v0WEJKa3yIs:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=qvnuiMAbgB8:v0WEJKa3yIs:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=qvnuiMAbgB8:v0WEJKa3yIs:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=qvnuiMAbgB8:v0WEJKa3yIs:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=qvnuiMAbgB8:v0WEJKa3yIs:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=qvnuiMAbgB8:v0WEJKa3yIs:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=qvnuiMAbgB8:v0WEJKa3yIs:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=qvnuiMAbgB8:v0WEJKa3yIs: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/qvnuiMAbgB8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tutorialzine.com/2012/04/timeline-portfolio/feed/</wfw:commentRss>
		<slash:comments>72</slash:comments>
		<feedburner:origLink>http://tutorialzine.com/2012/04/timeline-portfolio/</feedburner:origLink></item>
		<item>
		<title>Win a deal from Mighty Deals!</title>
		<link>http://feedproxy.google.com/~r/Tutorialzine/~3/CiNrooIcOPw/</link>
		<comments>http://tutorialzine.com/2012/03/win-deal-mightydeals/#comments</comments>
		<pubDate>Wed, 28 Mar 2012 16:49:35 +0000</pubDate>
		<dc:creator>Martin Angelov</dc:creator>
				<category><![CDATA[Tzine]]></category>

		<guid isPermaLink="false">http://tutorialzine.com/?p=1914</guid>
		<description><![CDATA[<div><a href="http://tutorialzine.com/2012/03/win-deal-mightydeals/"><img src="http://cdn.tutorialzine.com/img/featured/1914.jpg" /></a></div> Our friends at Mighty Deals are offering an exclusive offer for Tutorialzine readers.]]></description>
			<content:encoded><![CDATA[<div><a href="http://tutorialzine.com/2012/03/win-deal-mightydeals/"><img src="http://cdn.tutorialzine.com/img/featured/1914.jpg" /></a></div> <p>You probably know about <a href="http://www.mightydeals.com/" target="_blank">MightyDeals.com</a>, it is a flash sales platform for digital goods aimed at web professionals. Their deals include products and services that are heavily discounted, exclusively for their customers, usually from 50% to 90% off.</p>
<p>Today they are offering a one-time offer for Tutorialzine readers. <strong>Five of you</strong> will have a chance to get whichever deal their want from <a href="http://www.mightydeals.com/all_deals">their catalog</a> for free!</p>
<p><iframe src="http://player.vimeo.com/video/37259644?title=0&amp;byline=0&amp;portrait=0" frameborder="0" width="620" height="350"></iframe></p>
<h3>How to participate</h3>
<p>For a chance to win one of their deals, do the following:</p>
<ul>
<li><span style="text-decoration: line-through;">Enter your email in the box below;</span></li>
<li><span style="text-decoration: line-through;">Leave a comment (using the same email) with the deal you would like to win from the list of <a href="http://www.mightydeals.com/all_deals">currently active deals</a>.</span></li>
</ul>
<p><span style="text-decoration: line-through;">The winners will be chosen on <strong>April 4th </strong>using random.org and announced in this post.</span></p>
<p><strong>The winners have been chosen and contacted by Mighty Deals. Thanks to everybody that participated!<em><br />
</em></strong></p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=CiNrooIcOPw:_ShXENCbq-o:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=CiNrooIcOPw:_ShXENCbq-o:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=CiNrooIcOPw:_ShXENCbq-o:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=CiNrooIcOPw:_ShXENCbq-o:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=CiNrooIcOPw:_ShXENCbq-o:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=CiNrooIcOPw:_ShXENCbq-o:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=CiNrooIcOPw:_ShXENCbq-o:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=CiNrooIcOPw:_ShXENCbq-o:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=CiNrooIcOPw:_ShXENCbq-o:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=CiNrooIcOPw:_ShXENCbq-o: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/CiNrooIcOPw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tutorialzine.com/2012/03/win-deal-mightydeals/feed/</wfw:commentRss>
		<slash:comments>63</slash:comments>
		<feedburner:origLink>http://tutorialzine.com/2012/03/win-deal-mightydeals/</feedburner:origLink></item>
		<item>
		<title>DigiSeller Winners</title>
		<link>http://feedproxy.google.com/~r/Tutorialzine/~3/pp2JKauaNO0/</link>
		<comments>http://tutorialzine.com/2012/03/digiseller-winners/#comments</comments>
		<pubDate>Wed, 21 Mar 2012 07:47:25 +0000</pubDate>
		<dc:creator>Martin Angelov</dc:creator>
				<category><![CDATA[Tzine]]></category>

		<guid isPermaLink="false">http://tutorialzine.com/?p=1909</guid>
		<description><![CDATA[<div><a href="http://tutorialzine.com/2012/03/digiseller-winners/"><img src="http://cdn.tutorialzine.com/img/featured/1909.jpg" /></a></div> Announcing the winners of our DigiSeller contest.]]></description>
			<content:encoded><![CDATA[<div><a href="http://tutorialzine.com/2012/03/digiseller-winners/"><img src="http://cdn.tutorialzine.com/img/featured/1909.jpg" /></a></div> <p>Two weeks ago, you participated in the <a title="Win a Copy of DigiSeller, Our New Script!" href="http://tutorialzine.com/2012/03/win-a-copy-of-digiseller/">DigiSeller giveaway</a>. Now it&#8217;s time to draw the lucky winners.</p>
<p>And they are: <em><strong>Max Requião</strong></em>, <em><strong>chiuto</strong></em> and <em><strong>Giorgos Yfantis</strong></em>.</p>
<div id="attachment_1910" class="wp-caption alignnone" style="width: 630px"><a href="http://cdn.tutorialzine.com/wp-content/uploads/2012/03/digiseller-winners.jpg"><img class="size-full wp-image-1910" title="DigiSeller Winners" src="http://cdn.tutorialzine.com/wp-content/uploads/2012/03/digiseller-winners.jpg" alt="Winners" width="620" height="320" /></a><p class="wp-caption-text">Winners</p></div>
<p>The winners have been contacted and will receive their prizes shortly.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=pp2JKauaNO0:AmGzoEMMWt0:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=pp2JKauaNO0:AmGzoEMMWt0:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=pp2JKauaNO0:AmGzoEMMWt0:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=pp2JKauaNO0:AmGzoEMMWt0:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=pp2JKauaNO0:AmGzoEMMWt0:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=pp2JKauaNO0:AmGzoEMMWt0:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=pp2JKauaNO0:AmGzoEMMWt0:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=pp2JKauaNO0:AmGzoEMMWt0:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=pp2JKauaNO0:AmGzoEMMWt0:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=pp2JKauaNO0:AmGzoEMMWt0: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/pp2JKauaNO0" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tutorialzine.com/2012/03/digiseller-winners/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<feedburner:origLink>http://tutorialzine.com/2012/03/digiseller-winners/</feedburner:origLink></item>
		<item>
		<title>Making a Page Flip Magazine with turn.js</title>
		<link>http://feedproxy.google.com/~r/Tutorialzine/~3/DoO1_uCekps/</link>
		<comments>http://tutorialzine.com/2012/03/instagram-magazine-php-jquery/#comments</comments>
		<pubDate>Fri, 16 Mar 2012 19:02:32 +0000</pubDate>
		<dc:creator>Martin Angelov</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://tutorialzine.com/?p=1889</guid>
		<description><![CDATA[<div><a href="http://tutorialzine.com/2012/03/instagram-magazine-php-jquery/"><img src="http://cdn.tutorialzine.com/img/featured/1889.jpg" /></a></div> In this tutorial we are going to use PHP and the turn.js plugin, an implementation of the page flip effect with pure CSS3 and jQuery, to build an Instagram powered magazine.]]></description>
			<content:encoded><![CDATA[<div><a href="http://tutorialzine.com/2012/03/instagram-magazine-php-jquery/"><img src="http://cdn.tutorialzine.com/img/featured/1889.jpg" /></a></div> <p>The page flip effect used to be the quintessential Flash animation. On the web, it has powered everything from magazines to presentations, with its popularity declining over time, only to be reinvented on mobile devices as ebook reading apps.</p>
<p>In this tutorial we are going to use PHP and the <a href="http://www.turnjs.com/" target="_blank">turn.js plugin</a>, an implementation of the page flip effect with pure CSS3 and jQuery, to build a pretty magazine. We will fetch the most popular images from <a href="http://instagram.com/" target="_blank">Instagram</a> every hour, and use them as pages.</p>
<h3>HTML</h3>
<p>First we need to lay down the foundations of today&#8217;s example. We will use a single page design, which combines HTML5 markup and PHP in the same file for greater simplicity. You can see the resulting layout below:</p>
<h4>index.php</h4>
<pre class="brush:html">&lt;!DOCTYPE html&gt;
&lt;html&gt;
    &lt;head&gt;
        &lt;meta charset="utf-8" /&gt;
        &lt;title&gt;Making an Instagram Magazine | Tutorialzine Demo&lt;/title&gt;

        &lt;!-- Our Stylesheet --&gt;
        &lt;link rel="stylesheet" href="assets/css/styles.css" /&gt;

        &lt;!--[if lt IE 9]&gt;
          &lt;script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"&gt;&lt;/script&gt;
        &lt;![endif]--&gt;
    &lt;/head&gt;

    &lt;body&gt;

		&lt;div id="magazine" class="centerStart"&gt;

		&lt;!-- PHP will go here --&gt;

		&lt;/div&gt;

        &lt;!-- JavaScript includes - jQuery, turn.js and our own script.js --&gt;
		&lt;script src="http://code.jquery.com/jquery-1.7.1.min.js"&gt;&lt;/script&gt;
		&lt;script src="assets/js/turn.js"&gt;&lt;/script&gt;
		&lt;script src="assets/js/script.js"&gt;&lt;/script&gt;

    &lt;/body&gt;
&lt;/html&gt;</pre>
<p>We include <em>styles.css</em> in the head, and our JavaScript files at the bottom. The latter are the jQuery library, the turn.js plugin and script.js, where we will be initializing the plugin and listening for keyboard events. The PHP code that we will be writing in the next section will go in the <em>#magazine</em> div. PHP will have the job of generating the pages of our magazine, which will be used by turn.js.</p>
<p>As an example, here is the markup of the first three pages of the magazine:</p>
<h4>Generated code</h4>
<pre class="brush:html">&lt;div id="page1" class="page"&gt;
	&lt;div class="img1"&gt;

		&lt;!-- The pageNum span can be either on the left,
				or the right if the page is odd/even. --&gt;

		&lt;span class="pageNum right"&gt;1 // 32&lt;/span&gt;
		&lt;img src="assets/img/cover.jpg" alt="Cover" /&gt;
	&lt;/div&gt;
&lt;/div&gt;

&lt;div id="page2" class="page"&gt;
	&lt;div class="img2"&gt;
		&lt;span class="pageNum left"&gt;2 // 32&lt;/span&gt;
		&lt;img src="http://distilleryimage7.instagram.com/..." alt="Little tulips" /&gt;
	&lt;/div&gt;
&lt;/div&gt;

&lt;div id="page3" class="page"&gt;
	&lt;div class="img3"&gt;
		&lt;span class="pageNum right"&gt;3 // 32&lt;/span&gt;
		&lt;img src="http://distilleryimage2.instagram.com/..." alt="My style" /&gt;
	&lt;/div&gt;
&lt;/div&gt;</pre>
<p>The divs you see above are direct descendants of the #magazine div. This is the only requirement imposed by turn.js. You don&#8217;t need to have any special classes or data attributes for the elements to be interpreted as pages. With this we are ready to move on with the PHP code!</p>
<div id="attachment_1898" class="wp-caption alignnone" style="width: 630px"><a href="http://demo.tutorialzine.com/2012/03/instagram-magazine-php-jquery/"><img class="size-full wp-image-1898" title="Page Flip Magazine with CSS3 and jQuery" src="http://cdn.tutorialzine.com/wp-content/uploads/2012/03/instagram-page-flip-magazine-jquery-php.jpg" alt="Page Flip Magazine with CSS3 and jQuery" width="620" height="460" /></a><p class="wp-caption-text">Page Flip Magazine with CSS3 and jQuery</p></div>
<h3>PHP</h3>
<p>PHP will have the task of communicating with Instagram&#8217;s API, caching the results, and generating the markup you saw above.</p>
<p>The first step is to register at the <a href="http://instagram.com/developer/" target="_blank">Instagram developer</a> website. After you obtain your <strong>client_id</strong> key, place it in <em><strong>index.php</strong></em> as the value of <code>$instagramClientID</code>. We won&#8217;t be needing any of the advanced functionality of the API, we will only be requesting the most popular images. This frees us from having to implement OAuth authentication, which would make today&#8217;s example significantly more complex.</p>
<blockquote class="note"><p>Note that if you want to modify the magazine and show photos other than the most popular, say your latest images, you will need to implement OAuth and authenticate your app to have access to your photos. <a href="http://instagr.am/developer/auth/" target="_blank">Consult the docs</a> for further information.</p></blockquote>
<p>Here is an example JSON response of the currently popular images on Instagram. I have omitted some of the attributes to make the code easier to read.</p>
<h4>Popular images JSON response</h4>
<pre class="brush:js">{    "meta": {
        "code": 200
    },
    "data": [{
        "tags": ["beautiful", "sky"],
        "location": "null",
        "comments": {
            "count": 31,
            "data": [...]
        },
        "filter": "Normal",
        "created_time": "1331910134",
        "link": "http:\/\/instagr.am\/p\/IPNNknqs84\/",
        "likes": {
            "count": 391,
            "data": [..]
        },
        "images": {
            "low_resolution": {
                "url": "http:\/\/distilleryimage8.instagram.com\/03c80dd86f7911e1a87612313804ec91_6.jpg",
                "width": 306,
                "height": 306
            },
            "thumbnail": {
                "url": "http:\/\/distilleryimage8.instagram.com\/03c80dd86f7911e1a87612313804ec91_5.jpg",
                "width": 150,
                "height": 150
            },
            "standard_resolution": {
                "url": "http:\/\/distilleryimage8.instagram.com\/03c80dd86f7911e1a87612313804ec91_7.jpg",
                "width": 612,
                "height": 612
            }
        },
        "caption": {
            "created_time": "1331910148",
            "text": "Goodnight.\ue056",
            "from": {
                "username": "jent99",
                "profile_picture": "http:\/\/images.instagram.com\/profiles\/profile_6227738_75sq_1319878922.jpg",
                "id": "6227738",
                "full_name": "jent99"
            },
            "id": "148395540733414783"
        },
        "type": "image",
        "id": "148395420004568888_6227738",
        "user": {
            "username": "jent99",
            "website": "",
            "bio": "Mostly nature pics.\ue32b\ue32b\ue32b Hope you like them.\ue056\ue32a     \ue334gi\ue334                    ",
            "profile_picture": "http:\/\/images.instagram.com\/profiles\/profile_6227738_75sq_1319878922.jpg",
            "full_name": "jent99",
            "id": "6227738"
        }
    }, {
		/* More photos here*/
	}]
}</pre>
<p>The API is limited to returning only 32 pics, but this is plenty for our example. You can see that each photo has three image sizes, but we will only be needing the standard one. There is also various other information that you can use like caption, dimensions, tags, comments, and more.</p>
<p>PHP will cache the results of this API call so we hit Instagram&#8217;s servers only once per hour. This will make our application more responsive and limit the number of calls.</p>
<h4>index.php</h4>
<pre class="brush:php">// You can obtain this client ID from the Instagram API page
$instagramClientID = '-- place your client id key here --';

$api = 'https://api.instagram.com/v1/media/popular?client_id='.$instagramClientID;
$cache = 'cache.txt';

if(file_exists($cache) &amp;&amp; filemtime($cache) &gt; time() - 60*60){
	// If a cache file exists, and it is
	// fresher than 1 hour, use it
	$images = unserialize(file_get_contents($cache));
}
else{
	// Make an API request and create the cache file

	// Fetch the 32 most popular images on Instagram
	$response = file_get_contents($api);

	$images = array();

	// Decode the response and build an array
	foreach(json_decode($response)-&gt;data as $item){

		$title = '';

		if($item-&gt;caption){
			$title = mb_substr($item-&gt;caption-&gt;text,0,70,"utf8");
		}

		$src = $item-&gt;images-&gt;standard_resolution-&gt;url;

		$images[] = array(
			"title" =&gt; htmlspecialchars($title),
			"src" =&gt; htmlspecialchars($src)
		);
	}

	// Remove the last item, so we still have
	// 32 items when when the cover is added
	array_pop($images);

	// Push the cover in the beginning of the array
	array_unshift($images,array("title"=&gt;"Cover", "src"=&gt;"assets/img/cover.jpg"));

	// Update the cache file
	file_put_contents($cache,serialize($images));
}

# Generate the markup
$totalPages = count($images);
foreach($images as $i=&gt;$image){

	?&gt;

	&lt;div id="page&lt;?php echo $i+1?&gt;" class="page"&gt;
		&lt;div class="img&lt;?php echo $i+1?&gt;"&gt;
			&lt;span class="pageNum &lt;?php echo ($i+1)%2? 'right' : 'left'?&gt;"&gt;&lt;?php echo $i+1?&gt; // &lt;?php echo $totalPages?&gt;&lt;/span&gt;
			&lt;img src="&lt;?php echo $image['src']?&gt;" alt="&lt;?php echo $image['title']?&gt;" /&gt;
		&lt;/div&gt;
	&lt;/div&gt;

	&lt;?php

}</pre>
<p>Caching is straightforward: we are using a temporary file &#8211; <em>cache.txt</em> &#8211; to store a serialized representation of the image array. If the cache file is non-existing or is older than an hour, we issue a new API request.</p>
<p>Notice the calls to <em><strong>array_pop</strong></em> and <em><strong>array_unshift</strong></em>. These are necessary as to make room for the custom cover image that is stored in <span style="text-decoration: underline;"><em>assets/img</em></span>. The magazine works best if we have an even number of pages, otherwise we would be unable to turn the last one, which would feel unnatural.</p>
<p>We are now ready for the plugin!</p>
<h3>jQuery</h3>
<p>Using turn.js is really simple. As we already have the markup of the magazine, we just need to call the turn() method. While we are at it, we will also listen for presses on the arrow keys, which will trigger page transitions.</p>
<h4>assets/js/script.js</h4>
<pre class="brush:js">$(function(){

	var mag = $('#magazine');

	// initiazlie turn.js on the #magazine div
	mag.turn();

	// turn.js defines its own events. We are listening
	// for the turned event so we can center the magazine
	mag.bind('turned', function(e, page, pageObj) {

		if(page == 1 &amp;&amp; $(this).data('done')){
			mag.addClass('centerStart').removeClass('centerEnd');
		}
		else if (page == 32 &amp;&amp; $(this).data('done')){
			mag.addClass('centerEnd').removeClass('centerStart');
		}
		else {
			mag.removeClass('centerStart centerEnd');
		}

	});

	setTimeout(function(){
		// Leave some time for the plugin to
		// initialize, then show the magazine
		mag.fadeTo(500,1);
	},1000);

	$(window).bind('keydown', function(e){

		// listen for arrow keys

		if (e.keyCode == 37){
			mag.turn('previous');
		}
		else if (e.keyCode==39){
			mag.turn('next');
		}

	});

});</pre>
<p>You can read more about what events the plugin emits and how to use them, in the <a href="https://github.com/blasten/turn.js/wiki/Reference" target="_blank">turn.js reference</a>.</p>
<p>Now let&#8217;s make it pretty!</p>
<h3>CSS</h3>
<p>We need to set explicit dimensions of the magazine and style the pages and page numbers. turn.js will handle the rest.</p>
<h4>assets/css/styles.css</h4>
<pre class="brush:css">#magazine{
	width:1040px;
	height:520px;
	margin:0 auto;
	position:relative;
	left:0;

	opacity:0;

	-moz-transition:0.3s left;
	-webkit-transition:0.3s left;
	transition:0.3s left;
}

#magazine .page{
	width:520px;
	height:520px;
	background-color:#ccc;
	overflow:hidden;
}

/* Center the magazine when the cover is shown */
#magazine.centerStart{
	left:-260px;
}

/* Center the magazine when the last page is shown */
#magazine.centerEnd{
	left:260px;
}

.page img{
	height:520px;
	width:520px;
	display:block;
}

/* Show a dark shadow when the cover is shown */
.centerStart .turn-page-wrapper:first-child{
	box-shadow:0 0 10px #040404;
}

/* Page Numbers */

span.pageNum{
    background-color: rgba(0, 0, 0, 0.3);
    bottom: 25px;
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.25);
    color: #FFFFFF;
    font-size: 11px;
    height: 24px;
    line-height: 22px;
    opacity: 0.9;
    position: absolute;
    text-align: center;
    width: 55px;
}

span.pageNum.left{
	left:0;
	right:auto;
}

span.pageNum.right{
	left:auto;
	right:0;
}

/* Hide the page number on the cover */
#page1 .pageNum{
	display:none;
}</pre>
<p>With this our magazine is complete!</p>
<h3>We&#8217;re done!</h3>
<p>This example works in all recent browsers &#8211; Firefox, Chrome, Safari, Opera and even IE. It is even usable on iOS and Android. You can use this effect as part of photo galleries, templates or even real magazines. However you will have to create a fallback version for older browsers, which don&#8217;t have what it takes to display it properly.</p>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=DoO1_uCekps:GyZpbKQ-jn4:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=DoO1_uCekps:GyZpbKQ-jn4:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=DoO1_uCekps:GyZpbKQ-jn4:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=DoO1_uCekps:GyZpbKQ-jn4:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=DoO1_uCekps:GyZpbKQ-jn4:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=DoO1_uCekps:GyZpbKQ-jn4:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=DoO1_uCekps:GyZpbKQ-jn4:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=DoO1_uCekps:GyZpbKQ-jn4:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=DoO1_uCekps:GyZpbKQ-jn4:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=DoO1_uCekps:GyZpbKQ-jn4: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/DoO1_uCekps" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tutorialzine.com/2012/03/instagram-magazine-php-jquery/feed/</wfw:commentRss>
		<slash:comments>38</slash:comments>
		<feedburner:origLink>http://tutorialzine.com/2012/03/instagram-magazine-php-jquery/</feedburner:origLink></item>
		<item>
		<title>Win a Copy of DigiSeller, Our New Script!</title>
		<link>http://feedproxy.google.com/~r/Tutorialzine/~3/tUf0y1oOTB4/</link>
		<comments>http://tutorialzine.com/2012/03/win-a-copy-of-digiseller/#comments</comments>
		<pubDate>Mon, 05 Mar 2012 22:14:19 +0000</pubDate>
		<dc:creator>Martin Angelov</dc:creator>
				<category><![CDATA[Tzine]]></category>

		<guid isPermaLink="false">http://tutorialzine.com/?p=1877</guid>
		<description><![CDATA[<div><a href="http://tutorialzine.com/2012/03/win-a-copy-of-digiseller/"><img src="http://cdn.tutorialzine.com/img/featured/1877.jpg" /></a></div> Do you love to build things? If so our new script is for you - DigiSeller.]]></description>
			<content:encoded><![CDATA[<div><a href="http://tutorialzine.com/2012/03/win-a-copy-of-digiseller/"><img src="http://cdn.tutorialzine.com/img/featured/1877.jpg" /></a></div> <p>Do you love to build things? I know I do. It can be a web app, template, PSD, a PHP script, or even an ebook. Sooner or later, an idea comes to your mind &#8211; you can turn your love for building things into an extra revenue stream. But I have bad news for you.</p>
<h3>Selling online sucks</h3>
<p>You have a choice &#8211; join a marketplace or do it yourself. Doing it yourself clearly has a lot of benefits &#8211; you can choose your own pricing, design your shop, and keep all of your profits. But the bad thing is that you have to deal with heavy and archaic CMS systems that are a nightmare to customize, or join an equally unfriendly platform for a monthly fee.</p>
<p>I was looking for a solution that was quick to set up, easy to customize, and lightweight. I wanted something that I could throw on a domain and have a working microsite with PayPal integration. I couldn&#8217;t find one, so I built it myself.</p>
<h3>Introducing DigiSeller</h3>
<p><a href="http://www.zinescripts.com/products/digiseller/" target="_blank">DigiSeller</a> is a PHP+MySQL script for setting up a digital shop. It has full PayPal integration and helps you sell a digital item securely. You only need to upload it to your hosting space along with your product in a zip file, add your PayPal email address to the config file, and start selling!</p>
<div id="attachment_1880" class="wp-caption alignnone" style="width: 630px"><a href="http://www.zinescripts.com/products/digiseller/" target="_blank"><img class="size-full wp-image-1880  " title="DigiSeller - PHP Webshop Script" src="http://cdn.tutorialzine.com/wp-content/uploads/2012/03/digiseller-php-webshop-script.jpg" alt="DigiSeller - PHP Webshop Script" width="620" height="343" /></a><p class="wp-caption-text">DigiSeller - PHP Webshop Script</p></div>
<h4>Notable Features:</h4>
<div>
<ul>
<li>Everything is controlled from a <strong>config file</strong> &#8211; no cumbersome admin panel that will only be used once;</li>
<li>It has semantic HTML5 markup, with a pretty design that is easy to<strong> customize with CSS</strong>;</li>
<li>Has a straightforward integration with PayPal &#8211; you only need to add the email on which you wish to receive payments;</li>
<li>Buyers receive a <strong>download link</strong> after the purchase. This is the only way to download your file. The link expires after a set period of time;</li>
<li><em>DigiSeller</em> can <strong>collect email addresses</strong> for your newsletter and has a built-in <strong>contact form</strong>;</li>
<li>You get readable and well commented <strong>source code</strong> along with <strong>PSDs</strong>, so you can change everything;</li>
<li>You can use the script on <strong>unlimited domains</strong> and set it up for your clients.</li>
</ul>
<h3>Win a copy!</h3>
<p><strong>Three of you</strong> will have a chance to win a copy of the script for free. To participate, do the following:</p>
<ul>
<li>Leave a comment under the post;</li>
<li>Tweet about this article.</li>
</ul>
<p>The winners will be announced on <strong>March 20</strong> in a follow-up post.</p>
</div>
<div class="feedflare">
<a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=tUf0y1oOTB4:HrYzASTAGQ8:yIl2AUoC8zA"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?d=yIl2AUoC8zA" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=tUf0y1oOTB4:HrYzASTAGQ8:D7DqB2pKExk"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=tUf0y1oOTB4:HrYzASTAGQ8:D7DqB2pKExk" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=tUf0y1oOTB4:HrYzASTAGQ8:F7zBnMyn0Lo"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=tUf0y1oOTB4:HrYzASTAGQ8:F7zBnMyn0Lo" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=tUf0y1oOTB4:HrYzASTAGQ8:V_sGLiPBpWU"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=tUf0y1oOTB4:HrYzASTAGQ8:V_sGLiPBpWU" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=tUf0y1oOTB4:HrYzASTAGQ8:gIN9vFwOqvQ"><img src="http://feeds.feedburner.com/~ff/Tutorialzine?i=tUf0y1oOTB4:HrYzASTAGQ8:gIN9vFwOqvQ" border="0"></img></a> <a href="http://feeds.feedburner.com/~ff/Tutorialzine?a=tUf0y1oOTB4:HrYzASTAGQ8: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/tUf0y1oOTB4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://tutorialzine.com/2012/03/win-a-copy-of-digiseller/feed/</wfw:commentRss>
		<slash:comments>102</slash:comments>
		<feedburner:origLink>http://tutorialzine.com/2012/03/win-a-copy-of-digiseller/</feedburner:origLink></item>
	</channel>
</rss><!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using apc
Page Caching using apc
Object Caching 682/760 objects using apc
Content Delivery Network via cdn.tutorialzine.com

Served from: tutorialzine.com @ 2012-05-14 13:54:05 -->

