<?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>dustincaruso.com &#187; JavaScript</title>
	<atom:link href="http://dustincaruso.com/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://dustincaruso.com</link>
	<description>custom web app development</description>
	<lastBuildDate>Mon, 29 Mar 2010 11:44:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>updated mooInputLabel class for MooTools</title>
		<link>http://dustincaruso.com/javascript/mooinputlabel/</link>
		<comments>http://dustincaruso.com/javascript/mooinputlabel/#comments</comments>
		<pubDate>Sat, 14 Nov 2009 11:02:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[MooTools]]></category>

		<guid isPermaLink="false">http://dustincaruso.com/?p=268</guid>
		<description><![CDATA[I have taken the advice of 2 contributors to my original post (red link below), and have finally posted an update to this MooTools class that&#8230; adds the ability to set the blur and focus colors in the options sets the reusable reference to the element in the label class So, without any further explanation, [...]]]></description>
			<content:encoded><![CDATA[<p>I have taken the advice of 2 contributors to my original post (red link below), and have finally posted an update to this MooTools class that&#8230;</p>
<ol>
<li>adds the ability to set the blur and focus colors in the options</li>
<li>sets the reusable reference to the element in the label class</li>
</ol>
<p style="margin: 10px 0px 20px 0px;">So, without any further explanation, here&#8217;s the new code/instructions&#8230;</p>
<h4>mooInputLabel</h4>
<p style="margin-bottom: 15px;">&nbsp;<br /><b>1</b> &#8211; copy and paste the following code into your favorite text editor and save it as a new .js file (“mooInputLabel.js”, for example)…</p>
<p><code>var mooInputLabel = new Class({</code></p>
<p><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Implements: [Options, Events],</code></p>
<p><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;options: {</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;inputs: [ ],</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;blurColor: '#ccc',</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;focusColor: '#000'</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},</code></p>
<p><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;initialize: function(options) {</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.setOptions(options);</code></p>
<p><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var self = this;</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var inputs = this.options.inputs;</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var blurColor = this.options.blurColor;</code></p>
<p><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.blurColor = blurColor;</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.focusColor = this.options.focusColor;</code></p>
<p><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;inputs.each(function(e) {</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;e.addEvent(&#39;focus&#39;, function() {</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;e = new Event(e).stop();</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.inputFocus(this, e.id);</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;})</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.addEvent(&#39;blur&#39;, function() {</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;e = new Event(e).stop();</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.inputBlur(this, e.id);</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;})</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.setProperty(&#39;value&#39;, e.id)</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.setStyle(&#39;color&#39;, blurColor);</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},</code></p>
<p><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;inputFocus: function(x, id) {</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (x.value == &#39;&#39;) {</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;x.value = &#39;&#39;;</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;x.setStyle(&#39;color&#39;, this.focusColor);</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},</code></p>
<p><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;inputBlur: function(x, id) {</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if (x.value == &#39;&#39;) {</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;x.value = id;</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;x.setStyle(&#39;color&#39;, this.blurColor);</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else if (x.value == id) {</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;x.setStyle(&#39;color&#39;, this.blurColor);</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else {</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;x.setStyle(&#39;color&#39;, this.focusColor);</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</code><br />
<code>});</code></p>
<p>&nbsp;</p>
<p style="margin-bottom: 15px;"><b>2</b> &#8211; then, make sure to place links to your new .js file as well as the MooTools core in the <code>&lt;head&gt;</code> of your document</p>
<p><code>&lt;script type="text/javascript" src="mootools-1.2.4-core.js"&gt;&lt;/script&gt;</code><br />
<code>&lt;script type="text/javascript" src="mooInputLabel.js"&gt;&lt;/script&gt;</code></p>
<p>&nbsp;</p>
<p style="margin-bottom: 15px;"><b>3</b> &#8211; add the appropriate code to each <code>&lt;input&gt;</code> tag on the page that you want to use this feature &#8211; example(s)&#8230;</p>
<p><code>&lt;input type="text" id="username" class="label" /&gt;</code><br />
<code>&lt;input type="text" id="password" class="label" /&gt;</code></p>
<p class="note">* the &#8220;label&#8221; class signifies this input field as one that uses this feature.<br />The &#8220;id&#8221; is also the text used as the &#8220;label&#8221; value.</p>
<p>&nbsp;</p>
<p style="margin-bottom: 15px;"><b>4</b> &#8211; finally, we add a MooTools &#8220;domready&#8221; event to the page to set everything up once the page has completed loading and the DOM is ready. The following code will apply our new feature to all <code>&lt;input&gt;</code> elements with a class of &#8220;label&#8221;&#8230;</p>
<p><code>window.addEvent('domready', function() {</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;new mooInputLabel({</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;inputs: $$('input.label')</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});</code><br />
<code>});</code></p>
<p style="margin-bottom: 15px;">&nbsp;</p>
<p><b>working example:</b></p>
<input type="text" id="username" class="label" style="width: 150px; font-size: 18px; margin-right: 20px;" />
<input type="text" id="password" class="label" style="width: 150px; font-size: 18px;" />
<p>&nbsp;</p>
<p style="margin: 15px 0px 10px 0px;"><a href="http://dustincaruso.com/2009/01/defaultvalueactsashint/" style="color: red;">Click here to view the original article</a></p>
<p><script type="text/javascript" src="/wp-content/examples/mooInputLabel.js"></script></p>
<p><script type="text/javascript">
window.addEvent('domready', function() {
	new mooInputLabel({
    	inputs: $$('input.label')
    });
});
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://dustincaruso.com/javascript/mooinputlabel/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>defaultValueActsAsHint for MooTools</title>
		<link>http://dustincaruso.com/javascript/defaultvalueactsashint/</link>
		<comments>http://dustincaruso.com/javascript/defaultvalueactsashint/#comments</comments>
		<pubDate>Wed, 14 Jan 2009 16:07:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[MooTools]]></category>

		<guid isPermaLink="false">http://dustincaruso.com/?p=92</guid>
		<description><![CDATA[Click here to view my newer post with an updated class and new code I just got done reading a great article on Ajaxian about Thomas Fuchs&#8217; new JavaScript creation &#8211; defaultValueActsAsHint. It&#8217;s best described in his words&#8230; An often occuring UI pattern is “use the value of a textfield as hint what to input”. [...]]]></description>
			<content:encoded><![CDATA[<p style="margin: 15px 0px 10px 0px;"><a href="http://dustincaruso.com/2009/11/mooinputlabel/" style="color: red;">Click here to view my newer post with an updated class and new code</a></p>
<p>I just got done reading a <a href="http://ajaxian.com/archives/defaultvalueactsashint" target="_new">great article</a> on <a href="http://ajaxian.com" target="_new">Ajaxian</a> about <a href="http://mir.aculo.us/" target="_new">Thomas Fuchs</a>&#8217; new JavaScript creation &#8211; <a href="http://mir.aculo.us/2009/1/7/using-input-values-as-hints-the-easy-way" target="_new">defaultValueActsAsHint.</a> It&#8217;s best described in his words&#8230;</p>
<blockquote><p>An often occuring UI pattern is “use the value of a textfield as hint what to input”. These fields all auto-clear when the user first focuses it (by clicking or tabbing it), and if nothing is entered, the hint will be shown once again once the user leaves it.</p></blockquote>
<p>Then it hit me. We&#8217;ve been doing this in <a href="http://schmedley.com" target="_new">schmedley</a> for quite some time now in several of our schmidgets (Facebook, MySpace, Twitter, Sticky Note, To-Do List, Bookmarks and POP3/IMAP4 Email). It makes perfect sense that widget development would make good use of this <a href="http://ui-patterns.com/pattern/InputPrompt" target="_new">User Interface Pattern</a>, as screen real estate in a widget is extremely limited. There is no point in making space for &#8220;labels&#8221; for text input fields when you can put that text directly IN the field.</p>
<p>So &#8211; to make a long story short &#8211; I decided to do as Thomas has done and share my little JavaScript tidbit with the world. My version will be in the form of a <a href="http://www.mootools.net" target="_new">MooTools</a> class (since that is the framework that powers schmedley).</p>
<p>I&#8217;ve named it&#8230;</p>
<h4>mooInputLabel</h4>
<p style="margin-bottom: 15px;">&nbsp;<br /><b>1</b> &#8211; copy and paste the following code into your favorite text editor and save it as a new .js file (“mooInputLabel.js”, for example)…</p>
<p><code>var mooInputLabel = new Class({</code></p>
<p><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Implements: [Options, Events],</code></p>
<p><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;options: {</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;inputs: [ ]</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},</code></p>
<p><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;initialize: function(options) {</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;this.setOptions(options);</code></p>
<p><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var inputs = this.options.inputs;</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;var self = this;</code></p>
<p><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;inputs.each(function(e) {</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;e.addEvent(&#39;focus&#39;, function() {</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.inputFocus(e.id);</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;})</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.addEvent(&#39;blur&#39;, function() {</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;self.inputBlur(e.id);</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;})</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.setProperty(&#39;value&#39;, e.id)</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.setStyle(&#39;color&#39;, &#39;#ccc&#39;);</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},</code></p>
<p><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;inputFocus: function(x) {</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($(x).value == x) {</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(x).value = &#39;&#39;;</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</code></p>
<p><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(x).setStyle(&#39;color&#39;, &#39;#000&#39;);</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},</code></p>
<p><code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;inputBlur: function(x) {</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if ($(x).value == &#39;&#39;) {</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(x).value = x;</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(x).setStyle(&#39;color&#39;, &#39;#ccc&#39;);</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else if ($(x).value == x) {</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(x).setStyle(&#39;color&#39;, &#39;#ccc&#39;);</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else {</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$(x).setStyle(&#39;color&#39;, &#39;#000&#39;);</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</code><br />
<code>});</code></p>
<p>&nbsp;</p>
<p style="margin-bottom: 15px;"><b>2</b> &#8211; then, make sure to place links to your new .js file as well as the MooTools core in the <code>&lt;head&gt;</code> of your document</p>
<p><code>&lt;script type="text/javascript" src="mootools-1.2.1.js"&gt;&lt;/script&gt;</code><br />
<code>&lt;script type="text/javascript" src="mooInputLabel.js"&gt;&lt;/script&gt;</code></p>
<p>&nbsp;</p>
<p style="margin-bottom: 15px;"><b>3</b> &#8211; add the appropriate code to each <code>&lt;input&gt;</code> tag on the page that you want to use this feature &#8211; example(s)&#8230;</p>
<p><code>&lt;input type="text" id="username" class="label" /&gt;</code><br />
<code>&lt;input type="text" id="password" class="label" /&gt;</code></p>
<p class="note">* the &#8220;label&#8221; class signifies this input field as one that uses this feature.<br />The &#8220;id&#8221; is also the text used as the &#8220;label&#8221; value.</p>
<p>&nbsp;</p>
<p style="margin-bottom: 15px;"><b>4</b> &#8211; finally, we add a MooTools &#8220;domready&#8221; event to the page to set everything up once the page has completed loading and the DOM is ready. The following code will apply our new feature to all <code>&lt;input&gt;</code> elements with a class of &#8220;label&#8221;&#8230;</p>
<p><code>window.addEvent('domready', function() {</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;new mooInputLabel({</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;inputs: $$('input.label')</code><br />
<code>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;});</code><br />
<code>});</code></p>
<p style="margin-bottom: 15px;">&nbsp;</p>
<p><b>working example:</b></p>
<input type="text" id="username" class="evil" style="width: 150px; font-size: 18px; margin-right: 20px;" />
<input type="text" id="password" class="evil" style="width: 150px; font-size: 18px;" />
<p>&nbsp;</p>
<p style="margin: 15px 0px 10px 0px;"><a href="http://dustincaruso.com/2009/11/mooinputlabel/" style="color: red;">Click here to view my newer post with an updated class and new code</a></p>
<p><script type="text/javascript" src="/wp-content/examples/mooInputEVIL.js"></script></p>
<p><script type="text/javascript">
window.addEvent('domready', function() {
	new mooInputEVIL({
    	inputs: $$('input.evil')
    });
});
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://dustincaruso.com/javascript/defaultvalueactsashint/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>View Source on iPhone</title>
		<link>http://dustincaruso.com/javascript/view-source-on-iphone/</link>
		<comments>http://dustincaruso.com/javascript/view-source-on-iphone/#comments</comments>
		<pubDate>Wed, 28 Nov 2007 00:12:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Browsers]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[browser]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[developer]]></category>
		<category><![CDATA[safari]]></category>
		<category><![CDATA[source]]></category>
		<category><![CDATA[view]]></category>
		<category><![CDATA[web]]></category>

		<guid isPermaLink="false">http://dustincaruso.com/2007/11/27/view-source-on-iphone/</guid>
		<description><![CDATA[This is a cool little tidbit for those of you web developers that have an iPhone. A Safari bookmarklet that enables you to &#8220;View Source&#8221; for any web page while using Safari on the iPhone. A bookmarklet (in case you didn&#8217;t know) is &#8220;a JavaScript program stored as a URL within a bookmark&#8221; as defined [...]]]></description>
			<content:encoded><![CDATA[<p>This is a cool little tidbit for those of you web developers that have an iPhone. A Safari bookmarklet that enables you to &#8220;View Source&#8221; for any web page while using Safari on the iPhone. A <a href="http://en.wikipedia.org/wiki/Bookmarklet" target="_new">bookmarklet</a> (in case you didn&#8217;t know) is &#8220;a JavaScript program stored as a URL within a bookmark&#8221; as defined by <a href="http://wikipedia.org/" target="_new">Wikipedia</a>.</p>
<p>The steps that follow will walk you through the process&#8230;<br />&nbsp;</p>
<p><b>1</b> &#8211; Select and &#8220;copy&#8221; the long string of code below&#8230;</p>
<pre><code>
<script type="text/javascript">
if (navigator.userAgent.indexOf("Firefox")!=-1) {
document.write("javascript:var%20sourceWindow%20%3D%20window.open%28%27about%3Ablank");
document.write("\n");
document.write("%27%29%3B%20%0Avar%20newDoc%20%3D%20sourceWindow.document%3B%20%0Ane");
document.write("\n");
document.write("wDoc.open%28%29%3B%20%0AnewDoc.write%28%27%3Chtml%3E%3Chead%3E%3Ctit");
document.write("\n");
document.write("le%3ESource%20of%20%27%20%2B%20document.location.href%20%2B%20%27%3C");
document.write("\n");
document.write("/title%3E%3C/head%3E%3Cbody%3E%3C/body%3E%3C/html%3E%27%29%3B%20%0An");
document.write("\n");
document.write("ewDoc.close%28%29%3B%20%0Avar%20pre%20%3D%20newDoc.body.appendChild%");
document.write("\n");
document.write("28newDoc.createElement%28%22pre%22%29%29%3B%20%0Apre.appendChild%28n");
document.write("\n");
document.write("ewDoc.createTextNode%28document.documentElement.innerHTML%29%29%3B");
}
else {
document.write("javascript:var%20sourceWindow%20%3D%20window.open%28%27about%3Ablank%27%29%3B%20%0Avar%20newDoc%20%3D%20sourceWindow.document%3B%20%0AnewDoc.open%28%29%3B%20%0AnewDoc.write%28%27%3Chtml%3E%3Chead%3E%3Ctitle%3ESource%20of%20%27%20%2B%20document.location.href%20%2B%20%27%3C/title%3E%3C/head%3E%3Cbody%3E%3C/body%3E%3C/html%3E%27%29%3B%20%0AnewDoc.close%28%29%3B%20%0Avar%20pre%20%3D%20newDoc.body.appendChild%28newDoc.createElement%28%22pre%22%29%29%3B%20%0Apre.appendChild%28newDoc.createTextNode%28document.documentElement.innerHTML%29%29%3B");
}
</script>
</code></pre>
<p class="note">&nbsp;<br />* This needs to be one long continuous string, so if you&#8217;re cutting and pasting from Firefox, you&#8217;ll need to remove the line breaks and/or spaces.</p>
<p>&nbsp;<br /><b>2</b> &#8211; On your computer, go to ANY webpage in Safari and bookmark it using either the &#8220;+&#8221; (Add Bookmark) button or by choosing &#8220;Add Bookmark&#8230;&#8221; from the &#8220;Bookmarks&#8221; menu. When saving the bookmark name it &#8220;View Source&#8221; and save it wherever you&#8217;d like in your bookmark hierarchy.</p>
<p><b>3</b> &#8211; Now, go into the bookmark manager. Do this by clicking the bookmark icon in your bookmarks bar or by choosing &#8220;Show All Bookmarks&#8221; from the &#8220;Bookmarks&#8221; menu. Navigate to the bookmark you just saved.</p>
<p><b>4</b> &#8211; Single-click on the URL for the bookmark to highlight the text for editing, and paste the text/code you just copied above.</p>
<p><b>5</b> &#8211; Plug in your iPhone and sync it up w/ your bookmarks on your computer.<br />&nbsp;</p>
<p>Now, to actually use it &#8211; launch your Safari web browser on your iPhone and navigate to whatever web page you would like to view the source code for. After the page has loaded, click the bookmark icon in the lower Safari navigation bar (3rd from the left), and navigate to your &#8220;View Source&#8221; bookmark and click it.</p>
<p>And there you have it.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://dustincaruso.com/javascript/view-source-on-iphone/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>JavaScript email cloaking</title>
		<link>http://dustincaruso.com/xhtml/javascript-email-cloaking/</link>
		<comments>http://dustincaruso.com/xhtml/javascript-email-cloaking/#comments</comments>
		<pubDate>Sun, 25 Nov 2007 19:31:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[XHTML]]></category>

		<guid isPermaLink="false">http://dustincaruso.com/2007/11/25/anti-spam-javascript-email-cloaking/</guid>
		<description><![CDATA[Here&#8217;s another quick one. Below is a simple JavaScript that you can use to cloak your email address when posting it on your website. It dynamically writes the email link into the page which will thwart most spambots (server-side creation of the email link will always be a little more secure). Here&#8217;s how we do [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s another quick one. Below is a simple JavaScript that you can use to cloak your email address when posting it on your website. It dynamically writes the email link into the page which will thwart most spambots (server-side creation of the email link will always be a little more secure). Here&#8217;s how we do it&#8230;</p>
<p>&nbsp;<br /><b>1</b> &#8211; create a new JavaScript file, name it &#8220;email.js&#8221;, and paste in the following&#8230;</p>
<p><code>var prefix = "username";</code><br />
<code>var suffix = "domainname.com";</code><br />
<code>var address = prefix + "@" + suffix;</code></p>
<p><code>document.write('&lt;a href="mai');</code><br />
<code>document.write('lto:' + address + '"&gt;click here&lt;/a&gt;');</code></p>
<p>&nbsp;<br /><b>2</b> &#8211; then place the following code in your page where you want the link to appear&#8230;</p>
<p><code>&lt;script type="text/javascript" src="email.js"&gt;&lt;/script&gt;</code></p>
<p>&nbsp;<br /><b>example:</b></p>
<p><code>&lt;p&gt;to contact me via email, please &lt;script type="text/javascript" src="email.js"&gt;&lt;/script&gt;&lt;/p&gt;</code>
</p>
<p>&nbsp;<br /><b>result:</b></p>
<p>to contact me via email, please <script type="text/javascript" src="/wp-content/examples/email.js"></script></p>
<p>&nbsp;</p>
<p>All you have to do is change 3 variables. The email prefix and suffix are in the first 2 lines of code in the external JavaScript file. The text to display for the hyperlink is in the last line of code (in this case &#8211; &#8220;click here&#8221;). It&#8217;s pretty self-explanatory.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://dustincaruso.com/xhtml/javascript-email-cloaking/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
