<?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>cssgallery.info &#187; Tutorials</title>
	<atom:link href="http://cssgallery.info/category/tutorials/feed/" rel="self" type="application/rss+xml" />
	<link>http://cssgallery.info</link>
	<description>Resources for web developers</description>
	<lastBuildDate>Sun, 11 Jul 2010 16:19:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Making a combo-box in Titanium Appcelerator &#8211; code and video</title>
		<link>http://cssgallery.info/making-a-combo-box-in-titanium-appcelerator-code-and-video/</link>
		<comments>http://cssgallery.info/making-a-combo-box-in-titanium-appcelerator-code-and-video/#comments</comments>
		<pubDate>Sat, 29 May 2010 10:08:12 +0000</pubDate>
		<dc:creator>Dan Tamas</dc:creator>
				<category><![CDATA[Development tools]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[demo]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[getSelectedRow]]></category>
		<category><![CDATA[iphone combobox]]></category>
		<category><![CDATA[iphone tutorial]]></category>
		<category><![CDATA[picker_view]]></category>
		<category><![CDATA[textField]]></category>
		<category><![CDATA[titanium appcelerator combobox]]></category>
		<category><![CDATA[titanium tutorial]]></category>

		<guid isPermaLink="false">http://cssgallery.info/?p=1221</guid>
		<description><![CDATA[A true iPhone or Ipad combobox that allows you to use  the same textfield to input arbitrary text or select a value from a UIPicker element. All built with Titanium Appcelerator to include in your iPhone application.]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><!--S-ButtonZ 1.1.5 End--><div class="tweetmeme_button" style="float: right; margin: 10px !important;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcssgallery.info%2Fmaking-a-combo-box-in-titanium-appcelerator-code-and-video%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcssgallery.info%2Fmaking-a-combo-box-in-titanium-appcelerator-code-and-video%2F&amp;source=dan_tamas&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Sometimes we need a true combobox for our projects but iPhone SDK does not have a native one (at least from what I know)  and  of course neither has Titanium. </p>
<p>So we will build one. A &#8220;true&#8221; iPhone or Ipad combobox that allows you to use  the same textfield to input arbitrary text or select a value from a UIPicker element.</p>
<p>Updated with <a href="http://twitter.com/CJ_Reed">@CJ_Reed&#8217;s</a> screenshot and code at the final of the tutorial.</p>
<p>Let&#8217;s see the video first, then we&#8217;ll get to work:</p>
<p><object width="650" height="400"><param name="movie" value="http://www.youtube.com/v/2H-w_hUQtPw&#038;hl=en&#038;fs=1&#038;rel=0"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/2H-w_hUQtPw&#038;hl=en&#038;fs=1&#038;rel=0" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="650" height="400"></embed></object></p>
<h2>Ok, what do we need for this iPhone combobox ?</h2>
<p>First of all we need a <strong>textField</strong> to accept input from the user. Titanium lets you set the <strong>leftButton</strong> and <strong>rightButton</strong> for this <strong>textField</strong> while constructing it. So we will take advantage of this and create a textField as it follows:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> my_combo <span style="color: #339933;">=</span> Titanium.<span style="color: #660066;">UI</span>.<span style="color: #660066;">createTextField</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
	hintText<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;write your name or select one&quot;</span><span style="color: #339933;">,</span>
	height<span style="color: #339933;">:</span><span style="color: #CC0000;">40</span><span style="color: #339933;">,</span>
	width<span style="color: #339933;">:</span><span style="color: #CC0000;">300</span><span style="color: #339933;">,</span>
	top<span style="color: #339933;">:</span><span style="color: #CC0000;">20</span><span style="color: #339933;">,</span>
	borderStyle<span style="color: #339933;">:</span>Titanium.<span style="color: #660066;">UI</span>.<span style="color: #660066;">INPUT_BORDERSTYLE_ROUNDED</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Nothing special, a regular <strong>textField</strong> with a hint for the user  that will disappear when the <strong>textField</strong> has a value.</p>
<p>Now we need to create the <strong>rightButton</strong> for it.</p>
<p>We will  use a system button provided by Apple (<strong>Titanium.UI.iPhone.SystemButton.DISCLOSURE</strong>)  only that we will rotate it 90 degrees to server our purpose. This is the code that creates the <strong>rightButton</strong> and the transformation applied to it.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> tr <span style="color: #339933;">=</span> Titanium.<span style="color: #660066;">UI</span>.<span style="color: #660066;">create2DMatrix</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
tr <span style="color: #339933;">=</span> tr.<span style="color: #660066;">rotate</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">90</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> drop_button <span style="color: #339933;">=</span>  Titanium.<span style="color: #660066;">UI</span>.<span style="color: #660066;">createButton</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
		style<span style="color: #339933;">:</span>Titanium.<span style="color: #660066;">UI</span>.<span style="color: #660066;">iPhone</span>.<span style="color: #660066;">SystemButton</span>.<span style="color: #660066;">DISCLOSURE</span><span style="color: #339933;">,</span>
		transform<span style="color: #339933;">:</span>tr
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Now that we have the <strong>rightButton</strong> as we need it, the <strong>textField</strong> constructor becomes:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> my_combo <span style="color: #339933;">=</span> Titanium.<span style="color: #660066;">UI</span>.<span style="color: #660066;">createTextField</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
	hintText<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;write your name or select one&quot;</span><span style="color: #339933;">,</span>
	height<span style="color: #339933;">:</span><span style="color: #CC0000;">40</span><span style="color: #339933;">,</span>
	width<span style="color: #339933;">:</span><span style="color: #CC0000;">300</span><span style="color: #339933;">,</span>
	top<span style="color: #339933;">:</span><span style="color: #CC0000;">20</span><span style="color: #339933;">,</span>
	borderStyle<span style="color: #339933;">:</span>Titanium.<span style="color: #660066;">UI</span>.<span style="color: #660066;">INPUT_BORDERSTYLE_ROUNDED</span><span style="color: #339933;">,</span>
	rightButton<span style="color: #339933;">:</span>drop_button<span style="color: #339933;">,</span>
	rightButtonMode<span style="color: #339933;">:</span>Titanium.<span style="color: #660066;">UI</span>.<span style="color: #660066;">INPUT_BUTTONMODE_ALWAYS</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Please note the <strong>rightButtonMode:Titanium.UI.INPUT_BUTTONMODE_ALWAYS</strong> declaration, it makes this button visible all the time.</p>
<p>This is how it looks:</p>
<p><img class="alignnone size-full wp-image-1223" title="iPhone combobox with Titanium" src="http://cssgallery.info/wp-content/uploads/2010/05/capture-11.png" alt="iPhone combobox with Titanium" width="400" height="83" /></p>
<p>Pretty sexy, isn&#8217;t it? Well we&#8217;re not done yet.</p>
<h2>Building the modal picker</h2>
<p>When the user focuses on the <strong>textField</strong>, the keyboard appears &#8211; so we will have to build our <strong>picker</strong> to emulate the same behaviour and to maximize the usability of our form. For this we will need a <strong>Picker</strong>  and two buttons: <strong>Done</strong> and <strong>Cancel</strong>. These two buttons will be positioned in a <strong>Toolbar</strong>, again, to  emulate as good as possible the keyboard behaviour.</p>
<p>Let&#8217;s build everything:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> picker_view <span style="color: #339933;">=</span> Titanium.<span style="color: #660066;">UI</span>.<span style="color: #660066;">createView</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
	height<span style="color: #339933;">:</span><span style="color: #CC0000;">251</span><span style="color: #339933;">,</span>
	bottom<span style="color: #339933;">:</span><span style="color: #CC0000;">0</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> cancel <span style="color: #339933;">=</span>  Titanium.<span style="color: #660066;">UI</span>.<span style="color: #660066;">createButton</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
	title<span style="color: #339933;">:</span><span style="color: #3366CC;">'Cancel'</span><span style="color: #339933;">,</span>
	style<span style="color: #339933;">:</span>Titanium.<span style="color: #660066;">UI</span>.<span style="color: #660066;">iPhone</span>.<span style="color: #660066;">SystemButtonStyle</span>.<span style="color: #660066;">BORDERED</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> done <span style="color: #339933;">=</span>  Titanium.<span style="color: #660066;">UI</span>.<span style="color: #660066;">createButton</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
	title<span style="color: #339933;">:</span><span style="color: #3366CC;">'Done'</span><span style="color: #339933;">,</span>
	style<span style="color: #339933;">:</span>Titanium.<span style="color: #660066;">UI</span>.<span style="color: #660066;">iPhone</span>.<span style="color: #660066;">SystemButtonStyle</span>.<span style="color: #660066;">DONE</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> spacer <span style="color: #339933;">=</span>  Titanium.<span style="color: #660066;">UI</span>.<span style="color: #660066;">createButton</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
	systemButton<span style="color: #339933;">:</span>Titanium.<span style="color: #660066;">UI</span>.<span style="color: #660066;">iPhone</span>.<span style="color: #660066;">SystemButton</span>.<span style="color: #660066;">FLEXIBLE_SPACE</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> toolbar <span style="color: #339933;">=</span>  Titanium.<span style="color: #660066;">UI</span>.<span style="color: #660066;">createToolbar</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
	top<span style="color: #339933;">:</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span>
	items<span style="color: #339933;">:</span><span style="color: #009900;">&#91;</span>cancel<span style="color: #339933;">,</span>spacer<span style="color: #339933;">,</span>done<span style="color: #009900;">&#93;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> picker <span style="color: #339933;">=</span> Titanium.<span style="color: #660066;">UI</span>.<span style="color: #660066;">createPicker</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
		top<span style="color: #339933;">:</span><span style="color: #CC0000;">43</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
picker.<span style="color: #660066;">selectionIndicator</span><span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> picker_data <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>
	Titanium.<span style="color: #660066;">UI</span>.<span style="color: #660066;">createPickerRow</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>title<span style="color: #339933;">:</span><span style="color: #3366CC;">'John'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	Titanium.<span style="color: #660066;">UI</span>.<span style="color: #660066;">createPickerRow</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>title<span style="color: #339933;">:</span><span style="color: #3366CC;">'Alex'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	Titanium.<span style="color: #660066;">UI</span>.<span style="color: #660066;">createPickerRow</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>title<span style="color: #339933;">:</span><span style="color: #3366CC;">'Marie'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	Titanium.<span style="color: #660066;">UI</span>.<span style="color: #660066;">createPickerRow</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>title<span style="color: #339933;">:</span><span style="color: #3366CC;">'Eva'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
	Titanium.<span style="color: #660066;">UI</span>.<span style="color: #660066;">createPickerRow</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>title<span style="color: #339933;">:</span><span style="color: #3366CC;">'James'</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
picker.<span style="color: #660066;">add</span><span style="color: #009900;">&#40;</span>picker_data<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
picker_view.<span style="color: #660066;">add</span><span style="color: #009900;">&#40;</span>toolbar<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
picker_view.<span style="color: #660066;">add</span><span style="color: #009900;">&#40;</span>picker<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The code is a little long but is not rocket science. Some stuff to talk about though:</p>
<ul>
<li>Everyting is wrapped inside a view &#8211; <strong>picker_view</strong> &#8211;  because we will have to animate like the keyboard does, so it&#8217;s faster to animate one element only.</li>
<li>The height of <strong>picker_view</strong> is the height of the <strong>toolbar</strong> (43px) + the height of the <strong>picker</strong> (208px). How do I know this? I just used a ruler <img src='http://cssgallery.info/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' />  </li>
</ul>
<p>The combobox interface looks like this:</p>
<p><img class="alignnone size-full wp-image-1226" title="picker Titanium for combobox" src="http://cssgallery.info/wp-content/uploads/2010/05/capture-2.png" alt="picker Titanium for combobox" width="326" height="465" /></p>
<h2>Creating the picker animation</h2>
<p>We also need to create 2 animations: <strong>slide_in</strong> and <strong>slide_out</strong>. We will animate the <strong>bottom</strong> property of the <strong>picker_view</strong>. We will need to start with the <strong>picker_view</strong> off the screen, so we will build it with:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"> bottom<span style="color: #339933;">:-</span><span style="color: #CC0000;">251</span></pre></div></div>

<p>instead of 0 as it was initially.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> slide_in <span style="color: #339933;">=</span>  Titanium.<span style="color: #660066;">UI</span>.<span style="color: #660066;">createAnimation</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>bottom<span style="color: #339933;">:</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> slide_out <span style="color: #339933;">=</span>  Titanium.<span style="color: #660066;">UI</span>.<span style="color: #660066;">createAnimation</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>bottom<span style="color: #339933;">:-</span><span style="color: #CC0000;">251</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The logic behind the animations is this:</p>
<ul>
<li>The user focuses the <strong>textField</strong> &#8211;  the keyboard appears ( it&#8217;s done by the OS , no worries here) and if the <strong>picker_view</strong> is visible we need to hide it.</li>
<li>The user clicks the <strong>rightButton</strong> &#8211; we need to hide the keyboard and show the <strong>picker_view</strong>.</li>
</ul>
<p>Here is the code:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">my_combo.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'focus'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	picker_view.<span style="color: #660066;">animate</span><span style="color: #009900;">&#40;</span>slide_out<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
drop_button.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	picker_view.<span style="color: #660066;">animate</span><span style="color: #009900;">&#40;</span>slide_in<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	my_combo.<span style="color: #000066;">blur</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
cancel.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	picker_view.<span style="color: #660066;">animate</span><span style="color: #009900;">&#40;</span>slide_out<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>I also added the click event on the <strong>cancel</strong> button to hide the <strong>picker_view</strong>.</p>
<h2>Filling the textField with the picker&#8217;s value</h2>
<p>The only thing we have left is to actually put the value of the picker in the <strong>my_combo</strong> textField when the user clicks the <strong>done</strong> button  and hide the <strong>picker_view</strong>.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">done.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	my_combo.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span>  picker.<span style="color: #660066;">getSelectedRow</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">title</span><span style="color: #339933;">;</span>
	picker_view.<span style="color: #660066;">animate</span><span style="color: #009900;">&#40;</span>slide_out<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The <strong>getSelectedRow</strong> method of the picker is returning the selected row, and we use its <strong>title</strong>. The <strong>getSelectedRow</strong> argument is the <strong>index</strong> of the columns in the <strong>picker</strong>, and since we have only one, this is <strong>0</strong>.</p>
<h2>Download the project</h2>
<p>The Resource folder of the project can be downloaded from <a href="http://cssgallery.info/wp-content/combobox_tutorial.zip">here</a>.</p>
<p>Everything is MIT licensed, but as usual, spread the word <img src='http://cssgallery.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h2>We have an update</h2>
<p><a href="http://twitter.com/CJ_Reed">@CJ_Reed</a> used this tutorial &#8220;to produce multiple selection type data entry in a single window.&#8221;<br />
Here is how it looks like:<br />
<img src="http://cssgallery.info/wp-content/uploads/2010/05/large_multiCombo.jpg" alt="to produce multiple selection type data entry in a single window." title="multiple selection type data entry in a single window." width="550" height="254" class="alignnone size-full wp-image-1251" /><br />
You can take a look at he&#8217;s code <a href="http://www.pastie.org/983594">here</a>.<br />
Great work!</p>
<p><strong class="spanish">Check the Spanish version of this post:<br />
 <a href="http://nosoloweb.es/haciendo-una-lista-de-opciones-desplegables-en-titanium-appcelerator-codigo-y-video-2/" rel="me">Haciendo una lista de opciones desplegables en Titanium Appcelerator – Código y Vídeo</a></strong></p>
<div style="clear:both;">&nbsp;</div>

<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-knowledge">
<ul class="socials">
		<li class="shr-dzone">
			<a href="http://www.dzone.com/links/add.html?url=http://cssgallery.info/making-a-combo-box-in-titanium-appcelerator-code-and-video/&amp;title=Making+a+combo-box+in+Titanium+Appcelerator+-+code+and+video+&amp;description=A%20true%20iPhone%20or%20Ipad%20combobox%20that%20allows%20you%20to%20use%20%20the%20same%20textfield%20to%20input%20arbitrary%20text%20or%20select%20a%20value%20from%20a%20UIPicker%20element.%20All%20built%20with%20Titanium%20Appcelerator%20to%20include%20in%20your%20iPhone%20application." rel="nofollow" class="external" title="Add this to DZone">Add this to DZone</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://cssgallery.info/making-a-combo-box-in-titanium-appcelerator-code-and-video/&amp;title=Making+a+combo-box+in+Titanium+Appcelerator+-+code+and+video+" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://cssgallery.info/making-a-combo-box-in-titanium-appcelerator-code-and-video/&amp;title=Making+a+combo-box+in+Titanium+Appcelerator+-+code+and+video+" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://cssgallery.info/making-a-combo-box-in-titanium-appcelerator-code-and-video/&amp;title=Making+a+combo-box+in+Titanium+Appcelerator+-+code+and+video+" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://cssgallery.info/making-a-combo-box-in-titanium-appcelerator-code-and-video/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://cssgallery.info/making-a-combo-box-in-titanium-appcelerator-code-and-video/&amp;title=Making+a+combo-box+in+Titanium+Appcelerator+-+code+and+video+" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://cssgallery.info/making-a-combo-box-in-titanium-appcelerator-code-and-video/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://cssgallery.info/making-a-combo-box-in-titanium-appcelerator-code-and-video/&amp;t=Making+a+combo-box+in+Titanium+Appcelerator+-+code+and+video+" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-evernote">
			<a href="http://www.evernote.com/clip.action?url=http://cssgallery.info/making-a-combo-box-in-titanium-appcelerator-code-and-video/&amp;title=Making+a+combo-box+in+Titanium+Appcelerator+-+code+and+video+" rel="nofollow" class="external" title="Clip this to Evernote">Clip this to Evernote</a>
		</li>
		<li class="shr-googlereader">
			<a href="http://www.google.com/reader/link?url=http://cssgallery.info/making-a-combo-box-in-titanium-appcelerator-code-and-video/&amp;title=Making+a+combo-box+in+Titanium+Appcelerator+-+code+and+video+&amp;srcUrl=http://cssgallery.info/making-a-combo-box-in-titanium-appcelerator-code-and-video/&amp;srcTitle=Making+a+combo-box+in+Titanium+Appcelerator+-+code+and+video+&amp;snippet=A%20true%20iPhone%20or%20Ipad%20combobox%20that%20allows%20you%20to%20use%20%20the%20same%20textfield%20to%20input%20arbitrary%20text%20or%20select%20a%20value%20from%20a%20UIPicker%20element.%20All%20built%20with%20Titanium%20Appcelerator%20to%20include%20in%20your%20iPhone%20application." rel="nofollow" class="external" title="Add this to Google Reader">Add this to Google Reader</a>
		</li>
		<li class="shr-meneame">
			<a href="http://meneame.net/submit.php?url=http://cssgallery.info/making-a-combo-box-in-titanium-appcelerator-code-and-video/" rel="nofollow" class="external" title="Submit this to Meneame">Submit this to Meneame</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://cssgallery.info/making-a-combo-box-in-titanium-appcelerator-code-and-video/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Create a countdown timer with Titanium Appcelerator</title>
		<link>http://cssgallery.info/create-a-countdown-timer-with-titanium-appcelerator/</link>
		<comments>http://cssgallery.info/create-a-countdown-timer-with-titanium-appcelerator/#comments</comments>
		<pubDate>Thu, 27 May 2010 13:37:18 +0000</pubDate>
		<dc:creator>Dan Tamas</dc:creator>
				<category><![CDATA[Development tools]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[appcelearor]]></category>
		<category><![CDATA[countdoun timer]]></category>
		<category><![CDATA[counter]]></category>
		<category><![CDATA[reset timer]]></category>
		<category><![CDATA[set timer]]></category>
		<category><![CDATA[start timer]]></category>
		<category><![CDATA[stop timer]]></category>
		<category><![CDATA[timer]]></category>
		<category><![CDATA[titanium]]></category>
		<category><![CDATA[titanium tutorial]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://cssgallery.info/?p=1048</guid>
		<description><![CDATA[How to create a countdown timer for your iPhone with Titanium Appcelerator. Source code available for download. ]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><!--S-ButtonZ 1.1.5 End--><div class="tweetmeme_button" style="float: right; margin: 10px !important;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcssgallery.info%2Fcreate-a-countdown-timer-with-titanium-appcelerator%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcssgallery.info%2Fcreate-a-countdown-timer-with-titanium-appcelerator%2F&amp;source=dan_tamas&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>In this post we will try to show you how to make a countdown timer using Titanium Appcelerator for Iphone or Android applications.  </p>
<p>First we will create an <strong>OOP countDown</strong> object that can be used independently in the background of the application and then we will connect it with some interface elements.</p>
<h3>The countDown object</h3>
<p>To have functional a countdown timer we&#8217;ll need to declare some properties and some methods.</p>
<p>As properties we will set:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">time<span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span> m <span style="color: #339933;">:</span> minutes<span style="color: #339933;">,</span> s <span style="color: #339933;">:</span> seconds <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
total_seconds <span style="color: #339933;">:</span> m<span style="color: #339933;">*</span><span style="color: #CC0000;">60</span><span style="color: #339933;">+</span>s</pre></div></div>

<p>I think this is pretty clear, <strong>time</strong> is an object with minutes and seconds and <strong>total_seconds</strong> contains the number of seconds until we reach 00:00.</p>
<p>We will need to set methods that will allow us to:</p>
<ul>
<li><strong>set</strong> a time to count from</li>
<li><strong>stop</strong> the timer </li>
<li><strong>start</strong> it.</li>
</ul>
<p>We also ned to set some callback functions that will be executed on each tick of the timer   &#8211; <strong> fn_tick</strong> &#8211;  and one that will execute when the timer reaches 00:00 named <strong>fn_end.</strong></p>
<p>We won&#8217;t make a callback for start because we know when this occurs  we can trigger it by ourselves.</p>
<h2>The countDown timer will look like this:</h2>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> my_timer <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> countDown<span style="color: #009900;">&#40;</span> minutes<span style="color: #339933;">,</span> seconds<span style="color: #339933;">,</span> fn_tick<span style="color: #339933;">,</span> fn_complete<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>on this we will be able to apply</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">my_timer.<span style="color: #660066;">set</span><span style="color: #009900;">&#40;</span> minutes<span style="color: #339933;">,</span> seconds <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
my_timer.<span style="color: #660066;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
my_tmer.<span style="color: #000066;">stop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Below is the code that defines the countDown (pretty simple).</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> countDown <span style="color: #339933;">=</span>  <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span> m <span style="color: #339933;">,</span> s<span style="color: #339933;">,</span> fn_tick<span style="color: #339933;">,</span> fn_end  <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#123;</span>
		total_sec<span style="color: #339933;">:</span>m<span style="color: #339933;">*</span><span style="color: #CC0000;">60</span><span style="color: #339933;">+</span>s<span style="color: #339933;">,</span>
		timer<span style="color: #339933;">:</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">timer</span><span style="color: #339933;">,</span>
		set<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>m<span style="color: #339933;">,</span>s<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">total_sec</span> <span style="color: #339933;">=</span> parseInt<span style="color: #009900;">&#40;</span>m<span style="color: #009900;">&#41;</span><span style="color: #339933;">*</span><span style="color: #CC0000;">60</span><span style="color: #339933;">+</span>parseInt<span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">time</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>m<span style="color: #339933;">:</span>m<span style="color: #339933;">,</span>s<span style="color: #339933;">:</span>s<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
		start<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003366; font-weight: bold;">var</span> self <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">timer</span> <span style="color: #339933;">=</span> setInterval<span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>self.<span style="color: #660066;">total_sec</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					self.<span style="color: #660066;">total_sec</span><span style="color: #339933;">--;</span>
					self.<span style="color: #660066;">time</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span> m <span style="color: #339933;">:</span> parseInt<span style="color: #009900;">&#40;</span>self.<span style="color: #660066;">total_sec</span><span style="color: #339933;">/</span><span style="color: #CC0000;">60</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> s<span style="color: #339933;">:</span> <span style="color: #009900;">&#40;</span>self.<span style="color: #660066;">total_sec</span><span style="color: #339933;">%</span>60<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
					fn_tick<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
				<span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
					self.<span style="color: #000066;">stop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					fn_end<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
				<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">1000</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
		<span style="color: #000066;">stop</span><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			clearInterval<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">timer</span><span style="color: #009900;">&#41;</span>
			<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">time</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>m<span style="color: #339933;">:</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span>s<span style="color: #339933;">:</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">total_sec</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>And now to use it in our code we will do something like this:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> my_timer <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> countDown<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span> <span style="color: #339933;">,</span> <span style="color: #CC0000;">5</span> <span style="color: #339933;">,</span>
	<span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>	<span style="color: #009900;">&#123;</span>
		<span style="color: #006600; font-style: italic;">//something here...</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
	<span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #006600; font-style: italic;">// something here...</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
my_timer.<span style="color: #660066;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Ok, the above example is useless, we will need to display the current time on each tick of the countdown times (so on each second) and at the end we&#8217;ll have to alert the user when we reached 00:00.</p>
<p>We will also need some interface elements to access the countdown methods and to display the current time.</p>
<p>For this we will create a label named <strong>display_lbl</strong>, that will show the time and also 3 buttons : <strong>set_btn</strong> , <strong>start_btn</strong> and <strong>stop_btn</strong>.</p>
<p>Creating the code is pretty simple so I won&#8217;t put the code here but you will be able to take a look at it <a href="http://cssgallery.info/wp-content/countdown_tutorial.zip">downloading the countdown project</a>.</p>
<p>What is most important is to connect the interface with the countdown timer.</p>
<p>So we create the timer  and set the <strong>fn_tick</strong> and <strong>fn_end</strong> functions</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> my_timer <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> countDown<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">5</span><span style="color: #339933;">,</span><span style="color: #CC0000;">30</span><span style="color: #339933;">,</span> 
		<span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			display_lbl.<span style="color: #660066;">text</span> <span style="color: #339933;">=</span> my_timer.<span style="color: #660066;">time</span>.<span style="color: #660066;">m</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot; : &quot;</span><span style="color: #339933;">+</span>my_timer.<span style="color: #660066;">time</span>.<span style="color: #660066;">s</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
		<span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;The time is up!&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>And this is how we connect the buttons with <strong>my_timer</strong></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">&nbsp;
set_btn.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	display_lbl.<span style="color: #660066;">text</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;5 : 30&quot;</span><span style="color: #339933;">;</span>
	my_timer.<span style="color: #660066;">set</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">5</span><span style="color: #339933;">,</span><span style="color: #CC0000;">30</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
stop_btn.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	my_timer.<span style="color: #000066;">stop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
start_btn.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	my_timer.<span style="color: #660066;">start</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>As you see we also set the label&#8217;s text to the initial value when we set the timer because otherwise we&#8217;ll loose the first second. We do this here to keep the timer object clean of any external interaction so we can use it even without an interface.</p>
<h2>This is how the final project looks like</h2>
<p><img src="http://cssgallery.info/wp-content/uploads/2010/05/capture-1.png" alt="Countdown timer with Appcelerator" title="Countdown timer with Appcelerator" width="464" height="558" class="alignnone size-full wp-image-1208" /></p>
<p>Please keep in mind that this is just a simple example and we don&#8217;t have a control mechanism to detect when the user stopped the timer or it reached by itself 00:00 &#8211; but you can add it as an exercise <img src='http://cssgallery.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>You can download the <strong>Resources</strong> folder of the  project from <a href="http://cssgallery.info/wp-content/countdown_tutorial.zip">here</a>.</p>
<p>Everything is MIT licensed and you can use it in any application you want to, but spreading the word would be nice.</p>
<p><strong class="spanish">Check the Spanish version of this post:<br />
<a href="http://nosoloweb.es/crear-un-temporizador-regresivo-con-titanium-appcelerator/" rel="me">Crear un temporizador regresivo con Titanium Appcelerator</a></strong></p>
<div style="clear:both;">&nbsp;</div>

<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-knowledge">
<ul class="socials">
		<li class="shr-dzone">
			<a href="http://www.dzone.com/links/add.html?url=http://cssgallery.info/create-a-countdown-timer-with-titanium-appcelerator/&amp;title=Create+a+countdown+timer+with+Titanium+Appcelerator&amp;description=How%20to%20create%20a%20countdown%20timer%20for%20your%20iPhone%20with%20Titanium%20Appcelerator.%20Source%20code%20available%20for%20download.%20" rel="nofollow" class="external" title="Add this to DZone">Add this to DZone</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://cssgallery.info/create-a-countdown-timer-with-titanium-appcelerator/&amp;title=Create+a+countdown+timer+with+Titanium+Appcelerator" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://cssgallery.info/create-a-countdown-timer-with-titanium-appcelerator/&amp;title=Create+a+countdown+timer+with+Titanium+Appcelerator" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://cssgallery.info/create-a-countdown-timer-with-titanium-appcelerator/&amp;title=Create+a+countdown+timer+with+Titanium+Appcelerator" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://cssgallery.info/create-a-countdown-timer-with-titanium-appcelerator/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://cssgallery.info/create-a-countdown-timer-with-titanium-appcelerator/&amp;title=Create+a+countdown+timer+with+Titanium+Appcelerator" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://cssgallery.info/create-a-countdown-timer-with-titanium-appcelerator/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://cssgallery.info/create-a-countdown-timer-with-titanium-appcelerator/&amp;t=Create+a+countdown+timer+with+Titanium+Appcelerator" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-evernote">
			<a href="http://www.evernote.com/clip.action?url=http://cssgallery.info/create-a-countdown-timer-with-titanium-appcelerator/&amp;title=Create+a+countdown+timer+with+Titanium+Appcelerator" rel="nofollow" class="external" title="Clip this to Evernote">Clip this to Evernote</a>
		</li>
		<li class="shr-googlereader">
			<a href="http://www.google.com/reader/link?url=http://cssgallery.info/create-a-countdown-timer-with-titanium-appcelerator/&amp;title=Create+a+countdown+timer+with+Titanium+Appcelerator&amp;srcUrl=http://cssgallery.info/create-a-countdown-timer-with-titanium-appcelerator/&amp;srcTitle=Create+a+countdown+timer+with+Titanium+Appcelerator&amp;snippet=How%20to%20create%20a%20countdown%20timer%20for%20your%20iPhone%20with%20Titanium%20Appcelerator.%20Source%20code%20available%20for%20download.%20" rel="nofollow" class="external" title="Add this to Google Reader">Add this to Google Reader</a>
		</li>
		<li class="shr-meneame">
			<a href="http://meneame.net/submit.php?url=http://cssgallery.info/create-a-countdown-timer-with-titanium-appcelerator/" rel="nofollow" class="external" title="Submit this to Meneame">Submit this to Meneame</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://cssgallery.info/create-a-countdown-timer-with-titanium-appcelerator/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to make a glowing menu with MooTools in 3 easy steps</title>
		<link>http://cssgallery.info/how-to-make-a-glowing-menu-with-mootools-in-3-easy-steps/</link>
		<comments>http://cssgallery.info/how-to-make-a-glowing-menu-with-mootools-in-3-easy-steps/#comments</comments>
		<pubDate>Wed, 28 Apr 2010 12:11:17 +0000</pubDate>
		<dc:creator>Dan Tamas</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[MooTools]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[glowing menu]]></category>
		<category><![CDATA[how to make a menu]]></category>
		<category><![CDATA[javascript menu]]></category>
		<category><![CDATA[mootools tutorial]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://cssgallery.info/?p=906</guid>
		<description><![CDATA[<h3>Ingredients:</h3> sprites, unorderdered lists, Mootools knowledge.
<h3>Cooking time:</h3> 1 hr
<h3>Result:</h3>
Can be seen on our website -  <a title="Rborn web development agency" href="http://rborn.info" target="_blank">Rborn Web development</a> -  mouse-over the top menu.
<img class="alignnone size-full wp-image-907" title="Rborn web development glowing menu" src="http://cssgallery.info/wp-content/uploads/2010/04/capture-13.png" alt="Rborn web development glowing menu" width="380" height="110" />]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><!--S-ButtonZ 1.1.5 End--><div class="tweetmeme_button" style="float: right; margin: 10px !important;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcssgallery.info%2Fhow-to-make-a-glowing-menu-with-mootools-in-3-easy-steps%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcssgallery.info%2Fhow-to-make-a-glowing-menu-with-mootools-in-3-easy-steps%2F&amp;source=dan_tamas&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p><strong>Ingredients:</strong> sprites, unorderdered lists, Mootools knowledge.<br />
<strong>Cooking time:</strong> 1 hr<br />
<strong>Result:</strong><br />
Can be seen on our website &#8211;  <a title="Rborn web development agency" href="http://rborn.info" target="_blank">Rborn Web development</a> &#8211;  mouse-over the top menu.<br />
<img class="alignnone size-full wp-image-907" title="Rborn web development glowing menu" src="http://cssgallery.info/wp-content/uploads/2010/04/capture-13.png" alt="Rborn web development glowing menu" width="380" height="110" /></p>
<h2>Preparation of the Mootools glowing menu</h2>
<p>The menu is a list containing an <strong>A</strong> tag for each menu item. We are using <em>sprites</em> and <em>text-indent:-5000px</em> for accessibility purposes. <strong>The trick</strong> is that we use the image <strong>positioned top for LI</strong> and <strong>bottom for A HREF</strong></p>
<p><img class="alignnone size-full wp-image-908" title="menu sprite" src="http://cssgallery.info/wp-content/uploads/2010/04/capture-23.png" alt="" width="83" height="151" /></p>
<h2>Step 1: cook the HTML code</h2>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;ul id=&quot;mainnav&quot;&gt;
&lt;li&gt;&lt;a href=&quot;/&quot;&gt;home&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot;&gt;products&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot;&gt;portfolio&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;/blog/&quot;&gt;news&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;#&quot;&gt;contact&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</pre></div></div>

<h2>Step 2: add the CSS code</h2>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">li<span style="color: #6666ff;">.home</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">&quot;../img/home.png&quot;</span><span style="color: #00AA00;">&#41;</span> <span style="color: #000000; font-weight: bold;">top</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
li<span style="color: #6666ff;">.home</span> a <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">29px</span><span style="color: #00AA00;">;</span>background<span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">&quot;../img/home.png&quot;</span><span style="color: #00AA00;">&#41;</span> <span style="color: #000000; font-weight: bold;">bottom</span> <span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>This is the positioning of the background image I was talking about earlier.<br />
Now the magic of the glowing is made with few lines of code using MooTools.</p>
<h2>Step 3: spice with MooTools code</h2>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'mainnav'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getElements</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'li a'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #000066; font-weight: bold;">item</span>.<span style="color: #660066;">hasClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'clicked'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">item</span>.<span style="color: #660066;">setStyle</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'opacity'</span><span style="color: #339933;">,</span><span style="color: #CC0000;">0.01</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addEvent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'mouseenter'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>        
<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">fade</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addEvent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'mouseleave'</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">fade</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0.01</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>The code is triggered either on <strong>domready</strong> event, or put inside a <strong>script</strong> tag just before the body ends  so have the dom loaded and ready to be accessed by javascript.</p>
<p>Basically all we are doing is to get all the <strong>A</strong> tags inside the menu, set the opacity to <strong>0.01</strong> because if you set it to <strong>0</strong> MooTools will add <strong>display:none</strong> to the style and the links won&#8217;t be visible anymore.</p>
<p>Further we play with the <strong>fade</strong> method to increase the <strong>opacity</strong> to <strong>1</strong> or decrease back to <strong>0.01</strong> on the <strong>mouseenter</strong> and <strong>mouseleave</strong> event.</p>
<p>We also check if the menu is active or not &#8211; we are on the menu  page or not &#8211;  verifying if the item has a <strong>class &#8216;clicked&#8217;</strong>, set by the backend. If the item contains this class  we simply leave it alone and the item is <strong>&#8216;on&#8217;</strong> all the time.</p>
<p>That&#8217;s it. Let me know your thoughts.</p>
<p><strong class="spanish">Check the Spanish version of this post:<br />
<a href="http://nosoloweb.es/como-hacer-menu-brillante-mootools/" rel="me">Cómo hacer un menú brillante con MooTools en 3 pasos</a></strong></p>
<div style="clear:both;">&nbsp;</div>

<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-knowledge">
<ul class="socials">
		<li class="shr-dzone">
			<a href="http://www.dzone.com/links/add.html?url=http://cssgallery.info/how-to-make-a-glowing-menu-with-mootools-in-3-easy-steps/&amp;title=How+to+make+a+glowing+menu+with+MooTools+in+3+easy+steps&amp;description=Ingredients%3A%20sprites%2C%20unorderdered%20lists%2C%20Mootools%20knowledge.%0D%0ACooking%20time%3A%201%20hr%0D%0AResult%3A%0D%0ACan%20be%20seen%20on%20our%20website%20-%20%20Rborn%20Web%20development%20-%20%20mouse-over%20the%20top%20menu.%0D%0A" rel="nofollow" class="external" title="Add this to DZone">Add this to DZone</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://cssgallery.info/how-to-make-a-glowing-menu-with-mootools-in-3-easy-steps/&amp;title=How+to+make+a+glowing+menu+with+MooTools+in+3+easy+steps" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://cssgallery.info/how-to-make-a-glowing-menu-with-mootools-in-3-easy-steps/&amp;title=How+to+make+a+glowing+menu+with+MooTools+in+3+easy+steps" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://cssgallery.info/how-to-make-a-glowing-menu-with-mootools-in-3-easy-steps/&amp;title=How+to+make+a+glowing+menu+with+MooTools+in+3+easy+steps" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://cssgallery.info/how-to-make-a-glowing-menu-with-mootools-in-3-easy-steps/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://cssgallery.info/how-to-make-a-glowing-menu-with-mootools-in-3-easy-steps/&amp;title=How+to+make+a+glowing+menu+with+MooTools+in+3+easy+steps" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://cssgallery.info/how-to-make-a-glowing-menu-with-mootools-in-3-easy-steps/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://cssgallery.info/how-to-make-a-glowing-menu-with-mootools-in-3-easy-steps/&amp;t=How+to+make+a+glowing+menu+with+MooTools+in+3+easy+steps" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-evernote">
			<a href="http://www.evernote.com/clip.action?url=http://cssgallery.info/how-to-make-a-glowing-menu-with-mootools-in-3-easy-steps/&amp;title=How+to+make+a+glowing+menu+with+MooTools+in+3+easy+steps" rel="nofollow" class="external" title="Clip this to Evernote">Clip this to Evernote</a>
		</li>
		<li class="shr-googlereader">
			<a href="http://www.google.com/reader/link?url=http://cssgallery.info/how-to-make-a-glowing-menu-with-mootools-in-3-easy-steps/&amp;title=How+to+make+a+glowing+menu+with+MooTools+in+3+easy+steps&amp;srcUrl=http://cssgallery.info/how-to-make-a-glowing-menu-with-mootools-in-3-easy-steps/&amp;srcTitle=How+to+make+a+glowing+menu+with+MooTools+in+3+easy+steps&amp;snippet=Ingredients%3A%20sprites%2C%20unorderdered%20lists%2C%20Mootools%20knowledge.%0D%0ACooking%20time%3A%201%20hr%0D%0AResult%3A%0D%0ACan%20be%20seen%20on%20our%20website%20-%20%20Rborn%20Web%20development%20-%20%20mouse-over%20the%20top%20menu.%0D%0A" rel="nofollow" class="external" title="Add this to Google Reader">Add this to Google Reader</a>
		</li>
		<li class="shr-meneame">
			<a href="http://meneame.net/submit.php?url=http://cssgallery.info/how-to-make-a-glowing-menu-with-mootools-in-3-easy-steps/" rel="nofollow" class="external" title="Submit this to Meneame">Submit this to Meneame</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://cssgallery.info/how-to-make-a-glowing-menu-with-mootools-in-3-easy-steps/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Crossbrowser CSS dropshadows</title>
		<link>http://cssgallery.info/crossbrowsing-css-dropshadows/</link>
		<comments>http://cssgallery.info/crossbrowsing-css-dropshadows/#comments</comments>
		<pubDate>Mon, 26 Apr 2010 09:50:30 +0000</pubDate>
		<dc:creator>Lucica Ibanescu</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[crossbrowser]]></category>
		<category><![CDATA[dropshadow]]></category>
		<category><![CDATA[IE-compatible]]></category>
		<category><![CDATA[shadow]]></category>

		<guid isPermaLink="false">http://cssgallery.info/?p=769</guid>
		<description><![CDATA[Very simple problem with a pretty complicated solution, mostly because IE is ignoring the <strong>box-shadow</strong> CSS3 property. Instead <strong>progid:DXImageTransform.Microsoft.Shadow</strong> is doing the trick for it and an equivalent can be found. 

The result?
<img src="http://cssgallery.info/wp-content/uploads/2010/04/dropshadows-in-mozilla-and-internet-explorer.png" alt="crossbrowser dropshadows in mozilla and internet explorer" title="dropshadows-in-mozilla-and-internet-explorer" width="440" height="210" class="alignleft size-full wp-image-770" />
]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><!--S-ButtonZ 1.1.5 End--><div class="tweetmeme_button" style="float: right; margin: 10px !important;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcssgallery.info%2Fcrossbrowsing-css-dropshadows%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcssgallery.info%2Fcrossbrowsing-css-dropshadows%2F&amp;source=dan_tamas&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Very simple problem with a pretty complicated solution, mostly because IE is ignoring the <strong>box-shadow</strong> CSS3 property. Instead <strong>progid:DXImageTransform.Microsoft.Shadow</strong> is doing the trick for it and an equivalent can be found.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">box-shadow<span style="color: #00AA00;">:</span> <span style="color: #933;">4px</span> <span style="color: #933;">4px</span> <span style="color: #933;">8px</span> <span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span></pre></div></div>

<p> for the white shadow is visually-similar to</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">progid<span style="color: #3333ff;">:DXImageTransform</span><span style="color: #6666ff;">.Microsoft</span>.Shadow<span style="color: #00AA00;">&#40;</span><span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">=</span><span style="color: #cc00cc;">#000000</span><span style="color: #00AA00;">,</span><span style="color: #000000; font-weight: bold;">direction</span><span style="color: #00AA00;">=</span><span style="color: #cc66cc;">90</span><span style="color: #00AA00;">,</span>strength<span style="color: #00AA00;">=</span><span style="color: #cc66cc;">8</span><span style="color: #00AA00;">&#41;</span></pre></div></div>

<p>because <strong>box-shadow</strong> has the parameters:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">horizontal-offset<span style="color: #00AA00;">,</span> vertical-offset<span style="color: #00AA00;">,</span> blur-radius<span style="color: #00AA00;">,</span> <span style="color: #000000; font-weight: bold;">color</span></pre></div></div>

<p>and <strong>progid:DXImageTransform.Microsoft.Shadow</strong>:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">,</span> 
<span style="color: #000000; font-weight: bold;">direction</span> <span style="color: #00AA00;">&#40;</span><span style="color: #cc66cc;">90</span> for <span style="color: #000000; font-weight: bold;">right</span> <span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">,</span> it can also be <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">45</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">135</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">180</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">225</span><span style="color: #00AA00;">,</span> <span style="color: #cc66cc;">270</span> and <span style="color: #cc66cc;">315</span> <span style="color: #00AA00;">&#41;</span>
strength <span style="color: #00AA00;">&#40;</span>the distance<span style="color: #00AA00;">,</span> in pixels<span style="color: #00AA00;">,</span> that a filter effect extends - more like the combination of <span style="color: #933;">4px</span> <span style="color: #933;">4px</span> in the box-shadow<span style="color: #00AA00;">&#41;</span></pre></div></div>

<p>What it doesn&#8217;t have is the blur-radius. Altough progid:DXImageTransform.Microsoft.Blur exist, it will blur the content of the box too, making the text unreadable.</p>
<p>The result is quite similar, with some small differences in how IE displays the corners. As you can see the top-right corner and the bottom-right corner are a mess (the bottom-left doesn&#8217;t feel very well either), but let&#8217;s be grateful they exist&#8230;</p>
<p><img src="http://cssgallery.info/wp-content/uploads/2010/04/dropshadows-in-mozilla-and-internet-explorer.png" alt="crossbrowser dropshadows in mozilla and internet explorer" title="dropshadows-in-mozilla-and-internet-explorer" width="440" height="210" class="size-full wp-image-770" /></p>
<p>You can <a href="http://cssgallery.info/wp-content/CSS-drop-shadow/index.php" target="_blank">check the demo link</a> if you want to play with other browsers.<br />
The complete CSS code for all browsers is:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.black-shadow</span> <span style="color: #00AA00;">&#123;</span> 
-moz-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #933;">4px</span> <span style="color: #933;">4px</span> <span style="color: #933;">8px</span> <span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span>
-webkit-box-shadow<span style="color: #00AA00;">:</span> <span style="color: #933;">4px</span> <span style="color: #933;">4px</span> <span style="color: #933;">8px</span> <span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span>
box-shadow<span style="color: #00AA00;">:</span> <span style="color: #933;">4px</span> <span style="color: #933;">4px</span> <span style="color: #933;">8px</span> <span style="color: #cc00cc;">#000</span><span style="color: #00AA00;">;</span>
&nbsp;
filter<span style="color: #00AA00;">:</span> progid<span style="color: #3333ff;">:DXImageTransform</span><span style="color: #6666ff;">.Microsoft</span><span style="color: #6666ff;">.Shadow</span> <span style="color: #00AA00;">&#40;</span><span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">=</span><span style="color: #cc00cc;">#000000</span><span style="color: #00AA00;">,</span><span style="color: #000000; font-weight: bold;">direction</span><span style="color: #00AA00;">=</span><span style="color: #cc66cc;">90</span><span style="color: #00AA00;">,</span>strength<span style="color: #00AA00;">=</span><span style="color: #cc66cc;">8</span><span style="color: #00AA00;">&#41;</span>
        progid<span style="color: #3333ff;">:DXImageTransform</span><span style="color: #6666ff;">.Microsoft</span><span style="color: #6666ff;">.Shadow</span> <span style="color: #00AA00;">&#40;</span><span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">=</span><span style="color: #cc00cc;">#000000</span><span style="color: #00AA00;">,</span><span style="color: #000000; font-weight: bold;">direction</span><span style="color: #00AA00;">=</span><span style="color: #cc66cc;">180</span><span style="color: #00AA00;">,</span>strength<span style="color: #00AA00;">=</span><span style="color: #cc66cc;">8</span><span style="color: #00AA00;">&#41;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p><strong class="spanish">Check the Spanish version of this post:<br />
<a href="http://nosoloweb.es/sombras-css3-crossbrowser/" rel="me">Sombras CSS en múltiples navegadores</a></strong></p>
<div style="clear:both;">&nbsp;</div>

<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-knowledge">
<ul class="socials">
		<li class="shr-dzone">
			<a href="http://www.dzone.com/links/add.html?url=http://cssgallery.info/crossbrowsing-css-dropshadows/&amp;title=Crossbrowser+CSS+dropshadows&amp;description=Very%20simple%20problem%20with%20a%20pretty%20complicated%20solution%2C%20mostly%20because%20IE%20is%20ignoring%20the%20box-shadow%20CSS3%20property.%20Instead%20progid%3ADXImageTransform.Microsoft.Shadow%20is%20doing%20the%20trick%20for%20it%20and%20an%20equivalent%20can%20be%20found.%20%0D%0A%0D%0AThe%20result%3F%0D%0A%0D%0A" rel="nofollow" class="external" title="Add this to DZone">Add this to DZone</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://cssgallery.info/crossbrowsing-css-dropshadows/&amp;title=Crossbrowser+CSS+dropshadows" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://cssgallery.info/crossbrowsing-css-dropshadows/&amp;title=Crossbrowser+CSS+dropshadows" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://cssgallery.info/crossbrowsing-css-dropshadows/&amp;title=Crossbrowser+CSS+dropshadows" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://cssgallery.info/crossbrowsing-css-dropshadows/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://cssgallery.info/crossbrowsing-css-dropshadows/&amp;title=Crossbrowser+CSS+dropshadows" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://cssgallery.info/crossbrowsing-css-dropshadows/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://cssgallery.info/crossbrowsing-css-dropshadows/&amp;t=Crossbrowser+CSS+dropshadows" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-evernote">
			<a href="http://www.evernote.com/clip.action?url=http://cssgallery.info/crossbrowsing-css-dropshadows/&amp;title=Crossbrowser+CSS+dropshadows" rel="nofollow" class="external" title="Clip this to Evernote">Clip this to Evernote</a>
		</li>
		<li class="shr-googlereader">
			<a href="http://www.google.com/reader/link?url=http://cssgallery.info/crossbrowsing-css-dropshadows/&amp;title=Crossbrowser+CSS+dropshadows&amp;srcUrl=http://cssgallery.info/crossbrowsing-css-dropshadows/&amp;srcTitle=Crossbrowser+CSS+dropshadows&amp;snippet=Very%20simple%20problem%20with%20a%20pretty%20complicated%20solution%2C%20mostly%20because%20IE%20is%20ignoring%20the%20box-shadow%20CSS3%20property.%20Instead%20progid%3ADXImageTransform.Microsoft.Shadow%20is%20doing%20the%20trick%20for%20it%20and%20an%20equivalent%20can%20be%20found.%20%0D%0A%0D%0AThe%20result%3F%0D%0A%0D%0A" rel="nofollow" class="external" title="Add this to Google Reader">Add this to Google Reader</a>
		</li>
		<li class="shr-meneame">
			<a href="http://meneame.net/submit.php?url=http://cssgallery.info/crossbrowsing-css-dropshadows/" rel="nofollow" class="external" title="Submit this to Meneame">Submit this to Meneame</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://cssgallery.info/crossbrowsing-css-dropshadows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create a nifty tooltip in Titanium</title>
		<link>http://cssgallery.info/create-a-nifty-tooltip-in-titanium/</link>
		<comments>http://cssgallery.info/create-a-nifty-tooltip-in-titanium/#comments</comments>
		<pubDate>Mon, 19 Apr 2010 18:16:59 +0000</pubDate>
		<dc:creator>Dan Tamas</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[ebook]]></category>
		<category><![CDATA[nifty]]></category>
		<category><![CDATA[titanium]]></category>
		<category><![CDATA[Titanium how-to]]></category>
		<category><![CDATA[tooltip]]></category>

		<guid isPermaLink="false">http://cssgallery.info/?p=798</guid>
		<description><![CDATA[How to create a tooltip to those that are using Titanium to develop their iPhone apps. Download the code and test it by yourself.]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><!--S-ButtonZ 1.1.5 End--><div class="tweetmeme_button" style="float: right; margin: 10px !important;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcssgallery.info%2Fcreate-a-nifty-tooltip-in-titanium%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcssgallery.info%2Fcreate-a-nifty-tooltip-in-titanium%2F&amp;source=dan_tamas&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>In this post I will show how to create a tooltip to those that are using Titanium to develop their iPhone apps.<br />
Sometimes when we set a button with an icon &#8211;  lets say in navbar &#8211;  a simple icon is not enough to make the user understand what the button is supposed to do.</p>
<h3>For example this one:</h3>
<p><img class="alignnone size-full wp-image-799" title="capture-1" src="http://cssgallery.info/wp-content/uploads/2010/04/capture-12.png" alt="" width="320" height="132" /></p>
<p>What would the <strong>rightNavButton</strong> do ? The application is an ebook reader &#8211; if this helps, but I&#8217;m sure it will not&#8230;.</p>
<h3>What about this:</h3>
<p><a href="http://cssgallery.info/wp-content/uploads/2010/04/capture-22.png"><img class="alignnone size-full wp-image-800" title="capture-2" src="http://cssgallery.info/wp-content/uploads/2010/04/capture-22.png" alt="" width="320" height="132" /></a></p>
<p>Now you know that by hitting this button you can continue your reading &#8211;  in case something took you out from the chapter, like  changing a setting, or answering the phone or whatever&#8230;</p>
<p>So let&#8217;s start.</p>
<p>The tooltip is a simple view with the tip image set as background:<br />
<img class="alignnone size-full wp-image-804" title="bubble" src="http://cssgallery.info/wp-content/uploads/2010/04/bubble.png" alt="" width="205" height="57" /></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> lasttipView <span style="color: #339933;">=</span>  Titanium.<span style="color: #660066;">UI</span>.<span style="color: #660066;">createView</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
width<span style="color: #339933;">:</span><span style="color: #CC0000;">205</span><span style="color: #339933;">,</span>
height<span style="color: #339933;">:</span><span style="color: #CC0000;">57</span><span style="color: #339933;">,</span>
backgroundImage<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;img/bubble.png&quot;</span><span style="color: #339933;">,</span>
top<span style="color: #339933;">:</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span>
right<span style="color: #339933;">:</span><span style="color: #CC0000;">3</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>The &#8220;Continue reading&#8221; is a simple label added to this view</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> lasttipLabel <span style="color: #339933;">=</span>  Titanium.<span style="color: #660066;">UI</span>.<span style="color: #660066;">createLabel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
text<span style="color: #339933;">:</span><span style="color: #3366CC;">'Continue reading'</span><span style="color: #339933;">,</span>
color<span style="color: #339933;">:</span><span style="color: #3366CC;">'#fff'</span><span style="color: #339933;">,</span>
width<span style="color: #339933;">:</span><span style="color: #CC0000;">205</span><span style="color: #339933;">,</span>
height<span style="color: #339933;">:</span><span style="color: #CC0000;">34</span><span style="color: #339933;">,</span>
top<span style="color: #339933;">:</span><span style="color: #CC0000;">16</span><span style="color: #339933;">,</span>
font<span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span>
fontFamily<span style="color: #339933;">:</span><span style="color: #3366CC;">'Helvetica Neue'</span><span style="color: #339933;">,</span>
fontSize<span style="color: #339933;">:</span><span style="color: #CC0000;">13</span><span style="color: #339933;">,</span>
fontWeight<span style="color: #339933;">:</span><span style="color: #3366CC;">'bold'</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
textAlign<span style="color: #339933;">:</span><span style="color: #3366CC;">'center'</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
lasttipView.<span style="color: #660066;">add</span><span style="color: #009900;">&#40;</span>lasttipLabel<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>and the index window contains the tip view</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">index_win.<span style="color: #660066;">add</span><span style="color: #009900;">&#40;</span>lasttipView<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>I supposed we already have the index_win created.</p>
<p>Now when we open the index_win the tooltip will be there and the user will know what the <strong>rightNavButton</strong> does. But if the tooltip stays there it becomes annoying so we need to find a way to hide it. I choose to hide it when the user clicks the button by using a smooth fadeout.</p>
<p>The code below creates an animation and attaches it to the click event.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> anim_out <span style="color: #339933;">=</span> Titanium.<span style="color: #660066;">UI</span>.<span style="color: #660066;">createAnimation</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
anim_out.<span style="color: #660066;">opacity</span><span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
anim_out.<span style="color: #660066;">duration</span> <span style="color: #339933;">=</span> <span style="color: #CC0000;">250</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
last_read <span style="color: #339933;">=</span>  Titanium.<span style="color: #660066;">UI</span>.<span style="color: #660066;">createButton</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
image<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;img/tag1.png&quot;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
&nbsp;
last_read.<span style="color: #660066;">addEventListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
lasttipView.<span style="color: #660066;">animate</span><span style="color: #009900;">&#40;</span>anim_out<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
index_win.<span style="color: #660066;">setRightNavButton</span><span style="color: #009900;">&#40;</span> last_read <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Ok, here is the button code too but for simplicity I removed some parts that actually display the chapter and trigger other functions.</p>
<p>That&#8217;s all. Pretty simple, isn&#8217;t it ?</p>
<p><strong> PS.</strong> You can use the bubble image in your apps if you want, only just let me know &#8211; and if you are curious about the app here it is:<br />
<a title="Youth, Isaac Asimov iPhone ebook" href="itms://itunes.apple.com/us/app/youth-isaac-asimov/id367433025?mt=8" target="_blank"><img class="alignnone size-full wp-image-806" title="Youth -  Isaac Asimov iBook" src="http://cssgallery.info/wp-content/uploads/2010/04/iconapp.png" alt="" width="57" height="57" /> Youth, by Isaac Asimov iPhone ebook.</a></p>
<p><strong class="spanish">Check the Spanish version of this post:<br />
<a href="http://nosoloweb.es/crear-un-tooltip-en-titanium/" rel="me">Crear una ingeniosa herramienta de notificación en Titanium</a></strong></p>
<div style="clear:both;">&nbsp;</div>

<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-knowledge">
<ul class="socials">
		<li class="shr-dzone">
			<a href="http://www.dzone.com/links/add.html?url=http://cssgallery.info/create-a-nifty-tooltip-in-titanium/&amp;title=Create+a+nifty+tooltip+in+Titanium&amp;description=How%20to%20create%20a%20tooltip%20to%20those%20that%20are%20using%20Titanium%20to%20develop%20their%20iPhone%20apps.%20Download%20the%20code%20and%20test%20it%20by%20yourself." rel="nofollow" class="external" title="Add this to DZone">Add this to DZone</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://cssgallery.info/create-a-nifty-tooltip-in-titanium/&amp;title=Create+a+nifty+tooltip+in+Titanium" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://cssgallery.info/create-a-nifty-tooltip-in-titanium/&amp;title=Create+a+nifty+tooltip+in+Titanium" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://cssgallery.info/create-a-nifty-tooltip-in-titanium/&amp;title=Create+a+nifty+tooltip+in+Titanium" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://cssgallery.info/create-a-nifty-tooltip-in-titanium/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://cssgallery.info/create-a-nifty-tooltip-in-titanium/&amp;title=Create+a+nifty+tooltip+in+Titanium" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://cssgallery.info/create-a-nifty-tooltip-in-titanium/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://cssgallery.info/create-a-nifty-tooltip-in-titanium/&amp;t=Create+a+nifty+tooltip+in+Titanium" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-evernote">
			<a href="http://www.evernote.com/clip.action?url=http://cssgallery.info/create-a-nifty-tooltip-in-titanium/&amp;title=Create+a+nifty+tooltip+in+Titanium" rel="nofollow" class="external" title="Clip this to Evernote">Clip this to Evernote</a>
		</li>
		<li class="shr-googlereader">
			<a href="http://www.google.com/reader/link?url=http://cssgallery.info/create-a-nifty-tooltip-in-titanium/&amp;title=Create+a+nifty+tooltip+in+Titanium&amp;srcUrl=http://cssgallery.info/create-a-nifty-tooltip-in-titanium/&amp;srcTitle=Create+a+nifty+tooltip+in+Titanium&amp;snippet=How%20to%20create%20a%20tooltip%20to%20those%20that%20are%20using%20Titanium%20to%20develop%20their%20iPhone%20apps.%20Download%20the%20code%20and%20test%20it%20by%20yourself." rel="nofollow" class="external" title="Add this to Google Reader">Add this to Google Reader</a>
		</li>
		<li class="shr-meneame">
			<a href="http://meneame.net/submit.php?url=http://cssgallery.info/create-a-nifty-tooltip-in-titanium/" rel="nofollow" class="external" title="Submit this to Meneame">Submit this to Meneame</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://cssgallery.info/create-a-nifty-tooltip-in-titanium/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Custom row for TableView in Appcelerator Titanium</title>
		<link>http://cssgallery.info/custom-row-for-tableview-in-appcelerator-titanium/</link>
		<comments>http://cssgallery.info/custom-row-for-tableview-in-appcelerator-titanium/#comments</comments>
		<pubDate>Mon, 12 Apr 2010 12:07:39 +0000</pubDate>
		<dc:creator>Dan Tamas</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[Appcelerator]]></category>
		<category><![CDATA[custom table rows]]></category>
		<category><![CDATA[rows]]></category>
		<category><![CDATA[table]]></category>
		<category><![CDATA[titanium]]></category>

		<guid isPermaLink="false">http://cssgallery.info/?p=763</guid>
		<description><![CDATA[In this post  I will explain how to create custom rows for TableViews using Titanium Mobile. The project source can be downloaded to play with.]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><!--S-ButtonZ 1.1.5 End--><div class="tweetmeme_button" style="float: right; margin: 10px !important;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcssgallery.info%2Fcustom-row-for-tableview-in-appcelerator-titanium%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcssgallery.info%2Fcustom-row-for-tableview-in-appcelerator-titanium%2F&amp;source=dan_tamas&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>In this post  I will try to explain how to create custom rows for TableViews using Titanium Mobile.</p>
<p>If you don&#8217;t know what <a title="Appcelerator Titanium" href="http://www.appcelerator.com/" target="_blank">Titanium</a> is about,  take a look <a title="Appcelerator Titanium" href="http://www.appcelerator.com/" target="_blank">here</a>. I suppose you already know how to setup and start a Titanium project so I&#8217;ll show only how to create a custom row.</p>
<p>By default a TableView will let you create a row that can have: the left image, the title and the row type decorator set. The next code is an example of the standard data that needs to be passed to a TableView.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> RegData <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>
&nbsp;
<span style="color: #009900;">&#123;</span> leftImage<span style="color: #339933;">:</span><span style="color: #3366CC;">'es.png'</span><span style="color: #339933;">,</span> title<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;Spain&quot;</span><span style="color: #339933;">,</span> hasChild<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">true</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#123;</span> leftImage<span style="color: #339933;">:</span><span style="color: #3366CC;">'gb.png'</span><span style="color: #339933;">,</span> title<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;United Kingdom&quot;</span><span style="color: #339933;">,</span> hasChild<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">true</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#123;</span> leftImage<span style="color: #339933;">:</span><span style="color: #3366CC;">'us.png'</span><span style="color: #339933;">,</span> title<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;United States&quot;</span><span style="color: #339933;">,</span> hasChild<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">true</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#123;</span> leftImage<span style="color: #339933;">:</span><span style="color: #3366CC;">'fr.png'</span><span style="color: #339933;">,</span> title<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;France&quot;</span><span style="color: #339933;">,</span> hasChild<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">true</span> <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> TheTable <span style="color: #339933;">=</span> Titanium.<span style="color: #660066;">UI</span>.<span style="color: #660066;">createTableView</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
data<span style="color: #339933;">:</span>RegData
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h3>And the result is this:</h3>
<p><a href="http://cssgallery.info/wp-content/uploads/2010/04/capture-11.png"><img class="alignnone size-full wp-image-790" title="Normal table rows" src="http://cssgallery.info/wp-content/uploads/2010/04/capture-11.png" alt="" width="378" height="186" /></a></p>
<p>Ok, we would like to add more data to a row, maybe something like this:</p>
<p><a href="http://cssgallery.info/wp-content/uploads/2010/04/capture-21.png"><img class="alignnone size-full wp-image-791" title="Custom row example" src="http://cssgallery.info/wp-content/uploads/2010/04/capture-21.png" alt="" width="378" height="47" /></a></p>
<p>This will require to build the row &#8220;by hand&#8221;. So we need to add a 2 imageViews, the <strong>flag</strong> and the <strong>trend</strong>, and  labelViews for the <strong>country</strong> and the <strong>percent</strong> . We also need to change the data array of course.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> CustomData <span style="color: #339933;">=</span> <span style="color: #009900;">&#91;</span>
<span style="color: #009900;">&#123;</span> flag<span style="color: #339933;">:</span><span style="color: #3366CC;">'es.png'</span><span style="color: #339933;">,</span> country<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;Spain&quot;</span><span style="color: #339933;">,</span> trend<span style="color: #339933;">:</span><span style="color: #3366CC;">'up.png'</span><span style="color: #339933;">,</span> percent<span style="color: #339933;">:</span><span style="color: #3366CC;">'28%'</span> <span style="color: #339933;">,</span>hasChild<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">true</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#123;</span> flag<span style="color: #339933;">:</span><span style="color: #3366CC;">'gb.png'</span><span style="color: #339933;">,</span> country<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;United Kingdom&quot;</span><span style="color: #339933;">,</span> trend<span style="color: #339933;">:</span><span style="color: #3366CC;">'down.png'</span><span style="color: #339933;">,</span> percent<span style="color: #339933;">:</span><span style="color: #3366CC;">'-3%'</span><span style="color: #339933;">,</span> hasChild<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">true</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#123;</span> flag<span style="color: #339933;">:</span><span style="color: #3366CC;">'us.png'</span><span style="color: #339933;">,</span> country<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;United States&quot;</span><span style="color: #339933;">,</span> trend<span style="color: #339933;">:</span><span style="color: #3366CC;">'up.png'</span><span style="color: #339933;">,</span> percent<span style="color: #339933;">:</span><span style="color: #3366CC;">'8%'</span><span style="color: #339933;">,</span> hasChild<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">true</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
<span style="color: #009900;">&#123;</span> flag<span style="color: #339933;">:</span><span style="color: #3366CC;">'fr.png'</span><span style="color: #339933;">,</span> country<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;France&quot;</span><span style="color: #339933;">,</span> trend<span style="color: #339933;">:</span><span style="color: #3366CC;">'down.png'</span><span style="color: #339933;">,</span> percent<span style="color: #339933;">:</span><span style="color: #3366CC;">'-40%'</span><span style="color: #339933;">,</span> hasChild<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">true</span> <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></pre></div></div>

<p>We create a <strong>data</strong> variable as an array that will hold the row objects generated.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> data<span style="color: #339933;">=</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span></pre></div></div>

<p>then we walk through the CustomData array, create  a new row , the imageViews and labels and add them to the row.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> i <span style="color: #339933;">=</span> CustomData.<span style="color: #660066;">length</span> <span style="color: #339933;">-</span> <span style="color: #CC0000;">1</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span> i<span style="color: #339933;">--</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #003366; font-weight: bold;">var</span> row <span style="color: #339933;">=</span> Titanium.<span style="color: #660066;">UI</span>.<span style="color: #660066;">createTableViewRow</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> flag <span style="color: #339933;">=</span>  Titanium.<span style="color: #660066;">UI</span>.<span style="color: #660066;">createImageView</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
url<span style="color: #339933;">:</span>CustomData<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">flag</span><span style="color: #339933;">,</span>
width<span style="color: #339933;">:</span><span style="color: #CC0000;">32</span><span style="color: #339933;">,</span>
height<span style="color: #339933;">:</span><span style="color: #CC0000;">32</span><span style="color: #339933;">,</span>
left<span style="color: #339933;">:</span><span style="color: #CC0000;">4</span><span style="color: #339933;">,</span>
top<span style="color: #339933;">:</span><span style="color: #CC0000;">2</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> country <span style="color: #339933;">=</span> Titanium.<span style="color: #660066;">UI</span>.<span style="color: #660066;">createLabel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
text<span style="color: #339933;">:</span>CustomData<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">country</span><span style="color: #339933;">,</span>
font<span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span>fontSize<span style="color: #339933;">:</span><span style="color: #CC0000;">16</span><span style="color: #339933;">,</span>fontWeight<span style="color: #339933;">:</span><span style="color: #3366CC;">'bold'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
width<span style="color: #339933;">:</span><span style="color: #3366CC;">'auto'</span><span style="color: #339933;">,</span>
textAlign<span style="color: #339933;">:</span><span style="color: #3366CC;">'left'</span><span style="color: #339933;">,</span>
top<span style="color: #339933;">:</span><span style="color: #CC0000;">2</span><span style="color: #339933;">,</span>
left<span style="color: #339933;">:</span><span style="color: #CC0000;">40</span><span style="color: #339933;">,</span>
height<span style="color: #339933;">:</span><span style="color: #CC0000;">16</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> percent <span style="color: #339933;">=</span>  Titanium.<span style="color: #660066;">UI</span>.<span style="color: #660066;">createLabel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
text<span style="color: #339933;">:</span>CustomData<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">percent</span><span style="color: #339933;">,</span>
font<span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span>fontSize<span style="color: #339933;">:</span><span style="color: #CC0000;">12</span><span style="color: #339933;">,</span>fontWeight<span style="color: #339933;">:</span><span style="color: #3366CC;">'bold'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
width<span style="color: #339933;">:</span><span style="color: #3366CC;">'auto'</span><span style="color: #339933;">,</span>
textAlign<span style="color: #339933;">:</span><span style="color: #3366CC;">'left'</span><span style="color: #339933;">,</span>
bottom<span style="color: #339933;">:</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span>
left<span style="color: #339933;">:</span><span style="color: #CC0000;">60</span><span style="color: #339933;">,</span>
height<span style="color: #339933;">:</span><span style="color: #CC0000;">12</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> trend <span style="color: #339933;">=</span>  Titanium.<span style="color: #660066;">UI</span>.<span style="color: #660066;">createImageView</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
url<span style="color: #339933;">:</span>CustomData<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">trend</span><span style="color: #339933;">,</span>
width<span style="color: #339933;">:</span><span style="color: #CC0000;">16</span><span style="color: #339933;">,</span>
height<span style="color: #339933;">:</span><span style="color: #CC0000;">16</span><span style="color: #339933;">,</span>
right<span style="color: #339933;">:</span><span style="color: #CC0000;">10</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
row.<span style="color: #660066;">add</span><span style="color: #009900;">&#40;</span>flag<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
row.<span style="color: #660066;">add</span><span style="color: #009900;">&#40;</span>country<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
row.<span style="color: #660066;">add</span><span style="color: #009900;">&#40;</span>percent<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
row.<span style="color: #660066;">add</span><span style="color: #009900;">&#40;</span>trend<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
row.<span style="color: #660066;">hasChild</span><span style="color: #339933;">=</span>CustomData<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">hasChild</span><span style="color: #339933;">;</span>
&nbsp;
row.<span style="color: #660066;">className</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'coutry_row'</span><span style="color: #339933;">;</span>
&nbsp;
data.<span style="color: #660066;">push</span><span style="color: #009900;">&#40;</span>row<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>As you see we also add a <strong>className</strong> to the row to improve the rendering performance, as the iPhone will reuse the row template with every new data when rendering the table.</p>
<h3>The obtained result is this:</h3>
<p><a href="http://cssgallery.info/wp-content/uploads/2010/04/capture-41.png"><img class="alignnone size-full wp-image-792" title="Custom rows table" src="http://cssgallery.info/wp-content/uploads/2010/04/capture-41.png" alt="" width="379" height="222" /></a></p>
<p>You can download the complete Titanium project from <a title="Custom rows titanium project" href="http://cssgallery.info/wp-content/TableCustomView.zip">here</a>. You will have to create a new project in Titanium and replace the resource folder with the one in the archive.</p>
<p>Let me know your thoughts.</p>
<p><strong class="spanish">Check the Spanish version of this post:<br />
<a href="http://nosoloweb.es/filas-personalizadas-para-tableviews-con-titanium/" rel="me">Como crear filas personalizadas para TableViews usando Titanium Móvil</a></strong></p>
<div style="clear:both;">&nbsp;</div>

<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-knowledge">
<ul class="socials">
		<li class="shr-dzone">
			<a href="http://www.dzone.com/links/add.html?url=http://cssgallery.info/custom-row-for-tableview-in-appcelerator-titanium/&amp;title=Custom+row+for+TableView+in+Appcelerator+Titanium&amp;description=In%20this%20post%20%20I%20will%20explain%20how%20to%20create%20custom%20rows%20for%20TableViews%20using%20Titanium%20Mobile.%20The%20project%20source%20can%20be%20downloaded%20to%20play%20with." rel="nofollow" class="external" title="Add this to DZone">Add this to DZone</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://cssgallery.info/custom-row-for-tableview-in-appcelerator-titanium/&amp;title=Custom+row+for+TableView+in+Appcelerator+Titanium" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://cssgallery.info/custom-row-for-tableview-in-appcelerator-titanium/&amp;title=Custom+row+for+TableView+in+Appcelerator+Titanium" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://cssgallery.info/custom-row-for-tableview-in-appcelerator-titanium/&amp;title=Custom+row+for+TableView+in+Appcelerator+Titanium" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://cssgallery.info/custom-row-for-tableview-in-appcelerator-titanium/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://cssgallery.info/custom-row-for-tableview-in-appcelerator-titanium/&amp;title=Custom+row+for+TableView+in+Appcelerator+Titanium" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://cssgallery.info/custom-row-for-tableview-in-appcelerator-titanium/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://cssgallery.info/custom-row-for-tableview-in-appcelerator-titanium/&amp;t=Custom+row+for+TableView+in+Appcelerator+Titanium" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-evernote">
			<a href="http://www.evernote.com/clip.action?url=http://cssgallery.info/custom-row-for-tableview-in-appcelerator-titanium/&amp;title=Custom+row+for+TableView+in+Appcelerator+Titanium" rel="nofollow" class="external" title="Clip this to Evernote">Clip this to Evernote</a>
		</li>
		<li class="shr-googlereader">
			<a href="http://www.google.com/reader/link?url=http://cssgallery.info/custom-row-for-tableview-in-appcelerator-titanium/&amp;title=Custom+row+for+TableView+in+Appcelerator+Titanium&amp;srcUrl=http://cssgallery.info/custom-row-for-tableview-in-appcelerator-titanium/&amp;srcTitle=Custom+row+for+TableView+in+Appcelerator+Titanium&amp;snippet=In%20this%20post%20%20I%20will%20explain%20how%20to%20create%20custom%20rows%20for%20TableViews%20using%20Titanium%20Mobile.%20The%20project%20source%20can%20be%20downloaded%20to%20play%20with." rel="nofollow" class="external" title="Add this to Google Reader">Add this to Google Reader</a>
		</li>
		<li class="shr-meneame">
			<a href="http://meneame.net/submit.php?url=http://cssgallery.info/custom-row-for-tableview-in-appcelerator-titanium/" rel="nofollow" class="external" title="Submit this to Meneame">Submit this to Meneame</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://cssgallery.info/custom-row-for-tableview-in-appcelerator-titanium/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
		<item>
		<title>Using CSS3 to style forms written in HTML5</title>
		<link>http://cssgallery.info/using-css3-to-style-forms-written-in-html5/</link>
		<comments>http://cssgallery.info/using-css3-to-style-forms-written-in-html5/#comments</comments>
		<pubDate>Tue, 06 Oct 2009 10:24:09 +0000</pubDate>
		<dc:creator>Lucica Ibanescu</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[corners]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[dropshadow]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[formatting]]></category>
		<category><![CDATA[gradient]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[rounded]]></category>
		<category><![CDATA[style]]></category>

		<guid isPermaLink="false">http://cssgallery.info/?p=531</guid>
		<description><![CDATA[Styling a form is never an easy thing to do, but adding CSS3 on a HTML5 form is a task that shows a large variety of results when it comes to testing on different browsers. Check the test link. When it comes to CSS3 not much can be done: but adding rounded corners, gradients and [...]]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><!--S-ButtonZ 1.1.5 End--><div class="tweetmeme_button" style="float: right; margin: 10px !important;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcssgallery.info%2Fusing-css3-to-style-forms-written-in-html5%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcssgallery.info%2Fusing-css3-to-style-forms-written-in-html5%2F&amp;source=dan_tamas&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>Styling a form is never an easy thing to do, but adding CSS3 on a HTML5 form is a task that shows a large variety of results when it comes to testing on different browsers. <a href="http://cssgallery.info/wp-content/css3-styled-form/index.php" target="_blank">Check the test link.</a></p>
<p>When it comes to CSS3 not much can be done: but adding rounded corners, gradients and dropshadows is still more than nothing anf the overall aspect of the form is <em>waaaaaaaaay</em> better. But HTML5 is supported by few browsers (this HTML form only by Opera) and CSS3 also by few broswers &#8211; but different from the one supporting HTML5.</p>
<p><strong>The result:</strong> impossible to see the result on one browser only: the rounded corners can be seen on Mozilla/Chrome/Safari and the HTML5 elements on Opera.</p>
<p>Internet Explorer? Better don&#8217;t ask. No support whatsoever.</p>
<p>So the results:</p>
<ol>
<li><strong>Mozilla 3: </strong> rounded corners + / HTML 5 elements<br />
<img class="alignnone size-full wp-image-565" title="capture-2" src="http://cssgallery.info/wp-content/uploads/2009/10/capture-2.png" alt="capture-2" width="312" height="484" /></li>
<li><strong>Chrome: </strong> rounded corners + (they look weird) / HTML 5 elements -<br />
<img class="alignnone size-full wp-image-570" title="chrome-screenshot" src="http://cssgallery.info/wp-content/uploads/2009/10/chrome-screenshot.png" alt="chrome-screenshot" width="311" height="529" /></li>
<li><strong>Safari: </strong> rounded corners + / HTML 5 elements -<br />
<img class="alignnone size-full wp-image-566" title="capture-3" src="http://cssgallery.info/wp-content/uploads/2009/10/capture-3.png" alt="capture-3" width="312" height="484" /></li>
<li><strong>Opera 9: </strong> rounded corners &#8211; / HTML 5 elements +<br />
<img class="alignnone size-full wp-image-567" title="capture-1" src="http://cssgallery.info/wp-content/uploads/2009/10/capture-1.png" alt="capture-1" width="310" height="464" /></li>
<li><strong>IE (doesn&#8217;t matter which one): </strong> rounded corners &#8211; / HTML 5 elements -<br />
<img class="alignnone size-full wp-image-571" title="ie8-screenshot" src="http://cssgallery.info/wp-content/uploads/2009/10/ie8-screenshot.png" alt="ie8-screenshot" width="308" height="506" /></li>
</ol>
<p>It seems we have to wait a little longer till we can drop Javascript from styling the forms  <img src='http://cssgallery.info/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p><strong>UPDATE</strong></p>
<p><a href="http://twitter.com/ricferrer" target="_blank">Ric Ferrer</a> sent us a screenshot with the behavior of Mobile Safari from his Ipod. Thank you <img src='http://cssgallery.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><img class="alignnone size-full wp-image-689" title="37555934" src="http://cssgallery.info/wp-content/uploads/2009/10/37555934.jpg" alt="37555934" width="320" height="480" /></p>
<p><strong class="spanish">Check the Spanish version of this post:<br />
<a href="http://nosoloweb.es/usando-css3-para-dar-estilo-a-formularios-escritos-en-html5/" rel="me">Usando CSS3 para dar estilo a formularios escritos en HTML5</a></strong></p>
<div style="clear:both;">&nbsp;</div>

<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-knowledge">
<ul class="socials">
		<li class="shr-dzone">
			<a href="http://www.dzone.com/links/add.html?url=http://cssgallery.info/using-css3-to-style-forms-written-in-html5/&amp;title=Using+CSS3+to+style+forms+written+in+HTML5&amp;description=Styling%20a%20form%20is%20never%20an%20easy%20thing%20to%20do%2C%20but%20adding%20CSS3%20on%20a%20HTML5%20form%20is%20a%20task%20that%20shows%20a%20large%20variety%20of%20results%20when%20it%20comes%20to%20testing%20on%20different%20browsers.%20Check%20the%20test%20link.%0D%0A%0D%0AWhen%20it%20comes%20to%20CSS3%20not%20much%20can%20be%20done%3A%20but%20adding%20rounded%20corners%2C%20gradients%20and%20dropshadows%20is%20st" rel="nofollow" class="external" title="Add this to DZone">Add this to DZone</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://cssgallery.info/using-css3-to-style-forms-written-in-html5/&amp;title=Using+CSS3+to+style+forms+written+in+HTML5" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://cssgallery.info/using-css3-to-style-forms-written-in-html5/&amp;title=Using+CSS3+to+style+forms+written+in+HTML5" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://cssgallery.info/using-css3-to-style-forms-written-in-html5/&amp;title=Using+CSS3+to+style+forms+written+in+HTML5" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://cssgallery.info/using-css3-to-style-forms-written-in-html5/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://cssgallery.info/using-css3-to-style-forms-written-in-html5/&amp;title=Using+CSS3+to+style+forms+written+in+HTML5" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://cssgallery.info/using-css3-to-style-forms-written-in-html5/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://cssgallery.info/using-css3-to-style-forms-written-in-html5/&amp;t=Using+CSS3+to+style+forms+written+in+HTML5" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-evernote">
			<a href="http://www.evernote.com/clip.action?url=http://cssgallery.info/using-css3-to-style-forms-written-in-html5/&amp;title=Using+CSS3+to+style+forms+written+in+HTML5" rel="nofollow" class="external" title="Clip this to Evernote">Clip this to Evernote</a>
		</li>
		<li class="shr-googlereader">
			<a href="http://www.google.com/reader/link?url=http://cssgallery.info/using-css3-to-style-forms-written-in-html5/&amp;title=Using+CSS3+to+style+forms+written+in+HTML5&amp;srcUrl=http://cssgallery.info/using-css3-to-style-forms-written-in-html5/&amp;srcTitle=Using+CSS3+to+style+forms+written+in+HTML5&amp;snippet=Styling%20a%20form%20is%20never%20an%20easy%20thing%20to%20do%2C%20but%20adding%20CSS3%20on%20a%20HTML5%20form%20is%20a%20task%20that%20shows%20a%20large%20variety%20of%20results%20when%20it%20comes%20to%20testing%20on%20different%20browsers.%20Check%20the%20test%20link.%0D%0A%0D%0AWhen%20it%20comes%20to%20CSS3%20not%20much%20can%20be%20done%3A%20but%20adding%20rounded%20corners%2C%20gradients%20and%20dropshadows%20is%20st" rel="nofollow" class="external" title="Add this to Google Reader">Add this to Google Reader</a>
		</li>
		<li class="shr-meneame">
			<a href="http://meneame.net/submit.php?url=http://cssgallery.info/using-css3-to-style-forms-written-in-html5/" rel="nofollow" class="external" title="Submit this to Meneame">Submit this to Meneame</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://cssgallery.info/using-css3-to-style-forms-written-in-html5/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>A third way to write and validate forms &#8211; HTML5</title>
		<link>http://cssgallery.info/a-third-way-to-write-and-validate-forms-html5/</link>
		<comments>http://cssgallery.info/a-third-way-to-write-and-validate-forms-html5/#comments</comments>
		<pubDate>Tue, 04 Aug 2009 11:53:47 +0000</pubDate>
		<dc:creator>Lucica Ibanescu</dc:creator>
				<category><![CDATA[Accessibility]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[accessible]]></category>
		<category><![CDATA[html 5]]></category>
		<category><![CDATA[validate forms]]></category>

		<guid isPermaLink="false">http://cssgallery.info/?p=425</guid>
		<description><![CDATA[After writing an accessible form in XHTML and validating it with a PHP server side script &#38; after that with a Mootools client-side script, I write today about a third way of approaching the subject &#8211; using future-to-come HTML5 (by saying that, I really hope to be able to use it waaaay before 2011). The [...]]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><!--S-ButtonZ 1.1.5 End--><div class="tweetmeme_button" style="float: right; margin: 10px !important;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcssgallery.info%2Fa-third-way-to-write-and-validate-forms-html5%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcssgallery.info%2Fa-third-way-to-write-and-validate-forms-html5%2F&amp;source=dan_tamas&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>After writing an <a title="Accessible contact form with PHP server side validation" href="http://dev.rborn.info/accessible-contact-form/">accessible form in XHTML</a> and validating it with a PHP server side script &amp; after that with a <a title="Accessible contact form with Mootools client side validation" href="http://">Mootools client-side script</a>, I write today about a third way of approaching the subject &#8211; using future-to-come HTML5 (by saying that, I really hope to be able to use it waaaay before 2011).</p>
<p>The beauty consists in having all the above mentioned validation inside HTML code:  we&#8217;ll have</p>
<ul>
<li>input type=&#8221;email&#8221; for email addresses</li>
<li>type=&#8221;url&#8221; for urls</li>
<li>type=&#8221;date&#8221; and &#8220;datetime&#8221; for date fields (usually done with JS calendars until now), or &#8220;month&#8221;, &#8220;week&#8221;, &#8220;time&#8221;</li>
<li>type=&#8221;number&#8221;  for number only inputs</li>
<li>accessible sliders, with type=&#8221;range&#8221;</li>
<li>datalists</li>
<li>ability to add extra validation conditions after writing the tag, like: required, read-only,disabled, autofocus, a minimum value, a maximum accepted value/length</li>
</ul>
<h2>The code for our simple contact form will be much lighter:</h2>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;form action=&quot;index.php&quot; method=&quot;post&quot; name=&quot;contactform&quot; id=&quot;contact&quot;&gt;
&nbsp;
&lt;label for=&quot;name&quot;&gt;Name &lt;span&gt;(required)&lt;/span&gt;&lt;/label&gt;
&lt;input  tabindex=&quot;1&quot; type=&quot;text&quot; name=&quot;name&quot; id=&quot;name&quot; required /&gt;
&nbsp;
&lt;label for=&quot;mail&quot;&gt;Email &lt;span&gt;(required)&lt;/span&gt;&lt;/label&gt;
&lt;input  tabindex=&quot;2&quot; type=&quot;email&quot; name=&quot;mail&quot; id=&quot;mail&quot; required /&gt;
&nbsp;
&lt;label for=&quot;phone&quot;&gt;Telephone&lt;/label&gt;
&lt;input tabindex=&quot;3&quot; type=&quot;text&quot; name=&quot;phone&quot; id=&quot;phone&quot; /&gt;
&nbsp;
&lt;label for=&quot;message&quot;&gt;Message&lt;/label&gt;
&lt;textarea tabindex=&quot;4&quot; cols=&quot;30&quot; rows=&quot;10&quot; name=&quot;message&quot; id=&quot;message&quot;&gt;&lt;/textarea&gt;
&nbsp;
&lt;button tabindex=&quot;5&quot; type=&quot;submit&quot; name=&quot;submit&quot; id=&quot;send&quot;&gt;Submit&lt;/button&gt;
&nbsp;
&lt;/form&gt;</pre></div></div>

<p>The result will be a much easier way of writing and validating forms in an accessible manner, without adding extra load/code with PHP/JS scripts. All you have to do is place <em><strong>&#8220;required&#8221;</strong> </em> to all the required fields and use the above mentioned <em><strong>minimum value, maximum accepted value</strong></em>, etc to control the user&#8217;s input. </p>
<p>The entire list of types and useful tables with the methods that apply to each state can be found on <a href="http://www.w3.org/TR/html5/forms.html#forms" target="_self">W3C site</a></p>
<p>The problem right now is the inabilityof the browsers to work with lots of HTML5 features. And the future does not look good either. So far the only browser that supports the new forms is Opera 9.5+.  Internet Explorer 8 and below is not compatible and IE9 probably won&#8217;t be either (we&#8217;re talking about 2010).  Chrome 2+, Safari 4+ will partially support some features while Mozilla won&#8217;t do it even in its 4.0 version (due to launch in 2010).</p>
<p>Now, the same contact form we used to play with, but written in HTML5, will look the same but behave much more nicely (the code is lighter too). It&#8217;s saving us a lot of time and headaches and it&#8217;s much more user friendly.  <a title="Accessible form using HTML5" href="http://cssgallery.info/wp-content/accessible-contact-form-html5/" target="_blank">Play with the new example</a> &#8211; in Opera 9.5+ &#8211;  and drop us a feedback if you consider that the subject is interesting enough to come back with more code-examples.</p>
<p><strong class="spanish">Check the Spanish version of this post:<br />
<a href="http://nosoloweb.es/una-tercera-manera-de-escribir-y-validar-formularios-htmll5/" rel="me">Una tercera manera de escribir y validar formularios – HTML5</a></strong></p>
<div style="clear:both;">&nbsp;</div>

<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-knowledge">
<ul class="socials">
		<li class="shr-dzone">
			<a href="http://www.dzone.com/links/add.html?url=http://cssgallery.info/a-third-way-to-write-and-validate-forms-html5/&amp;title=A+third+way+to+write+and+validate+forms+-+HTML5&amp;description=After%20writing%20an%20accessible%20form%20in%20XHTML%20and%20validating%20it%20with%20a%20PHP%20server%20side%20script%20%26amp%3B%20after%20that%20with%20a%20Mootools%20client-side%20script%2C%20I%20write%20today%20about%20a%20third%20way%20of%20approaching%20the%20subject%20-%20using%20future-to-come%20HTML5%20%28by%20saying%20that%2C%20I%20really%20hope%20to%20be%20able%20to%20use%20it%20waaaay%20before%20201" rel="nofollow" class="external" title="Add this to DZone">Add this to DZone</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://cssgallery.info/a-third-way-to-write-and-validate-forms-html5/&amp;title=A+third+way+to+write+and+validate+forms+-+HTML5" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://cssgallery.info/a-third-way-to-write-and-validate-forms-html5/&amp;title=A+third+way+to+write+and+validate+forms+-+HTML5" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://cssgallery.info/a-third-way-to-write-and-validate-forms-html5/&amp;title=A+third+way+to+write+and+validate+forms+-+HTML5" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://cssgallery.info/a-third-way-to-write-and-validate-forms-html5/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://cssgallery.info/a-third-way-to-write-and-validate-forms-html5/&amp;title=A+third+way+to+write+and+validate+forms+-+HTML5" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://cssgallery.info/a-third-way-to-write-and-validate-forms-html5/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://cssgallery.info/a-third-way-to-write-and-validate-forms-html5/&amp;t=A+third+way+to+write+and+validate+forms+-+HTML5" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-evernote">
			<a href="http://www.evernote.com/clip.action?url=http://cssgallery.info/a-third-way-to-write-and-validate-forms-html5/&amp;title=A+third+way+to+write+and+validate+forms+-+HTML5" rel="nofollow" class="external" title="Clip this to Evernote">Clip this to Evernote</a>
		</li>
		<li class="shr-googlereader">
			<a href="http://www.google.com/reader/link?url=http://cssgallery.info/a-third-way-to-write-and-validate-forms-html5/&amp;title=A+third+way+to+write+and+validate+forms+-+HTML5&amp;srcUrl=http://cssgallery.info/a-third-way-to-write-and-validate-forms-html5/&amp;srcTitle=A+third+way+to+write+and+validate+forms+-+HTML5&amp;snippet=After%20writing%20an%20accessible%20form%20in%20XHTML%20and%20validating%20it%20with%20a%20PHP%20server%20side%20script%20%26amp%3B%20after%20that%20with%20a%20Mootools%20client-side%20script%2C%20I%20write%20today%20about%20a%20third%20way%20of%20approaching%20the%20subject%20-%20using%20future-to-come%20HTML5%20%28by%20saying%20that%2C%20I%20really%20hope%20to%20be%20able%20to%20use%20it%20waaaay%20before%20201" rel="nofollow" class="external" title="Add this to Google Reader">Add this to Google Reader</a>
		</li>
		<li class="shr-meneame">
			<a href="http://meneame.net/submit.php?url=http://cssgallery.info/a-third-way-to-write-and-validate-forms-html5/" rel="nofollow" class="external" title="Submit this to Meneame">Submit this to Meneame</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://cssgallery.info/a-third-way-to-write-and-validate-forms-html5/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Clientside validation for accessible forms with mootools</title>
		<link>http://cssgallery.info/clientside-validation-for-accessible-forms-with-mootools/</link>
		<comments>http://cssgallery.info/clientside-validation-for-accessible-forms-with-mootools/#comments</comments>
		<pubDate>Wed, 29 Jul 2009 17:11:27 +0000</pubDate>
		<dc:creator>Dan Tamas</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[MooTools]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[accessible forms]]></category>
		<category><![CDATA[class required]]></category>
		<category><![CDATA[clientside validation]]></category>
		<category><![CDATA[form validator class]]></category>
		<category><![CDATA[mootools validation]]></category>

		<guid isPermaLink="false">http://cssgallery.info/?p=421</guid>
		<description><![CDATA[Validate forms client side with MooTools.]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><!--S-ButtonZ 1.1.5 End--><div class="tweetmeme_button" style="float: right; margin: 10px !important;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcssgallery.info%2Fclientside-validation-for-accessible-forms-with-mootools%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcssgallery.info%2Fclientside-validation-for-accessible-forms-with-mootools%2F&amp;source=dan_tamas&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>As we discussed in a previous article about forms -<a title="Basic copy-paste accessible contact form" rel="bookmark" href="http://cssgallery.info/basic-copy-paste-accessible-contact-form/">Basic copy-paste accessible contact form</a> -  we made the form validation accessible using a class that will highlight and point to the elements that need to be filled or corrected in case the validation failed.</p>
<p>Now, the only weak point form the user&#8217;s point of view is the fact that we need to refresh the page every time he hits submit, this being somehow annoying. Nowadays most browsers offer a client-side processing capabilities ( javascript ) that can be used for local validation &#8211; avoiding the refresh of the page.</p>
<p>Don&#8217;t get me wrong. The server side part needs to remain intact for accessibility purposes. </p>
<p>The last MooTools version offers a validation plugin in the mootools-more package, that will help us to solve our task. Basicaly we need to add some classes to out inputs, to reflect the type of validation we want. For our form, we need only name &#8211; mandatory, and email &#8211;  mandatory + correct email formating.</p>
<p>So we&#8217;ll use <strong>required</strong> and <strong>validate-email</strong> from the <a title="Mootools validators" href="http://mootools.net/docs/more/Forms/FormValidator#Validators" target="_blank">list of the validators</a> already included, like this:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;label for=&quot;name&quot;&gt; Name &lt;span&gt; (required) &lt;/span&gt;&lt;/label&gt;
&lt;input  tabindex=&quot;1&quot; type=&quot;text&quot; name=&quot;name&quot; id=&quot;name&quot; class=&quot;required&quot; /&gt;
&lt;label for=&quot;mail&quot;&gt; Email &lt;span&gt; (required)&lt;/span&gt;&lt;/label&gt;
&lt;input  tabindex=&quot;2&quot; type=&quot;text&quot; name=&quot;mail&quot; id=&quot;mail&quot; class=&quot;validate-email required&quot; /&gt;</pre></div></div>

<h2>The next step is to create the code that does the validation:</h2>
<p>On the <strong>domready</strong> event of the window (we need to allow the html to load and therefore to be able to access it)  we attach the validator to our form with the methods needed to show the user what he did wrong (in case he did it). To keep the presentation and the accessibility intact &#8211; as in the back-end validation &#8211; we  will add the next code:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">window.<span style="color: #660066;">addEvent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'domready'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> myFormValidator <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> FormValidator<span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'contact'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
		onFormValidate<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>ok<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'error_wrapper'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getElements</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">dispose</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>ok<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'contact'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getElements</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.validation-failed'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>el<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #003366; font-weight: bold;">var</span> a <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Element<span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;a&quot;</span><span style="color: #339933;">,</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">'href'</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;#add&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
                            .<span style="color: #660066;">addEvent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> el.<span style="color: #000066;">focus</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
                            .<span style="color: #660066;">set</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'text'</span><span style="color: #339933;">,</span> el.<span style="color: #660066;">get</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'id'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">capitalize</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
                            .<span style="color: #660066;">inject</span><span style="color: #009900;">&#40;</span>$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'error_wrapper'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
&nbsp;
				$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'error_wrapper'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">setStyle</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'display'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'block'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
				$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'error_wrapper'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">setStyle</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'display'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'none'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
		stopOnFailure<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
		evaluateFieldsOnBlur<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">false</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>Ok, it&#8217;s a little long but basically it&#8217;s validating each field it needs to, as specified in the class, and  attach in the error_wrapper the labels to the erroneous inputs.  It&#8217;s better  to study the code and see exactly how it&#8217;s done.</p>
<p><strong>Now, what is happening?</strong></p>
<p>The MooTools library is validating each field we specified on the <strong>submit event</strong> of the form and adds by default a class <strong>validation-failed</strong> or <strong>validation-passed</strong> to each field that was submitted to the validation routine.</p>
<p>We can use these two classes to visually improve the form &#8211;  here I just made the faulty ones red. If the validation failed the <strong>submit event</strong> of the form is stopped  and the incomplete data is not reaching the server.</p>
<p><strong>Next step:</strong> to complete the correct data, and resubmit.</p>
<p><a href="http://cssgallery.info/wp-content/accessible-contact-form/index_mootools_validation.php">Here is the DEMO</a></p>
<p>The form validator class is more powerful than this so take a look at the documentation on the MooTools site.<br />
Anyway, no matter what you do, <strong>do not forget</strong> to make the server side validation too. It is mandatory for your (server&#8217;s ) security.</p>
<div style="clear:both;">&nbsp;</div>

<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-knowledge">
<ul class="socials">
		<li class="shr-dzone">
			<a href="http://www.dzone.com/links/add.html?url=http://cssgallery.info/clientside-validation-for-accessible-forms-with-mootools/&amp;title=Clientside+validation+for+accessible+forms+with+mootools&amp;description=Validate%20forms%20client%20side%20with%20MooTools." rel="nofollow" class="external" title="Add this to DZone">Add this to DZone</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://cssgallery.info/clientside-validation-for-accessible-forms-with-mootools/&amp;title=Clientside+validation+for+accessible+forms+with+mootools" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://cssgallery.info/clientside-validation-for-accessible-forms-with-mootools/&amp;title=Clientside+validation+for+accessible+forms+with+mootools" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://cssgallery.info/clientside-validation-for-accessible-forms-with-mootools/&amp;title=Clientside+validation+for+accessible+forms+with+mootools" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://cssgallery.info/clientside-validation-for-accessible-forms-with-mootools/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://cssgallery.info/clientside-validation-for-accessible-forms-with-mootools/&amp;title=Clientside+validation+for+accessible+forms+with+mootools" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://cssgallery.info/clientside-validation-for-accessible-forms-with-mootools/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://cssgallery.info/clientside-validation-for-accessible-forms-with-mootools/&amp;t=Clientside+validation+for+accessible+forms+with+mootools" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-evernote">
			<a href="http://www.evernote.com/clip.action?url=http://cssgallery.info/clientside-validation-for-accessible-forms-with-mootools/&amp;title=Clientside+validation+for+accessible+forms+with+mootools" rel="nofollow" class="external" title="Clip this to Evernote">Clip this to Evernote</a>
		</li>
		<li class="shr-googlereader">
			<a href="http://www.google.com/reader/link?url=http://cssgallery.info/clientside-validation-for-accessible-forms-with-mootools/&amp;title=Clientside+validation+for+accessible+forms+with+mootools&amp;srcUrl=http://cssgallery.info/clientside-validation-for-accessible-forms-with-mootools/&amp;srcTitle=Clientside+validation+for+accessible+forms+with+mootools&amp;snippet=Validate%20forms%20client%20side%20with%20MooTools." rel="nofollow" class="external" title="Add this to Google Reader">Add this to Google Reader</a>
		</li>
		<li class="shr-meneame">
			<a href="http://meneame.net/submit.php?url=http://cssgallery.info/clientside-validation-for-accessible-forms-with-mootools/" rel="nofollow" class="external" title="Submit this to Meneame">Submit this to Meneame</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://cssgallery.info/clientside-validation-for-accessible-forms-with-mootools/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Basic copy-paste accessible contact form</title>
		<link>http://cssgallery.info/basic-copy-paste-accessible-contact-form/</link>
		<comments>http://cssgallery.info/basic-copy-paste-accessible-contact-form/#comments</comments>
		<pubDate>Mon, 13 Jul 2009 11:36:43 +0000</pubDate>
		<dc:creator>Lucica Ibanescu</dc:creator>
				<category><![CDATA[Accessibility]]></category>
		<category><![CDATA[Php]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[accessible contact form]]></category>
		<category><![CDATA[accessible form]]></category>
		<category><![CDATA[labels]]></category>
		<category><![CDATA[PHP server side validation]]></category>
		<category><![CDATA[WCAG]]></category>

		<guid isPermaLink="false">http://cssgallery.info/?p=411</guid>
		<description><![CDATA[A good way to learn about accessibility is through examples and discussions. In this post I will try to translate the WCAG sometimes-hard-to-get rules into a copy-paste real contact form example.  You can check the test link, download the code and/or keep reading a bit more. As I mentioned before, contact forms are in great [...]]]></description>
			<content:encoded><![CDATA[<!--S-ButtonZ 1.1.5 Start--><!--S-ButtonZ 1.1.5 End--><div class="tweetmeme_button" style="float: right; margin: 10px !important;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fcssgallery.info%2Fbasic-copy-paste-accessible-contact-form%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fcssgallery.info%2Fbasic-copy-paste-accessible-contact-form%2F&amp;source=dan_tamas&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>A good way to learn about accessibility is through examples and discussions. In this post I will try to translate the WCAG sometimes-hard-to-get rules into a copy-paste real contact form example.  You can <a href="http://dev.rborn.info/accessible-contact-form/">check the test link</a>, <a href="http://dev.rborn.info/accessible-contact-form/accessible-contact-form.zip">download the code</a> and/or keep reading a bit more.</p>
<p>As I mentioned <a href="http://cssgallery.info/common-sense-accessibility-20/">before,</a> contact forms are in great need of special markup in order to be accessible. And it seems that there&#8217;s always room for improvements &#8211; in case you have suggestions or your approach is different,  I&#8217;d love to hear from you.</p>
<p>My suggestion is a simple 4 fields contact form with PHP server side validation. After the user submits the required information the page is reloaded and new messages are displayed depending on the user actions.  Of course you all know that the form needs</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;label for=&quot;name&quot;&gt;</pre></div></div>

<p> tag and some sort of validation &#8211; everybody is writing about the need to display  in an accesible way which fields are required and also the error messages (usually indicating the missing fields)  &#8211; but few actually offer a simple straightforward code to copy-paste in our sites.</p>
<p>The stylesheet is very light &#8211; we have to style the form &#8211; but the novelty is a class for the fields that are required and not yet filled. This way after we validate we return the error message with links to the missing fields but we also hightlight them for a more usable and intuitive experience. The PHP part is reading the inputs, checks them and sees if the required ones were filled.  A thank you message is displayed in case the user filled all the required fields.</p>
<p>The number of fields can easily be increased but don&#8217;t forget to validate them -when someone understands how the form works and which were the accessibility elements that were included then buiding more complex forms becomes just a matter of typing.</p>
<p><strong class="spanish">Check the Spanish version of this post:<br />
<a href="http://nosoloweb.es/un-basico-copia-y-pega-de-un-formulario-de-contacto-accesible/" rel="me">Un básico copia y pega de un formulario de contacto accesible</a></strong></p>
<div style="clear:both;">&nbsp;</div>

<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center shr-bookmarks-bg-knowledge">
<ul class="socials">
		<li class="shr-dzone">
			<a href="http://www.dzone.com/links/add.html?url=http://cssgallery.info/basic-copy-paste-accessible-contact-form/&amp;title=+Basic+copy-paste+accessible+contact+form&amp;description=A%20good%20way%20to%20learn%20about%20accessibility%20is%20through%20examples%20and%20discussions.%20In%20this%20post%20I%20will%20try%20to%20translate%20the%20WCAG%20sometimes-hard-to-get%20rules%20into%20a%20copy-paste%20real%20contact%20form%20example.%C2%A0%20You%20can%20check%20the%20test%20link%2C%20download%20the%20code%20and%2For%20keep%20reading%20a%20bit%20more.%0D%0A%0D%0AAs%20I%20mentioned%20befor" rel="nofollow" class="external" title="Add this to DZone">Add this to DZone</a>
		</li>
		<li class="shr-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://cssgallery.info/basic-copy-paste-accessible-contact-form/&amp;title=+Basic+copy-paste+accessible+contact+form" rel="nofollow" class="external" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="shr-delicious">
			<a href="http://delicious.com/post?url=http://cssgallery.info/basic-copy-paste-accessible-contact-form/&amp;title=+Basic+copy-paste+accessible+contact+form" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://cssgallery.info/basic-copy-paste-accessible-contact-form/&amp;title=+Basic+copy-paste+accessible+contact+form" rel="nofollow" class="external" title="Digg this!">Digg this!</a>
		</li>
		<li class="shr-googlebuzz">
			<a href="http://www.google.com/buzz/post?url=http://cssgallery.info/basic-copy-paste-accessible-contact-form/&amp;imageurl=" rel="nofollow" class="external" title="Post on Google Buzz">Post on Google Buzz</a>
		</li>
		<li class="shr-reddit">
			<a href="http://reddit.com/submit?url=http://cssgallery.info/basic-copy-paste-accessible-contact-form/&amp;title=+Basic+copy-paste+accessible+contact+form" rel="nofollow" class="external" title="Share this on Reddit">Share this on Reddit</a>
		</li>
		<li class="shr-technorati">
			<a href="http://technorati.com/faves?add=http://cssgallery.info/basic-copy-paste-accessible-contact-form/" rel="nofollow" class="external" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://cssgallery.info/basic-copy-paste-accessible-contact-form/&amp;t=+Basic+copy-paste+accessible+contact+form" rel="nofollow" class="external" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-evernote">
			<a href="http://www.evernote.com/clip.action?url=http://cssgallery.info/basic-copy-paste-accessible-contact-form/&amp;title=+Basic+copy-paste+accessible+contact+form" rel="nofollow" class="external" title="Clip this to Evernote">Clip this to Evernote</a>
		</li>
		<li class="shr-googlereader">
			<a href="http://www.google.com/reader/link?url=http://cssgallery.info/basic-copy-paste-accessible-contact-form/&amp;title=+Basic+copy-paste+accessible+contact+form&amp;srcUrl=http://cssgallery.info/basic-copy-paste-accessible-contact-form/&amp;srcTitle=+Basic+copy-paste+accessible+contact+form&amp;snippet=A%20good%20way%20to%20learn%20about%20accessibility%20is%20through%20examples%20and%20discussions.%20In%20this%20post%20I%20will%20try%20to%20translate%20the%20WCAG%20sometimes-hard-to-get%20rules%20into%20a%20copy-paste%20real%20contact%20form%20example.%C2%A0%20You%20can%20check%20the%20test%20link%2C%20download%20the%20code%20and%2For%20keep%20reading%20a%20bit%20more.%0D%0A%0D%0AAs%20I%20mentioned%20befor" rel="nofollow" class="external" title="Add this to Google Reader">Add this to Google Reader</a>
		</li>
		<li class="shr-meneame">
			<a href="http://meneame.net/submit.php?url=http://cssgallery.info/basic-copy-paste-accessible-contact-form/" rel="nofollow" class="external" title="Submit this to Meneame">Submit this to Meneame</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>

]]></content:encoded>
			<wfw:commentRss>http://cssgallery.info/basic-copy-paste-accessible-contact-form/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
