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

<channel>
	<title>Webstuffshare - Learn and share. The simplest harmony. &#187; Code Snippet</title>
	<atom:link href="http://www.webstuffshare.com/tag/code-snippet/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.webstuffshare.com</link>
	<description>Learn and share. The simplest harmony.</description>
	<lastBuildDate>Tue, 04 Oct 2011 02:11:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>[CodeSnippet] CSS3 Flying Menu</title>
		<link>http://www.webstuffshare.com/2010/06/codesnippet-css3-flying-menu/</link>
		<comments>http://www.webstuffshare.com/2010/06/codesnippet-css3-flying-menu/#comments</comments>
		<pubDate>Fri, 25 Jun 2010 13:41:28 +0000</pubDate>
		<dc:creator>Hidayat Sagita</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Code Snippet]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Menu]]></category>

		<guid isPermaLink="false">http://www.webstuffshare.com/?p=2193</guid>
		<description><![CDATA[This is a request post from my reader. He asks me how to create a simple menu that have a flying effect when user hovering them using only CSS. As [...]]]></description>
			<content:encoded><![CDATA[<p><img src='http://www.webstuffshare.com/wp-content/plugins/simple-post-thumbnails/timthumb.php?src=/wp-content/thumbnails/2193.jpg&amp;w=200&amp;h=150&amp;zc=1&amp;ft=jpg' alt='post thumbnail' /></p>
<p>This is a request post from my reader. He asks me how to create a simple menu that have a flying effect when user hovering them using only CSS. As we know CSS3 is more powerful with its transition property, it help us creating animation without any JavaScript or even Flash help. We&#8217;ll use them for creating the flying effect and here is the result. Enjoy!<br />
<span id="more-2193"></span></p>
<div class="button-show-implementation"><a href="http://webstuffshare.com/demo/CSSFlyMenu/">Show Implementation</a></div>
<div class="button-download-source"><a href="http://www.webstuffshare.com/download/CSSFlyMenu.zip">Download Source</a></div>
<div class="cleaner"></div>
<p>Firstly, we need to create list menu using unordered list element :</p>
<pre name="code" class="html">/* Sample #1 */
<ul id="fly-menu">
<li>
		<a href="http://www.webstuffshare.com">
			<img src="images/heart.png" alt="webstuffshare" /> Webstuffshare Home
		</a></li>
<li>
		<a href="http://feeds.feedburner.com/webstuffsharecom">
			<img src="images/rss.png" alt="rss" /> Subscribe RSS Feed
		</a></li>
<li>
		<a href="http://feedburner.google.com/fb/a/mailverify?uri=webstuffsharecom">
			<img src="images/email.png" alt="email" /> Subscribe Email
		</a></li>
<li>
		<a href="http://twitter.com/hdytsgt">
			<img src="images/twitter.png" alt="twitter" /> Follow Twitter
		</a></li>
</ul>

/* Sample #2 */
<ul id="fly-glow-menu">
<li>
		<a href="http://www.webstuffshare.com">
			<img src="images/heart.png" alt="webstuffshare" /> Webstuffshare Home
		</a></li>
<li>
		<a href="http://feeds.feedburner.com/webstuffsharecom">
			<img src="images/rss.png" alt="rss" /> Subscribe RSS Feed
		</a></li>
<li>
		<a href="http://feedburner.google.com/fb/a/mailverify?uri=webstuffsharecom">
			<img src="images/email.png" alt="email" /> Subscribe Email
		</a></li>
<li>
		<a href="http://twitter.com/hdytsgt">
			<img src="images/twitter.png" alt="twitter" /> Follow Twitter
		</a></li>
</ul>
</pre>
<p><br/><br />
They are arranged vertically by default, so we must arrange them horizontally using CSS property &#8216;<strong>float</strong>&#8216; with &#8216;<strong>left</strong>&#8216; value. Next, add CSS transition to make any properties change on it animated, we set the duration in <strong>0.3 seconds</strong> or <strong>300 milliseconds</strong>.</p>
<pre name="code" class="css">.cleaner {
	clear: both;
}

#fly-menu, #fly-glow-menu {
	margin: 1em auto 0 auto;
}

	#fly-menu li, #fly-glow-menu li {

		/* Basic style */
		list-style-type: none;
		margin-right: .5em;
		float: left;
		font-size: 15px;
		background: #cacaca;
		padding: 10px;
		cursor: pointer;

		/* Add shadow */
		-webkit-box-shadow: inset 0px 0px 10px rgba(0,0,0, .3);
		-moz-box-shadow: inset 0px 0px 10px rgba(0,0,0, .3);
		box-shadow: inset 0px 0px 10px rgba(0,0,0, .3);

		/*
			Add animation using transition
			-webkit : Safari &amp; Chrome.
			-moz : Firefox
			-o : Opera
		*/
		-webkit-transition: .3s ease-in-out;
  		-moz-transition: .3s ease-in-out;
  		-o-transition: .3s ease-in-out;
	}</pre>
