<?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>unthink media &#187; javascript</title>
	<atom:link href="http://blog.unthinkmedia.com/category/programing/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.unthinkmedia.com</link>
	<description>creativity + technology</description>
	<lastBuildDate>Wed, 11 Jan 2012 22:20:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Twitter-style Status TextArea w/ XUI JavaScript and CSS for PhoneGap</title>
		<link>http://blog.unthinkmedia.com/2009/12/15/twitter-style-status-textarea-w-xui-javascript-and-css/</link>
		<comments>http://blog.unthinkmedia.com/2009/12/15/twitter-style-status-textarea-w-xui-javascript-and-css/#comments</comments>
		<pubDate>Tue, 15 Dec 2009 18:18:46 +0000</pubDate>
		<dc:creator>Alex Britez</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[programing]]></category>
		<category><![CDATA[project]]></category>

		<guid isPermaLink="false">http://blog.unthinkmedia.com/?p=306</guid>
		<description><![CDATA[Note: XUI is developed for WebKit (hence it&#8217;s light weight) since that is the mobile browser of choice for most devices. If something doesn&#8217;t seem to work, try using Chrome or Safari since they too use Webkit. Here is some code for a JavaScript, CSS, Twitter style status text area that i plan on using [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Note:</strong> XUI is developed for WebKit (hence it&#8217;s light weight) since that is the mobile browser of choice for most devices. If something doesn&#8217;t seem to work, try using Chrome or Safari since they too use Webkit.</p>
<p><a href="http://project.unthinkmedia.com/test/javascript/twitterMessageArea/test.html" target = "_blank"><img src="http://blog.unthinkmedia.com/wp-content/uploads/TwitterTextArea.png" alt="Twitter Style TextArea" title="Twitter Style TextArea" width="314" height="112" class="alignright size-full wp-image-312" /></a></p>
<p>Here is some code for a JavaScript, CSS, Twitter style status text area that i plan on using on a <a href="http://www.phonegap.com">PhoneGap</a> project i am working on.  It makes use of the <a href="http://xuijs.com/">XUI</a> Javascript framework, which i use throughout the project.  <a href="http://xuijs.com/">XUI</a>, compared to other Javascript frameworks is super light, and is developed by the the people behind <a href="http://www.phonegap.com">PhoneGap</a><br />
You could find the XUI framework at <a href="http://xuijs.com/">http://xuijs.com/</a></p>
<p>The code supports:</p>
<ul style="list-style-type: square;padding: 0 0">
<li style="list-style-type: square;padding: 0 0">140 character count down</li>
<li style="list-style-type: square;padding: 0 0">Visual styling cue when you go over 140 characters</li>
<li style="list-style-type: square;padding: 0 0">prompting text when textarea is empty</li>
</ul>
<p><span id="more-306"></span></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;html&gt;
&lt;head&gt;
&nbsp;
&lt;script type=&quot;text/javascript&quot; src=&quot;includes/js/xui.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;includes/js/messageBox.js&quot;&gt;&lt;/script&gt;
&lt;link rel=&quot;stylesheet&quot; href=&quot;includes/css/messageBox.css&quot; type=&quot;text/css&quot; media=&quot;screen&quot; title=&quot;no title&quot; charset=&quot;utf-8&quot; /&gt;
&nbsp;
&lt;/head&gt;
&lt;body&gt;
  &lt;div class=&quot;promptTextField&quot;&gt;
	&lt;form name=&quot;myForm&quot;&gt;
		&lt;textarea id=&quot;messageAreaTxt&quot; onKeyDown=&quot;checkCharCount(this.value)&quot; onBlur=&quot;checkCharCount(this.value);handleMessageBlur(this.value);&quot; onFocus=&quot;handleMessageFocus(event);&quot; &gt;&lt;/textarea&gt;
	&lt;/form&gt;
	&lt;div id=&quot;textPromptText&quot; onClick=&quot;document.myForm.messageAreaTxt.focus();&quot; class=&quot;textPromptText active&quot;&gt;Type in your message...&lt;/div&gt;
	&lt;div id=&quot;charCount&quot;&gt;140&lt;/div&gt;
  &lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></td></tr></table></div>

<p>CSS Styling</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
</pre></td><td class="code"><pre class="css" style="font-family:monospace;">div.promptTextField<span style="color: #00AA00;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span>
		<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">100px</span><span style="color: #00AA00;">;</span>
		<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">300px</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span>
&nbsp;
	<span style="color: #cc00cc;">#messageAreaTxt</span><span style="color: #00AA00;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
		resize<span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
		<span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>
		<span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">0px</span><span style="color: #00AA00;">;</span>
		<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">100px</span><span style="color: #00AA00;">;</span>
		<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">300px</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span>
	<span style="color: #cc00cc;">#charCount</span><span style="color: #00AA00;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
		<span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">78px</span><span style="color: #00AA00;">;</span>
		<span style="color: #000000; font-weight: bold;">right</span><span style="color: #00AA00;">:</span><span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
&nbsp;
	<span style="color: #00AA00;">&#125;</span>
	<span style="color: #cc00cc;">#textPromptText</span><span style="color: #00AA00;">&#123;</span>
		-khtml-user-select<span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
		<span style="color: #000000; font-weight: bold;">font-style</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">italic</span><span style="color: #00AA00;">;</span>
		<span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#999999</span><span style="color: #00AA00;">;</span>
		<span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
		<span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span><span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
		<span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span>
	<span style="color: #cc00cc;">#textPromptText</span>.inactive<span style="color: #00AA00;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span>
	<span style="color: #cc00cc;">#textPromptText</span>.active<span style="color: #00AA00;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
	<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>JavaScript Coding</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> MAX_CHARACTER_LENGTH<span style="color: #339933;">=</span><span style="color: #CC0000;">140</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;">function</span> checkCharCount<span style="color: #009900;">&#40;</span>str<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		console.<span style="color: #660066;">log</span><span style="color: #009900;">&#40;</span>str.<span style="color: #660066;">length</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot; characters typed&quot;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #003366; font-weight: bold;">var</span> count <span style="color: #339933;">=</span> MAX_CHARACTER_LENGTH <span style="color: #339933;">-</span> str.<span style="color: #660066;">length</span>
		x$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#charCount'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'inner'</span><span style="color: #339933;">,</span> count.<span style="color: #660066;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</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: #009900;">&#40;</span>str.<span style="color: #660066;">length</span><span style="color: #339933;">-</span><span style="color: #CC0000;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> <span style="color: #009900;">&#40;</span>MAX_CHARACTER_LENGTH<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			x$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#messageAreaTxt'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">setStyle</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'color'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'#000000'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			x$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#messageAreaTxt'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">setStyle</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'background'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'#FFFFFF'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			x$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#charCount'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">setStyle</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'color'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'#000000'</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>
			x$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#messageAreaTxt'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">setStyle</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'color'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'#FFFFFF'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			x$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#messageAreaTxt'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">setStyle</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'background'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'#FF0000'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			x$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#charCount'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">setStyle</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'color'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'#FFFFFF'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;">function</span> handleMessageFocus<span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'textPromptText'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">className</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;inactive&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;">function</span> handleMessageBlur<span style="color: #009900;">&#40;</span>str<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>str.<span style="color: #660066;">length</span> <span style="color: #339933;">==</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'textPromptText'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">className</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;active&quot;</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>
			document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'textPromptText'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">className</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;inactive&quot;</span><span style="color: #339933;">;</span> 
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<div class='kouguu_fb_like_button'><iframe src="http://www.facebook.com/plugins/like.php?href=http://blog.unthinkmedia.com/2009/12/15/twitter-style-status-textarea-w-xui-javascript-and-css/&#038;layout=standart&#038;show_faces=true&#038;width=450&#038;height=65&#038;action=like&#038;colorscheme=light&#038;" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:65px;"></iframe></div>
<img src="http://blog.unthinkmedia.com/?ak_action=api_record_view&id=306&type=feed" alt="" />]]></content:encoded>
			<wfw:commentRss>http://blog.unthinkmedia.com/2009/12/15/twitter-style-status-textarea-w-xui-javascript-and-css/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

