<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2enclosuresfull.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:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>Goksel Eryigit - Front-end Developer</title>
	
	<link>http://geryit.com/blog</link>
	<description>Just another WordPress site</description>
	<lastBuildDate>Sat, 11 May 2013 13:48:48 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/goksel" /><feedburner:info uri="goksel" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><itunes:explicit>no</itunes:explicit><itunes:subtitle>Just another WordPress site</itunes:subtitle><feedburner:emailServiceId>goksel</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item>
		<title>Creating a simple jQuery plugin for Pinterest</title>
		<link>http://feedproxy.google.com/~r/goksel/~3/SWO5lX58aBo/</link>
		<comments>http://geryit.com/blog/creating-a-simple-jquery-plugin-for-pinterest/#comments</comments>
		<pubDate>Sat, 11 May 2013 13:47:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Jquery]]></category>

		<guid isPermaLink="false">http://geryit.com/blog/?p=1405</guid>
		<description><![CDATA[Introduction Plugins play a great part in the success of jQuery. There are hundreds of them out there, and having the ability to create your own is a great skill to have. With all of the interest in Pinterest (no pun intended), I thought it would be a good idea to do up a quick [...]]]></description>
				<content:encoded><![CDATA[<div class="entry-content se-content">
<h2>Introduction</h2>
<p class="single-first-p">Plugins play a great part in the success of jQuery. There are hundreds of them out there, and having the ability to create your own is a great skill to have. With all of the interest in <a href="http://pinterest.com/" target="_blank">Pinterest</a> (no pun intended), I thought it would be a good idea to do up a quick and simple Pinterest sharing plugin for jQuery.</p>
<h2>Getting started</h2>
<p>First we need to grab the jQuery plugin <a href="http://docs.jquery.com/Plugins/Authoring" target="_blank">boilerplate</a></p>
<pre class="brush: js">                                            (function( $ ) {
                                            $.fn.pinterest = function(options) {

                                            var settings = $.extend( {
                                            }, options);

                                            return this.each(function() {

                                            });

                                            };
                                            })( jQuery );</pre>
<p>This boilerplate provides us with the ability to specify default configuration values (settings) and ensures that the infamous jQuery chaining ability is maintained (the return this.each). I’m going to take advantage of the default configuration values by specifying the default Pinterest image we’ll be using. This can be overridden when initializing the plugin by specifying the url to the preferred image.</p>
<h3>Default image</h3>
<p><img class="alignnone" alt="" src="http://business.pinterest.com/assets/img/builder/builder_opt_1.png" width="40" height="20" /></p>
<h3>Custom image</h3>
<p><img class="aligncenter size-full wp-image-4090" alt="pinterest-alt" src="http://developerdrive.developerdrive.netdna-cdn.com/wp-content/uploads/2013/05/pinterest-alt.png" width="52" height="25" /></p>
<pre class="brush: js">                                            (function( $ ) {
                                            $.fn.pinterest = function(options) {

                                            var settings = $.extend( {
                                            'button' : 'http://business.pinterest.com/assets/img/builder/builder_opt_1.png'
                                            }, options);

                                            return this.each(function() {

                                            });

                                            };
                                            })( jQuery );

                                            $(document).on('ready', function(){
                                            $('img#share').pinterest({ button: 'pinterest-alt.png'});
                                            });</pre>
<p>Now that we have a basic framework done, let’s start adding some functionality. We need to update the this.each function to initialize each image and add some events for us. I’ve chosen to have the icon hover over the image being shared. To do this, I need to <a href="http://docs.jquery.com/Manipulation/wrap" target="_blank">wrap</a> the image in a span element that positioned ‘relative’, I then need to <a href="http://docs.jquery.com/Manipulation/append" target="_blank">append</a> the share image and position it absolutely. I’m going with the bottom right, but feel free to have a play</p>
<pre class="brush: js">(function( $ ) {
                                            $.fn.pinterest = function(options) {

                                            var settings = $.extend( {
                                            'button' : 'http://business.pinterest.com/assets/img/builder/builder_opt_1.png'
                                            }, options);

                                            return this.each(function() {
                                            img = $(this);
                                            img.wrap('&lt;span class="pin-it" style="position: relative;" /&gt;');
                                            img.parent('span.pin-it').append('&lt;img src="' + settings.button + '" style="display: none;position: absolute; bottom: 20px; right: 20px;cursor: hand; cursor: pointer;" /&gt;');
                                            });
                                            };
                                            })( jQuery );

                                            $(document).on('ready', function(){
                                            $('img#share').pinterest({ button: 'pinterest-alt.png'});
                                            });</pre>
<p>Now that the elements that we need are there, we can start attaching our events. I’m going to use the hover and click events. When the user hovers over the main image, the share button will appear.</p>
<pre class="brush: js">                                            (function( $ ) {
                                            $.fn.pinterest = function(options) {

                                            var settings = $.extend( {
                                            'button' : 'http://business.pinterest.com/assets/img/builder/builder_opt_1.png'
                                            }, options);

                                            function on_click () {
                                            };

                                            function on_hover_in() {
                                            $(this).siblings('img:first').show(500);
                                            };

                                            return this.each(function() {
                                            img = $(this);
                                            img.wrap('&lt;span class="pin-it" style="position: relative;" /&gt;');
                                            img.parent('span.pin-it').append('&lt;img src="' + settings.button + '" style="display: none;position: absolute; bottom: 20px; right: 20px;cursor: hand; cursor: pointer;" /&gt;');
                                            img.hover(on_hover_in);
                                            img.siblings('img:first').on('click', on_click);
                                            });

                                            };
                                            })( jQuery );

                                            $(document).on('ready', function(){
                                            $('img#share').pinterest({ button: 'pinterest-small.png'});
                                            });</pre>
<p>The on_click event looks like the following</p>
<pre class="brush: js">                                            function on_click () {
                                            img = $(this).siblings('img:first');
                                            description = img.attr('title');
                                            url = document.location;
                                            media = img.attr('src');

                                            var pin_url = 'http://pinterest.com/pin/create/button/?url=' + encodeURIComponent( url ) +
                                            '&amp;media=' + encodeURIComponent( media ) +
                                            '&amp;description=' + encodeURIComponent( description );

                                            window.open(pin_url, 'Pin - ' + description, 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600');
                                            $(this).hide(1000);
                                            };</pre>
<p>It’s grabbing the image we want to share, and then reading it’s title and src attributes. It’s also getting the current pages url using document.location. The Pinterest share url has 3 parameters that we are interested in:</p>
<ul>
<li>url – the page we are sharing from</li>
<li>media – the image we want to share</li>
<li>description – the text we want to share with the image</li>
</ul>
<p>When I’m creating the share url, I’m also using the JavaScript <a href="https://developer.mozilla.org/en/docs/JavaScript/Reference/Global_Objects/encodeURIComponent" target="_blank">encodeURIComponent</a> function to make sure the values are properly escaped.</p>
<p>One final thing we need to allow for is if the image src url is relative or not. If it’s relative we’ll need to update the media url to be fully qualified.</p>
<pre class="brush: js">                                            function getUrl(src){
                                            var url = document.location.toString();
                                            var http = /^https?:\/\//i;
                                            if (!http.test(src)) {
                                            if(src[0] == '/'){
                                            url = url.substring(0, url.lastIndexOf('/')) + src;
                                            } else {
                                            url = url.substring(0, url.lastIndexOf('/')) + '/' + src;
                                            }
                                            } else {
                                            url = src;
                                            }

                                            return url;
                                            };</pre>
<p>This function is checking to see if the provided src URL starts with http or not. If it doesn’t it then creates an absolute url and returns it.</p>
<p>And that’s it, we now have a fully functional jQuery plugin for sharing images on Pinterest. You can see the full HTML and JavaScript or download it below. The image I’m sharing by the way is <a href="http://en.wikipedia.org/wiki/Three_Musicians" target="_blank">Picasso’s Three Musicians</a></p>
<pre class="brush: js">                                            &lt;!DOCTYPE html&gt;
                                            &lt;html lang="en"&gt;
                                            &lt;head&gt;
                                            &lt;meta http-equiv="content-type" content="text/html; charset=utf-8"&gt;
                                            &lt;title&gt;Creating a simple Pinterest! jQuery&lt;/title&gt;
                                            &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
                                            &lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"&gt;&lt;/script&gt;

                                            &lt;script type="text/javascript"&gt;

                                            (function( $ ) {
                                            $.fn.pinterest = function(options) {

                                            var settings = $.extend( {
                                            'button' : 'http://business.pinterest.com/assets/img/builder/builder_opt_1.png'
                                            }, options);

                                            function getUrl(src){
                                            var url = document.location.toString();
                                            var http = /^https?:\/\//i;
                                            if (!http.test(src)) {
                                            if(src[0] == '/'){
                                            url = url.substring(0, url.lastIndexOf('/')) + src;
                                            } else {
                                            url = url.substring(0, url.lastIndexOf('/')) + '/' + src;
                                            }
                                            } else {
                                            url = src;
                                            }

                                            return url;
                                            };

                                            function on_click () {
                                            img = $(this).siblings('img:first');
                                            description = img.attr('title');
                                            url = document.location;
                                            media = getUrl( img.attr('src') );

                                            var pin_url = 'http://pinterest.com/pin/create/button/?url=' + url +
                                            '&amp;media=' + media +
                                            '&amp;description=' + description;

                                            window.open(pin_url, 'Pin - ' + description, 'menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600');
                                            $(this).hide(1000);
                                            };

                                            function on_hover_in() {
                                            $(this).siblings('img:first').show(500);
                                            };

                                            return this.each(function() {
                                            img = $(this);
                                            img.wrap('&lt;span class="pin-it" style="position: relative;" /&gt;');
                                            img.parent('span.pin-it').append('&lt;img src="' + settings.button + '" style="display: none;position: absolute; bottom: 20px; right: 20px;cursor: hand; cursor: pointer;" /&gt;');
                                            img.hover(on_hover_in);
                                            img.siblings('img:first').on('click', on_click);
                                            });

                                            };
                                            })( jQuery );
                                            &lt;/script&gt;
                                            &lt;/head&gt;
                                            &lt;body&gt;
                                            &lt;div id="page"&gt;
                                            &lt;!-- [banner] --&gt;
                                            &lt;header id="banner"&gt;
                                            &lt;hgroup&gt;
                                            &lt;h1&gt;Creating a simple Pinterest! jQuery&lt;/h1&gt;
                                            &lt;/hgroup&gt;
                                            &lt;/header&gt;
                                            &lt;!-- [content] --&gt;
                                            &lt;section id="content"&gt;
                                            &lt;img id="share" src="picasso.jpg" title="Three Musicians" /&gt;
                                            &lt;/section&gt;

                                            &lt;script&gt;
                                            $(document).on('ready', function(){
                                            $('img#share').pinterest({ button: 'pinterest-small.png'});
                                            });
                                            &lt;/script&gt;
                                            &lt;/div&gt;
                                            &lt;!-- [/page] --&gt;
                                            &lt;/body&gt;
                                            &lt;/html&gt;</pre>
<p><a href="http://developerdrive.developerdrive.netdna-cdn.com/wp-content/uploads/2013/05/index1.html" target="_blank"><img class="aligncenter size-full wp-image-3371" alt="" src="http://developerdrive.developerdrive.netdna-cdn.com/wp-content/uploads/2013/02/view-demo-button.jpg" width="232" height="60" /></a></p>
<p><a href="http://developerdrive.developerdrive.netdna-cdn.com/wp-content/uploads/2013/05/jquery-pinterest1.zip"><img class="aligncenter size-full wp-image-3629" alt="" src="http://developerdrive.developerdrive.netdna-cdn.com/wp-content/uploads/2013/03/download.jpg" width="300" height="53" /></a></p>
<div class="post-author-bio">
<div class="asection-title">ABOUT THE AUTHOR</div>
<div class="clr">
<div class="author-bio-text">A battle hardened software developer with a mixed and colorful background, who can’t come up with a decent author bio <a href="http://schnittger.me">http://schnittger.me</a></div>
<div class="clr"></div>
</div>
</div>
</div>
<img src="http://feeds.feedburner.com/~r/goksel/~4/SWO5lX58aBo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geryit.com/blog/creating-a-simple-jquery-plugin-for-pinterest/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<media:content url="http://feedproxy.google.com/~r/goksel/~5/NZfidd5DiWc/jquery-pinterest1.zip" fileSize="39770" type="application/zip" /><itunes:explicit>no</itunes:explicit><itunes:subtitle>Introduction Plugins play a great part in the success of jQuery. There are hundreds of them out there, and having the ability to create your own is a great skill to have. With all of the interest in Pinterest (no pun intended), I thought it would be a goo</itunes:subtitle><itunes:summary>Introduction Plugins play a great part in the success of jQuery. There are hundreds of them out there, and having the ability to create your own is a great skill to have. With all of the interest in Pinterest (no pun intended), I thought it would be a good idea to do up a quick [...]</itunes:summary><itunes:keywords>Jquery</itunes:keywords><feedburner:origLink>http://geryit.com/blog/creating-a-simple-jquery-plugin-for-pinterest/</feedburner:origLink><enclosure url="http://feedproxy.google.com/~r/goksel/~5/NZfidd5DiWc/jquery-pinterest1.zip" length="39770" type="application/zip" /><feedburner:origEnclosureLink>http://developerdrive.developerdrive.netdna-cdn.com/wp-content/uploads/2013/05/jquery-pinterest1.zip</feedburner:origEnclosureLink></item>
		<item>
		<title>Convert Old CSS To LESS</title>
		<link>http://feedproxy.google.com/~r/goksel/~3/9zS_HRkNw3o/</link>
		<comments>http://geryit.com/blog/convert-old-css-to-less/#comments</comments>
		<pubDate>Tue, 19 Mar 2013 18:10:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Css3]]></category>
		<category><![CDATA[Fun Stuff]]></category>

		<guid isPermaLink="false">http://geryit.com/blog/?p=1400</guid>
		<description><![CDATA[We have covered much of the basics for LESS in our previous posts. If you have been following our LESS series, we believe that at this point you already have a good idea about how to use the Variables, Mixins and Operation in LESS. We have also mentioned how to convert LESS into regular CSS, [...]]]></description>
				<content:encoded><![CDATA[<div class="sContent intxt">
                    <!-- google_ad_section_start --></p>
<p>We have covered much of the basics for LESS in our <a href="http://www.hongkiat.com/blog/tag/less-css/">previous posts</a>. If you have been following our LESS series, we believe that at this point you already have a good idea about how to use the <strong><a href="http://www.hongkiat.com/blog/less-css-tutorial-design-slick-menu-nav-bar/">Variables</a></strong><a href="http://www.hongkiat.com/blog/less-css-tutorial-design-slick-menu-nav-bar/">, <strong>Mixins</strong> and <strong>Operation</strong></a> in <a rel="external" href="http://lesscss.org/">LESS</a>.</p>
<p class="sw"><img src="http://media02.hongkiat.com/css-to-less/css-less-cover.jpg" width="500" height="300"></p>
<p>We have also mentioned how to convert LESS into <a rel="external" href="http://www.hongkiat.com/blog/css-back-to-basics-terminology-explained/">regular CSS</a>, with an app or with a compiler. But, how do we do the opposite; to convert CSS into LESS? Well, this tip is for you.</p>
<h3>Using a Tool</h3>
<p>With increasing popularity of <strong>CSS preprocessor</strong>, some new tools and apps  that essentially aim to makea web designer&#8217;s or developer&#8217;s life easier, such as this tool: <a rel="external" href="http://css2less.cc/">CSS2Less</a>.</p>
<p>This tool allows us to convert regular CSS into LESS. So, let&#8217;s give it a try. I have the following CSS rules from my old file to be converted.</p>
<pre name="code" class="css">
                        nav {
                        height: 40px;
                        width: 100%;
                        background: #000;
                        border-bottom: 2px solid #fff;
                        }
                        nav ul {
                        padding: 0;
                        margin: 0 auto;
                        }
                        nav li {
                        display: inline;
                        float: left;
                        }
                        nav a {
                        color: #fff;
                        display: inline-block;
                        width: 100px;
                        text-shadow: 1px 1px 0px #000;
                        }
                        nav li a {
                        border-right: 1px solid #fff;
                        box-sizing:border-box;
                        }
                        nav li:last-child a {
                        border-right: 0;
                        }
                        nav a:hover, nav a:active {
                        background-color: #fff;
                        }
                    </pre>
<p>Here is the result.</p>
<p class="sw"><img src="http://media02.hongkiat.com/css-to-less/css-less-result.jpg" width="500" height="300"></p>
<pre name="code" class="css">
                        nav a:hover, nav a:active {
                        background-color: #fff;
                        }
                        nav {
                        height: 40px;
                        width: 100%;
                        background: #000;
                        border-bottom: 2px solid #fff;
                        a {
                        color: #fff;
                        display: inline-block;
                        width: 100px;
                        text-shadow: 1px 1px 0px #000;
                        }
                        ul {
                        padding: 0;
                        margin: 0 auto;
                        }
                        li:last-child {
                        a {
                        border-right: 0;
                        }
                        }
                        li {
                        display: inline;
                        float: left;
                        a {
                        border-right: 1px solid #fff;
                        box-sizing:border-box;
                        }
                        }
                        }
                    </pre>
<p>As we can see above, our old CSS is now nested like in LESS.</p>
<h3>Limitation</h3>
<p>However we can also see some limitations in the results of the conversion. In the old CSS, we have several same colors, such as in these two declarations <code>border-bottom: 2px solid #fff;</code> and <code>border-right: 1px solid #fff;</code> we have  both borders in white. In LESS we can actually store this constant value in a <strong>Variable</strong>.</p>
<p>It also does not nest and separate the <a rel="external" href="http://www.hongkiat.com/blog/pseudo-element-before-after/"><em>pseudo-*</em></a> with an ampersand (&amp;) symbol, such as in the following rules <code>li:last-child</code> and <code>nav a:hover, nav a:active</code>. They just remain as they are, where we can actually simplify the rulesets this way;</p>
<pre name="code" class="css">
                        li {
                        &amp;:first-child {

                        }
                        a {
                        &amp;:hover {

                        }
                        &amp;:active {

                        }
                        }
                        }
                    </pre>
<h3>Conclusion</h3>
<p>Despite the limitations it currently still has, this tool can quite helpful in saving our time for nesting CSS rulesets. We only need to do the rest manually; possibly until the the limitations above are <strong>resolved</strong>.</p>
<div class="gad_wrap">
                        <script language="JavaScript">
                            function google_ad_request_done(google_ads) {
                                var s = ''; var i;
                                if (google_ads.length == 0) { return; }
                                if (google_ads.length == 1) {
                                    s += '
<div class=\"gad_adFeedback\"><a href=\"'+google_info.feedback_url+'\">Ads by Google</a></div>
<div class=\"gad_unit\"><a class=\"gad_adTitle\" href=\"'+google_ads[0].url+'\" onmouseout=\"window.status=\" onmouseover=\"window.status=\'go to '+google_ads[0].visible_url+';return true\'\"><span>'+google_ads[0].line1+'</span></a><a class=\"gad_adURL\" href=\"'+google_ads[0].url+'\" onmouseout=\"window.status=\'\'\" onmouseover=\"window.status=\'go to '+google_ads[0].visible_url+';return true\'\"><span>'+google_ads[0].visible_url+'</span></a> <span class=\"gad_adText\">'+google_ads[0].line2+' '+google_ads[0].line3+'</span></div>
<p>';
                                }
                                else if (google_ads.length > 1) {
                                    s += '
<div class=\"gad_adFeedback\"><a href=\"' + google_info.feedback_url + '\">Ads by Google</a></div>
<p>'
                                    for(i = 0; i < google_ads.length; ++i) {
                                        s += '
<div class=\"gad_unit\"><a class=\"gad_adTitle\" href=\"'+google_ads[i].url+'\" onmouseout=\"window.status=\" onmouseover=\"window.status=\'go to '+google_ads[i].visible_url+';return true\'\"><span>'+google_ads[i].line1+'</span></a><a class=\"gad_adURL\" href=\"'+google_ads[i].url+'\" onmouseout=\"window.status=\'\'\" onmouseover=\"window.status=\'go to '+google_ads[i].visible_url+';return true\'\"><span>'+google_ads[i].visible_url+'</span></a> <span class=\"gad_adText\">'+google_ads[i].line2+' '+google_ads[i].line3+'</span></div>
<p>';
                                    }
                                }
                                if (google_ads[0].bidtype == "CPC") {
                                    google_adnum = google_adnum + google_ads.length;
                                }
                                document.write(s);
                                return;
                            }
                            google_ad_client = 'pub-8918970543424762';
                            google_ad_channel = '0118666992';
                            google_ad_output = 'js';
                            google_max_num_ads = '2';
                            google_ad_type = 'text';
                            google_feedback = 'on';
                            google_skip = google_adnum;
                        </script><br />
                        <script language="JavaScript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
                    </div>
<p>                    <!-- google_ad_section_end -->
                </div>
<img src="http://feeds.feedburner.com/~r/goksel/~4/9zS_HRkNw3o" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geryit.com/blog/convert-old-css-to-less/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://geryit.com/blog/convert-old-css-to-less/</feedburner:origLink></item>
		<item>
		<title>css3 Radio Switcher</title>
		<link>http://feedproxy.google.com/~r/goksel/~3/h6V3hDOgZGc/</link>
		<comments>http://geryit.com/blog/css3-radio-switcher/#comments</comments>
		<pubDate>Tue, 25 Dec 2012 00:49:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Cool Stuff]]></category>
		<category><![CDATA[Css3]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://geryit.com/blog/?p=1384</guid>
		<description><![CDATA[I needed a css 3 radio switcher for a project I am working on, coded it, and sharing with you. Demo switch test2 on off switch test2 on off .switcher-on { background: #6c8c37 ; background: -moz-linear-gradient(#6c8c37, #7fa341) ; background: -webkit-linear-gradient(#6c8c37, #7fa341) ; background: -o-linear-gradient(#6c8c37, #7fa341) ; background: -ms-linear-gradient(#6c8c37, #7fa341) ; background: linear-gradient(#6c8c37, #7fa341) ; border-color: [...]]]></description>
				<content:encoded><![CDATA[<p>I needed a css 3 radio switcher for a project I am working on, coded it, and sharing with you.</p>
<h2 style="margin-top: 30px;">Demo</h2>
<div style="" class="switcher-wrapper clearfix">
            <label style="float: left; margin-right: 10px;" for="test2">switch test2</label><br />
            <input type="checkbox" id="test2" checked=""></p>
<div class="switcher-no-js " style="float: left;">
                <span>on</span><br />
                <span>off</span><br />
                <label for="test2"></label></p>
<div></div>
</p></div>
</p></div>
<style>
.switcher-on {
  background: #6c8c37 ;
  background: -moz-linear-gradient(#6c8c37, #7fa341) ;
  background: -webkit-linear-gradient(#6c8c37, #7fa341) ;
  background: -o-linear-gradient(#6c8c37, #7fa341) ;
  background: -ms-linear-gradient(#6c8c37, #7fa341) ;
  background: linear-gradient(#6c8c37, #7fa341) ;
  border-color: #404e29;
}
.switcher-on div {
  left: 38px;
}
.switcher-on:hover div {
  left: 35px;
}
.switcher-wrapper input {
  display: none;
}
.switcher-wrapper input:checked ~ .switcher-no-js {
  background: #6c8c37 ;
  background: -moz-linear-gradient(#6c8c37, #7fa341) ;
  background: -webkit-linear-gradient(#6c8c37, #7fa341) ;
  background: -o-linear-gradient(#6c8c37, #7fa341) ;
  background: -ms-linear-gradient(#6c8c37, #7fa341) ;
  background: linear-gradient(#6c8c37, #7fa341) ;
  border-color: #404e29;
}
.switcher-wrapper input:checked ~ .switcher-no-js div {
  left: 38px;
}
.switcher-wrapper input:checked ~ .switcher-no-js:hover div {
  left: 35px;
}
.switcher-no-js {
  width: 80px;
  height: 23px;
  border-radius: 3px;
  background: #952b37 ;
  background: -moz-linear-gradient(#952b37, #952b37) ;
  background: -webkit-linear-gradient(#952b37, #952b37) ;
  background: -o-linear-gradient(#952b37, #952b37) ;
  background: -ms-linear-gradient(#952b37, #952b37) ;
  background: linear-gradient(#952b37, #952b37) ;
  border: 1px solid #4e2933;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3);
  position: relative;
  cursor: pointer;
  overflow: hidden;
}
.switcher-no-js span {
  width: 50%;
  text-align: center;
  color: #fff !important;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3) !important;
  font-size: 11px;
  text-transform: uppercase;
  line-height: 21px;
  float: left;
  margin: 0 !important;
}
.switcher-no-js label {
  position: absolute;
  width: 100%;
  height: 100%;
  z-index: 1;
  left: 0;
  top: 0;
}
.switcher-no-js div {
  position: absolute;
  width: 50%;
  background: #ffffff ;
  background: -moz-linear-gradient(#ffffff, #dadada) ;
  background: -webkit-linear-gradient(#ffffff, #dadada) ;
  background: -o-linear-gradient(#ffffff, #dadada) ;
  background: -ms-linear-gradient(#ffffff, #dadada) ;
  background: linear-gradient(#ffffff, #dadada) ;
  top: 1px;
  left: 1px;
  border-radius: 3px;
  bottom: 1px;
  text-align: center;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);
  border: 1px solid #4e2933;
  line-height: 16px;
  -webkit-transition: left 0.1s ease;
  -moz-transition: left 0.1s ease;
  -o-transition: left 0.1s ease;
  transition: left 0.1s ease;
  cursor: pointer;
}
.switcher-no-js div:before,
.switcher-no-js div:after {
  content: '';
  width: 1px;
  height: 8px;
  display: inline-block;
  box-shadow: -1px 0 #bebebe, -2px 0 #ffffff, 1px 0 #ffffff;
  margin: 0 1px;
}
.switcher-no-js div:after {
  box-shadow: -1px 0 #bebebe, 1px 0 #ffffff, 2px 0 #bebebe;
}
.switcher-no-js:hover div {
  left: 4px;
}
.switcher-no-js.on {
  background: #6c8c37 ;
  background: -moz-linear-gradient(#6c8c37, #7fa341) ;
  background: -webkit-linear-gradient(#6c8c37, #7fa341) ;
  background: -o-linear-gradient(#6c8c37, #7fa341) ;
  background: -ms-linear-gradient(#6c8c37, #7fa341) ;
  background: linear-gradient(#6c8c37, #7fa341) ;
  border-color: #404e29;
}
.switcher-no-js.on div {
  left: 38px;
}
.switcher-no-js.on:hover div {
  left: 35px;
}
.switcher-no-js.disabled {
  cursor: default;
}
.switcher-no-js.disabled div {
  background: #d8d8d8 ;
  background: -moz-linear-gradient(#d8d8d8, #dbdbdb) ;
  background: -webkit-linear-gradient(#d8d8d8, #dbdbdb) ;
  background: -o-linear-gradient(#d8d8d8, #dbdbdb) ;
  background: -ms-linear-gradient(#d8d8d8, #dbdbdb) ;
  background: linear-gradient(#d8d8d8, #dbdbdb) ;
}
.switcher-no-js.disabled.off {
  background: #957F82;
}
.switcher-no-js.disabled.off:hover div {
  left: 1px;
}
.switcher-no-js.disabled.on {
  background: #848C77;
}
.switcher-no-js.disabled.on:hover div {
  left: 38px;
}</p>
</style>
<pre class="brush: html" title="html">
<div style="" class="switcher-wrapper clearfix">
            <label style="float: left; margin-right: 10px;" for="test2">switch test2</label>
            <input type="checkbox" id="test2" checked="">
            <div class="switcher-no-js " style="float: left;">
                <span>on</span>
                <span>off</span>
                <label for="test2"></label>
                <div></div>
            </div>
        </div></pre>
<pre class="brush: css" title="css">
.switcher-on {
  background: #6c8c37 ;
  background: -moz-linear-gradient(#6c8c37, #7fa341) ;
  background: -webkit-linear-gradient(#6c8c37, #7fa341) ;
  background: -o-linear-gradient(#6c8c37, #7fa341) ;
  background: -ms-linear-gradient(#6c8c37, #7fa341) ;
  background: linear-gradient(#6c8c37, #7fa341) ;
  border-color: #404e29;
}
.switcher-on div {
  left: 38px;
}
.switcher-on:hover div {
  left: 35px;
}
.switcher-wrapper input {
  display: none;
}
.switcher-wrapper input:checked ~ .switcher-no-js {
  background: #6c8c37 ;
  background: -moz-linear-gradient(#6c8c37, #7fa341) ;
  background: -webkit-linear-gradient(#6c8c37, #7fa341) ;
  background: -o-linear-gradient(#6c8c37, #7fa341) ;
  background: -ms-linear-gradient(#6c8c37, #7fa341) ;
  background: linear-gradient(#6c8c37, #7fa341) ;
  border-color: #404e29;
}
.switcher-wrapper input:checked ~ .switcher-no-js div {
  left: 38px;
}
.switcher-wrapper input:checked ~ .switcher-no-js:hover div {
  left: 35px;
}
.switcher-no-js {
  width: 80px;
  height: 23px;
  border-radius: 3px;
  background: #952b37 ;
  background: -moz-linear-gradient(#952b37, #952b37) ;
  background: -webkit-linear-gradient(#952b37, #952b37) ;
  background: -o-linear-gradient(#952b37, #952b37) ;
  background: -ms-linear-gradient(#952b37, #952b37) ;
  background: linear-gradient(#952b37, #952b37) ;
  border: 1px solid #4e2933;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3);
  position: relative;
  cursor: pointer;
  overflow: hidden;
}
.switcher-no-js span {
  width: 50%;
  text-align: center;
  color: #fff !important;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.3) !important;
  font-size: 11px;
  text-transform: uppercase;
  line-height: 21px;
  float: left;
  margin: 0 !important;
}
.switcher-no-js label {
  position: absolute;
  width: 100%;
  height: 100%;
  z-index: 1;
  left: 0;
  top: 0;
}
.switcher-no-js div {
  position: absolute;
  width: 50%;
  background: #ffffff ;
  background: -moz-linear-gradient(#ffffff, #dadada) ;
  background: -webkit-linear-gradient(#ffffff, #dadada) ;
  background: -o-linear-gradient(#ffffff, #dadada) ;
  background: -ms-linear-gradient(#ffffff, #dadada) ;
  background: linear-gradient(#ffffff, #dadada) ;
  top: 1px;
  left: 1px;
  border-radius: 3px;
  bottom: 1px;
  text-align: center;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.5);
  border: 1px solid #4e2933;
  line-height: 16px;
  -webkit-transition: left 0.1s ease;
  -moz-transition: left 0.1s ease;
  -o-transition: left 0.1s ease;
  transition: left 0.1s ease;
  cursor: pointer;
}
.switcher-no-js div:before,
.switcher-no-js div:after {
  content: '';
  width: 1px;
  height: 8px;
  display: inline-block;
  box-shadow: -1px 0 #bebebe, -2px 0 #ffffff, 1px 0 #ffffff;
  margin: 0 1px;
}
.switcher-no-js div:after {
  box-shadow: -1px 0 #bebebe, 1px 0 #ffffff, 2px 0 #bebebe;
}
.switcher-no-js:hover div {
  left: 4px;
}
.switcher-no-js.on {
  background: #6c8c37 ;
  background: -moz-linear-gradient(#6c8c37, #7fa341) ;
  background: -webkit-linear-gradient(#6c8c37, #7fa341) ;
  background: -o-linear-gradient(#6c8c37, #7fa341) ;
  background: -ms-linear-gradient(#6c8c37, #7fa341) ;
  background: linear-gradient(#6c8c37, #7fa341) ;
  border-color: #404e29;
}
.switcher-no-js.on div {
  left: 38px;
}
.switcher-no-js.on:hover div {
  left: 35px;
}
.switcher-no-js.disabled {
  cursor: default;
}
.switcher-no-js.disabled div {
  background: #d8d8d8 ;
  background: -moz-linear-gradient(#d8d8d8, #dbdbdb) ;
  background: -webkit-linear-gradient(#d8d8d8, #dbdbdb) ;
  background: -o-linear-gradient(#d8d8d8, #dbdbdb) ;
  background: -ms-linear-gradient(#d8d8d8, #dbdbdb) ;
  background: linear-gradient(#d8d8d8, #dbdbdb) ;
}
.switcher-no-js.disabled.off {
  background: #957F82;
}
.switcher-no-js.disabled.off:hover div {
  left: 1px;
}
.switcher-no-js.disabled.on {
  background: #848C77;
}
.switcher-no-js.disabled.on:hover div {
  left: 38px;
}
</pre>
<pre class="brush: css" title="less">
.switcher-on {
    .grad(#6c8c37,#7fa341);
    border-color: #404e29;
    div {
        left: 38px;
    }
    &#038;:hover div {
        left: 35px;
    }
}

.switcher-wrapper {
    input {
        display: none;
        &#038;:checked ~ .switcher-no-js {
            .switcher-on;
        }
    }
}
.switcher-no-js {
    width: 80px;
    height: 23px;
    border-radius: 3px;
    .grad(#952b37, #952b37);
    border: 1px solid #4e2933;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, .3);
    position: relative;
    cursor: pointer;
    overflow: hidden;
    span {
        width: 50%;
        text-align: center;
        color: #fff !important;
        text-shadow: 0 1px 1px rgba(0, 0, 0, .3) !important;
        font-size: 11px;
        text-transform: uppercase;
        line-height: 21px;
        float: left;
        margin: 0 !important;
    }
    label {
        position: absolute;
        width: 100%;
        height: 100%;
        z-index: 1;
        left: 0;
        top: 0;
    }
    div {
        position: absolute;
        width: 50%;
        .grad(#fff,#dadada);
        top: 1px;
        left: 1px;
        border-radius: 3px;
        bottom: 1px;
        text-align: center;
        box-shadow: 0 1px 1px rgba(0, 0, 0, .5);
        border: 1px solid #4e2933;
        line-height: 16px;
        .transition(left .1s ease);
        cursor: pointer;
        &#038;:before, &#038;:after {
            content: '';
            width: 1px;
            height: 8px;
            display: inline-block;
            box-shadow: -1px 0 #bebebe, -2px 0 #fff, 1px 0 #fff;
            margin: 0 1px;
        }
        &#038;:after {
            box-shadow: -1px 0 #bebebe, 1px 0 #fff, 2px 0 #bebebe;
        }
    }

    &#038;:hover div {
        left: 4px;
    }
    &#038;.on {
        .switcher-on;
    }
    &#038;.disabled {
        cursor: default;
        div {
            .grad(#d8d8d8,#dbdbdb);
        }
        &#038;.off {
            background: #957F82;
            &#038;:hover div {
                left: 1px;
            }
        }
        &#038;.on {
            background: #848C77;
            &#038;:hover div {
                left: 38px;
            }
        }
    }
}
</pre>
<img src="http://feeds.feedburner.com/~r/goksel/~4/h6V3hDOgZGc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geryit.com/blog/css3-radio-switcher/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://geryit.com/blog/css3-radio-switcher/</feedburner:origLink></item>
		<item>
		<title>Pure css ribbons</title>
		<link>http://feedproxy.google.com/~r/goksel/~3/OcQHaMMCpSs/</link>
		<comments>http://geryit.com/blog/pure-css-ribbons/#comments</comments>
		<pubDate>Tue, 13 Nov 2012 02:05:49 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Css3]]></category>

		<guid isPermaLink="false">http://geryit.com/blog/?p=1376</guid>
		<description><![CDATA[NEW ★ FEATURED NEW &#9733; FEATURED .course-ribbon { position: absolute; right: -11px; top: 20px; z-index: 1; } .course-ribbon:before { background: #666666 ; background: -moz-linear-gradient(#666666, #000000) ; background: -webkit-linear-gradient(#666666, #000000) ; background: -o-linear-gradient(#666666, #000000) ; background: -ms-linear-gradient(#666666, #000000) ; background: linear-gradient(#666666, #000000) ; bottom: -7px; content: ""; height: 6px; position: absolute; right: 1px; -moz-transform: skewY(-20deg); -webkit-transform: [...]]]></description>
				<content:encoded><![CDATA[<p><a href="http://geryit.com/blog/wp-content/uploads/2012/11/Screen-Shot-2012-11-12-at-10.34.27-PM.png"><img src="http://geryit.com/blog/wp-content/uploads/2012/11/Screen-Shot-2012-11-12-at-10.34.27-PM.png" alt="" title="Screen Shot 2012-11-12 at 10.34.27 PM" width="428" height="284" class="alignnone size-full wp-image-1377" /></a></p>
<div style="position: relative; width: 120px;height: 100px;background: white;margin-top: 10px;">
<div class="course-ribbon orange"><b>NEW</b></div>
<div class="course-ribbon green" style="top:60px"><b>★ FEATURED</b></div>
</div>
<style>
<p>.course-ribbon {
  position: absolute;
  right: -11px;
  top: 20px;
  z-index: 1;
}
.course-ribbon:before {
  background: #666666 ;
  background: -moz-linear-gradient(#666666, #000000) ;
  background: -webkit-linear-gradient(#666666, #000000) ;
  background: -o-linear-gradient(#666666, #000000) ;
  background: -ms-linear-gradient(#666666, #000000) ;
  background: linear-gradient(#666666, #000000) ;
  bottom: -7px;
  content: "";
  height: 6px;
  position: absolute;
  right: 1px;
  -moz-transform: skewY(-20deg);
  -webkit-transform: skewY(-20deg);
  -o-transform: skewY(-20deg);
  -ms-transform: skewY(-20deg);
  transform: skewY(-20deg);
  -webkit-backface-visibility: hidden;
  width: 10px;
  display: block;
}
.course-ribbon b {
  border: 1px solid #4F2C1D;
  border-radius: 4px;
  color: #fff;
  padding: 7px 10px 7px 8px;
  position: relative;
  box-shadow: 0 1px rgba(255, 255, 255, 0.5) inset, 0 3px 2px rgba(0, 0, 0, 0.2);
  text-shadow: 0 -1px 1px rgba(0, 0, 0, 0.5);
}
.course-ribbon b:before,
.course-ribbon b:after {
  border-color: #4F2C1D;
  border-style: solid;
  content: "";
  height: 50%;
  left: -4px;
  position: absolute;
  width: 8px;
}
.course-ribbon b:before {
  border-width: 1px 0 0 1px;
  box-shadow: 0 1px rgba(255, 255, 255, 0.5) inset;
  top: -1px;
  -moz-transform: skewX(21deg);
  -webkit-transform: skewX(21deg);
  -o-transform: skewX(21deg);
  -ms-transform: skewX(21deg);
  transform: skewX(21deg);
  -webkit-backface-visibility: hidden;
}
.course-ribbon b:after {
  border-width: 0 0 1px 1px;
  bottom: -1px;
  -moz-transform: skewX(-21deg);
  -webkit-transform: skewX(-21deg);
  -o-transform: skewX(-21deg);
  -ms-transform: skewX(-21deg);
  transform: skewX(-21deg);
  -webkit-backface-visibility: hidden;
  box-shadow: 0 5px 2px -2px rgba(0, 0, 0, 0.2);
}
.course-ribbon b i {
  font-style: normal;
  font-size: 20px;
}
.course-ribbon.orange b {
  background: #f79f4f ;
  background: -moz-linear-gradient(#f79f4f, #aa0642) ;
  background: -webkit-linear-gradient(#f79f4f, #aa0642) ;
  background: -o-linear-gradient(#f79f4f, #aa0642) ;
  background: -ms-linear-gradient(#f79f4f, #aa0642) ;
  background: linear-gradient(#f79f4f, #aa0642) ;
}
.course-ribbon.orange b:before {
  background: #f79f4f ;
  background: -moz-linear-gradient(#f79f4f, #d0684a) ;
  background: -webkit-linear-gradient(#f79f4f, #d0684a) ;
  background: -o-linear-gradient(#f79f4f, #d0684a) ;
  background: -ms-linear-gradient(#f79f4f, #d0684a) ;
  background: linear-gradient(#f79f4f, #d0684a) ;
}
.course-ribbon.orange b:after {
  background: #d0684a ;
  background: -moz-linear-gradient(#d0684a, #aa0642) ;
  background: -webkit-linear-gradient(#d0684a, #aa0642) ;
  background: -o-linear-gradient(#d0684a, #aa0642) ;
  background: -ms-linear-gradient(#d0684a, #aa0642) ;
  background: linear-gradient(#d0684a, #aa0642) ;
}
.course-ribbon.green b {
  background: #8ab933 ;
  background: -moz-linear-gradient(#8ab933, #4a631c) ;
  background: -webkit-linear-gradient(#8ab933, #4a631c) ;
  background: -o-linear-gradient(#8ab933, #4a631c) ;
  background: -ms-linear-gradient(#8ab933, #4a631c) ;
  background: linear-gradient(#8ab933, #4a631c) ;
}
.course-ribbon.green b:before {
  background: #8ab933 ;
  background: -moz-linear-gradient(#8ab933, #688b29) ;
  background: -webkit-linear-gradient(#8ab933, #688b29) ;
  background: -o-linear-gradient(#8ab933, #688b29) ;
  background: -ms-linear-gradient(#8ab933, #688b29) ;
  background: linear-gradient(#8ab933, #688b29) ;
}
.course-ribbon.green b:after {
  background: #688b29 ;
  background: -moz-linear-gradient(#688b29, #4a631c) ;
  background: -webkit-linear-gradient(#688b29, #4a631c) ;
  background: -o-linear-gradient(#688b29, #4a631c) ;
  background: -ms-linear-gradient(#688b29, #4a631c) ;
  background: linear-gradient(#688b29, #4a631c) ;
}
</style>
<pre class="brush: css">
<div class="course-ribbon orange"><b>NEW</b></div>
<div class="course-ribbon green" style="top:60px"><b>&#9733; FEATURED</b></div>
</pre>
<pre class="brush: css">

.course-ribbon {
  position: absolute;
  right: -11px;
  top: 20px;
  z-index: 1;
}
.course-ribbon:before {
  background: #666666 ;
  background: -moz-linear-gradient(#666666, #000000) ;
  background: -webkit-linear-gradient(#666666, #000000) ;
  background: -o-linear-gradient(#666666, #000000) ;
  background: -ms-linear-gradient(#666666, #000000) ;
  background: linear-gradient(#666666, #000000) ;
  bottom: -7px;
  content: "";
  height: 6px;
  position: absolute;
  right: 1px;
  -moz-transform: skewY(-20deg);
  -webkit-transform: skewY(-20deg);
  -o-transform: skewY(-20deg);
  -ms-transform: skewY(-20deg);
  transform: skewY(-20deg);
  -webkit-backface-visibility: hidden;
  width: 10px;
  display: block;
}
.course-ribbon b {
  border: 1px solid #4F2C1D;
  border-radius: 4px;
  color: #fff;
  padding: 7px 10px 7px 8px;
  position: relative;
  box-shadow: 0 1px rgba(255, 255, 255, 0.5) inset, 0 3px 2px rgba(0, 0, 0, 0.2);
  text-shadow: 0 -1px 1px rgba(0, 0, 0, 0.5);
}
.course-ribbon b:before,
.course-ribbon b:after {
  border-color: #4F2C1D;
  border-style: solid;
  content: "";
  height: 50%;
  left: -4px;
  position: absolute;
  width: 8px;
}
.course-ribbon b:before {
  border-width: 1px 0 0 1px;
  box-shadow: 0 1px rgba(255, 255, 255, 0.5) inset;
  top: -1px;
  -moz-transform: skewX(21deg);
  -webkit-transform: skewX(21deg);
  -o-transform: skewX(21deg);
  -ms-transform: skewX(21deg);
  transform: skewX(21deg);
  -webkit-backface-visibility: hidden;
}
.course-ribbon b:after {
  border-width: 0 0 1px 1px;
  bottom: -1px;
  -moz-transform: skewX(-21deg);
  -webkit-transform: skewX(-21deg);
  -o-transform: skewX(-21deg);
  -ms-transform: skewX(-21deg);
  transform: skewX(-21deg);
  -webkit-backface-visibility: hidden;
  box-shadow: 0 5px 2px -2px rgba(0, 0, 0, 0.2);
}
.course-ribbon b i {
  font-style: normal;
  font-size: 20px;
}
.course-ribbon.orange b {
  background: #f79f4f ;
  background: -moz-linear-gradient(#f79f4f, #aa0642) ;
  background: -webkit-linear-gradient(#f79f4f, #aa0642) ;
  background: -o-linear-gradient(#f79f4f, #aa0642) ;
  background: -ms-linear-gradient(#f79f4f, #aa0642) ;
  background: linear-gradient(#f79f4f, #aa0642) ;
}
.course-ribbon.orange b:before {
  background: #f79f4f ;
  background: -moz-linear-gradient(#f79f4f, #d0684a) ;
  background: -webkit-linear-gradient(#f79f4f, #d0684a) ;
  background: -o-linear-gradient(#f79f4f, #d0684a) ;
  background: -ms-linear-gradient(#f79f4f, #d0684a) ;
  background: linear-gradient(#f79f4f, #d0684a) ;
}
.course-ribbon.orange b:after {
  background: #d0684a ;
  background: -moz-linear-gradient(#d0684a, #aa0642) ;
  background: -webkit-linear-gradient(#d0684a, #aa0642) ;
  background: -o-linear-gradient(#d0684a, #aa0642) ;
  background: -ms-linear-gradient(#d0684a, #aa0642) ;
  background: linear-gradient(#d0684a, #aa0642) ;
}
.course-ribbon.green b {
  background: #8ab933 ;
  background: -moz-linear-gradient(#8ab933, #4a631c) ;
  background: -webkit-linear-gradient(#8ab933, #4a631c) ;
  background: -o-linear-gradient(#8ab933, #4a631c) ;
  background: -ms-linear-gradient(#8ab933, #4a631c) ;
  background: linear-gradient(#8ab933, #4a631c) ;
}
.course-ribbon.green b:before {
  background: #8ab933 ;
  background: -moz-linear-gradient(#8ab933, #688b29) ;
  background: -webkit-linear-gradient(#8ab933, #688b29) ;
  background: -o-linear-gradient(#8ab933, #688b29) ;
  background: -ms-linear-gradient(#8ab933, #688b29) ;
  background: linear-gradient(#8ab933, #688b29) ;
}
.course-ribbon.green b:after {
  background: #688b29 ;
  background: -moz-linear-gradient(#688b29, #4a631c) ;
  background: -webkit-linear-gradient(#688b29, #4a631c) ;
  background: -o-linear-gradient(#688b29, #4a631c) ;
  background: -ms-linear-gradient(#688b29, #4a631c) ;
  background: linear-gradient(#688b29, #4a631c) ;
}
</pre>
<img src="http://feeds.feedburner.com/~r/goksel/~4/OcQHaMMCpSs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geryit.com/blog/pure-css-ribbons/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://geryit.com/blog/pure-css-ribbons/</feedburner:origLink></item>
		<item>
		<title>geryit.com is now responsive</title>
		<link>http://feedproxy.google.com/~r/goksel/~3/GbymYNj1LIo/</link>
		<comments>http://geryit.com/blog/geryit-com-is-now-responsive/#comments</comments>
		<pubDate>Wed, 12 Sep 2012 14:01:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Personal]]></category>

		<guid isPermaLink="false">http://geryit.com/blog/?p=1362</guid>
		<description><![CDATA[I finally had a chance to work on my site and made it responsive. Why dont you check it on your iphone too? Here are some screenshots:]]></description>
				<content:encoded><![CDATA[<p>I finally had a chance to work on my site and made it responsive. Why dont you check it on your iphone too?</p>
<p>Here are some screenshots: </p>
<div class="clearfix"><a href="http://geryit.com/blog/wp-content/uploads/2012/09/ss11.png"><img src="http://geryit.com/blog/wp-content/uploads/2012/09/ss11-200x300.png" alt="" title="ss1" width="200" height="300" class="alignleft size-medium wp-image-1364" /></a><a href="http://geryit.com/blog/wp-content/uploads/2012/09/ss2.png"><img src="http://geryit.com/blog/wp-content/uploads/2012/09/ss2-200x300.png" alt="" title="ss2" width="200" height="300" class="alignleft size-medium wp-image-1370" /></a><a href="http://geryit.com/blog/wp-content/uploads/2012/09/ss3.png"><img src="http://geryit.com/blog/wp-content/uploads/2012/09/ss3-200x300.png" alt="" title="ss3" width="200" height="300" class="alignleft size-medium wp-image-1371" /></a></div></p>
<img src="http://feeds.feedburner.com/~r/goksel/~4/GbymYNj1LIo" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geryit.com/blog/geryit-com-is-now-responsive/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://geryit.com/blog/geryit-com-is-now-responsive/</feedburner:origLink></item>
		<item>
		<title>Code Snippet: Keep Sidebar Elements in View When Scrolling</title>
		<link>http://feedproxy.google.com/~r/goksel/~3/GN4kBA80dWs/</link>
		<comments>http://geryit.com/blog/code-snippet-keep-sidebar-elements-in-view-when-scrolling/#comments</comments>
		<pubDate>Mon, 27 Aug 2012 12:14:15 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Css3]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://geryit.com/blog/?p=1352</guid>
		<description><![CDATA[Whether it is a list of products you are promoting, published ads or other elements on the sidebar, you will likely want to have these elements in view at all times even when scrolling. By using JQuery, you can make this possible. To do this, use the code snippet below: //keep element in view (function($) [...]]]></description>
				<content:encoded><![CDATA[<div>
<p>Whether it is a list of products you are promoting, published ads or other elements on the sidebar, you will likely want to have these elements in view at all times even when scrolling. By using JQuery, you can make this possible.<span id="more-2701"></span></p>
<p>To do this, use the code snippet below:</p>
<pre class="brush: js">//keep element in view
(function($)
{
    $(document).ready( function()
    {
        var elementPosTop = $('#sidebar-ads').position().top;
        $(window).scroll(function()
        {
            var wintop = $(window).scrollTop(), docheight = $(document).height(), winheight = $(window).height();
            //if top of element is in view
            if (wintop &gt; elementPosTop)
            {
                //always in view
                $('#sidebar-ads').css({ "position":"fixed", "top":"10px" });
            }
            else
            {
                //reset back to normal viewing
                $('#sidebar-ads').css({ "position":"inherit" });
            }
        });
    });
})(jQuery);</pre>
<p>The above code can also be made into a JQuery plug-in and used on WordPress sites.</p>
<p>Here is the plug-in version of the above code:</p>
<pre class="brush: js">/**
 *  jQuery keep element in view plugin.
 *
 *  @author      David Gitonga
 *  @copyright   Copyright (c) 2012 DeveloperDrive
 *  @license     Licensed
 *  @link        http://developerdrive.com
 *  @since       Version 1.0
 *
 */

(function($)
{
    $.fn.keepElementInView = function()
    {
        var elemPosTop = this.position().top;
        $(window).scroll(function()
        {
            var wintop = $(window).scrollTop(), docheight = $(document).height(), winheight = $(window).height();
            if (wintop &gt; elemPosTop)
            {
                this.css({ "position":"fixed", "top":"10px" });
            }
            else
            {
                this.css({ "position":"inherit" });
            }
        });
        return this;
    };

    $(document).ready( function()
    {
        jQuery('#sidebar-ads').keepElementInView();
    });
})(jQuery);</pre>
<p>Remember to define the element you want to keep in view in the code by changing the ‘#sidebar-ads’ element to your preferences.</p>
<p>Note that the plug-in only works on scroll down elements.</p>
<p>Check out the demo page below that has been created using the above code:</p>
<p><a href="http://www.jquery4u.com/">http://www.jquery4u.com/</a></p>
<p><!-- SimpleReach Slide Plugin Version: 0.6.0 --><br />
<script type="text/javascript" id="simplereach-slide-tag">
    __spr_config = {
      pid: '4f0ba8b7396cef56480000a3',
      title: 'Code Snippet: Keep Sidebar Elements in View When Scrolling',
      ckw: 'Cascading Style Sheets,CSS,Function (mathematics),HTML element,JavaScript,JQuery,Window,WordPress',
      chan: '',
      no_slide: '',
      slide_logo: false,
      pub: '2012-08-22 07:47:29',
      url: 'http%3A%2F%2Fwww.developerdrive.com%2F2012%2F08%2Fcode-snippet-keep-sidebar-elements-in-view-when-scrolling%2F',
      header: 'RECOMMENDED FOR YOU'
    };
    var content = document.getElementById('simplereach-slide-tag').parentNode, loc;
    if (content.className){ loc = '.' + content.className; }
    if (content.id){ loc = '#' + content.id; }
    __spr_config.loc = loc || content;
    (function(){
    var s = document.createElement('script');
      s.async = true;
      s.type = 'text/javascript';
      s.src = document.location.protocol + '//d8rk54i4mohrb.cloudfront.net/js/slide.js';
      __spr_config.css = 'http://www.developerdrive.com/css/sr.css';
      var tg = document.getElementsByTagName('head')[0];
      if (!tg) {tg = document.getElementsByTagName('body')[0];}
      if (tg) {tg.appendChild(s);}
    })();
</script>
			    </div>
<img src="http://feeds.feedburner.com/~r/goksel/~4/GN4kBA80dWs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geryit.com/blog/code-snippet-keep-sidebar-elements-in-view-when-scrolling/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://geryit.com/blog/code-snippet-keep-sidebar-elements-in-view-when-scrolling/</feedburner:origLink></item>
		<item>
		<title>Implementing Drag and Drop Functions with HTML5 and JavaScript</title>
		<link>http://feedproxy.google.com/~r/goksel/~3/U_b27CHzhMw/</link>
		<comments>http://geryit.com/blog/implementing-drag-and-drop-functions-with-html5-and-javascript/#comments</comments>
		<pubDate>Mon, 26 Mar 2012 22:28:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Out-source]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://geryit.com/blog/?p=1347</guid>
		<description><![CDATA[With HTML5 and JavaScript, you can implement native drag and drop functions within the Web browser. This is one of the emerging HTML5 tools that promises to make websites more interactive without relying on additional technologies such as Flash. In this tutorial we will create a simple page with images the user can drag and [...]]]></description>
				<content:encoded><![CDATA[<p>With HTML5 and JavaScript, you can implement native drag and<br />
		drop functions within the Web browser.</p>
<p>
		This is one of the emerging HTML5 tools that promises to make websites<br />
		more interactive without relying on additional technologies such as<br />
		Flash. In this tutorial we will create a simple page with images the<br />
		user can drag and drop into designated areas.<span id="more-1592"></span>
	</p>
<h2>Create an HTML5 Web Page</h2>
<p>Create an HTML file for your drag and drop function. Use the<br />
		following basic outline, with sections for JavaScript and CSS in the<br />
		head area:</p>
<pre class="brush: js">&lt;!DOCTYPE HTML&gt;
&lt;html&gt;
&lt;head&gt;
&lt;style type="text/css"&gt;
/*styling here*/
&lt;/style&gt;
&lt;script type="text/javascript"&gt;
//functions here
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;!--page elements--&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<h2>Add Drag Targets to the Page</h2>
<p>Your page will contain elements that can be dragged and elements<br />
		in which the dragged items can be dropped. Start with the areas your<br />
		user will be able to drop draggable elements into, adding the<br />
		following in your page body section:</p>
<pre class="brush: js">&lt;div class="pics"&gt;
&lt;div id="place1" ondrop="dropIt(event);" ondragover="event.preventDefault();"&gt;
&lt;/div&gt;
&lt;div id="place2" ondrop="dropIt(event);" ondragover="event.preventDefault();"&gt;
&lt;/div&gt;
&lt;div id="place3" ondrop="dropIt(event);" ondragover="event.preventDefault();"&gt;
&lt;/div&gt;
&lt;div id="place4" ondrop="dropIt(event);" ondragover="event.preventDefault();"&gt;
&lt;/div&gt;
&lt;div id="place5" ondrop="dropIt(event);" ondragover="event.preventDefault();"&gt;
&lt;/div&gt;
&lt;/div&gt;</pre>
<p>The draggable images in the page will be able to drop within<br />
		these elements. Each has an ID to identify it within the JavaScript<br />
		code. The “ondrop” event specifies a function that will execute when<br />
		an item is dropped over one of these elements. The “ondragover” event<br />
		simply instructs the browser not to do what it does by default, which<br />
		is to prevent items being dropped within other elements – we are<br />
		telling the browser to allow elements to be dropped by preventing this<br />
		default behavior.</p>
<h2>Add Draggable Elements to the Page</h2>
<p>Let’s use a couple of image elements to drag within the page.<br />
		Use the following markup for each one, altering the image source<br />
		attributes for your own images:</p>
<pre class="brush: js">&lt;img src="pic1.jpg" width="80" height="80" draggable="true" ondragstart="dragIt(event);" id="pic1" /&gt;</pre>
<p>Alter the width and height to suit your own images and give each<br />
		one a unique ID attribute value. The draggable attribute instructs the<br />
		browser to allow users to drag the image element. The “ondragstart”<br />
		event attribute specifies a JavaScript function to execute when<br />
		dragging commences. Add a couple of these inside two of your<br />
		placeholder elements, resulting in markup like this:</p>
<pre class="brush: js">&lt;div class="pics"&gt;
&lt;div id="place1" ondrop="dropIt(event);" ondragover="event.preventDefault();"&gt;
&lt;img src="pic1.jpg" width="80" height="80" draggable="true" ondragstart="dragIt(event);" id="pic1" /&gt;
&lt;/div&gt;
&lt;div id="place2" ondrop="dropIt(event);" ondragover="event.preventDefault();"&gt;
&lt;img src="pic2.jpg" width="80" height="80" draggable="true" ondragstart="dragIt(event);" id="pic2" /&gt;
&lt;/div&gt;
&lt;div id="place3" ondrop="dropIt(event);" ondragover="event.preventDefault();"&gt;
&lt;/div&gt;
&lt;div id="place4" ondrop="dropIt(event);" ondragover="event.preventDefault();"&gt;
&lt;/div&gt;
&lt;div id="place5" ondrop="dropIt(event);" ondragover="event.preventDefault();"&gt;
&lt;/div&gt;
&lt;/div&gt;</pre>
<p>Alter the image elements to suit the name, location and<br />
		dimensions of your own image files as well as your chosen IDs.</p>
<h2>Style the Elements</h2>
<p>Add the following declarations to the style section in your page<br />
		head:</p>
<pre class="brush: js">div[id^="place"]
{float:left; width:80px; height:80px; margin:3px; padding:3px; border:1px dotted #333333; background-color:#ffff99;}</pre>
<p>These declarations apply to all elements whose ID attributes<br />
		begin with “place” as our holder elements do. The shorthand notation<br />
		uses a wildcard to specify this, rather than having to specify every<br />
		ID attribute for the elements that your items can be dropped within.<br />
		Alter the dimensions to suit your images and the styling for<br />
		backgrounds or borders in any way you like. To make the demonstration<br />
		clearer, you can add the following HTML at the bottom of the page:</p>
<pre class="brush: js">&lt;div class="nums"&gt;
&lt;span&gt;1&lt;/span&gt;
&lt;span&gt;2&lt;/span&gt;
&lt;span&gt;3&lt;/span&gt;
&lt;span&gt;4&lt;/span&gt;
&lt;span&gt;5&lt;/span&gt;
&lt;/div&gt;</pre>
<p>Style the new elements by adding the following to your CSS code,<br />
		so that you can see at a glance which element you are dragging and<br />
		dropping into:</p>
<pre class="brush: js">span
{float:left; width:80px; margin:3px; padding:3px; border:1px solid #999999; color:#333333;}
.pics, .nums
{clear:both; text-align:center;}</pre>
<h2>Implement Dragging</h2>
<p>Add the following function inside the script section in your<br />
		page head:</p>
<pre class="brush: js">//function called when drag starts
function dragIt(theEvent) {
//tell the browser what to drag
theEvent.dataTransfer.setData("Text", theEvent.target.id);
}</pre>
<p>If you look at your image elements you will see that this is the<br />
		function specified within the “ondragstart” event attribute. The<br />
		content of the function specifies the image element, letting the<br />
		browser know that is what to drag. The function receives an event<br />
		variable providing access to data about the element being dragged.</p>
<h2>Implement Dropping</h2>
<p>Add the following function after your dragging function:</p>
<pre class="brush: js">//function called when element drops
function dropIt(theEvent) {
//get a reference to the element being dragged
var theData = theEvent.dataTransfer.getData("Text");
//get the element
var theDraggedElement = document.getElementById(theData);
//add it to the drop element
theEvent.target.appendChild(theDraggedElement);
//instruct the browser to allow the drop
theEvent.preventDefault();
}</pre>
<p>This code first gets a reference to the dragged element, then<br />
		adds it to the element it is being dropped in. Again, the code tells<br />
		the browser not to implement the default behavior so that the image<br />
		can be dropped successfully. This function also receives the event<br />
		data indicating information about the dragged element and the element<br />
		being dropped over.</p>
<p>Open your page in the browser and test it by clicking and<br />
		dragging the images. Notice that if you drag the images over a page<br />
		area that you have not explicitly instructed the browser to allow<br />
		dropping in, they snap back to their original position. As long as you<br />
		drop over a designated element, your images can be moved around.<br />
		Notice also that if you drop one image on top of another, the next<br />
		time you drag one, they both drag.</p>
<h2>Conclusion</h2>
<p>HTML5 functions bring a greatly enhanced level of interactivity<br />
		to Web development. The future looks pretty exciting, but for the<br />
		moment remember to take care of users with browsers that do not<br />
		support these emerging techniques.</p>
<img src="http://feeds.feedburner.com/~r/goksel/~4/U_b27CHzhMw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geryit.com/blog/implementing-drag-and-drop-functions-with-html5-and-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://geryit.com/blog/implementing-drag-and-drop-functions-with-html5-and-javascript/</feedburner:origLink></item>
		<item>
		<title>Creating “Next Level” Search Form Using jQuery &amp; CSS3 [Webstuffshare]</title>
		<link>http://feedproxy.google.com/~r/goksel/~3/ruzGvHwPTKc/</link>
		<comments>http://geryit.com/blog/creating-next-level-search-form-using-jquery-css3-webstuffshare/#comments</comments>
		<pubDate>Tue, 14 Feb 2012 10:55:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Css3]]></category>
		<category><![CDATA[Html5]]></category>
		<category><![CDATA[Out-source]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://geryit.com/blog/?p=1340</guid>
		<description><![CDATA[Lately we found ton of new style search form crafted beautifully using CSS3 and JavaScript. Apple&#8217;s for example, widen the input field when it receive focus from user. The question is &#8220;how far we can go for styling search form?&#8221;, in this tutorial we are going to move search form to the next level using [...]]]></description>
				<content:encoded><![CDATA[<div class="content-post">
<p>
		Lately we found ton of new style search form crafted beautifully using CSS3 and JavaScript. <a href="http://livepage.apple.com" target="_blank">Apple&#8217;s</a> for example, widen the input field when it receive focus from user. The question is &#8220;how far we can go for styling search form?&#8221;, in this tutorial we are going to move search form to the next level using jQuery &#038; CSS3.
	</p>
<p>
		<span id="more-2350"></span>
	</p>
<div class="button-show-implementation">
		<a href="http://webstuffshare.com/demo/NextLevelSearch/">Show Implementation</a>
	</div>
<div class="button-download-source">
		<a href="http://www.webstuffshare.com/download/NextLevelSearch.zip">Download Source</a>
	</div>
<div class="cleaner"></div>
<h3>Simple Style</h3>
<p>First to go we will create a simple animated search form that show only search button with search image on it. When the button receives a click, the input field will widen while the search image will move to left filling the left blank space before input text.</p>
<p>
		<img src="http://www.webstuffshare.com/wp-content/uploads/2012/02/simple-style2.jpg" alt="" title="simple style" class="aligncenter size-full wp-image-2352" /><br /> </br>
	</p>
<p>Based on the picture above, the HTML element will consists of 4 elements, a div for elements wrapper, an input text, an input button for search button and an image search. All of them will be stacked each other where the div wrapper is at the very bottom of the stack and image search at the very top. Here&#8217;s the HTML and CSS :</p>
<pre name="code" class="brush: html">
<div class="wrapper-simple">
<input type="text" value="Type and enter..." />
<input type="submit" value="" />
	<img src="images/search-icon-big.png" />
</div>
</pre>
<pre name="code" class="brush: css">
.wrapper-simple {
	text-align: center;
	margin: 0 auto;
	display: block;
	width: 60px;
	height: 45px;
	padding: 10px 5px;
	background: -webkit-gradient(linear, left top, left bottom, from(#f5fafe), to(#e2edf4));
	border-radius: 5px;
	box-shadow: inset rgba(255, 254, 255, 1) 0 0.1em 2px,
					#9bb6c9 0 1px 2px;
	position: relative;
}

.wrapper-simple input[type=submit] {
	margin-top: .2em;
	z-index: 2;
	position: relative;
	vertical-align: top;
	height: 43px;
	min-width: 55px;
	border-radius: 3px;
	border: 1px solid #aa7818;
	background: -webkit-gradient(linear, left top, left bottom, from(#ffb700), to(#ff8c00));
	box-shadow: inset rgba(255, 255, 255, .5) 0 0.1em 0.1em;
	cursor: pointer;
}

	.wrapper-simple input[type=submit]:active {
		box-shadow: inset rgba(0,0,0,.4) 0 1px 1px;
	}

	.wrapper-simple input[type=submit]:hover {
		background: -webkit-gradient(linear, left top, left bottom, from(#ffcb48), to(#ff9c23));
	}

.wrapper-simple input[type=text] {
	font-family: Arial;
	font-weight: bold;
	color: #1a3d51;
	background: #d8e6ef;
	border-radius:2px;
	padding: 10px 10px 15px 10px;
	width: 250px;
	border: 0;
	font-size: 16px;
	text-shadow: rgba(255, 255, 255, 0.7) 1px 1px 1px;
	box-shadow: inset rgba(0,0,0,.4) 0 1px 1px;
	position: absolute;
	width: 1px;
	z-index: 2;
	padding-left: 2em;
	margin-left: .2em;
}

.wrapper-simple img {
	position: absolute;
	top: 1.5em;
	left: 1.5em;
	z-index: 4;
}
</pre>
<p>Now we will read the click event on search button and animate the form using jQuery.</p>
<pre name="code" class="javascript">
$('.wrapper-simple input[type=submit]').toggle(function(){

	$('.wrapper-simple').animate({'width':'300px'})
	  .end().find('.wrapper-simple input[type=text]').animate({'width': '250px'})
	  .end().find('.wrapper-simple img').animate({'marginLeft': '-5px'})
	  .end().find(this).animate({'marginLeft':'22em'}).attr('value', 'CANCEL');

}, function() {

	$('.wrapper-simple').animate({'width':'60px'})
	  .end().find('.wrapper-simple input[type=text]').animate({'width': '1px'})
	  .end().find('.wrapper-simple img').animate({'marginLeft': '0'})
	  .end().find(this).animate({'marginLeft':'0'}).attr('value', '');

});
</pre>
<p>
		The script toggling user&#8217;s click. First click will widen the div wrapper and input text, move the search button to the edge of input text and move image search to fill the left blank space before input text. Second click will revert to normal.</p>
<h3>Cube Style</h3>
<p>
		After making simple animated search form, actually we aren&#8217;t moving too far. So we will make another experiment, how about show the search form rotating like a cube? Well, CSS3 properties like transform, perspective and animation seems very helpful. <strong>The thing that we must give more attention that the following code and demo currently work only on Safari 5+</strong>.
	</p>
<p>
		<img src="http://www.webstuffshare.com/wp-content/uploads/2012/02/cube-style2.jpg" alt="" title="cube style" class="aligncenter size-full wp-image-2354" /></p>
<p>Making a cube is a bit tricky, for vertical rotate and one direction (up to down) we can create a cube by making 2 div, first div as a front side of the cube and the second div as a top side. The top side div must be rotated so it will be like coming from the top when the cube rotating.</p>
<p>
		<img src="http://www.webstuffshare.com/wp-content/uploads/2012/02/layer2.jpg" alt="" title="layer" class="aligncenter size-full wp-image-2355" /></p>
<p>The structure of elements will be :</p>
<pre name="code" class="brush: html">
<div class="wrapper1">
<div class="content-wrapper1">
<div class="search-button1">
			<span><img src="images/search-icon.png" /></span>
		</div>
<div class="search-box1">
<input type="text" value="Type your keyword..." />
			<img src="images/close.png" />
		</div>
</div>
</div>
</pre>
<p>wrapper1 acting as wrapper for all elements inside, content-wrapper1 also as a wrapper that will be rotated, search button-1 as top side and search-box1 as front side. The styling :</p>
<pre name="code" class="brush: css">
.wrapper1 {
	display: block;
	width: 300px;
	margin: 0 auto;
	-webkit-perspective : 1200px;
}

	.search-button1 span {
		display: block;
		margin: 0 auto;
		background: #643904;
		border-radius: 30px;
		width: 30px;
		height: 30px;
		box-shadow: rgba(255,255,255,.3) 0 1px 0px;
	}

		.search-button1 span img {
			vertical-align: middle;
			padding-top: 7px;
		}

	.search-button1:hover {
		background: -webkit-gradient(linear, left top, left bottom, from(#ffcb48), to(#ff9c23));
	}

	.search-button1:active {
		margin-top: 0.2em;
		box-shadow: inset rgba(255, 254, 255, 0.2) 0 0.3em .3em,
						#8e620e 0 0.3em 0,
						rgba(0, 0, 0, 0.2) 0 0.5em 3px;
	}

.search-box1 {
	margin-top: -.6em;
	display: none;
	position: absolute;
	width: 300px;
	height: 50px;
	padding: 10px 6px;
	background: -webkit-gradient(linear, left top, left bottom, from(#f5fafe), to(#e2edf4));
	border: 1px solid #9bb6c9;
	border-bottom: 1px solid rgba(255,255,255,0.2);
	border-radius: 5px;
	box-shadow: inset rgba(255, 254, 255, 0.2) 0 0.3em .3em,
					#899faf 0 .5em 0px,
					rgba(0, 0, 0, 0.2) 0 .9em 3px;

	-webkit-transform:	rotate3d(1,0,0,90deg)
								translateZ(20px);
}

	.search-box1 input {
		font-family: Arial;
		font-weight: bold;
		color: #1a3d51;
		background: #d8e6ef;
		border-radius:2px;
		padding: 10px 10px 15px 10px;
		width: 250px;
		border: 0;
		font-size: 16px;
		text-shadow: rgba(255, 255, 255, 0.7) 1px 1px 1px;
		box-shadow: inset rgba(0,0,0,.4) 0 1px 1px;
	}

		.search-box1 input:focus {
			outline: none;
		}

	.search-box1 img {
		opacity: .5;
		position: absolute;
		margin: .6em 0 0 -2em;
		cursor: pointer;
		-webkit-transition: 0.5s linear;
	}

		.search-box1 img:hover {
			opacity: 1;
		}

.hide-search-button {
	display: none;
}

.show-search-button {
	display: block;
}

.show-search-box {
	display: block;
}

.showed-search-box {
	display: block;
	-webkit-transform: rotate3d(1,0,0,0deg);
}

.hidden-search-box {
	-webkit-transform:	rotate3d(1,0,0,90deg)
								translateZ(25px);
}

.switch-show {
	height: 50px;
	-webkit-transform-style: preserve-3d;
	-webkit-animation: showBox 0.5s ease-in-out;
}

.switch-hide {
	height: 50px;
	-webkit-transform-style: preserve-3d;
	-webkit-animation: hideBox 0.5s ease-in-out;
}

.switch-show {
	height: 50px;
	-webkit-transform-style: preserve-3d;
	-webkit-animation: showBox 0.5s ease-in-out;
}

.switch-hide {
	height: 50px;
	-webkit-transform-style: preserve-3d;
	-webkit-animation: hideBox 0.5s ease-in-out;
}

@-webkit-keyframes showBox{
	0% { -webkit-transform: rotate3d(1,0,0,0); }
	100% { -webkit-transform: rotate3d(1,0,0,-90deg); }
}

@-webkit-keyframes hideBox{
	0% { -webkit-transform: rotate3d(1,0,0,-90deg); }
	100% { -webkit-transform: rotate3d(1,0,0,0); }
}
</pre>
<p>We&#8217;re a half set up, now we will read the click event from the user and rotate the cube.</p>
<pre name="code" class="brush: javascript">
$('.search-button1').click(function() {

	$('.content-wrapper1').addClass('switch-show');
	$('.search-box1').addClass('show-search-box');

	setTimeout(function(){

		$('.content-wrapper1').removeClass('switch-show');
		$('.search-button1').removeClass('show-search-button').addClass('hide-search-button');
		$('.search-box1').addClass('showed-search-box');

	},480);
});

$('.search-box1 img').click(function() {

	$('.search-button1').removeClass('hide-search-button');
	$('.search-box1').addClass('hidden-search-box');
	$('.content-wrapper1').addClass('switch-hide');

	setTimeout(function(){

		$('.content-wrapper1').removeClass('switch-hide');
		$('.search-button1').removeClass('show-search-button');
		$('.search-box1').removeClass('show-search-box showed-search-box hidden-search-box');

	},480);

});
</pre>
<p>
		The script above act as an animation delegator, all animation handled by CSS. Since the CSS animation we describe before only works once and revert to the normal state, we force the current showed side to visible and other side to hidden until the animation works before revert back, this is do the trick. </p>
<h3>Cube Style With Animate</h3>
<p>At some point we might animate the front side before rotate the cube. Then we reduce the front side&#8217;s width and widen it before rotate.</p>
<p>
		<img src="http://www.webstuffshare.com/wp-content/uploads/2012/02/cube-style-animate2.jpg" alt="" title="cube style animate" class="aligncenter size-full wp-image-2353" /></p>
<pre name="code" class="brush: javascript">
$('.search-button2').click(function() {

	$('.arrow').hide();

	$(this).stop().animate({'width':'300px'}, 500, function() {

		$('.content-wrapper2').addClass('switch-show');
		$('.search-box2').addClass('show-search-box');

		setTimeout(function(){

			$('.content-wrapper2').removeClass('switch-show');
			$('.search-button2').removeClass('show-search-button').addClass('hide-search-button');
			$('.search-box2').addClass('showed-search-box');

		},480);

	});
});

$('.search-box2 img').click(function() {

	$('.search-button2').removeClass('hide-search-button');
	$('.search-box2').addClass('hidden-search-box');
	$('.content-wrapper2').addClass('switch-hide');

	$('.search-button2').addClass('show-search-button').stop().delay(500).animate({'width':'50px'}, 500, function() {

		$('.content-wrapper2').removeClass('switch-hide');
		$('.search-button2').removeClass('show-search-button');
		$('.search-box2').removeClass('show-search-box showed-search-box hidden-search-box');

		$('.arrow').show();

	});
});
</pre>
<p>
		We use jQuery&#8217;s <strong>animate()</strong> function to widen the front side&#8217;s width and reduce it back when user close the form. </p>
<h3>Conclusion</h3>
<p>CSS3 and jQuery combination help us improve current web user interface into unlimited state, depend on our imagination. Did I missed something? I&#8217;d love to hear.</p>
</div>
<img src="http://feeds.feedburner.com/~r/goksel/~4/ruzGvHwPTKc" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geryit.com/blog/creating-next-level-search-form-using-jquery-css3-webstuffshare/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<media:content url="http://feedproxy.google.com/~r/goksel/~5/LQIDzzAUlcA/NextLevelSearch.zip" fileSize="100060" type="application/zip" /><itunes:explicit>no</itunes:explicit><itunes:subtitle>Lately we found ton of new style search form crafted beautifully using CSS3 and JavaScript. Apple&amp;#8217;s for example, widen the input field when it receive focus from user. The question is &amp;#8220;how far we can go for styling search form?&amp;#8221;, in this</itunes:subtitle><itunes:summary>Lately we found ton of new style search form crafted beautifully using CSS3 and JavaScript. Apple&amp;#8217;s for example, widen the input field when it receive focus from user. The question is &amp;#8220;how far we can go for styling search form?&amp;#8221;, in this tutorial we are going to move search form to the next level using [...]</itunes:summary><itunes:keywords>Css3, Html5, Out-source, Tutorials</itunes:keywords><feedburner:origLink>http://geryit.com/blog/creating-next-level-search-form-using-jquery-css3-webstuffshare/</feedburner:origLink><enclosure url="http://feedproxy.google.com/~r/goksel/~5/LQIDzzAUlcA/NextLevelSearch.zip" length="100060" type="application/zip" /><feedburner:origEnclosureLink>http://www.webstuffshare.com/download/NextLevelSearch.zip</feedburner:origEnclosureLink></item>
		<item>
		<title>Build Awesome Apps with CSS3 Animations [sitepoint.com]</title>
		<link>http://feedproxy.google.com/~r/goksel/~3/Ayk7R38ernk/</link>
		<comments>http://geryit.com/blog/build-awesome-apps-with-css3-animations/#comments</comments>
		<pubDate>Mon, 13 Feb 2012 11:14:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Cool Stuff]]></category>
		<category><![CDATA[Css3]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Fun Stuff]]></category>
		<category><![CDATA[Html5]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Out-source]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://geryit.com/blog/?p=1329</guid>
		<description><![CDATA[Today’s HTML5 applications can provide awesome experiences thanks to the new CSS3 specifications. One of them is CSS3 Animations. It can help you building rich animations on HTML elements. This can provide interesting feedbacks to the users and enables fast &#38; fluid UIs. As those new animations are most of the time hardware accelerated by [...]]]></description>
				<content:encoded><![CDATA[<div class="format_text entry-content">
<p>
		Today’s HTML5 applications can provide awesome experiences thanks to the new CSS3 specifications. One of them is <strong>CSS3 Animations</strong>. It can help you building rich animations on HTML elements. This can provide interesting feedbacks to the users and enables fast &amp; fluid UIs. As those new animations are most of the time hardware accelerated by the GPU, they definitely raise the quality bar of the new generation of HTML5 applications.
	</p>
<p>
		According to the “CSS Animation Module Level 3” specification on the <a href="http://www.w3.org/TR/css3-animations/" onclick="javascript:_gaq.push(['_trackEvent','outbound-article','http://www.w3.org']);">W3C site</a>, CSS3 Animations <em>introduces defined animations, which specify the values that CSS properties will take over a given time interval. This specification is an extension to CSS Transitions</em>.
	</p>
<p>
		As CSS3 Animation is an <strong>extension to CSS3 Transitions</strong>, you should first read the article of my colleague David Catuhe on Transitions here: <a href="http://blogs.msdn.com/b/eternalcoding/archive/2011/11/01/css3-transitions.aspx" onclick="javascript:_gaq.push(['_trackEvent','outbound-article','http://blogs.msdn.com']);">Introduction to CSS3 Transitions</a>.
	</p>
<p>We’ll see in this article an interesting demo highlighting the potential of CSS3 animations, how to build simple animations &amp; how to handle fallback in JavaScript:</p>
<ol start="1">
<li><a href="http://blogs.msdn.com/b/davrous/archive/2011/12/06/introduction-to-css3-animations.aspx#intro" onclick="javascript:_gaq.push(['_trackEvent','outbound-article','http://blogs.msdn.com']);">CSS3 Animationsa></li>
<li><a href="http://blogs.msdn.com/b/davrous/archive/2011/12/06/introduction-to-css3-animations.aspx#support" onclick="javascript:_gaq.push(['_trackEvent','outbound-article','http://blogs.msdn.com']);">Browsers Support</a></li>
<li><a href="http://blogs.msdn.com/b/davrous/archive/2011/12/06/introduction-to-css3-animations.aspx#fallback" onclick="javascript:_gaq.push(['_trackEvent','outbound-article','http://blogs.msdn.com']);">CSS3 Animations JavaScript fallback library</a></li>
<li><a href="http://blogs.msdn.com/b/davrous/archive/2011/12/06/introduction-to-css3-animations.aspx#conclusion" onclick="javascript:_gaq.push(['_trackEvent','outbound-article','http://blogs.msdn.com']);">Conclusion</a></li>
</ol>
<p>Let’s first start by quickly demonstrating what CSS3 Animations are. Here is a sample animation of a Star Wars AT-AT which uses CSS3 Animations to animate parts of the transport (and which will fall back to JavaScript if your browser doesn’t support CSS3 Animations):</p>
<div>
		<script type='text/javascript'>
			GA_googleFillSlot("InArticle_728x90_1");
		</script>
	</div>
</p>
<p>
		<iframe style="border-width: 0px; border-style: solid; border-color: #ffffff;" src="http://david.blob.core.windows.net/html5/css3atat/index.htm" scrolling="no" width="716" height="570"></iframe>
	</p>
<p>
		You can test this sample also in a separate window here: <a title="http://david.blob.core.windows.net/html5/css3atat/index.htm" href="http://david.blob.core.windows.net/html5/css3atat/index.htm" onclick="javascript:_gaq.push(['_trackEvent','outbound-article','http://david.blob.core.windows.net']);">http://david.blob.core.windows.net/html5/css3atat/index.htm</a>
	</p>
<p>
		<strong><span style="text-decoration: underline;">Note:</span></strong> this sample has been tested successfully with native animations under IE10 PP3/PP4, Chrome 15, Firefox 8 &amp; iPad 2 and with JS fallback under IE9 desktop &amp; mobile (Windows Phone). For an unknown reason, it behaves in weird way under Opera 11.50 but works fine with the 11.60. Moreover, our lovely blogging platform is most of the time forcing the IE9 rendering engine via a meta tag. To force it back to the IE10 standards mode, press the F12 key and change the value of “Document Mode” back to IE10. Otherwise, view the demo in a separate window.
	</p>
<p>
		This sample is based on the awesome work done by <a href="http://twitter.com/acalzadilla" onclick="javascript:_gaq.push(['_trackEvent','outbound-article','http://twitter.com']);">Anthony Calzadilla</a>. You can check other incredible demos on his website here: <a href="http://www.anthonycalzadilla.com/" onclick="javascript:_gaq.push(['_trackEvent','outbound-article','http://www.anthonycalzadilla.com']);">http://www.anthonycalzadilla.com</a> . I’m a huge fan of the <a href="http://www.anthonycalzadilla.com/i-twitty-the-fool/" onclick="javascript:_gaq.push(['_trackEvent','outbound-article','http://www.anthonycalzadilla.com']);">I twitty the fool</a> sample using SVG &amp; CSS3 Animation for instance.
	</p>
<h3>CSS3 Animations</h3>
<h4>Introduction</h4>
<p>Let’s first review on what you can play to build the animations. CSS3 Animations works basically on the same values as CSS3 Transition.</p>
<p>Here they are:</p>
<ul>
<li><strong>color</strong>: interpolated via red, green, blue and alpha components (treating each as a number, see below)</li>
<li><strong>length</strong>: interpolated as real numbers.</li>
<li><strong>percentage</strong>: interpolated as real numbers.</li>
<li><strong>integer</strong>: interpolated via discrete steps (whole numbers). The interpolation happens in real number space and is converted to an integer using floor().</li>
<li><strong>number</strong>: interpolated as real (floating point) numbers.</li>
<li><strong>transform list</strong>: see CSS Transforms specification: <a href="http://www.w3.org/TR/css3-2d-transforms/" onclick="javascript:_gaq.push(['_trackEvent','outbound-article','http://www.w3.org']);">http://www.w3.org/TR/css3-2d-transforms/</a></li>
<li><strong>rectangle</strong>: interpolated via the x, y, width and height components (treating each as a number).</li>
<li><strong>visibility</strong>: interpolated via a discrete step. The interpolation happens in real number space between 0 and 1, where 1 is &#8220;visible&#8221; and all other values are &#8220;hidden&#8221;.</li>
<li><strong>shadow</strong>: interpolated via the color, x, y and blur components (treating them as color and numbers where appropriate). In the case where there are lists of shadows, the shorter list is padded at the end with shadows whose color is transparent and all lengths (x, y, blur) are 0.</li>
<li><strong>gradient</strong>: interpolated via the positions and colors of each stop. They must have the same type (radial or linear) and same number of stops in order to be animated.</li>
<li><strong>paint server</strong> (SVG): interpolation is only supported between: gradient to gradient and color to color. They then work as above.</li>
<li><strong>space-separated list of above</strong>: If the lists have the same number of items, each item in the list is interpolated using the rules above. Otherwise, no interpolation.</li>
<li><strong>a shorthand property</strong>: If all the parts of a shorthand can be animated, then interpolation is performed as if each property was individually specified.</li>
</ul>
<p>And the following properties must be supported for animations:</p>
<ul>
<li>background-color (<em>color</em>)
		</li>
<li>background-image (<em>only gradients</em>)
		</li>
<li>background-position (<em>percentage and length</em>)
		</li>
<li>border-bottom-color (<em>color</em>)
		</li>
<li>border-bottom-width (<em>length</em>)
		</li>
<li>border-color (<em>color</em>)
		</li>
<li>border-left-color (<em>color</em>)
		</li>
<li>border-left-width (<em>length</em>)
		</li>
<li>border-right-color (<em>color</em>)
		</li>
<li>border-right-width (<em>length</em>)
		</li>
<li>border-spacing (<em>length</em>)
		</li>
<li>border-top-color (<em>color</em>)
		</li>
<li>border-top-width (<em>length</em>)
		</li>
<li>border-width (<em>length</em>)
		</li>
<li>bottom (<em>length and percentage</em>)
		</li>
<li>color (<em>color</em>)
		</li>
<li>crop (<em>rectangle</em>)
		</li>
<li>font-size (<em>length and percentage</em>)
		</li>
<li>font-weight (<em>number</em>)
		</li>
<li>grid-* (<em>various</em>)
		</li>
<li>height (<em>length and percentage</em>)
		</li>
<li>left (<em>length and percentage</em>)
		</li>
<li>letter-spacing (<em>length</em>)
		</li>
<li>line-height (<em>number, length and percentage</em>)
		</li>
<li>margin-bottom (<em>length</em>)
		</li>
<li>margin-left (<em>length</em>)
		</li>
<li>margin-right (<em>length</em>)
		</li>
<li>margin-top (<em>length</em>)
		</li>
<li>max-height (<em>length and percentage</em>)
		</li>
<li>max-width (<em>length and percentage</em>)
		</li>
<li>min-height (<em>length and percentage</em>)
		</li>
<li>min-width (<em>length and percentage</em>)
		</li>
<li>opacity (<em>number</em>)
		</li>
<li>outline-color (<em>color</em>)
		</li>
<li>outline-offset (<em>integer</em>)
		</li>
<li>outline-width (<em>length</em>)
		</li>
<li>padding-bottom (<em>length</em>)
		</li>
<li>padding-left (<em>length</em>)
		</li>
<li>padding-right (<em>length</em>)
		</li>
<li>padding-top (<em>length</em>)
		</li>
<li>right (<em>length and percentage</em>)
		</li>
<li>text-indent (<em>length and percentage</em>)
		</li>
<li>text-shadow (<em>shadow</em>)
		</li>
<li>top (<em>length and percentage</em>)
		</li>
<li>vertical-align (<em>keywords, length and percentage</em>)
		</li>
<li>visibility (<em>visibility</em>)
		</li>
<li>width (<em>length and percentage</em>)
		</li>
<li>word-spacing (<em>length and percentage</em>)
		</li>
<li>z-index (<em>integer</em>)
		</li>
<li>zoom (<em>number</em>)
		</li>
</ul>
<h4>SVG</h4>
<p>
		The properties of SVG objects are animatable when they are defined as <strong>animatable:true</strong> in the SVG specification: <a href="http://www.w3.org/TR/SVG/struct.html" onclick="javascript:_gaq.push(['_trackEvent','outbound-article','http://www.w3.org']);">http://www.w3.org/TR/SVG/struct.html</a>. But at the time where this article is written, I didn’t manage to combine CSS3 Animation directly on SVG elements in any of the latest browsers versions. Today’s samples on the web are then doing a little trick: they are embedding SVG resources into different DIV animated by CSS3 like the <a href="http://www.anthonycalzadilla.com/i-twitty-the-fool/" onclick="javascript:_gaq.push(['_trackEvent','outbound-article','http://www.anthonycalzadilla.com']);">I twitty the fool</a> sample.
	</p>
<h4>Declarations</h4>
<p>To declare an animation in a CSS file, here is the kind of generic code you’ll need to write:</p>
<pre class="brush:css">@keyframes name_of_the_animation {
  from {
    property_to_animate: initial_value;
  }
  50% {
    property_to_animate: intermediate_value;
  }
  to {
    property_to_animate: final_value;
  }
}</pre>
<p>Which could also be written like that:</p>
<pre class="brush:css">@keyframes name_of_the_animation {
  0% {
    property_to_animate: initial_value;
  }
  50% {
    property_to_animate: intermediate_value;
  }
  100% {
    property_to_animate: final_value;
  }
}</pre>
<p>
		This animation definition declares 3 steps 0, 50 &amp; 100%. You should at least set a <strong><em>from</em></strong> (or 0%) and a <strong><em>to</em></strong> (or 100%) steps to build a correct animation (minimum 2 steps thus). Once done, you may add as many keyframes as you’d like between 0 and 100% to handle precisely the various steps of your animations.
	</p>
<p>Once the definition is declared, you can affect it to an element using the classical CSS3 selectors and you’ll need also to configure the animation options. Here the kind of generic blocks you’ll see:</p>
<pre class="brush:css">#id_of_the_html_element {
    animation-name: name_of_the_animation;
    animation-duration: number_of_seconds s;
    animation-iteration-count: number | infinite;
}</pre>
<p>To better understand, let’s review a real sample. First of all, as the CSS3 Animations specification is still in a draft stage, you’ll need to use the appropriate vendor prefix. Let’s use IE10 as a sample with the –ms prefix then. Let’s now see how the head of our AT-AT is moving.</p>
<p>Here’s the animation declaration:</p>
<pre class="brush:css">@-ms-keyframes rotate-skull {
    0% {
        -ms-transform: rotate(0deg)
    }
    25% {
        -ms-transform: rotate(15deg)
    }
    50% {
        -ms-transform: rotate(-5deg)
    }
    55% {
        -ms-transform: rotate(0deg)
    }
    75% {
        -ms-transform: rotate(-10deg)
    }
    100% {
        -ms-transform: rotate(0deg)
    }
}</pre>
<p>We’ve got 6 steps (0, 25, 50, 55, 75 &amp; 100%) working on the CSS3 2D transform attributes by changing the value of the rotation.</p>
<p>The animation is then applied via this CSS rule:</p>
<pre class="brush:css">#skull
{
    -ms-animation-name: rotate-skull;
    -ms-animation-duration: 7s;
    -ms-animation-iteration-count: infinite;
}</pre>
<p>
		We’re targeting the<br />
		<code>&lt;div&gt;</code><br />
		element having the “<br />
		<code><br />
			id=<strong>skull</strong><br />
		</code><br />
		” and we’re applying the animation named “<strong><code>rotate-skull</code></strong>” on it. The animation will have to be completed in <strong>7s</strong> and be played an <strong>infinite</strong> number of times.
	</p>
<p>Here is the living result if your browser supports CSS3 Animations:</p>
<p>
		<iframe style="border-bottom: #ffffff 0px solid; border-left: #ffffff 0px solid; border-top: #ffffff 0px solid; border-right: #ffffff 0px solid" height="200" src="http://david.blob.core.windows.net/html5/css3atat/AnimSkullATAT.htm" width="400" scrolling="no"></iframe>
	</p>
<p>We could have written this rule in a shorter manner using the animation shorthand property:</p>
<pre class="brush:css">#skull {
    -ms-animation: rotate-skull 7s infinite;
}</pre>
<p>
		The animations will be triggered as soon as a matching rule is applied. You can then play or stop animations simply via <strong>JavaScript</strong> or via CSS3 to play with the <strong>classes affected to a tag</strong>.
	</p>
<h4>Non-linear animations</h4>
<p>The “animation-timing-function” property can be used if you want non-linear animations. You can even mix the type of timing functions during each keyframe.</p>
<p>
		Basically, CSS3 animations will use <a href="http://en.wikipedia.org/wiki/B%C3%A9zier_curve#Cubic_B.C3.A9zier_curves" onclick="javascript:_gaq.push(['_trackEvent','outbound-article','http://en.wikipedia.org']);">cubic bezier curve</a> to smooth the animation by computing different speed over its duration.
	</p>
<p>The following functions are supported:</p>
<ul>
<li><em>linear</em>: Constant speed</li>
<li><em>cubic-bezier</em>: Speed will be computed according to a cubic bezier curve define by two control points : P0 and P1 (so you will have to define 4 values here : P0x, P0y and P1x, P1y.</li>
<li><em>ease</em>: Speed will be computed with cubic-bezier(0.25, 0.1, 0.25, 1)</li>
<li><em>ease-in</em>: Speed will be computed with cubic-bezier(0.42, 0, 1, 1)</li>
<li><em>ease-inout</em>: Speed will be computed with cubic-bezier(0.42, 0, 0.58, 1)</li>
<li><em>ease-out</em>: Speed will be computed with cubic-bezier(0, 0, 0.58, 1)</li>
</ul>
<p>
		Here is a simulation tool written by <a href="http://blogs.msdn.com/b/eternalcoding/archive/2011/11/01/css3-transitions.aspx" onclick="javascript:_gaq.push(['_trackEvent','outbound-article','http://blogs.msdn.com']);">David Catuhe</a> that uses pure JavaScript to show the impact of each timing function:
	</p>
<p>
		<iframe style="border-bottom: #ffffff 0px solid; border-left: #ffffff 0px solid; border-top: #ffffff 0px solid; border-right: #ffffff 0px solid" height="650" src="http://www.catuhe.com/msdn/transitions/easingfunctions.htm" width="1000"></iframe>
	</p>
<p>
		<strong><span style="text-decoration: underline;">Note:</span></strong> this tool uses in-line SVG supported by Firefox, Chrome, Opera 11.60 &amp; IE9/10. It won’t work properly under Opera 11.50 &amp; Safari on iPad thus.
	</p>
<p>This is an awesome tool using SVG. You can even play with your mouse on the custom function to edit the curve. If you’d like to know more about this tool, please again have a look to David’s article.</p>
<p>
		If your browser supports CSS3 animations, let’s now see a simple demo using <strong>easing functions to animate a canvas tag</strong> containing an animated sprite with CSS3.
	</p>
<p>Here is the CSS3 animations code that will be used in this demo:</p>
<pre class="brush:css">@-ms-keyframes demo {
    from {
    -ms-animation-timing-function: ease;
    -ms-transform: translateX(0px);
    }
    50% {
    -ms-animation-timing-function: ease-in;
    -ms-transform: translateX(300px);
    }
    to {
    -ms-animation-timing-function: ease-inout;
    -ms-transform: translateX(900px);
    }
}
&nbsp;
#testCanvas
{
    -ms-animation-delay: 0s;
    -ms-animation-duration: 6s;
    -ms-animation-iteration-count: infinite;
    -ms-animation-name: demo;
}</pre>
<p>As well as all the vendor prefixes variations to make sure it works also in Google Chrome &amp; Mozilla Firefox. And here’s the living output:</p>
<p>
		<iframe style="border-bottom: #ffffff 0px solid; border-left: #ffffff 0px solid; border-top: #ffffff 0px solid; border-right: #ffffff 0px solid" height="90" src="http://david.blob.core.windows.net/html5/css3animcanvas/sprites.htm" width="1000"></iframe>
	</p>
<p>If your browser doesn’t support CSS3 Animation but support canvas, the sprite’s running animation should be displayed but the character won’t move through the width of the screen.</p>
<p>
		<strong><span style="text-decoration: underline;">Note:</span></strong> if you’d like to know more about canvas and sprites animation, you can have a look to this article: <a href="http://blogs.msdn.com/b/davrous/archive/2011/07/21/html5-gaming-animating-sprites-in-canvas-with-easeljs.aspx" onclick="javascript:_gaq.push(['_trackEvent','outbound-article','http://blogs.msdn.com']);">HTML5 Gaming: animating sprites in Canvas with EaselJS</a>
	</p>
<h4>Delay</h4>
<p>The “animation-delay” property simply allows an animation to begin execution some time after it is applied.</p>
<h4>Events</h4>
<p>
		3 <strong>events</strong> could be raised during an animation. They are named “Animation<em>Start</em>”, “Animation<em>End</em>” and “Animation<em>Iteration</em>”. Depending on your browser, the correct name will be for instance:
	</p>
<ul>
<li>Chrome:<em> webkitAnimationEnd</em></li>
<li>Firefox: <em>mozAnimationEnd</em></li>
<li>Internet Explorer:<em> MSAnimationEnd</em></li>
</ul>
<p>The event will give you the following details:</p>
<ul>
<li><em>animationName</em>: name of the animation which raised the event</li>
<li><em>elapsedTime</em>: the amount of time the animation has been running, in seconds</li>
</ul>
<p>Here is an usage sample for IE10:</p>
<pre class="brush:css">elementToAnimate.addEventListener("MSAnimationEnd", function () {
    alert("the end !");
}, false);</pre>
<h3>More about CSS3 animations</h3>
<p>CSS3 animations are really useful for 2 main reasons:</p>
<ul>
<li><strong>Hardware acceleration:</strong> CSS3 Animations are most of the time directly handled by the GPU and could produce smoother results. This could then be a very interesting approach for mobile devices.</li>
<li><strong>Better separation between code and design</strong>: I know there is some debates on this point but with David, we think that a developer shouldn’t be aware of animations or anything related to design as much as possible. In the same way the designer/artist must not be aware of JavaScript. CSS3 offers then this possibility and could let the designers work with their classical tools to generate the appropriate animations on elements, between screens, etc.</li>
</ul>
<p>
		To highlight this importance in performance, the following HTML5 game I wrote using a full frame &lt;canvas&gt;: <a title="http://blogs.msdn.com/b/davrous/archive/2011/09/09/html5-platformer-the-complete-port-of-the-xna-game-to-lt-canvas-gt-with-easeljs.aspx" href="http://blogs.msdn.com/b/davrous/archive/2011/09/09/html5-platformer-the-complete-port-of-the-xna-game-to-lt-canvas-gt-with-easeljs.aspx" onclick="javascript:_gaq.push(['_trackEvent','outbound-article','http://blogs.msdn.com']);">HTML5 Platformer</a> run at 60 fps in IE9/IE10 on my PC but at 10 fps max on a iPad 2. This is because its CPU is much more limited and the iPad is currently not hardware-accelerating &lt;canvas&gt;. Using CSS3 Transitions/Animations to animate several smaller &lt;canvas&gt; elements could provide a huge performance boost for this game. Think about it when you’re targeting mobile devices!
	</p>
<h3>Browsers Support</h3>
<p>
		Since the Platform Preview 3 of IE10 available in the <a href="http://msdn.microsoft.com/en-us/windows/apps/br229516" onclick="javascript:_gaq.push(['_trackEvent','outbound-article','http://msdn.microsoft.com']);">Windows Developer Preview</a>, we’re supporting CSS3 Animations. And as you can see on the following report produced by <a href="http://caniuse.com/#search=CSS3%20animation" onclick="javascript:_gaq.push(['_trackEvent','outbound-article','http://caniuse.com']);">caniuse.com</a>, the CSS3 animations are now supported on a wide range of browsers:
	</p>
<p>
		<img class="alignnone size-full wp-image-51037" title="fig2" src="http://cdn.sitepoint.com/wp-content/uploads/2012/02/fig2.png" alt="browser support" width="761" height="275" />
	</p>
<p>
		But as the specification is not finished yet (<em>working draft</em>), you must use vendor’s prefixes such as –ms-, –moz-, –webkit-, –o- to make a cross-browsers compatible application.
	</p>
<p>But the question could be: how to handle browsers that don’t support this new feature?</p>
<p>
		First option is to just do nothing. Thanks to the beauty of graceful degradation, you could just let the user only see a static image if you’ve worked correctly. This is for instance the case of these 2 original samples of Anthony: <a href="http://www.anthonycalzadilla.com/i-twitty-the-fool/" onclick="javascript:_gaq.push(['_trackEvent','outbound-article','http://www.anthonycalzadilla.com']);">I Twitty the Fool!</a> and <a href="http://www.anthonycalzadilla.com/css3-ATAT/" onclick="javascript:_gaq.push(['_trackEvent','outbound-article','http://www.anthonycalzadilla.com']);">Pure CSS3 AT-AT Walker</a> . When watched in IE9, it looks like we only have a static image. When watched in IE10, the very same code shows nice animations. IE10 users will then have an enhanced version while IE9 will still be able to view and use properly the website. The more modern your browser is, the more visual bonus you will have.
	</p>
<p>The second option is to detect the feature via a JS library like Modernizr and try to offer the same animation via a JavaScript library that will mimic the animations. This is what we usually call a fallback mechanism. Unfortunately, I haven’t found today a working &amp; complete JS library that could replace CSS3 animations when not supported by the browser.</p>
<p>I have then written a sample JS library more or less specifically designed for the AT-AT sample.</p>
<h3>CSS3 Animations JavaScript fallback library</h3>
<p>Animations are nothing more than a series of transitions separated by a certain duration defined via the keyframes. I’ve then reused the concepts built by David Catuhe in his transitions helper library. I let you reviewing his article to check the base of the concepts behind the code.</p>
<p>On my side, I’ve added some support to animate the CSS3 2D Transform rotation &amp; translation values and a way to iterate through the keyframes.</p>
<p>Here is the main part of the library you need to review:</p>
<pre class="brush:css">// Animation object
// It need the HTML targeted element, the name of the animation, its duration &amp; iteration count and
// the keyframes contained in an array object
// View the animation simply as a sequence of transitions played a certain number of times
ANIMATIONSHELPER.animation = function (target, name, duration, iterationcount, keyframes) {
    // saving the properties values
    this.name = name;
    this.duration = duration;
    this.iterationcount = iterationcount;
    this.target = target;
&nbsp;
    var elapsedtime = 0;
    var keyframeduration = 0;
    var elapsedtime = 0;
&nbsp;
    // Transforming the percentage of each keyframe into duration value
    for (var i = 0; i &lt; keyframes.length; i++) {
        keyframeduration = ((keyframes[i].percentage * duration) / 100) - elapsedtime;
        keyframes[i].duration = keyframeduration;
        elapsedtime += keyframeduration;
    }
&nbsp;
    this.currentTransition = { isPlaying: false };
    this.keyframes = keyframes;
    this.keyframesCount = keyframes.length;
    this.currentKeyFrameIndex = 0;
&nbsp;
    // The nextTransition() function return the next transition to run
    // based on the current keyframe to play
    this.nextTransition = function (keyframe, ease, customEaseP1X, customEaseP1Y, customEaseP2X, customEaseP2Y) {
        var properties = [];
        var finalValues = [];
        var transition;
&nbsp;
        // Compared to the original TRANSITIONSHELPER of David Catuhe
        // We need a specific code to play with the CSS3 2D Transform properties values
        if (keyframe.propertyToAnimate === "transform") {
            for (var i = 0; i &lt; keyframe.transformType.length; i++) {
                properties.push(keyframe.transformType[i].type);
                if (keyframe.transformType[i].type == "rotate") {
                    finalValues.push({ deg: keyframe.transformType[i].value1 });
                }
                else {
                    finalValues.push({ x: keyframe.transformType[i].value1, y: keyframe.transformType[i].value2 });
                }
            }
&nbsp;
            // Create a new transition
            transition = {
                name: this.name + this.currentKeyFrameIndex,
                target: this.target,
                properties: properties,
                finalValues: finalValues,
                originalValues: ANIMATIONSHELPER.extractValues(target.style[ANIMATIONSHELPER.currentTransformProperty], this.name),
                duration: keyframe.duration,
                startDate: (new Date).getTime(),
                currentDate: (new Date).getTime(),
                ease: ease,
                customEaseP1X: customEaseP1X,
                customEaseP2X: customEaseP2X,
                customEaseP1Y: customEaseP1Y,
                customEaseP2Y: customEaseP2Y,
                isPlaying: true,
                type: "transform"
            };
&nbsp;
            return transition;
        }
        // If it's a classic property to animate, we're using more or less the TRANSITIONSHELPER as-is
        else {
            return TRANSITIONSHELPER.transition(this.target, keyframe.propertyToAnimate, keyframe.value, keyframe.duration, TRANSITIONSHELPER.easingFunctions.linear);
        }
    };
&nbsp;
    // each animation object has a tick function
    // that will be called every 17 ms (to target 60 fps)
    // This ticker is monitoring the current state of the transition and
    // create a new transition as soon as the old one is finished/dead
    this.tick = function () {
        if (this.iterationcount &gt; 0) {
            if (!this.currentTransition.isPlaying) {
                this.currentTransition = this.nextTransition(this.keyframes[this.currentKeyFrameIndex], ANIMATIONSHELPER.easingFunctions.linear);
                // We're using our own global ticker only for the 2D transformations
                // Otherwise, we're using the one from the TRANSITIONSHELPER library
                if (this.currentTransition.type === "transform") {
                    ANIMATIONSHELPER.currentTransitions.push(this.currentTransition);
                }
                this.currentKeyFrameIndex++;
&nbsp;
                // We've reached the last keyframe (100%). We're starting back from the beginning
                if (this.currentKeyFrameIndex &gt;= this.keyframesCount) {
                    this.currentKeyFrameIndex = 0;
                    this.iterationcount--;
                }
            }
        }
    };
};</pre>
<p>
		The first part of the code is iterating through each keyframe to compute the exact duration specified by each percentage. We’re then defining a<br />
		<code>nextTransition()</code><br />
		function that will dynamically build the next transition to play based on the current index into the keyframes collection. At last, we’ve got a<br />
		<code>tick()</code><br />
		function that will monitor the current state of the transition applied. Once the transition is finished or dead, it asks for the next transition, push it to the stack of transitions to be played and moves the indexes.
	</p>
<p>
		This<br />
		<code>tick()</code><br />
		function is called thanks to this code:
	</p>
<pre class="brush:js">ANIMATIONSHELPER.launchAnimation = function (animation) {
    // Launching the tick service if required
    if (ANIMATIONSHELPER.tickIntervalID == 0) {
        ANIMATIONSHELPER.tickIntervalID = setInterval(ANIMATIONSHELPER.tick, 17);
    }
&nbsp;
    // Little closure to launch the tick method on the appropriate animation instance
    setInterval(function () { animation.tick(); }, 17);
};</pre>
<p>At last, we have this kind of code that helps us building the keyframes:</p>
<pre class="brush:js">// Object to build a new generic keyframe (not working on the CSS3 2D Transform properties thus)
ANIMATIONSHELPER.keyframe = function (percentage, propertyToAnimate, value) {
    this.percentage = percentage;
    this.propertyToAnimate = propertyToAnimate;
    this.value = value;
};
&nbsp;
//Objects to build specific rotation keyframes
ANIMATIONSHELPER.rotationkeyframe = function (percentage, value) {
    this.percentage = percentage;
    this.propertyToAnimate = "transform";
    this.transformType = [];
    this.transformType.push(new ANIMATIONSHELPER.transformType("rotate", value));
};</pre>
<p>To highlight its usage, let’s recreate the previous simple CSS3 Animation skull sample with this library :</p>
<pre class="brush:js">// number of times you'd like the animations to be run
var iterationsNumber = 100;
&nbsp;
var skullElement = document.getElementById("skull");
var keyframes = [];
keyframes.push(new ANIMATIONSHELPER.rotationkeyframe(25, 15));
keyframes.push(new ANIMATIONSHELPER.rotationkeyframe(50, -5));
keyframes.push(new ANIMATIONSHELPER.rotationkeyframe(55, 0));
keyframes.push(new ANIMATIONSHELPER.rotationkeyframe(75, -10));
keyframes.push(new ANIMATIONSHELPER.rotationkeyframe(100, 0));
&nbsp;
var animation1 = new ANIMATIONSHELPER.animation(skullElement, "rotate-skull", 7000,
                            iterationsNumber, keyframes);
&nbsp;
ANIMATIONSHELPER.launchAnimation(animation1, ANIMATIONSHELPER.easingFunctions.linear);</pre>
<p>And here is the result that will now work in every browser supporting CSS3 2D Transform:</p>
<p>
		<iframe style="border-bottom: #ffffff 0px solid; border-left: #ffffff 0px solid; border-top: #ffffff 0px solid; border-right: #ffffff 0px solid" height="200" src="http://david.blob.core.windows.net/html5/css3atat/indexSkullJS.htm" width="400" scrolling="no"></iframe>
	</p>
<p>At last, the very first sample demonstrated at the beginning of this article uses Modernizr to check the support for CSS3 Animations. If it’s not the case, it loads the code that will mimic the keyframes defined in the file master.css, moz-master.css &amp; ms-master.css :</p>
<pre class="brush:js">// Checking if CSS3 animations is supported
if (!Modernizr.cssanimations) {
// if so, we can use our JS fallback library
    supportElement.innerHTML = "CSS3 Animations &lt;strong&gt;are not supported&lt;/strong&gt;";
    LoadJSAnimationsFallback();
}
else {
    // if CSS3 animation is supported, we have nothing to do.
    // The *master.css stylesheets will be automatically applied &amp; used.
    supportElement.innerHTML = "CSS3 Animations &lt;strong&gt;are supported&lt;/strong&gt;";
}</pre>
<p>
		The <em>LoadJSAnimationsFallback()</em> function is defined into <em>jsfallback-master.js</em> which simply contains all the keyframes declarations and the 19 animations needed to mimic the behavior created by Anthony in pure CSS3. In this approach, the designer then needs to rewrite all rules using the library. Another approach could be to parse one of the CSS file using an XHR call and to create dynamically the JavaScript calls to the library. This needs more work as you almost need to reimplement the CSS3 animations specifications in JavaScript!
	</p>
<p>You now have an idea on the way to build a fallback mechanism to support more browsers while starting to use the latest CSS3 specifications.</p>
<p>
		You can download the files for the main sample here: <a title="http://david.blob.core.windows.net/html5/css3atat/CSS3ATATNonMinified.zip" href="http://david.blob.core.windows.net/html5/css3atat/CSS3ATATNonMinified.zip" onclick="javascript:_gaq.push(['_trackEvent','download','http://david.blob.core.windows.net/html5/css3atat/CSS3ATATNonMinified.zip']);">http://david.blob.core.windows.net/html5/css3atat/CSS3ATATNonMinified.zip</a>
	</p>
<p>It contains the unminified versions of the animationsHelper.js, transitionsHelper.js, jsfallback-master.js JavaScript files as well as the various CSS3 declinaison files for the main vendors prefixes.</p>
<h3>Conclusion</h3>
<p>CSS3 Animations is a powerful technology to push HTML5 applications to a new level. It offers interesting scenarios. Designers could use it to create a new generation of UI screens with smooth &amp; fluid animations without the need of developers. As it’s hardware-accelerated most of the time, developers should also pay attention to this specification. At last, both could collaborate. Designers could work on a series of predefined animations covering most scenarios. Developers could then create JavaScript libraries that will implement those animations. This library could offer in a transparent way 2 implementations: a dynamic generation of CSS3 on the fly or a fallback for older browsers.</p>
<h3>Going further</h3>
<ul>
<li>Article about CSS3 Transitions by David Catuhe: <a href="http://blogs.msdn.com/b/eternalcoding/archive/2011/11/01/css3-transitions.aspx" onclick="javascript:_gaq.push(['_trackEvent','outbound-article','http://blogs.msdn.com']);">Introduction to CSS3 Transitions</a></li>
<li>CSS3 Animations specifications: <a title="http://www.w3.org/TR/css3-animations/" href="http://www.w3.org/TR/css3-animations/" onclick="javascript:_gaq.push(['_trackEvent','outbound-article','http://www.w3.org']);">http://www.w3.org/TR/css3-animations/</a></li>
<li>IE Test Drive on CSS3 animations: <a title="http://ie.microsoft.com/testdrive/Graphics/hands-on-css3/hands-on_animations.htm" href="http://ie.microsoft.com/testdrive/Graphics/hands-on-css3/hands-on_animations.htm" onclick="javascript:_gaq.push(['_trackEvent','outbound-article','http://ie.microsoft.com']);">http://ie.microsoft.com/testdrive/Graphics/hands-on-css3/hands-on_animations.htm</a></li>
</ul>
<p>
		<strong>Other useful posts:</strong>
	</p>
<ul>
<li>Events are relatively limited in the CSS3 Animation spec. Joe Lambert is proposing an interesting solution to trigger events on each keyframe: <a href="http://blog.joelambert.co.uk/2011/05/20/css-animation-keyframe-events-javascript-solution/" onclick="javascript:_gaq.push(['_trackEvent','outbound-article','http://blog.joelambert.co.uk']);">CSS Animation Keyframe Events (Javascript solution)</a></li>
</ul>
</div>
<img src="http://feeds.feedburner.com/~r/goksel/~4/Ayk7R38ernk" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geryit.com/blog/build-awesome-apps-with-css3-animations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<media:content url="http://feedproxy.google.com/~r/goksel/~5/b7ABXivOZgA/CSS3ATATNonMinified.zip" fileSize="251415" type="application/x-zip-compressed" /><itunes:explicit>no</itunes:explicit><itunes:subtitle>Today’s HTML5 applications can provide awesome experiences thanks to the new CSS3 specifications. One of them is CSS3 Animations. It can help you building rich animations on HTML elements. This can provide interesting feedbacks to the users and enables fa</itunes:subtitle><itunes:summary>Today’s HTML5 applications can provide awesome experiences thanks to the new CSS3 specifications. One of them is CSS3 Animations. It can help you building rich animations on HTML elements. This can provide interesting feedbacks to the users and enables fast &amp;#38; fluid UIs. As those new animations are most of the time hardware accelerated by [...]</itunes:summary><itunes:keywords>Cool Stuff, Css3, Development, Fun Stuff, Html5, Javascript, Out-source, Tips and Tricks, Tutorials</itunes:keywords><feedburner:origLink>http://geryit.com/blog/build-awesome-apps-with-css3-animations/</feedburner:origLink><enclosure url="http://feedproxy.google.com/~r/goksel/~5/b7ABXivOZgA/CSS3ATATNonMinified.zip" length="251415" type="application/x-zip-compressed" /><feedburner:origEnclosureLink>http://david.blob.core.windows.net/html5/css3atat/CSS3ATATNonMinified.zip</feedburner:origEnclosureLink></item>
		<item>
		<title>Amazing things to do with PHP and cURL</title>
		<link>http://feedproxy.google.com/~r/goksel/~3/G7fJ-d509o8/</link>
		<comments>http://geryit.com/blog/amazing-things-to-do-with-php-and-curl/#comments</comments>
		<pubDate>Tue, 07 Feb 2012 09:25:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Out-source]]></category>
		<category><![CDATA[Performance]]></category>
		<category><![CDATA[Php]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://geryit.com/blog/?p=1325</guid>
		<description><![CDATA[cURL, and its PHP extension libcURL, are very useful tools for tasks like simulating a web browser, submit forms or login to a web service. In this article, I’m going to show you some amazing things that you can do using PHP and cURL. Check if a specific website is available Want to know if [...]]]></description>
				<content:encoded><![CDATA[<p>cURL, and its PHP extension libcURL, are very useful tools for tasks like simulating a web browser, submit forms or login to a web service. In this article, I’m going to show you some amazing things that you can do using PHP and cURL.</p>
<h2>Check if a specific website is available</h2>
<p>Want to know if a specific website is available? cURL is here to help. This script can be used with a cron job to monitor your websites.</p>
<p>Don&#8217;t forget to update the script with the url you want to check on line 3. Once done, just paste it somewhere and it will let you know about the site availability.</p>
<pre>
&lt;?php

       if (isDomainAvailible(&#39;http://www.css-tricks.com&#39;))
       {
               echo &quot;Up and running!&quot;;
       }
       else
       {
               echo &quot;Woops, nothing found there.&quot;;
       }

       //returns true, if domain is availible, false if not
       function isDomainAvailible($domain)
       {
               //check, if a valid url is provided
               if(!filter_var($domain, FILTER_VALIDATE_URL))
               {
                       return false;
               }

               //initialize curl
               $curlInit = curl_init($domain);
               curl_setopt($curlInit,CURLOPT_CONNECTTIMEOUT,10);
               curl_setopt($curlInit,CURLOPT_HEADER,true);
               curl_setopt($curlInit,CURLOPT_NOBODY,true);
               curl_setopt($curlInit,CURLOPT_RETURNTRANSFER,true);

               //get answer
               $response = curl_exec($curlInit);

               curl_close($curlInit);

               if ($response) return true;

               return false;
       }
?&gt;
</pre>
<p>
	<strong>&rarr; Source: <a href="http://css-tricks.com/snippets/php/check-if-website-is-available/">http://css-tricks.com/snippets/php/check-if-website-is-available/</a></strong>
</p>
<h2>cURL replacement for file_get_contents()</h2>
<p>
	The<br />
	<code>file_get_contents()</code><br />
	function is very useful but it is unfortunely deactivated by default on some webhosts. Using cURL, we can write a replacement function that works exactly like<br />
	<code>file_get_contents()</code><br />
	.
</p>
<pre>
function file_get_contents_curl($url) {
	$ch = curl_init();

	curl_setopt($ch, CURLOPT_HEADER, 0);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Set curl to return the data instead of printing it to the browser.
	curl_setopt($ch, CURLOPT_URL, $url);

	$data = curl_exec($ch);
	curl_close($ch);

	return $data;
}
</pre>
<p>
	<strong>&rarr; Source: <a href="http://snipplr.com/view/4084">http://snipplr.com/view/4084</a></strong>
</p>
<h2>Get latest Twitter status</h2>
<p>
	Using PHP and cURL, it is pretty easy to get the status of a specific user. Once you have it, what about displaying it on your blog, like I do in <a href="http://www.wprecipes.com">WPRecipes</a> footer?
</p>
<pre class="brush: php">function get_status($twitter_id, $hyperlinks = true) {
    $c = curl_init();
    curl_setopt($c, CURLOPT_URL, "http://twitter.com/statuses/user_timeline/$twitter_id.xml?count=1");
    curl_setopt($c, CURLOPT_RETURNTRANSFER, 1);
    $src = curl_exec($c);
    curl_close($c);
    preg_match('/&lt;text&gt;(.*)&lt;\/text&gt;/', $src, $m);
    $status = htmlentities($m[1]);
    if( $hyperlinks ) $status = ereg_replace("[[:alpha:]]+://[^&lt;&gt;[:space:]]+[[:alnum:]/]", '&lt;a href="%5C%22%5C%5C0%5C%22"&gt;\\0&lt;/a&gt;', $status);
    return($status);
}</pre>
<p>The function is super easy to use:</p>
<pre>echo get_status('catswhocode');</pre>
<p>
	<strong>&rarr; Source: <a href="http://www.catswhocode.com/blog/php-snippets-to-interact-with-twitter">http://www.catswhocode.com/blog/php-snippets-to-interact-with-twitter</a></strong>
</p>
<h2>Twitter: test friendship between two users</h2>
<p>
	If you want to know if a specific user is following you (or someone else) you have to use the Twitter API. This snippet will echo<br />
	<code>true</code><br />
	if the two users specified on lines 18 and 19 are friends. It will return<br />
	<code>false</code><br />
	otherwise.
</p>
<pre>
function make_request($url) {
	$ch = curl_init();
	curl_setopt($ch,CURLOPT_URL,$url);
	curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
	$result = curl_exec($ch);
	curl_close($ch);
	return $result;
}

/* gets the match */
function get_match($regex,$content) {
	preg_match($regex,$content,$matches);
	return $matches[1];
}

/* persons to test */
$person1 = 'phpsnippets';
$person2 = 'catswhocode';

/* send request to twitter */
$url = 'https://api.twitter.com/1/friendships/exist';
$format = 'xml';

/* check */
$persons12 = make_request($url.'.'.$format.'?user_a='.$person1.'&amp;user_b='.$person2);
$result = get_match('/&lt;friends&gt;(.*)&lt;\/friends&gt;/isU',$persons12);
echo $result; // returns "true" or "false"
</pre>
<p>
	<strong>&rarr; Source: <a href="http://www.catswhocode.com/blog/php-snippets-to-interact-with-twitter">http://www.catswhocode.com/blog/php-snippets-to-interact-with-twitter</a></strong>
</p>
<h2>Download and save images from a page using cURL</h2>
<p>Here is a set of functions that can be very useful: Give this script the url of a webpage, and it will save all images from this page on your server.</p>
<pre>
function getImages($html) {
    $matches = array();
    $regex = &#39;~http://somedomain.com/images/(.*?)\.jpg~i&#39;;
    preg_match_all($regex, $html, $matches);
    foreach ($matches[1] as $img) {
        saveImg($img);
    }
}

function saveImg($name) {
    $url = &#39;http://somedomain.com/images/&#39;.$name.&#39;.jpg&#39;;
    $data = get_data($url);
    file_put_contents(&#39;photos/&#39;.$name.&#39;.jpg&#39;, $data);
}

$i = 1;
$l = 101;

while ($i &lt; $l) {
    $html = get_data(&#39;http://somedomain.com/id/&#39;.$i.&#39;/&#39;);
    getImages($html);
    $i += 1;
}
</pre>
<p>
	<strong>&rarr; Source: <a href="http://stackoverflow.com/questions/7747875/grab-download-images-from-multiple-pages-using-php-preg-match-all-curl">http://stackoverflow.com/questions/7747875/grab-download-images-from-multiple-pages-using-php-preg-match-all-curl</a></strong>
</p>
<h2>Convert currencies using cURl and Google</h2>
<p>
	Converting currencies isn&#8217;t very hard to do, but as the currencies fluctuates all the time, we definitely need to use a service like Google to get the most recent values. The<br />
	<code>currency()</code><br />
	function take 3 parameters: from, to, and sum.
</p>
<pre>
function currency($from_Currency,$to_Currency,$amount) {
    $amount = urlencode($amount);
    $from_Currency = urlencode($from_Currency);
    $to_Currency = urlencode($to_Currency);
    $url = &quot;http://www.google.com/ig/calculator?hl=en&amp;q=$amount$from_Currency=?$to_Currency&quot;;
    $ch = curl_init();
    $timeout = 0;
    curl_setopt ($ch, CURLOPT_URL, $url);
    curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch,  CURLOPT_USERAGENT , &quot;Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)&quot;);
    curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
    $rawdata = curl_exec($ch);
    curl_close($ch);
    $data = explode(&#39;&quot;&#39;, $rawdata);
    $data = explode(&#39; &#39;, $data[&#39;3&#39;]);
    $var = $data[&#39;0&#39;];
    return round($var,2);
}
</pre>
<p>
	<strong>&rarr; Source: <a href="http://l33ts.org/forum/Thread-PHP-Convert-currencies-using-Google-and-cURL-Snippet">http://l33ts.org/forum/Thread-PHP-Convert-currencies-using-Google-and-cURL-Snippet</a></strong>
</p>
<h2>Get remote filesize using cURL</h2>
<p>Want to be able to calculate the size of a specific file? The following function can help. It takes 3 parameters: the file url, and in case the file is password protected, a username and a password.</p>
<pre>
function remote_filesize($url, $user = &quot;&quot;, $pw = &quot;&quot;){
    ob_start();
    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch, CURLOPT_NOBODY, 1);

    if(!empty($user) &amp;&amp; !empty($pw))
    {
        $headers = array(&#39;Authorization: Basic &#39; .  base64_encode(&quot;$user:$pw&quot;));
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    }

    $ok = curl_exec($ch);
    curl_close($ch);
    $head = ob_get_contents();
    ob_end_clean();

    $regex = &#39;/Content-Length:\s([0-9].+?)\s/&#39;;
    $count = preg_match($regex, $head, $matches);

    return isset($matches[1]) ? $matches[1] : &quot;unknown&quot;;
}
</pre>
<p>
	<strong>&rarr; Source: <a href="http://megasnippets.com/source-codes/php/get_remote_filesize">http://megasnippets.com/source-codes/php/get_remote_filesize</a></strong>
</p>
<h2>FTP upload with cURL</h2>
<p>PHP does have a FTP library, but you can also use cURL to upload files on a FTP server. Here is a working example:</p>
<pre>
// open a file pointer
$file = fopen("/path/to/file", "r");

// the url contains most of the info needed
$url = "ftp://username:password@mydomain.com:21/path/to/new/file";

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

// upload related options
curl_setopt($ch, CURLOPT_UPLOAD, 1);
curl_setopt($ch, CURLOPT_INFILE, $fp);
curl_setopt($ch, CURLOPT_INFILESIZE, filesize("/path/to/file"));

// set for ASCII mode (e.g. text files)
curl_setopt($ch, CURLOPT_FTPASCII, 1);

$output = curl_exec($ch);
curl_close($ch);
</pre>
<img src="http://feeds.feedburner.com/~r/goksel/~4/G7fJ-d509o8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://geryit.com/blog/amazing-things-to-do-with-php-and-curl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://geryit.com/blog/amazing-things-to-do-with-php-and-curl/</feedburner:origLink></item>
	<media:rating>nonadult</media:rating></channel>
</rss>
