<?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>Ionut Staicu - Webdeveloper Blog &#187; jquery</title>
	<atom:link href="http://dev.iamntz.com/category/javascript/jquery/feed" rel="self" type="application/rss+xml" />
	<link>http://dev.iamntz.com</link>
	<description>Stuff about CSS, XHTML, Javascript and jQuery</description>
	<lastBuildDate>Thu, 26 May 2011 05:43:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Add some html to your images in that lightbox!</title>
		<link>http://dev.iamntz.com/230/add-some-html-to-your-images-in-that-lightbox</link>
		<comments>http://dev.iamntz.com/230/add-some-html-to-your-images-in-that-lightbox#comments</comments>
		<pubDate>Thu, 30 Jul 2009 12:53:50 +0000</pubDate>
		<dc:creator>Staicu IonuÈ›-Bogdan</dc:creator>
				<category><![CDATA[Experiments]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://dev.iamntz.com/?p=230</guid>
		<description><![CDATA[One of the biggest drawback of the lightbox-style plugins are that you are not allowed to use html code in your image description. If you need to bold or emphasize some part of the description title you are kinda screwed. &#8230; <a href="http://dev.iamntz.com/230/add-some-html-to-your-images-in-that-lightbox">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>One of the biggest drawback of the <a href="http://leandrovieira.com/projects/jquery/lightbox/">lightbox</a>-style plugins are that you are not allowed to use html code in your image description. If you need to bold or emphasize some part of the description title you are kinda screwed. Of course, you don&#8217;t want to use a long and boring description, but if you want to make a list (for example) you are some how limited. Not by lightbox plugin but the html language itself. </p>
<h3>How image description works?</h3>
<pre lang="html">
<a href="image.jpg" title="some extra-long description" rel="lightbox"><img src [...] /></a>
</pre>
<p>This is the basic structure for lightbox-enabled links. The lightbox plugin use that title to add a small description when the big image is showed. What if &#8211; let&#8217;s say &#8211; you need to emphasize the word &#8216;extra&#8217;? How would you proceed? You could use some html tags ( <code>&lt;em&gt;</code> ) but with some validation error and maybe some unpredictible result on various browsers (or parsers, if you use xhtml). The solution? Use <a href="http://en.wikipedia.org/wiki/BBCode">BBcode</a>!</p>
<h3>BBcode for the rescue!</h3>
<p>The above code is transformed to:</p>
<pre lang="html">
<a href="image.jpg" title="some [i]extra[/i]-long [b]description[/b]" rel="lightbox"><img src [...] /></a>
</pre>
<p>And some js magic:</p>
<pre lang="javascript">
String.prototype.replaceAll = function(strTarget, strSubString){
	var strText = this;
	var intIndexOfMatch = strText.indexOf( strTarget );
		while (intIndexOfMatch != -1){
 		strText = strText.replace( strTarget, strSubString )
		intIndexOfMatch = strText.indexOf( strTarget );
 	};
	return( strText );
};
</pre>
<p>The reason that we use this custom function is that the javascript internal <code>replace</code> function will work only for first item found. Now, if you use jQuery, you have to do this:</p>
<pre lang="javascript">
$('a[rel=lightbox]').each(function(){
	var t=$(this);
	t.attr( 'title', t.attr('title').replaceAll('[i]', '<em>').replaceAll('[/i]', '</em>').replaceAll('[b]', '<strong>').replaceAll('[/b]', '</strong>') )
}).lightBox();
</pre>
<p>What&#8217;s just happened? The BB code was replaced with html tags. Of course, if you need more tags, you can add it below <img src='http://dev.iamntz.com/wp-includes/images/smilies/wink.gif' alt=';)' class='wp-smiley' /> </p>
<h3>Be careful!</h3>
<p>I didn&#8217;t test it on large sets of images (i had only 6 to 12 images per page) so I have no idea if will affect the performance in any way!</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.iamntz.com/230/add-some-html-to-your-images-in-that-lightbox/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Simple jQuery Accordion tutorial</title>
		<link>http://dev.iamntz.com/166/jquery-accordion-tutorial</link>
		<comments>http://dev.iamntz.com/166/jquery-accordion-tutorial#comments</comments>
		<pubDate>Fri, 20 Mar 2009 15:21:57 +0000</pubDate>
		<dc:creator>Staicu IonuÈ›-Bogdan</dc:creator>
				<category><![CDATA[CSS/XHTML]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://dev.iamntz.com/?p=166</guid>
		<description><![CDATA[Today I will show you how you can do a small and very simple &#8211; yet powerful &#8211; accordion script. The html code is very basic and consist in a standard DL/DT/DD structure: Title Content Another title Another content Because &#8230; <a href="http://dev.iamntz.com/166/jquery-accordion-tutorial">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Today I will show you how you can do a small and very simple &#8211; yet powerful &#8211; accordion script.</p>
<p>The html code is very basic and consist in a standard DL/DT/DD structure:</p>
<pre lang="html" line="1">
<dl class="ntzAccordion">
<dt>Title</dt>
<dd>Content</dd>
<dt>Another title</dt>
<dd>Another content</dd>
</dl>
</pre>
<p>Because is very possible to want to use this kind of accordion in many places, i did a small function:</p>
<pre lang="javascript" line="1">
function ntzAccordion(e) {
	$(e).find('dd').hide();
	$(e).find('dt').bind('mouseover click', function(){
		if($(e).find('dd').is(':animated') || $(this).next('dd').is(':visible')) {return false;}
			$(e).find('dt.opened').removeClass('opened');
			$(e).find('dd:visible').slideUp('slow');
			$(this).next('dd').slideDown('slow').end().addClass('opened');
	});
	$(e).find('.active').trigger('click');
};//ntzAccordion
</pre>
<p>Of course, we don&#8217;t forget to call this function on page load:</p>
<pre lang="javascript" line="1">
$().ready(function(){
	ntzAccordion($('.ntzAccordion')); // we call function with DL selector as parameter
});
</pre>
<h3>Let&#8217;s see how is made</h3>
<p>1. We find all DD&#8217;s inside of the <code>e</code> variable (which is <code>$('.ntzAccordion')</code>) and we hide them;</p>
<p>2. We bind mouse over and click events on <code>DT</code>. You can have both or none of them (you can use almost all <a href="http://docs.jquery.com/Events">events available</a> on javascipt); Also, we will reffer to current <code>DT</code> as <code>$(this)</code>;</p>
<p>3. If there is a <code>DD</code> which is hiding or showing in that moment, we return false. This way you can avoid odd behaviour and jumps;</p>
<p>3.1. Also, we check to see if the &#8216;victim&#8217; (DD) is visible. Again, if this is visible, we return false to avoid repetitive close/open of <code>DD</code>;</p>
<p>4. We remove <code>.opened</code> class from all DT elements. We use this class to be able to add/change different style for different states of DT;</p>
<p>5. If there is an opened <code>DD</code>, we close it. </p>
<p>6. Because we use a structure like <code>DT/DD</code>, the next element right after DT is&#8230; a DD (doh!). We slide down that DD and we return back to DT (using <code>.end()</code>) and add the &#8216;opened&#8217; class. It&#8217;s the exactly the one that we remove few steps above;</p>
<p>7. If you want to have a default element that is opened on page load, this line will do the trick: we trigger an event that is binded few lines above.</p>
<p>8. You sit back and enjoy <img src='http://dev.iamntz.com/wp-includes/images/smilies/smile.gif' alt=':)' class='wp-smiley' />  8)</p>
<h3>Attention!</h3>
<p>For some reasons that I think is a jQuery bug, you need to add one for those extra CSS for DD&#8217;s:</p>
<ul>
<li>float:left;clear:left</li>
<li>position:relative</li>
<li>height:ZZpx;</li>
<li>width:ZZpx</li>
</ul>
<p>If you don&#8217;t do this way and the DD have padding/margin, you will have a weird (and annoying too!) jump when the accordion expands or contract.</p>
<p>Also, don&#8217;t forget to view source on demo page <img src='http://dev.iamntz.com/wp-includes/images/smilies/wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><a href="http://iamntz.com/experiments/tutorial-jquery/accordion.html"><img src="http://www.iamntz.com/demo.jpg" alt="Trhy it!"/></a></p>
]]></content:encoded>
			<wfw:commentRss>http://dev.iamntz.com/166/jquery-accordion-tutorial/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>jQuery 1.3 launched!</title>
		<link>http://dev.iamntz.com/147/jquery-13-launched</link>
		<comments>http://dev.iamntz.com/147/jquery-13-launched#comments</comments>
		<pubDate>Wed, 14 Jan 2009 16:03:04 +0000</pubDate>
		<dc:creator>Staicu IonuÈ›-Bogdan</dc:creator>
				<category><![CDATA[jquery]]></category>
		<category><![CDATA[Short news]]></category>

		<guid isPermaLink="false">http://dev.iamntz.com/?p=147</guid>
		<description><![CDATA[After exactly three years from the very first version, we jave jQuery 1.3. What&#8217;s new here? Sizzle: A sizzlin’ hot CSS selector engine. Live Events: Event delegation with a jQuery twist. jQuery Event Overhaul: Completely rewired to simplify event handling. &#8230; <a href="http://dev.iamntz.com/147/jquery-13-launched">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>After exactly three years from the very first version, we jave jQuery 1.3. What&#8217;s new here?</p>
<ul>
<li> Sizzle: A sizzlin’ hot CSS selector engine.</li>
<li> Live Events: Event delegation with a jQuery twist.</li>
<li> jQuery Event Overhaul: Completely rewired to simplify event handling.</li>
<li> HTML Injection Rewrite: Lightning-fast HTML appending.</li>
<li> Offset Rewrite: Super-quick position calculation.</li>
<li> No More Browser Sniffing: Using feature detection to help jQuery last for many more years to come</li>
<li>.hide() and .show() have been rewritten to become much faster. The frequently-used methods are now almost 2.5x faster. </li>
<li>Default animations have been smoothed. Traditionally show/hide and slideUp/slideDown have only animated width, height, and/or opacity. We&#8217;ve added in margin and padding as well to provide a smoother animation. More information: show, hide, toggle, slideDown, slideUp, slideToggle</li>
<li>and many, more. You can read full release post <a href="http://blog.jquery.com/2009/01/14/jquery-13-and-the-jquery-foundation/">here</a></li>
</ul>
<p>Long story short: we have a better library with a better than ever selector engine. We can now wait and wait for jQuery UI 1.6 final (now is on rc4) and we are all set <img src='http://dev.iamntz.com/wp-includes/images/smilies/biggrin.gif' alt=':D' class='wp-smiley' /><br />
Also, you can find a new <a href="http://api.jquery.com/">api documentation for jQuery </a>1.3. </p>
]]></content:encoded>
			<wfw:commentRss>http://dev.iamntz.com/147/jquery-13-launched/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Great news!</title>
		<link>http://dev.iamntz.com/132/great-news</link>
		<comments>http://dev.iamntz.com/132/great-news#comments</comments>
		<pubDate>Mon, 22 Dec 2008 18:10:03 +0000</pubDate>
		<dc:creator>Staicu IonuÈ›-Bogdan</dc:creator>
				<category><![CDATA[jquery]]></category>
		<category><![CDATA[Short news]]></category>

		<guid isPermaLink="false">http://dev.iamntz.com/?p=132</guid>
		<description><![CDATA[Well&#8230; jQuery 1.3 is out. It&#8217;s beta, but still! A brand new selector engine DOM manipulation engine has been almost rewritten Event Namespace rewritten. And more Go claim your copy and start testing! Also, the best IM client from the &#8230; <a href="http://dev.iamntz.com/132/great-news">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Well&#8230; jQuery 1.3 is out. It&#8217;s beta, but still!</p>
<ul>
<li>A brand new selector engine</li>
<li>DOM manipulation engine has been almost rewritten</li>
<li>Event Namespace rewritten.</li>
<li><a href="http://blog.jquery.com/2008/12/22/help-test-jquery-13-beta-1/">And more</a></li>
</ul>
<p>Go claim your copy and start testing! </p>
<p>Also, the best IM client from the ice age until now &#8211; pidgin &#8211; has a <a href="http://pidgin.im/">new improved version</a> 2.5.3.</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.iamntz.com/132/great-news/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A nice sortable trick (jQuery UI)</title>
		<link>http://dev.iamntz.com/101/a-nice-sortable-trick-jquery-ui</link>
		<comments>http://dev.iamntz.com/101/a-nice-sortable-trick-jquery-ui#comments</comments>
		<pubDate>Thu, 20 Nov 2008 13:51:32 +0000</pubDate>
		<dc:creator>Staicu IonuÈ›-Bogdan</dc:creator>
				<category><![CDATA[jquery]]></category>
		<category><![CDATA[Jquery UI]]></category>
		<category><![CDATA[Tips & tricks]]></category>

		<guid isPermaLink="false">http://dev.iamntz.com/?p=101</guid>
		<description><![CDATA[On a recent project i had to use sortable a LOT. I mean over 3-4 different sortable on page. So, how i manage to avoid heavy code? One function to rule them all: $('.sortable').each(function(){ var _t = $(this); _t.sortable({ handle:'.move', &#8230; <a href="http://dev.iamntz.com/101/a-nice-sortable-trick-jquery-ui">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>On a recent project i had to use sortable a LOT. I mean over 3-4 different sortable on page. So, how i manage to avoid heavy code?</p>
<p>One function to rule them all:</p>
<pre lang="javascript" line="1">
$('.sortable').each(function(){
	var _t = $(this);
	_t.sortable({
		handle:'.move',
		items:'dd',
		update:function(){
			$.ajax({
				type: "POST",
				url: $(this).find('a.move:eq(0)').attr('href'),
				data: _t.sortable('serialize'),
				cache: false
			});
		}
	});
});
</pre>
<p>The HTML markup (for two sortables) is this:</p>
<pre lang="html" line="1">
<dl class="sortable">
<dd id="sotableEl1-1"><a href="updateUrl.php?id=sortableID-1" class="move">move</a></dd>
<dd id="sotableEl1-2"><a href="updateUrl.php?id=sortableID-1" class="move">move</a></dd>
<dd id="sotableEl1-3"><a href="updateUrl.php?id=sortableID-1" class="move">move</a></dd>
</dl>
<dl class="sortable">
<dd id="sotableEl2-1"><a href="updateUrl.php?id=sortableID-2" class="move">move</a></dd>
<dd id="sotableEl2-2"><a href="updateUrl.php?id=sortableID-2" class="move">move</a></dd>
<dd id="sotableEl2-3"><a href="updateUrl.php?id=sortableID-2" class="move">move</a></dd>
</dl>
</pre>
<p>This means that you don&#8217;t need to use an ID for each sortable. Instead, you add the id to the update URL, on MOVE handler (which MUST be a link). I think this is pretty simple and useful trick.</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.iamntz.com/101/a-nice-sortable-trick-jquery-ui/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A VERY nice Modal box</title>
		<link>http://dev.iamntz.com/52/jquery-modal-lightbox-alternative</link>
		<comments>http://dev.iamntz.com/52/jquery-modal-lightbox-alternative#comments</comments>
		<pubDate>Thu, 25 Sep 2008 22:16:00 +0000</pubDate>
		<dc:creator>Staicu IonuÈ›-Bogdan</dc:creator>
				<category><![CDATA[Experiments]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://dev.iamntz.com/?p=52</guid>
		<description><![CDATA[How many times did you need a light modal box? To display an error mesage, a picture or even another web page inside of the current page? And every single time, you ended with using a large-full-of-useless-options script. Yeah, i &#8230; <a href="http://dev.iamntz.com/52/jquery-modal-lightbox-alternative">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>How many times did you need a light modal box? To display an error mesage, a picture or even another web page inside of the current page? And every single time, you ended with using a large-full-of-useless-options script. Yeah, i know the feeling. Seriously, i know it VERY well. That&#8217;s why i wrote this piece of code to display modal boxes <img src='http://dev.iamntz.com/wp-includes/images/smilies/smile.gif' alt=':)' class='wp-smiley' />  Anyhow, this works BEST with AJAX content <img src='http://dev.iamntz.com/wp-includes/images/smilies/wink.gif' alt=';)' class='wp-smiley' /> </p>
<h2>UPDATES: known issues</h2>
<p>If you need to display more content than fit into a screen height, you won&#8217;t see the content after the fold. To fix this, just remove the scroll bind on document:</p>
<pre lang="javascript">
(document).bind('scroll', function(){
		$('#ntz_modal').css({
			top:$(document).scrollTop()
		});
	});
</pre>
<h2>How to use?</h2>
<p>Just call with <code>modalBox('content', 200)</code> where <em>content</em> is what do you want to display (which can be an ajax result) and 200 is the width of the modal box. If you don&#8217;t specify any width, the default value (350) is used.</p>
<h2>How to close the modal box?</h2>
<p>Well&#8230; Just call the function <code>modalBox()</code>. When no parameter is passed, then the modal goes off. Nice, isn&#8217;t it? <img src='http://dev.iamntz.com/wp-includes/images/smilies/biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<h2>Browser compatibility</h2>
<p>The script was tested in FF 2, FF 3, IE 6, IE 7, Safari (on Win), Opera 9.5. If you don&#8217;t know what these letter means, there is a very high probability to don&#8217;t need this snippet <img src='http://dev.iamntz.com/wp-includes/images/smilies/wink.gif' alt=';)' class='wp-smiley' /> </p>
<h2>Selectboxes on IE6 &#8211; how they are managed?</h2>
<p>Very simple: i hide ALL selects when modal is shown and i show them back when modal is destroyed. Ofcourse, you can use bgiframe plugin. Which is </p>
<h2>Requirements</h2>
<p>The script is tested with last version of jQuery (1.2.6) but should work fine with previous (and ofcourse next) versions. If you use an ancient version, you may need some extra plugins (like dimensions)</p>
<h2>What&#8217;s the cost?</h2>
<p>Prepare you credit card, prepare you paypal account or whatever you want. Because this is totally FREE. You may use, modify and distribute whatever you like. A small link back would be nice (but <strong>NOT</strong> mandatory).</p>
<p>You bastard! You use your name in modal elements! Yeah, so? No, seriously, i used this way because there is no way to know what div did you use. And the chance to have a div called <code>ntz_modal</code> in your code is kinda.. hmm&#8230; Right! ZERO! Of course, you can change these ID&#8217;s whatever you like it <img src='http://dev.iamntz.com/wp-includes/images/smilies/smile.gif' alt=':)' class='wp-smiley' /> </p>
<h2>How do I get the code?</h2>
<p>Keep reading!<br />
<!--adsense--></p>
<pre lang="javascript" line="1">
var IE6 = false /*@cc_on || @_jscript_version < 5.7 @*/;
function modalBox(content, width, callback) {
	if(!content){
		$('#ntz_modal').remove();
		$('#ntz_overlay').fadeOut(function(){$(this).remove();});
		try{if(IE6){$('body').find('select.unhideThis').removeClass('unhideThis').visibility('visible');}}catch(err){};
		$('embed.unhideThis, object.unhideThis').removeClass('unhideThis').css('visibility', 'visible');
		return false;
	}
	try{if(IE6){$('body').find('select:visible').addClass('unhideThis').visibility('hidden');}}catch(err){};
	$('embed:visible, object:visible').addClass('unhideThis').css('visibility', 'hidden');
	$('body').append('
<div id="ntz_overlay"></div>

');
	$('#ntz_overlay').css({
		width		:	'100%',
		height		:	$(document).height(),
		position	:	'absolute',
		left		:	0,
		top		:	0,
		backgroundColor	:	'#FFFFFF',
		zIndex		:	9990,
		opacity		:	0
	}).fadeTo(200, 0.5);
	$('body').append('
<div id="ntz_modal"></div>

');
	$('#ntz_modal').css({
		border		:	'1px solid #2d7abb',
		width		:	width ? width : 350,
		backgroundColor	:	'#FFFFFF',
		position	:	'absolute',
		left		:	'50%',
		top		:	$(document).scrollTop(),
		zIndex		:	9995,
		marginLeft	:	-(Math.ceil((width ? width : 800)/2))
	}).append(content);
	$('#ntz_modal a:eq(0), #ntz_modal input, #ntz_modal textarea').focus();
	try{
		callback.call();
	}catch(err){};
	$(document).bind('scroll', function(){
		$('#ntz_modal').css({
			top:$(document).scrollTop()
		});
	});
};
</pre>
<p><a href="http://iamntz.com/experiments/modal.html"><img src="http://www.iamntz.com/demo.jpg" alt="" /></a><br />
Note: the example is VERY intrusive <img src='http://dev.iamntz.com/wp-includes/images/smilies/biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://dev.iamntz.com/52/jquery-modal-lightbox-alternative/feed</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>AutoCarousel &#8211; Let&#8217;s make things rolls!</title>
		<link>http://dev.iamntz.com/45/autocarousel-lets-make-things-rolls</link>
		<comments>http://dev.iamntz.com/45/autocarousel-lets-make-things-rolls#comments</comments>
		<pubDate>Fri, 12 Sep 2008 15:05:20 +0000</pubDate>
		<dc:creator>Staicu IonuÈ›-Bogdan</dc:creator>
				<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://dev.iamntz.com/?p=45</guid>
		<description><![CDATA[Ok, so it&#8217;s been a while, huh? I promised you i will learn how to autoslide previous carousel. Now you can find how (is ridiculous!) Ok, so we will use previous slider and we add this at the end of &#8230; <a href="http://dev.iamntz.com/45/autocarousel-lets-make-things-rolls">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Ok, so it&#8217;s been a while, huh? I promised you i will learn how to autoslide previous carousel. Now you can find how (is ridiculous!)</p>
<p>Ok, so we will use previous slider and we add this at the end of the script:</p>
<pre lang="javascript" line="1">
var slideThis = window.setInterval("$('.carousel').find('a.next').trigger('click')", 1000);
$('.carousel').bind('mouseenter', function(){
	window.clearInterval(slideThis);
}).bind('mouseleave', function(){
	slideThis = window.setInterval("$('.carousel').find('a.next').trigger('click')", 1000);
});
</pre>
<p>Ok, what happened? Well&#8230; let see:</p>
<p>1) We set an interval of how often carousel should ride. The time is in milliseconds, so 1000 is one second. If you want five seconds you put 5000 and so on. I defined a variable for slide because we want to be able to manipulate somehow. Every time you set a timer (either is setInterval or setTimeout) you will get an ID of that timer. If you don&#8217;t want to interact with slider, just remove the variable <img src='http://dev.iamntz.com/wp-includes/images/smilies/smile.gif' alt=':)' class='wp-smiley' /><br />
2) On <code>mouseenter</code> event, we clear the previous timer, based on previous ID;<br />
3) On <code>mouseleave</code> event we set the interval back. And&#8230; This is it <img src='http://dev.iamntz.com/wp-includes/images/smilies/biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>Ok, you may wonder why i used <code>mouseenter</code>/<code>mouseleave</code> events instead of <code>hover</code>. I don&#8217;t know if the problem is with jQuery or with Javascript (i admit, i DON&#8217;T know Javascript!), but when you use <code>hover</code>, on first element inside of your hovered element you will simply loose&#8230; hover. Is weird, sounds complicated, but if you try this, you will see what i mean <img src='http://dev.iamntz.com/wp-includes/images/smilies/wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><strong>But wait, what will I do if I have more than one slider?</strong><br />
As I said before, i suck at javascript. I know some basic timer tricks and&#8230; that&#8217;s it. Maybe is possible to use same function for many sliders, i don&#8217;t know. I never need more than one auto-slider on a page <img src='http://dev.iamntz.com/wp-includes/images/smilies/biggrin.gif' alt=':D' class='wp-smiley' />  Anyhow, i saw there is a problem with timers when you have too many (high CPU usage) so.. use carefully.</p>
<p><a href="http://iamntz.com/experiments/carousel/autoSlider.html"><img src="http://www.iamntz.com/demo.jpg" alt="" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://dev.iamntz.com/45/autocarousel-lets-make-things-rolls/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Advanced Carousel &#8211; Part II</title>
		<link>http://dev.iamntz.com/41/advanced-carousel-part-ii</link>
		<comments>http://dev.iamntz.com/41/advanced-carousel-part-ii#comments</comments>
		<pubDate>Sun, 17 Aug 2008 15:29:47 +0000</pubDate>
		<dc:creator>Staicu IonuÈ›-Bogdan</dc:creator>
				<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://dev.iamntz.com/?p=41</guid>
		<description><![CDATA[As i said before, i will show you some more nice tricks on that carousel. Today i will show you how can you put a fully automated pagination. How it works? A page have five items. So we need to &#8230; <a href="http://dev.iamntz.com/41/advanced-carousel-part-ii">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>As <a href="http://dev.iamntz.com/39/advanced-carousel">i said before</a>, i will show you some more nice tricks on that carousel. Today i will show you how can you put a fully automated pagination.</p>
<p>How it works?</p>
<p>A page have five items. So we need to scroll five items with one click. We take the full width of carousel items wrapper (<code>UL</code>) and divide to carousel width (<code>div.carousel</code>). To be sure we will have an integer number, we will round up the number (using <code>Math.ceil()</code>). After that, we will insert a link for each page between <em>previous</em> and <em>next</em> link. So, here how I did it: (to avoid confusion, i will use italics for <em>previous/next</em> links &#8211; which actually is the carousel control)<br />
<span id="more-41"></span><br />
Just before of closing carousel function (actually <code>each</code> loop), we add this lines:<br />
<!--adsense--></p>
<pre lang="javascript" line="1">
$(_this).find('a.prev').after('<span></span>');
for(i=0;i<Math.ceil($(_this).find('ul').width()/$(_this).width());i++){
	$(_this).find('.ctrls span').append('<a href="#">'+(i+1)+'</a>');
}
</pre>
<p><!--adsense--><br />
What is happening here? We insert a <code>span</code> tag just after the first existing link (<em>previous</em>). Then, for each available page, we add a link. For now, you will have NO action on that links.</p>
<pre lang="javascript" line="1">
$(_this).find('.ctrls span a').unbind().click(function(){
	var incrementWith = $(_this).find('.ctrls span a').index(this);
	$(_this).find('ul').animate({left:-(incrementWith*$(_this).width())},function(){
		carouselCtrls();
	});
	return false;
});
</pre>
<p>In other words you will detect which link was clicked and multiply his index with carousel width. Because index is starting with zero, page 1 will be the first.</p>
<p>Ok, that is all for today. In few days i will show you how to make this carousel to be autoscrolled on certain period of time. To give you a hint, i tell you it&#8217;s all about setInterval (javascript) and trigger (jquery) <img src='http://dev.iamntz.com/wp-includes/images/smilies/wink.gif' alt=';)' class='wp-smiley' />  Meanwhile, you can see a demo for this pagination <a href="http://iamntz.com/experiments/carousel/carousel2.html">HERE</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.iamntz.com/41/advanced-carousel-part-ii/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>jQuery UI Accordion jump bug</title>
		<link>http://dev.iamntz.com/40/jquery-ui-accordion-jump-bug</link>
		<comments>http://dev.iamntz.com/40/jquery-ui-accordion-jump-bug#comments</comments>
		<pubDate>Sat, 09 Aug 2008 22:37:11 +0000</pubDate>
		<dc:creator>Staicu IonuÈ›-Bogdan</dc:creator>
				<category><![CDATA[jquery]]></category>
		<category><![CDATA[Jquery UI]]></category>

		<guid isPermaLink="false">http://dev.iamntz.com/?p=40</guid>
		<description><![CDATA[If you ever used jQuery UI Accordion before, you probably notice that sometimes you have an annoyng bug when you change between accordion items: the bottom of the accordion jumps few pixels. Why is that? That&#8217;s why because Dimension plugins &#8230; <a href="http://dev.iamntz.com/40/jquery-ui-accordion-jump-bug">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>If you ever used jQuery UI Accordion before, you probably notice that sometimes you have an annoyng bug when you change between accordion items: the bottom of the accordion jumps few pixels. Why is that? That&#8217;s why because Dimension plugins (which  is included on last version of jquery, by the way) doesn&#8217;t know to compute very well the dimensions if you have padding/border attributes.</p>
<p>So, what can I do, perhaps you ask yourself?</p>
<ul>
<li>Don&#8217;t use padding and borders anymore. Uh&#8230; Not too reliable, isn&#8217;t? <img src='http://dev.iamntz.com/wp-includes/images/smilies/smile.gif' alt=':)' class='wp-smiley' /> </li>
<li>Use extra markup. Well&#8230; Is not too elegant, but is the best (and also the simplest) way to get rid of headaches! So the only thing you must do is to wrap all accordion item content into a div :</li>
</ul>
<p><span id="more-40"></span><br />
<!--adsense--></p>
<pre lang="html" line="1">
<dt>Accordion title</dt>
<dd>Accordion content</dd>
</pre>
<p>Becomes</p>
<pre lang="html" line="1">
<dt>Accordion title</dt>
<dd>
<div class="innerAccordion">Accordion content</div>
</dd>
</pre>
<p>All you have to do is to move all DD styles to <code>.innerAccordion</code> and your nightmares is GONE <img src='http://dev.iamntz.com/wp-includes/images/smilies/smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>By the way, in next few days (max a week) i will post the part II of the slider/carousel tutorial. All i have to do is to finish my curent projects (yeah, i have two <img src='http://dev.iamntz.com/wp-includes/images/smilies/angry.gif' alt=':(' class='wp-smiley' />  ). Anyway, stay close!</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.iamntz.com/40/jquery-ui-accordion-jump-bug/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Advanced Carousel</title>
		<link>http://dev.iamntz.com/39/advanced-carousel</link>
		<comments>http://dev.iamntz.com/39/advanced-carousel#comments</comments>
		<pubDate>Thu, 31 Jul 2008 21:40:25 +0000</pubDate>
		<dc:creator>Staicu IonuÈ›-Bogdan</dc:creator>
				<category><![CDATA[jquery]]></category>
		<category><![CDATA[Wordpress]]></category>
		<category><![CDATA[XHTML]]></category>

		<guid isPermaLink="false">http://dev.iamntz.com/?p=39</guid>
		<description><![CDATA[Ok, as ai said you before, i want to make a tutorial about a more advanced carousel than previous was. I won&#8217;t explain HTML and CSS code (is very simple and intutive): Previous Next CSS file: * {margin:0;padding:0;} .clearfix:after {content:".";display:block;height:0;clear:both;visibility:hidden} &#8230; <a href="http://dev.iamntz.com/39/advanced-carousel">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Ok, as ai said you before, i want to make a tutorial about a more advanced carousel than previous was. </p>
<p>I won&#8217;t explain HTML and CSS code (is very simple and intutive):</p>
<pre lang="html" line="1">
<div class="carousel">
<div class="ctrls">
		<a href="#" class="prev">Previous</a>
		<a href="#" class="next">Next</a>
	</div>
<ul class="clearfix">
<li><img src="http://farm4.static.flickr.com/3164/2719962411_77cf9e1699_t.jpg" alt="" /></li>
<li><img src="http://farm4.static.flickr.com/3159/2720786298_d33f97bfcd_t.jpg" alt="" /></li>
<li><img src="http://farm4.static.flickr.com/3280/2719962373_f49bb3e2a2_t.jpg" alt="" /></li>
<li><img src="http://farm4.static.flickr.com/3001/2720787742_d2f263372c_t.jpg" alt="" /></li>
<li><img src="http://farm4.static.flickr.com/3046/2720787680_8f358f938e_t.jpg" alt="" /></li>
<li><img src="http://farm4.static.flickr.com/3108/2719963843_f2e963af8f_t.jpg" alt="" /></li>
<li><img src="http://farm4.static.flickr.com/3141/2719965289_83902cf96c_t.jpg" alt="" /></li>
<li><img src="http://farm4.static.flickr.com/3164/2719962411_77cf9e1699_t.jpg" alt="" /></li>
<li><img src="http://farm4.static.flickr.com/3159/2720786298_d33f97bfcd_t.jpg" alt="" /></li>
<li><img src="http://farm4.static.flickr.com/3280/2719962373_f49bb3e2a2_t.jpg" alt="" /></li>
<li><img src="http://farm4.static.flickr.com/3001/2720787742_d2f263372c_t.jpg" alt="" /></li>
<li><img src="http://farm4.static.flickr.com/3046/2720787680_8f358f938e_t.jpg" alt="" /></li>
<li><img src="http://farm4.static.flickr.com/3108/2719963843_f2e963af8f_t.jpg" alt="" /></li>
<li><img src="http://farm4.static.flickr.com/3141/2719965289_83902cf96c_t.jpg" alt="" /></li>
</ul>
</div>
</pre>
<p>CSS file:</p>
<pre lang="css" line="1">
* {margin:0;padding:0;}

.clearfix:after {content:".";display:block;height:0;clear:both;visibility:hidden}
.clearfix {display:inline-block}
/* Hide from IE Mac \*/
.clearfix {display:block}
/* End hide from IE Mac */
* html .clearfix {height:1px}
.carousel {
	position: relative;
	overflow:hidden;
	height:500px;
	width:540px;
	margin:50px auto
}
	.carousel .ctrls {
		margin:10px
	}
	.carousel ul {
		position: absolute;
		width:8000px;
	}
		.carousel li {
			float:left;
			width:98px;
			height:98px;
			border: 1px solid #fff;
			list-style:none;
			margin-right:10px;
			text-align: center;
		}
</pre>
<p>The good part of this carousel is that you can have as many as you want in your page. You can have both fixed and fluid width and will work with no problem. Or at least no problem: on fluid layout, some images can be cutted. So, the best use is fixed width. Also, you can have autoscroll (with timers, i will say more later), but is not recommended because you may encounter some performance troubles.</p>
<p>After we include last version of <a href="http://jquery.com/">jQuery</a>, we have to do these things:</p>
<p>1) Iterate trough all <code>.carousel</code> containers (if you want to pick another name, this is the place and this is also the time!) and set the width. </p>
<pre lang="javascript" line="1">
$('.carousel').each(function(){
	var _this=this;
	var elWidth = $(_this).find('li:eq(0)').width()+12;
	$(_this).find('ul').width(elWidth*$(_this).find('li').length).css('left', 0);
});
</pre>
<p>We assume that all <code>LI</code> have same width, 10px margin and a border. So we adjust the width with 12 px (2px from border). If you have a wider margin (or none) change it, otherwise you will have some serious problems <img src='http://dev.iamntz.com/wp-includes/images/smilies/biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>The previous/next buttons we will control with a separate function, because we don&#8217;t have double scroll on double click, right? We put the function INSIDE of the <code>each</code> loop:</p>
<pre lang="javascript" line="1">
function carouselCtrls () {
	$(_this).find('a.prev').unbind().click(function(){
		$(this).unbind();
		if(parseInt($(_this).find('ul').css('left'))<0) {
			$(_this).find('ul').animate({
				left: '+='+elWidth
			}, function(){
				carouselCtrls();
			});
		}
		return false;
	});
	$(_this).find('a.next').unbind().click(function(){
		$(this).unbind();
		var maxWidth = (parseInt($(_this).find('ul').width())-$(_this).width()-10)-(-parseInt($(_this).find('ul').css('left')));
		if(maxWidth>0){

		$(_this).find('ul').animate({
			left: '-='+elWidth
		}, function(){
				carouselCtrls();
			});
		}else {
			$(_this).find('ul').animate({left:0},function(){
				carouselCtrls();
			});
		}
		return false;
	});
	};
</pre>
<p><!--adsense--><br />
Let see how it works (i will explain only one link because the other one works same &#8211; but reverted):<br />
<span id="more-39"></span></p>
<ol>
<li>Unbind any action from current link. This is because some users use double click on web (yes, there is some users like that!). So, once clicked, you can&#8217;t click again on the same link. Will won&#8217;t work. Seriously!</li>
<li>We verify if the carousel is scrolled, and if it is, to be scrolled enough to not be outside the area</li>
<li>Animate the carousel and call the control function after the animation is complete. After the animation is complete, you can click on the next/prev button</li>
</ol>
<p>So, the final code looks like this:</p>
<pre lang="javascript" line="1">
$('.carousel').each(function(){
	var _this=this;
	var elWidth = $(_this).find('li:eq(0)').width()+12;
	$(_this).find('ul').width(elWidth*$(_this).find('li').length).css('left', 0);
	carouselCtrls();

	function carouselCtrls () {
	$(_this).find('a.prev').unbind().click(function(){
		$(this).unbind();
		if(parseInt($(_this).find('ul').css('left'))<0) {
			$(_this).find('ul').animate({
				left: '+='+elWidth
			}, function(){
				carouselCtrls();
			});
		}
		return false;
	});
	$(_this).find('a.next').unbind().click(function(){
		$(this).unbind();
		var maxWidth = (parseInt($(_this).find('ul').width())-$(_this).width()-10)-(-parseInt($(_this).find('ul').css('left')));
		if(maxWidth>0){

		$(_this).find('ul').animate({
			left: '-='+elWidth
		}, function(){
				carouselCtrls();
			});
		}else {
			$(_this).find('ul').animate({left:0},function(){
				carouselCtrls();
			});
		}
		return false;
	});
	};
});
</pre>
<p><!--adsense--><br />
And that&#8217;s all!<br />
You can see a demo <a href="http://iamntz.com/experiments/carousel/">HERE</a>. In few days i will show you how to make a pagination on this carousel and how to make an autoscroll carousel <img src='http://dev.iamntz.com/wp-includes/images/smilies/smile.gif' alt=':)' class='wp-smiley' />  Stay tuned!</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.iamntz.com/39/advanced-carousel/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>One nice form trick</title>
		<link>http://dev.iamntz.com/36/one-nice-form-trick</link>
		<comments>http://dev.iamntz.com/36/one-nice-form-trick#comments</comments>
		<pubDate>Wed, 09 Jul 2008 16:48:44 +0000</pubDate>
		<dc:creator>Staicu IonuÈ›-Bogdan</dc:creator>
				<category><![CDATA[jquery]]></category>
		<category><![CDATA[Good to know]]></category>
		<category><![CDATA[How is made?]]></category>
		<category><![CDATA[How to]]></category>

		<guid isPermaLink="false">http://dev.iamntz.com/?p=36</guid>
		<description><![CDATA[One of the most useful thing on forms is an &#8220;autoselect&#8221; function. How is this work? Let&#8217;s assume that you have a standard search box: When textbox is focused you can do three things: Do nothing. Let the user to &#8230; <a href="http://dev.iamntz.com/36/one-nice-form-trick">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>One of the most useful thing on forms is an &#8220;autoselect&#8221; function. How is this work? Let&#8217;s assume that you have a standard search box:</p>
<p><img src="http://content.screencast.com/media/8cfff461-6694-44c8-a583-8c878c95a3e9_d7f54780-c151-49ea-a042-52aa03b281d6_static_0_0_2008-07-09_1941.png" alt=" " width="300" height="34" /></p>
<p>When textbox is focused you can do three things:</p>
<ol>
<li>Do nothing. Let the user to delete all text. Not good for lazy people, right? <img src='http://dev.iamntz.com/wp-includes/images/smilies/biggrin.gif' alt=':D' class='wp-smiley' /> </li>
<li>Autoclear box. But if user want only to change a letter (typo) or add another word, then he should re-type all things. Not good for usability.</li>
<li>Autoselect box content. Is just like the user double clicks on the text. How can you do this? Read further to see <img src='http://dev.iamntz.com/wp-includes/images/smilies/smile.gif' alt=':)' class='wp-smiley' /> </li>
</ol>
<pre lang="javascript" line="1">
var initValue;
$(document).ready(function(){
$(':text').each(function(){
	$(this).focus(function(){
		initValue = $(this).attr('value');
		$(this).select();
	});
	$(this).blur(function(){
		if($(this).val() == ''){
			$(this).val(initValue);
		}
	});
});
});
</pre>
<p>What is the best thing with this? Well&#8230; If an user just leave the text box blank, that form is auto filled with previous value.</p>
<p>Pretty nice, huh? Well&#8230; I think is pretty useful too <img src='http://dev.iamntz.com/wp-includes/images/smilies/smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><!--adsense--></p>
]]></content:encoded>
			<wfw:commentRss>http://dev.iamntz.com/36/one-nice-form-trick/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>jQuery AJAX trick (very useful!)</title>
		<link>http://dev.iamntz.com/34/jquery-ajax-trick-very-useful</link>
		<comments>http://dev.iamntz.com/34/jquery-ajax-trick-very-useful#comments</comments>
		<pubDate>Thu, 03 Jul 2008 00:28:22 +0000</pubDate>
		<dc:creator>Staicu IonuÈ›-Bogdan</dc:creator>
				<category><![CDATA[Advices]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[How is made?]]></category>

		<guid isPermaLink="false">http://dev.iamntz.com/?p=34</guid>
		<description><![CDATA[Did you ever ask yourself how can you display a &#8220;loading&#8221; indicator when you make ajax calls using various libraries? The simple but efficient answer is this: $(document).ready(function(){ $(' Loading... ') .ajaxStart(function() {$(this).show();}) .ajaxStop(function() {$(this).hide();}) .appendTo('body'); }); And that&#8217;s all. &#8230; <a href="http://dev.iamntz.com/34/jquery-ajax-trick-very-useful">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Did you ever ask yourself how can you display a &#8220;loading&#8221; indicator when you make ajax calls using various libraries?</p>
<p>The simple but efficient answer is this:</p>
<pre lang="javascript" line="1">
$(document).ready(function(){
$('
<div id="busy">Loading...</div>

')
        .ajaxStart(function() {$(this).show();})
        .ajaxStop(function() {$(this).hide();})
        .appendTo('body');
});
</pre>
<p>And that&#8217;s all. You need to do this only once.</p>
<p>Ofcourse, you can apply some CSS styles to #busy div, using an image generated with <a href="http://ajaxload.info/">ajaxload</a> or something similar.</p>
<p>I didn&#8217;t use any other libraries (actually i used prototype with scriptaculous sometime like AGES ago), but i think all cool libraries (like jQuery) have similar methods.</p>
<p>Another great news: with MORE than 50 fixes (but no new features tough) <a href="http://jquery.com/blog/2008/06/27/jquery-ui-151/">jQuery UI 1.5.1 is out</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.iamntz.com/34/jquery-ajax-trick-very-useful/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>jQuery UI 1.5</title>
		<link>http://dev.iamntz.com/25/jquery-ui-15</link>
		<comments>http://dev.iamntz.com/25/jquery-ui-15#comments</comments>
		<pubDate>Tue, 03 Jun 2008 07:07:17 +0000</pubDate>
		<dc:creator>Staicu IonuÈ›-Bogdan</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://dev.iamntz.com/?p=25</guid>
		<description><![CDATA[As you can read on the official blog, a new version of UI is available for download. Let&#8217;s see how good it is]]></description>
			<content:encoded><![CDATA[<p>As you can read on the <a href="http://jquery.com/blog/2008/06/02/jquery-ui-15-release-candidate-were-getting-excited/">official blog,</a> a new version of UI is available for download. Let&#8217;s see how good it is <img src='http://dev.iamntz.com/wp-includes/images/smilies/biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://dev.iamntz.com/25/jquery-ui-15/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple carousel (slider)</title>
		<link>http://dev.iamntz.com/24/simple-carousel-slider</link>
		<comments>http://dev.iamntz.com/24/simple-carousel-slider#comments</comments>
		<pubDate>Fri, 30 May 2008 16:42:05 +0000</pubDate>
		<dc:creator>Staicu IonuÈ›-Bogdan</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSS/XHTML]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[XHTML]]></category>

		<guid isPermaLink="false">http://dev.iamntz.com/?p=24</guid>
		<description><![CDATA[Ok, as i said before, i will make an article about what option you have when you want to use a carousel. As a jQuery user as I am, the first option i have is Sorgalla&#8217;s Carousel. It&#8217;s pretty easy &#8230; <a href="http://dev.iamntz.com/24/simple-carousel-slider">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Ok, as i said before, i will make an article about what option you have when you want to use a carousel. As a jQuery user as I am, the first option i have is <a href="http://sorgalla.com/projects/jcarousel/">Sorgalla&#8217;s Carousel</a>. It&#8217;s pretty easy to use but has some disadvantages:</p>
<ul>
<li>big size &#8211; around 50k, maybe more, without another 20k for jQuery</li>
<li>some IE6 problems &#8211; yes, IE6 still has a huge market share. We still need to pull out our hair to make this piece of crap display good all pages</li>
<li>you cannot highlight current tab &#8211; if you want to use it as a tab pagination, you simply cannot highlight selected tab. Or current page.</li>
</ul>
<p>So, on an older project of mine, i wanted to use a very light script for doing this. Because i was in a really rush, i didn&#8217;t  focus on unobtrusive scripts so i put some inline javascript (yes, shame on me).</p>
<pre lang="html" line="1">
<div id="slideCtrl">
 <a class="s1 s" onclick="showSlide(1);return false;" href="#">Tab 1</a>
 <a class="s2" onclick="showSlide(2);return false;" href="#">Tab 2</a>
 <a class="s3" onclick="showSlide(3);return false;" href="#">Tab 3</a></div>
</pre>
<p>Ok, this is for control. The most important thing is that you can put this ANYWHERE in your page. For example, you can put controls on header and slider on footer of your page. Only your imagination is the limit.</p>
<p>The next thing you have to do is to put some markup:</p>
<pre lang="html" line="1">
<div id="slider">
<div class="slider">
<div class="slideWrapper">
<div class="box">Tab 1 content</div>
<div class="box">Tab 2 content</div>
<div class="box">Tab 3 content</div>
</div>

<!--/.slideWrapper--></div>

<!--/.slider--></div>

<!--/slider--></pre>
<p>This script also has some limitation:</p>
<ul>
<li>You can have only one on page;</li>
<li>Is pretty obtrusive;</li>
<li>Doesn&#8217;t do auto slide. Of course, you can set a timer for this, but i wanted an easy example.</li>
</ul>
<h3>The next thing we have to do is to set some CSS.</h3>
<p>Width and height for carousel:</p>
<pre lang="css">#slider {
	width:674px;
	height:185px;
}
</pre>
<p><span id="more-24"></span><!--adsense--><br />
The magic of this script (and also of all carousel scripts) consists in playing with position relative and position absolute:</p>
<pre lang="css">#slider .slider {
	width:660px;
	overflow:hidden;
	margin:0 auto;
	position: relative;
	height:160px;
}
#slider .slideWrapper {
	width:2640px;
	position: absolute;
	height:160px;
}
</pre>
<p>The <code>slideWrapper</code> container must have a big width: a tab width * number of tabs. If you have five tabs with 500px wide each, the slideWrapper must have around 2500px wide (even more, nobody will be upset).</p>
<p>The next thing we have to stylize is each tab-box (.box). For this, we need to float each box:</p>
<pre lang="css">#slider .box {
	width:660px;
	float:left;
	padding:20px 0;
}</pre>
<p>The result will be a wide container which has all boxes on one row. Well.. The html/css part is ends here. The next is&#8230; Javascript (or jQuery) part.</p>
<p>The most basic use is this:</p>
<pre lang="javascript">var currentslide = 1
function showSlide(nrSld) {
	currentslide = parseInt(nrSld)
	$('#slider .slideWrapper').animate({left:-660*(parseInt(nrSld)-1)})
	redrawBullets(nrSld);
};
</pre>
<p>What we do? Long story short: we move the <code>slideWrapper</code> container in its parent from left to right and from right to left, according to our needs. Simple, eh?</p>
<p>The <code>redrawBullets</code> function is for highlighting the current selection:</p>
<pre lang="javascript">function redrawBullets(slide) {
	var currentBullet = 's'+slide;
	$('#slideCtrl a').each(function(){
	$(this).removeClass('s');
	if($(this).hasClass(currentBullet)){
		$(this).addClass('s')
		}
	});
};
</pre>
<p>What do we need next? Well.. We only need to test. Here it is a <a href="http://www.iamntz.com/portfolio/writing%20school%20wp-theme/page1.html">demo </a>(is already used in a site). If you want, you can use <a href="http://gsgd.co.uk/sandbox/jquery/easing/">EaseIn </a>plugin to add some nice effects on slide.</p>
<p>We have a nice tabbed based navigation with a very cool effect which is ready to use on your site.</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.iamntz.com/24/simple-carousel-slider/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Playing with lists</title>
		<link>http://dev.iamntz.com/10/playing-with-lists</link>
		<comments>http://dev.iamntz.com/10/playing-with-lists#comments</comments>
		<pubDate>Wed, 14 May 2008 14:01:49 +0000</pubDate>
		<dc:creator>Staicu IonuÈ›-Bogdan</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[CSS/XHTML]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[XHTML]]></category>

		<guid isPermaLink="false">http://dev.iamntz.com/?p=10</guid>
		<description><![CDATA[In this article we will be playing with list elements to create amazing menus. Most html menus are created using list because LI tag is the most appropiate tag for this, giving the developer posibility to play in many ways, &#8230; <a href="http://dev.iamntz.com/10/playing-with-lists">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>In this article we will be playing with list elements to create amazing menus. </p>
<p>Most html menus are created using list because LI tag is the most appropiate tag for this, giving the developer posibility to play in many ways, achivieng nice effects. I won&#8217;t touch the vertical lists because it&#8217;s their default display. Instead, i will cover some of horizontal lists.</p>
<h3>Basic list</h3>
<p>The basic setup for a horizontal list is to set float to list elements:</p>
<pre lang="html">
<ul id="list1">
<li><a href="#">Menu item 1</a></li>
<li><a href="#">Menu item 2</a></li>
<li><a href="#">Menu item 3</a></li>
<li><a href="#">Menu item 4</a></li>
</ul>
</pre>
<pre lang="css">#list1 li {
	float:left;
	list-style:none;
	margin-right:10px;
}
</pre>
<p>At this point we have a one level horizontal menu, created with list and you can see this on many (and i mean MANY) sites. Ofcourse, you can add some extra styles such as border, background (color or image) for links inside <code>LI</code> elements for getting even a nicer look. <a href="http://iamntz.com/experiments/playing-with-list/floating.html">Demo here</a>.</p>
<h3>One level drop down menu (suckerfish)</h3>
<p><span id="more-10"></span></p>
<p>The next menu i show, is a little bit more complicated, but also is more useful when you have category and sub-category. For example, imagine this blog with main category Javascript and sub-category jQuery. If i had many sub-categories, i would probably used a dropdown menu for using less space. This kind of menu is named <a href="http://www.alistapart.com/articles/dropdowns">Suckerfish (A list apart)</a>.</p>
<p>For this, we will use nested list and we will show only parents:</p>
<pre lang="html">
<ul id="list2">
<li><a href="#">Menu item 1</a>
<ul>
<li><a href="#">Sub menu 1</a></li>
<li><a href="#">Sub menu 1</a></li>
<li><a href="#">Sub menu 1</a></li>
<li><a href="#">Sub menu 1</a></li>
</ul>
</li>
<li><a href="#">Menu item 2</a>
<ul>
<li><a href="#">Sub menu 1</a></li>
<li><a href="#">Sub menu 1</a></li>
<li><a href="#">Sub menu 1</a></li>
<li><a href="#">Sub menu 1</a></li>
</ul>
</li>
<li><a href="#">Menu item 3</a>
<ul>
<li><a href="#">Sub menu 1</a></li>
<li><a href="#">Sub menu 1</a></li>
<li><a href="#">Sub menu 1</a></li>
<li><a href="#">Sub menu 1</a></li>
</ul>
</li>
<li><a href="#">Menu item 4</a></li>
</ul>
</pre>
<p>Ofcourse, we still need to float first level in the same way as we did in first example:</p>
<pre lang="css">#list2 li {
	float:left;
	list-style:none;
	margin-right:10px;
}
</pre>
<p>I said before we will hide all nested list elements, so here we go:</p>
<pre lang="css">#list2 li ul{
	display:none
}
</pre>
<p>Right now, we have a basic horizontal list. Next step is to show second level of list on hover. Because IE6 don&#8217;t know what is hover on all elements (only on <code>A</code> tag), for this browser we will use some javascript (but later).</p>
<pre lang="css">#list2 li:hover ul{
	display:block
}
</pre>
<p>Because we need to have a nice display for submenus, we have to relatively positioning main <code>LI</code> tags, so on the <code>#list2 li</code> rules add</p>
<pre lang="css">	position:relative
</pre>
<p>Also, the inner <code>UL</code> tags we need to change to:</p>
<pre lang="css">#list2 li ul{
	display:none;
	position: absolute;
	left:0;
	top:1em;
	width:150px;
}
</pre>
<p>In this point we have a very basic suckerfish menu that works on all browser except, ofcourse, IE6 <img src='http://dev.iamntz.com/wp-includes/images/smilies/biggrin.gif' alt=':D' class='wp-smiley' />  As i said before, we will make a little javascript snippet for adding or remove <code>over</code> class for LI elements. If you are using jQuery (like i do), the whole thing is easier than you think:</p>
<pre lang="javascript">	var IE6 = false /*@cc_on || @_jscript_version &lt; 5.7 @*/;
	if(IE6){$(#list2 li).hover(function(){$(this).addClass('over')}, function(){$(this).removeClass('over')})}
</pre>
<p>If you don&#8217;t want to use a javascript library (either you have a small page or you like to develop your own code), you can use next code (and add just before body tag closes):</p>
<pre lang="javascript">var IE6 = false /*@cc_on || @_jscript_version &lt; 5.7 @*/;
if(IE6){
	startList = function() {
		navRoot = document.getElementById('list2');
		for (i=0; i</pre>
<p>Well&#8230; Yes, that&#8217;s all. We only need to add an extra rule on CSS and <code>#list2 li:hover ul</code> become:</p>
<pre lang="css">	#list2 li:hover ul,
	#list2 li.over ul
</pre>
<p>At this point we have a fully functional suckerfish menu (but still with an ugly look), working on all modern browsers (even IE6). You can see the demo <a href="http://iamntz.com/experiments/playing-with-list/suckerfish.html">here</a>.</p>
<h3>Breadcrumb</h3>
<p>This one is one of my favorite toys <img src='http://dev.iamntz.com/wp-includes/images/smilies/biggrin.gif' alt=':D' class='wp-smiley' />  With this type of menu we get a &#8220;vista explorer look&#8221; breadcrumb, ready to use on your site. We will use same markup as suckerfish and also a library (i like jQuery, so i will use it)</p>
<pre lang="javascript">$(document).ready(function(){
	$('ul#list2 ul').toggle().hide();
	$('ul#list2 ul').parent('li').append('<a class="dropDown" href="#">-</a>');
	$('a.dropDown').click(function(){
		var t=this;
		$('ul#list2 ul').not($(t).parent('li').find('ul')).hide();
		$(t).parent('li').find('ul').toggle();
		$(document).unbind('click').click(function(e){
			if($(e.target).parents('ul#list2').length>1){
				$('ul#list2 ul').hide();
			}
		})

		return false;
	})
});
</pre>
<p>You can see<a href="http://iamntz.com/experiments/playing-with-list/breadcrumb.html">here</a> the demo.</p>
<p>Ofcourse, you may want to change the content for drop down links (you may want to put an arrow, your choice) for even a nicer and authentic effect.</p>
<h3>Conclusion</h3>
<p>List is so simple yet so powerful tools available for creating nice menus (the final results is up to your imagination). The final result is cross browser (yes, even IE6!), the code make sense (is semanticaly, right?) and if you don&#8217;t have javascript enabled, you can still use drop down menus (for this time not in IE6 <img src='http://dev.iamntz.com/wp-includes/images/smilies/angry.gif' alt=':(' class='wp-smiley' />  ). With a little imagination, you are able to create even nicer menus. For example, i made some time ago a scrollable menu, like iPhone menus (yes, with nested lists!). I didn&#8217;t spend too much time with it (so it won&#8217;t work too well) and i conssidered useless to post here.</p>
<p>What kind of menus do you use?</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.iamntz.com/10/playing-with-lists/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