<p><br/><br />
Since each menu is having float with left value, we need a cleaner element to make another element not floating into the menu.<br />
The last are reading hover event on each menu by adding pseudo property <strong>:hover</strong> and change the &#8216;<strong>margin-top</strong>&#8216; properties into -1em. This will make our menu fly upwards when user hovering them.</p>
<pre name="code" class="css">#fly-menu li:hover {
	margin-top: -1em;
}</pre>
<p align="center"><a href="http://webstuffshare.com/demo/CSSFlyMenu/"><img src="http://www.webstuffshare.com/http://www.webstuffshare.com/wp-content/uploads/2010/06/Picture-22.png" alt="Picture 2" title="Picture 2" width="500" height="58" class="aligncenter size-full wp-image-2197" /></a></p>
<p><br/></p>
<p>We can also make the animation nicer by changing menu&#8217;s background color and modify its box shadow properties or anything we need.</p>
<pre name="code" class="css">#fly-glow-menu li:hover {

	margin-top: -1em;
	background: #fff;

	-webkit-box-shadow: 0px 0px 10px rgba(0,0,0, .3);
	-moz-box-shadow: 0px 0px 10px rgba(0,0,0, .3);
	box-shadow: 0px 0px 10px rgba(0,0,0, .3);
}</pre>
<p align="center"><a href="http://webstuffshare.com/demo/CSSFlyMenu/"><img src="http://www.webstuffshare.com/http://www.webstuffshare.com/wp-content/uploads/2010/06/Picture-41.png" alt="Picture 4" title="Picture 4" width="500" height="53" class="aligncenter size-full wp-image-2196" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.webstuffshare.com/2010/06/codesnippet-css3-flying-menu/feed/</wfw:commentRss>
		<slash:comments>35</slash:comments>
		</item>
		<item>
		<title>[CodeSnippet] Twitter-like Input Using CSS3</title>
		<link>http://www.webstuffshare.com/2010/05/codesnippet-twitter-like-input-using-css3/</link>
		<comments>http://www.webstuffshare.com/2010/05/codesnippet-twitter-like-input-using-css3/#comments</comments>
		<pubDate>Mon, 17 May 2010 11:47:20 +0000</pubDate>
		<dc:creator>Hidayat Sagita</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Code Snippet]]></category>
		<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://www.webstuffshare.com/?p=2093</guid>
		<description><![CDATA[Twitter has a nice effect in presenting their tweet box by adding outer glow effect on it while the tweeps are tweeting. If you&#8217;re webkit-based browser user you must&#8217;ve notice [...]]]></description>
			<content:encoded><![CDATA[<p><img src='http://www.webstuffshare.com/wp-content/plugins/simple-post-thumbnails/timthumb.php?src=/wp-content/thumbnails/2093.jpg&amp;w=200&amp;h=150&amp;zc=1&amp;ft=jpg' alt='post thumbnail' /></p>
<p>Twitter has a nice effect in presenting their tweet box by adding outer glow effect on it while the tweeps are tweeting. If you&#8217;re webkit-based browser user you must&#8217;ve notice that glowing effect works with the animation. We&#8217;ve discussed that technique on previous post (<a href="http://www.webstuffshare.com/2010/04/stylize-input-element-using-css3/"><strong>Stylize Input Element Using CSS3</strong></a>), the thing we&#8217;ve not yet do is adding the animation on it.<span id="more-2093"></span></p>
<div class="button-show-implementation"><a href="http://webstuffshare.com/demo/AnimateStylizeInput/">Show Implementation</a></div>
<div class="button-download-source"><a href="http://www.webstuffshare.com/download/AnimateStylizeInput.zip">Download Source</a></div>
<div class="cleaner"></div>
<p>Just like the previous post, for creating glowing effect we can use box shadow property on the input and for adding the animation on it we can add css animation property (<strong>transition</strong>) on the input (in this case textare) element, set the <strong>duration</strong> property into 0.3 seconds and timing <strong>function property</strong> into <strong>ease-in-out</strong>. Take a look at following script :</p>
<pre name="code" class="css">textarea {
	padding: 5px;
	font-size: 15px;
	text-shadow: 0px 1px 0px #fff;
	outline: none;
	-webkit-border-radius: 3px;
	-moz-border-radius: 3px;
	border-radius: 3px;
	border: 1px solid #ccc;
	-webkit-transition: .3s ease-in-out;
  	-moz-transition: .3s ease-in-out;
}

	textarea:focus {
		border: 1px solid #fafafa;
		-webkit-box-shadow: 0px 0px 6px #007eff;
		-moz-box-shadow: 0px 0px 5px #007eff;
		box-shadow: 0px 0px 5px #007eff;
	}</pre>
<p align="center"><img src="http://www.webstuffshare.com/http://www.webstuffshare.com/wp-content/uploads/2010/05/Picture-1-copy1.png" alt="Picture 1 copy" title="Picture 1 copy" width="532" height="198" class="aligncenter size-full wp-image-2106" /></p>
<p>Since the textarea element has css transition on it, it will have glowing effect with animation when the textarea has a focus state. The animation works beautifully on <strong>Safari 4.0.5</strong> and <strong>Chrome 5.0.375.38</strong>, the demo won&#8217;t work on current Firefox version since Firefox will support css transition on <a target="_blank" href="https://developer.mozilla.org/en/CSS/-moz-transition">version 3.7</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webstuffshare.com/2010/05/codesnippet-twitter-like-input-using-css3/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>10 Random jQuery Snippet</title>
		<link>http://www.webstuffshare.com/2010/04/10-random-jquery-snippet/</link>
		<comments>http://www.webstuffshare.com/2010/04/10-random-jquery-snippet/#comments</comments>
		<pubDate>Wed, 21 Apr 2010 05:58:32 +0000</pubDate>
		<dc:creator>Hidayat Sagita</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Code Snippet]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.webstuffshare.com/?p=1872</guid>
		<description><![CDATA[In this post, I will list 10 random jQuery snippets I collected from all of my previous tutorial. If you always follow my tutorial you must be familiar with the [...]]]></description>
			<content:encoded><![CDATA[<p><img src='http://www.webstuffshare.com/wp-content/plugins/simple-post-thumbnails/timthumb.php?src=/wp-content/thumbnails/1872.jpg&amp;w=200&amp;h=150&amp;zc=1&amp;ft=jpg' alt='post thumbnail' /></p>
<p>In this post, I will list 10 random jQuery snippets I collected from all of my previous tutorial. If you always follow my tutorial you must be familiar with the following snippets, enjoy!<span id="more-1872"></span><br />
<br/><br />
<strong>Traversing Each Element and Do The Same Action</strong><br />
This code will traversing each element that have a class and do the same action on each element. We&#8217;ve used this code on  &#8220;<a href="http://www.webstuffshare.com/2010/02/how-to-create-iphone-style-navigation-part-i/">How To Create iPhone-Style Navigation (Part I)</a>&#8221; and &#8220;<a href="http://www.webstuffshare.com/2010/02/iphone-style-navigationajax-rotate-part-ii/">iPhone-Style Navigation:AJAX + Rotate (Part II)</a>&#8221;</p>
<pre name="code" class="javascript">
$('.additional-block').each(function() {
	//Do action
});
</pre>
<p><br/></p>
<p><strong>Count Previous Siblings</strong><br />
Sometimes we need to count the previous siblings of selected element, we&#8217;ve used this code on &#8220;<a href="http://www.webstuffshare.com/2010/02/animated-navigation-menu">Create Animated Navigation Menu From Stratch</a>&#8220;.</p>
<pre name="code" class="javascript">
countPreviousItem = $(this).prevAll('element').length;
</pre>
<p><br/></p>
<p><strong>Animate Previous Element&#8217;s Parent</strong><br />
Just like above code this code we&#8217;ve used on &#8220;<a href="http://www.webstuffshare.com/2010/02/animated-navigation-menu">Create Animated Navigation Menu From Stratch</a>&#8220;, we can animate or doing some action to the previous element&#8217;s parent from the selected element.</p>
<pre name="code" class="javascript">
$(this).parents('element').prev('element').animate({ marginLeft: someFunctin }, 300);
</pre>
<p><br/></p>
<p><strong>Get Element&#8217;s Index Number</strong><br />
We can get element&#8217;s index number from its parent using following code, we&#8217;ve used this code on &#8220;<a href="http://www.webstuffshare.com/2010/04/create-groovershark-like-widget-slider/">Create Groovershark-like Widget Slider</a>&#8220;.</p>
<pre name="code" class="javascript">
indexNumber	= $('element').index();
</pre>
<p><br/></p>
<p><strong>Get Checkbox Value</strong><br />
On &#8220;<a href="http://www.webstuffshare.com/2010/03/stylize-your-own-checkboxes/">Stylize Your Own Checkboxes</a>&#8221; and &#8220;<a href="http://www.webstuffshare.com/2010/02/code-snippet-jquery-checkbox-table/">[Code Snippet] jQuery : Checkbox &#038; Table</a>&#8221; posts we needed a code to check the checkbox is being checked or not, and we&#8217;ve used this following code.</p>
<pre name="code" class="javascript">
checkboxValue = $('checkbox-element').attr('checked');
//OR
checkboxValue = $('checkbox-element')[0].checked;
</pre>
<p><br/></p>
<p><strong>Count Element&#8217;s Padding</strong><br />
Count current element&#8217;s padding using this script, we&#8217;ve used this script on &#8220;<a href="http://www.webstuffshare.com/2010/02/animated-navigation-menu">Create Animated Navigation Menu From Stratch</a>&#8221;</p>
<pre name="code" class="javascript">
$('element').css('padding-left');
//OR another padding
$('element').css('padding-top');
</pre>
<p><br/></p>
<p><strong>Does The Element Exists?</strong><br />
Before do some action to the selected element we can check its existance, does it exists or not. We&#8217;ve used this code on &#8220;<a href="http://www.webstuffshare.com/2010/03/codesnippet-jquery-confirm-users-action/">[CodeSnippet] jQuery : Confirm User’s Action</a>&#8220;.</p>
<pre name="code" class="javascript">
if($(element).next('anotherElement').length <= 0) {
	//element doesn't exists;
}  else {
	//element exists;
}
</pre>
<p><br/></p>
<p><strong>Inject Event Function on Any Additional Element</strong><br />
On "<a href="http://www.webstuffshare.com/2010/03/codesnippet-jquery-confirm-users-action/">[CodeSnippet] jQuery : Confirm User’s Action</a>" we also use this following code to inject an event function on any additional element we've added.</p>
<pre name="code" class="javascript">
$('element').live('click', function(){
	//Do some action
});
</pre>
<p><br/></p>
<p><strong>Toggle The Function</strong><br />
On "<a href="http://www.webstuffshare.com/2010/02/iphone-style-navigationajax-rotate-part-ii/">iPhone-Style Navigation:AJAX + Rotate (Part II)</a>" post, we've created a button toggle to rotate and rotate back the iPhone, here is the short code :</p>
<pre name="code" class="javascript">
$('element').toggle(
	function() {
		//Rotate or do some action
	},
	function() {
		//Rotate back or do some action
	}
);
</pre>
<p><br/></p>
<p><strong>Toggle Mouseover and Mouseout</strong><br />
If we want to call different action when user mouseover or mouseout our element, we can use this following code that we've used on "<a href="http://www.webstuffshare.com/2010/01/how-to-create-the-wire-tumblr-in-realtime-alike/">How to create The Wire Tumblr in Realtime-alike</a>".</p>
<pre name="code" class="javascript">
$('element').hover(
	function() {
		//When mouseover do some action
	},
	function() {
		//When mouseout do some action
	}
);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.webstuffshare.com/2010/04/10-random-jquery-snippet/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>[CodeSnippet] jQuery :  Fade In Webpage</title>
		<link>http://www.webstuffshare.com/2010/04/codesnippet-jquery-fade-in-webpage/</link>
		<comments>http://www.webstuffshare.com/2010/04/codesnippet-jquery-fade-in-webpage/#comments</comments>
		<pubDate>Sun, 04 Apr 2010 10:59:41 +0000</pubDate>
		<dc:creator>Hidayat Sagita</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Code Snippet]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.webstuffshare.com/?p=1782</guid>
		<description><![CDATA[The following short code is a way to add a fade in effect to your webpage. The main task we want to do are hiding our webpage content then display [...]]]></description>
			<content:encoded><![CDATA[<p><img src='http://www.webstuffshare.com/wp-content/plugins/simple-post-thumbnails/timthumb.php?src=/wp-content/thumbnails/1782.jpg&amp;w=200&amp;h=150&amp;zc=1&amp;ft=jpg' alt='post thumbnail' /></p>
<p>The following short code is a way to add a fade in effect to your webpage. The main task we want to do are hiding our webpage content then display it with fade in effect when the user load the webpage. These step will use two jQuery built-in function, <strong>hide()</strong> and <strong>fadeIn()</strong>. <span id="more-1782"></span></p>
<div class="button-show-implementation"><a href="http://webstuffshare.com/demo/FadeInWebpage/">Show Implementation</a></div>
<div class="button-download-source"><a href="http://www.webstuffshare.com/download/FadeInWebpage.zip">Download Source</a></div>
<div class="cleaner"></div>
<pre name="code" class="javascript">
$(document).ready(function() {
	$('body').hide().fadeIn(1000);
});
</pre>
<p>First we hide the whole body using <strong>hide()</strong> and display it using <strong>fadeIn()</strong> in 1000 milliseconds. The last, <strong>never</strong> hide your whole body using CSS and display them using JavaScript to avoid your content stay hidden because of the user disabling the JavaScript.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.webstuffshare.com/2010/04/codesnippet-jquery-fade-in-webpage/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>[CodeSnippet] jQuery : Confirm User&#8217;s Action</title>
		<link>http://www.webstuffshare.com/2010/03/codesnippet-jquery-confirm-users-action/</link>
		<comments>http://www.webstuffshare.com/2010/03/codesnippet-jquery-confirm-users-action/#comments</comments>
		<pubDate>Fri, 26 Mar 2010 16:53:52 +0000</pubDate>
		<dc:creator>Hidayat Sagita</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Code Snippet]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Forms]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.webstuffshare.com/?p=1718</guid>
		<description><![CDATA[Don&#8217;t let your link that have a critical action (such as delete some data or something else) fly away on their own self, we must put a confirmation before do [...]]]></description>
			<content:encoded><![CDATA[<p><img src='http://www.webstuffshare.com/wp-content/plugins/simple-post-thumbnails/timthumb.php?src=/wp-content/thumbnails/1718.jpg&amp;w=200&amp;h=150&amp;zc=1&amp;ft=jpg' alt='post thumbnail' /></p>
<p>Don&#8217;t let your link that have a critical action (such as delete some data or something else) fly away on their own self, we must put a confirmation before do the action to prevent user&#8217;s mistake. Now, let us make that one.<span id="more-1718"></span></p>
<div class="button-show-implementation"><a href="http://webstuffshare.com/demo/AskUserAction/">Show Implementation</a></div>
<div class="button-download-source"><a href="http://www.webstuffshare.com/download/AskUserAction.zip">Download Source</a></div>
<div class="cleaner"></div>
<p>Java Script has a built-in function to create a user confirmation box ( <strong>confirm()</strong> ), it means we can call that confirmation box  to confirm user&#8217;s action. So if the user click a link, they must confirm that before we process the action. If the answer is cancel the default action will be cancelled and vice versa. We can use <strong>preventDefault()</strong> function to  cancel the default action from our link. Take a look at following script. (<strong>Implementation #1</strong>).</p>
<pre name="code" class="javascript">
$('.ask-plain').click(function(e) {

	e.preventDefault();
	thisHref	= $(this).attr('href');

	if(confirm('Are you sure')) {
		window.location = thisHref;
	}

});
</pre>
<p>If the user click the link we cancel its default action, grab its default link and confirm the user. If the user confirms his action then we&#8217;ll redirect to the default link. But that&#8217;s too plain, we&#8217;ll replace them with a cute one by adding some CSS properties and jQuery magic. (<strong>Implementation #2 and #3</strong>).</p>
<pre name="code" class="javascript">
$('.ask').click(function(e) {

	e.preventDefault();
	thisHref	= $(this).attr('href');

	if($(this).next('div.question').length <= 0)
		$(this).after('
<div class="question">Are you sure?<br/> <span class="yes">Yes</span><span class="cancel">Cancel</span></div>

');

	$('.question').animate({opacity: 1}, 300);

	$('.yes').live('click', function(){
		window.location = thisHref;
	});

	$('.cancel').live('click', function(){
		$(this).parents('div.question').fadeOut(300, function() {
			$(this).remove();
		});
});
</pre>
<p>The process is similar to the first script, but we&#8217;ll use our customized confirmation box (<strong>div</strong> with class <strong>question</strong>) instead of <strong>confirm()</strong> function. By attaching div element after clicked link element, our confirmation box will appear and displaying a confirmation. If the user confirms his action then we&#8217;ll redirect to the default link, else we&#8217;ll remove our confirmation box. That&#8217;s it, we have a cute confirmation box <img src='http://www.webstuffshare.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.webstuffshare.com/2010/03/codesnippet-jquery-confirm-users-action/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>[Code Snippet] CSS : Hover and Press Button</title>
		<link>http://www.webstuffshare.com/2010/03/code-snippet-css-hover-and-press-button/</link>
		<comments>http://www.webstuffshare.com/2010/03/code-snippet-css-hover-and-press-button/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 06:31:27 +0000</pubDate>
		<dc:creator>Hidayat Sagita</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Code Snippet]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Menu]]></category>

		<guid isPermaLink="false">http://www.webstuffshare.com/?p=1570</guid>
		<description><![CDATA[You must be familiar with css button with hovered and pressed-style, we always meet them around the internet world with ease. Fortunately, we can make them with a very simple [...]]]></description>
			<content:encoded><![CDATA[<p><img src='http://www.webstuffshare.com/wp-content/plugins/simple-post-thumbnails/timthumb.php?src=/wp-content/thumbnails/1570.jpg&amp;w=200&amp;h=150&amp;zc=1&amp;ft=jpg' alt='post thumbnail' /></p>
<p>You must be familiar with css button with hovered and pressed-style, we always meet them around the internet world with ease. Fortunately, we can make them with a very simple css technique. By using built-in css pseudo selector (<strong>:hover</strong> and <strong>:active</strong>) we can manipulate a boring link navigator into a cute one. <span id="more-1570"></span></p>
<div class="button-show-implementation"><a href="http://webstuffshare.com/demo/ButtonPressed/">Show Implementation</a></div>
<div class="button-download-source"><a href="http://www.webstuffshare.com/download/ButtonPressed.zip">Download Source</a></div>
<div class="cleaner">&nbsp;</div>
<p>As i said before we&#8217;ll use css pseudo selector, <strong>:hover</strong> and <strong>:active</strong>. <strong>:hover</strong> is a pseudo-selector to read user&#8217;s hovering action to our element while <strong>:active</strong> read pressing action. To make the button we need button image sprites as the background image, the image sprites divided into three states :  normal state, hover state and press state.</p>
<p style="text-align: center; "><img src="http://www.webstuffshare.com/http://www.webstuffshare.com/wp-content/uploads/2010/03/button3.jpg" alt="button3" title="button3" width="201" height="201" class="aligncenter size-full wp-image-1590" /></p>
<p>We&#8217;ll put the image sprite as background image and play it&#8217;s position based on the user action, for example in the normal state the background image position will be set to &#8216;<strong>top left</strong>&#8216;, hover state set to &#8216;<strong>center left</strong>&#8216; and press state set to &#8216;<strong>bottom left</strong>&#8216;. These setted position will automatically set our background image position as our request.</p>
<p><img class="text-align: right" title="button2" src="http://www.webstuffshare.com/http://www.webstuffshare.com/wp-content/uploads/2010/03/button2.jpg" alt="button2" width="480" height="235" /></p>
<p>We&#8217;ll set the html into following script :</p>
<pre name="code" class="html"><a class="yellow-button" href="#">This is a Yellow Button</a></pre>
<p>And the last script is CSS :</p>
<pre name="code" class="css">.yellow-button {
	display:block;
	width: 201px;
	height: 46px;
	padding: 21px 0 0 0;
	background: url('images/yellow-button.png') top left no-repeat;
	margin-bottom: 2em;
	margin-right: 2em;
	float: left;
}

	.yellow-button:hover {
		background-position: center left;
	}

	.yellow-button:active {
		background-position: bottom left;
		padding-top: 22px;
	}</pre>
<p>Ok, that&#8217;s it, thank you for reading!  You can get regular useful updates about web-stuff by subscribing <a href="http://feeds.feedburner.com/webstuffsharecom"><strong>webstuffshare RSS feed</strong></a> or  <a href="http://feedburner.google.com/fb/a/mailverify?uri=webstuffsharecom&amp;loc=en_US"><strong>webstuffshare FREE Email subscription</strong></a>. If you like this post, your sharing and feedback would be very appreciated <img src='http://www.webstuffshare.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.webstuffshare.com/2010/03/code-snippet-css-hover-and-press-button/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>[Code Snippet] jQuery : Show/Hide Element</title>
		<link>http://www.webstuffshare.com/2010/03/code-snippet-jquery-showhide-element/</link>
		<comments>http://www.webstuffshare.com/2010/03/code-snippet-jquery-showhide-element/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 05:34:21 +0000</pubDate>
		<dc:creator>Hidayat Sagita</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Code Snippet]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[Menu]]></category>

		<guid isPermaLink="false">http://www.webstuffshare.com/?p=1500</guid>
		<description><![CDATA[This is a very basic technique to show and hide HTML element, we just need to define the element then show or hide them with jQuery built-in function, $.slideToggle(). But [...]]]></description>
			<content:encoded><![CDATA[<p><img src='http://www.webstuffshare.com/wp-content/plugins/simple-post-thumbnails/timthumb.php?src=/wp-content/thumbnails/1500.jpg&amp;w=200&amp;h=150&amp;zc=1&amp;ft=jpg' alt='post thumbnail' /></p>
<p>This is a very basic technique to show and hide HTML element, we just need to define the element then show or hide them with jQuery built-in function, <strong>$.slideToggle()</strong>. But if you see my sidebar in <strong>&#8216;Tags Collection&#8217;</strong> section, you&#8217;ll notice that there&#8217;s a toggle to show or hide the tags collection (with <strong>undefined</strong> div&#8217;s height, of course) and that&#8217;s what i will explain.<span id="more-1500"></span></p>
<p>First we make up the html :</p>
<pre name="code" class="html">
<div class="list-tag">
<div class="content-list-tag">
	<!-- fill with content as much as possible --></div>
</div>
<div class="more-tags">
	<img src="images/down.png" border="0" alt="" />
</div>
</pre>
<pre name="code" class="css">
.list-tag {
	height: 195px;
	overflow: hidden;
}

.more-tags {
	cursor: pointer;
	padding-top: 15px;
	background: url('shade-tag.png') center top no-repeat;
	display:block;
	text-align: center;
}
</pre>
<p>Div list-tag is a div binder of div content-list-tag, the div content-list-tag has undefined height whilst the div binder has the pre-defined height, based on our needs. Div more-tags is a toggle to show or hide the div content-list-tag.</p>
<p>First we must inject div more-tags with <strong>$.toggle()</strong> function to make it toggled, read the div content-list-tag&#8217;s height by <strong>$.height()</strong> function, show the div content-list-tag&#8217;s content by animating it then rotate the <strong>down.png</strong> image to 180deg (we need a <a target=_blank"" href="http://www.zachstronaut.com/posts/2009/08/07/jquery-animate-css-rotate-scale.html">jquery plugin</a> to do this step).  If the user click the toggle once more, then we just need to revert previous step.<br/><br/></p>
<pre name="code" class="javascript">$('.more-tags').toggle(function() {

	contentTagsHeight	= $('.content-list-tag').height();

	$('.list-tag').animate({height : contentTagsHeight});
	$(this).children('img').animate({rotate: '180deg'});

}, function() {

	$('.list-tag').animate({height : '195px'});
	$(this).children('img').animate({rotate: '0deg'});

});</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.webstuffshare.com/2010/03/code-snippet-jquery-showhide-element/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>[Code Snippet] jQuery : Confirm Before Exit</title>
		<link>http://www.webstuffshare.com/2010/03/code-snippet-jquery-confirm-before-exit/</link>
		<comments>http://www.webstuffshare.com/2010/03/code-snippet-jquery-confirm-before-exit/#comments</comments>
		<pubDate>Mon, 01 Mar 2010 08:07:46 +0000</pubDate>
		<dc:creator>Hidayat Sagita</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Code Snippet]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.webstuffshare.com/?p=1440</guid>
		<description><![CDATA[Gmail compose has functionality to detect any content modification and confirm us before closing browser&#8217;s window because of unsaved content that we&#8217;ve modify, yes in this post i will try [...]]]></description>
			<content:encoded><![CDATA[<p><img src='http://www.webstuffshare.com/wp-content/plugins/simple-post-thumbnails/timthumb.php?src=/wp-content/thumbnails/1440.jpg&amp;w=200&amp;h=150&amp;zc=1&amp;ft=jpg' alt='post thumbnail' /></p>
<p>Gmail compose has functionality to detect any content modification and confirm us before closing browser&#8217;s window because of unsaved content that we&#8217;ve modify, yes in this post i will try to explain how to make these function work on our webapps. <span id="more-1440"></span></p>
<div class="button-show-implementation"><a href="http://webstuffshare.com/demo/ConfirmBeforeExit/">Show Implementation</a></div>
<div class="button-download-source"><a href="http://www.webstuffshare.com/download/ConfirmBeforeExit.zip">Download Source</a></div>
<div class="cleaner">&nbsp;</div>
<p>Firstly, we create a boolean variable with default value <strong>false</strong> then we check is there any content in our input that have been modified by the user. If the user has been modified then we change the boolean variable value to <strong>true</strong>.</p>
<p>Now, we create a function (named checkIsEdit) to check the value of the boolean variable, if the value is true then alert the user that the&#8217;ve modify some content.  And the last step, we attach checkIsEdit function to the window event (onbeforeunload) to check whether the window is being refreshed or closed and fire up the function. That&#8217;s it, check out this following code :</p>
<pre name="code" class="javascript">
$(document).ready(function() {

	var isEdit	= false;

	$('input').change(function() {
		isEdit = true;
	});

	function checkIsEdit() {
		if(isEdit)
			return "You have modify some content";
	}

	window.onbeforeunload = checkIsEdit;
});
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.webstuffshare.com/2010/03/code-snippet-jquery-confirm-before-exit/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>[Code Snippet] jQuery : Checkbox &amp; Table</title>
		<link>http://www.webstuffshare.com/2010/02/code-snippet-jquery-checkbox-table/</link>
		<comments>http://www.webstuffshare.com/2010/02/code-snippet-jquery-checkbox-table/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 06:46:06 +0000</pubDate>
		<dc:creator>Hidayat Sagita</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Code Snippet]]></category>
		<category><![CDATA[Grid]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.webstuffshare.com/?p=1339</guid>
		<description><![CDATA[Today&#8217;s code snippet is how to automagically check/uncheck checkbox element by clicking a single row of a table using jQuery. Firstly we add click event on the table&#8217;s row, it [...]]]></description>
			<content:encoded><![CDATA[<p><img src='http://www.webstuffshare.com/wp-content/plugins/simple-post-thumbnails/timthumb.php?src=/wp-content/thumbnails/1339.jpg&amp;w=200&amp;h=150&amp;zc=1&amp;ft=jpg' alt='post thumbnail' /></p>
<p>Today&#8217;s code snippet is how to automagically check/uncheck checkbox element by clicking a single row of a table using jQuery. Firstly we add click event on the table&#8217;s row, it will help us read click event on each row. Grab checkbox element on its row, check whether this checkbox was checked or not yet, then add checked or unchecked value on it.<span id="more-1339"></span></p>
<div class="button-show-implementation"><a href="http://webstuffshare.com/demo/jQuery-Checkbox-Table/">Show Implementation</a></div>
<div class="button-download-source"><a href="http://www.webstuffshare.com/download/jQuery-Checkbox-Table.zip">Download Source</a></div>
<div class="cleaner">&nbsp;</div>
<pre name="code" class="javascript">
$('table tr').click(function() {

	checkBox = $(this).children('td').children('input[type=checkbox]');

	if(checkBox.attr('checked'))
		checkBox.attr('checked', '');
	else
		checkBox.attr('checked', 'checked');
});
</pre>
<p><br/></p>
<p>Now our row have functionality to check/uncheck checkbox element, but how about we add a little function to check/uncheck all checkbox in our table by clicking only one checkbox, here is the code : <br/> <br/></p>
<pre name="code" class="javascript">
$('.check-all').click(function() {

	checkBox = $('table tr').children('td').children('input[type=checkbox]');

	if($(this).attr('checked'))
		checkBox.attr('checked', 'checked');
	else
		checkBox.attr('checked', '');
});
</pre>
<p>We also can add another functionality such as delete checked row or etc. Just play around with jQuery function and happy coding <img src='http://www.webstuffshare.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.webstuffshare.com/2010/02/code-snippet-jquery-checkbox-table/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>[Code Snippet] WordPress : Current Week Post</title>
		<link>http://www.webstuffshare.com/2010/02/code-snippet-wordpress-current-week-post/</link>
		<comments>http://www.webstuffshare.com/2010/02/code-snippet-wordpress-current-week-post/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 00:16:11 +0000</pubDate>
		<dc:creator>Hidayat Sagita</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Code Snippet]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://www.webstuffshare.com/?p=1247</guid>
		<description><![CDATA[Sometimes we want to show current week posts in our blog, it can easily do with basic WordPress&#8217;s query_posts function. Firstly we grab current week number of a year with [...]]]></description>
			<content:encoded><![CDATA[<p><img src='http://www.webstuffshare.com/wp-content/plugins/simple-post-thumbnails/timthumb.php?src=/wp-content/thumbnails/1247.jpg&amp;w=200&amp;h=150&amp;zc=1&amp;ft=jpg' alt='post thumbnail' /></p>
<p>Sometimes we want to show current week posts in our blog, it can easily do with basic WordPress&#8217;s <strong>query_posts</strong> function. Firstly we grab current week number of a year with php function <strong>date(&#8216;W&#8217;)</strong> (ISO-8601) then add its value to the query, and voila we&#8217;ve just created current week posts from our blog. Let&#8217;s see the code :<br/><br/><span id="more-1247"></span></p>
<pre name="code" class="php">
/* Help the query to create pagination  */
$limit = get_option('posts_per_page');
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

/* Grab this week number of a year (ISO-8601) */
$thisWeek = date('W');

/* Start to query! */
$currentPosts 	= query_posts('showposts=' . $limit .
				 '&#038;paged=' . $paged .
				 '&#038;w='.$thisWeek);</pre>
<p><br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.webstuffshare.com/2010/02/code-snippet-wordpress-current-week-post/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Served from: www.webstuffshare.com @ 2012-02-04 18:53:47 -->
