<?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>hocuspokus &#187; jquery</title>
	<atom:link href="http://hocuspokus.net/tag/jquery/feed" rel="self" type="application/rss+xml" />
	<link>http://hocuspokus.net</link>
	<description>the life and times of a code monkey</description>
	<lastBuildDate>Tue, 01 Jun 2010 16:40:43 +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>Release: toggleController Plugin&#160;1.0</title>
		<link>http://hocuspokus.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fhocuspokus.net%2F2008%2F10%2Frelease-togglecontroller-plugin-10&amp;seed_title=Release%3A+toggleController+Plugin%26%23160%3B1.0</link>
		<comments>http://hocuspokus.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fhocuspokus.net%2F2008%2F10%2Frelease-togglecontroller-plugin-10&amp;seed_title=Release%3A+toggleController+Plugin%26%23160%3B1.0#comments</comments>
		<pubDate>Sat, 04 Oct 2008 18:02:21 +0000</pubDate>
		<dc:creator>Daz</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://hocuspokus.net/?p=215</guid>
		<description><![CDATA[I&#8217;ve just spent the last week on a Javascript and Ajax course (thanks to work for footing the bill)! As such I come armed with some newfound javascript knowledge! Here&#8217;s the first fruits of my labour - a very simple &#8230; <a href="http://hocuspokus.net/feeder/?FeederAction=clicked&#38;feed=Articles+%28RSS2%29&#38;seed=http%3A%2F%2Fhocuspokus.net%2F2008%2F10%2Frelease-togglecontroller-plugin-10&#38;seed_title=Release%3A+toggleController+Plugin%26%23160%3B1.0">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just spent the last week on a Javascript and Ajax course (thanks to work for footing the bill)! As such I come armed with some newfound javascript knowledge! <img src='http://hocuspokus.net/wp-content/plugins/smilies-themer/tango/face-smile.png' alt=':)' class='wp-smiley' /> </p>

<p>Here&#8217;s the first fruits of my labour - a very simple <a href="http://www.jquery.com">jQuery</a> plugin that enables you to unobtrusively make an element on a webpage collapsable, and have the showing/hiding controlled by another element.</p>

<p>Like I said, this is very basic stuff and there is probably about a million other (most likely more feature-full and better) plugins that do the same thing already on the web, but it&#8217;s all I really need for it to be useful for my stuff and I had fun learning how to do this - never know someone else may find it useful!</p>

<p>If you want to have a play, here&#8217;s where to go:</p>

<p><a href="http://hocuspokus.net/projects/jquery-plugins/">My Projects Page</a><br />
<a href="http://hocuspokus.net/stuff/jquerytogglecontrol/">Demo/Documentation</a></p>
]]></content:encoded>
			<wfw:commentRss>http://hocuspokus.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fhocuspokus.net%2F2008%2F10%2Frelease-togglecontroller-plugin-10&amp;seed_title=Release%3A+toggleController+Plugin%26%23160%3B1.0/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Default Text Field Values That Disappear on&#160;Focus</title>
		<link>http://hocuspokus.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fhocuspokus.net%2F2008%2F05%2Fdefault-text-field-values-that-disappear-on-focus&amp;seed_title=Default+Text+Field+Values+That+Disappear+on%26%23160%3BFocus</link>
		<comments>http://hocuspokus.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fhocuspokus.net%2F2008%2F05%2Fdefault-text-field-values-that-disappear-on-focus&amp;seed_title=Default+Text+Field+Values+That+Disappear+on%26%23160%3BFocus#comments</comments>
		<pubDate>Fri, 16 May 2008 18:08:58 +0000</pubDate>
		<dc:creator>Daz</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[noteworthy]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[prototype]]></category>

		<guid isPermaLink="false">http://hocuspokus.net/?p=146</guid>
		<description><![CDATA[You will have noticed this effect out on your travels on the internet - a text input field has some default text in it (often in a slightly dimmed colour), and when you click on the text box, default text &#8230; <a href="http://hocuspokus.net/feeder/?FeederAction=clicked&#38;feed=Articles+%28RSS2%29&#38;seed=http%3A%2F%2Fhocuspokus.net%2F2008%2F05%2Fdefault-text-field-values-that-disappear-on-focus&#38;seed_title=Default+Text+Field+Values+That+Disappear+on%26%23160%3BFocus">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>You will have noticed this effect out on your travels on the internet - a text input field has some default text in it (often in a slightly dimmed colour), and when you click on the text box, default text disappears and then reappears when you click away from the box.  It happens on the search box to the right here too.</p>

<p>I needed this same effect at work today so a quick Google came up with this great <a href="http://webdeveloper.beforeseven.com/jquery/default-text-field-value-disappears-focus">blog post</a> - a lovely example of the exact effect I was looking for in both raw javascript and a version using the <a href="http://jquery.com/">jQuery</a> library.</p>

<blockquote>
  <p>The script searches the page that it&#8217;s inserted on for all form input fields that have a class of &#8216;default-value&#8217; applied. Each form input field must also have a unique ID.</p>
  
  <p>When the page loads the script changes the color of the text in the text fields it has found to the value of &#8216;inactive&#95;color&#8217;. If the user clicks on the input field, the default text is blanked, and the colour changed to &#8216;active&#95;color&#8217;. If the user clicks away from the input field, i.e. the input field loses focus, the value of the text field will revert back to the original text, and the colour will change back to &#8216;inactive&#95;color&#8217;, unless the user has entered some other text.</p>
</blockquote>

<p>Here&#8217;s a copy of the jQuery version for my own personal notes, never know when that could be useful:</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
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">/*
 * Written by Rob Schmitt, The Web Developer's Blog
 * http://webdeveloper.beforeseven.com/
 */</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> active_color <span style="color: #339933;">=</span> <span style="color: #3366CC;">'#000'</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Colour of user provided text</span>
<span style="color: #003366; font-weight: bold;">var</span> inactive_color <span style="color: #339933;">=</span> <span style="color: #3366CC;">'#999'</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Colour of default text</span>
&nbsp;
$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</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: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;input.default-value&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;color&quot;</span><span style="color: #339933;">,</span> inactive_color<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #003366; font-weight: bold;">var</span> default_values <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;input.default-value&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066;">focus</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: #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>default_values<span style="color: #009900;">&#91;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">id</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      default_values<span style="color: #009900;">&#91;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">id</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">value</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">==</span> default_values<span style="color: #009900;">&#91;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">id</span><span style="color: #009900;">&#93;</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;">value</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">''</span><span style="color: #339933;">;</span>
      <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">style</span>.<span style="color: #660066;">color</span> <span style="color: #339933;">=</span> active_color<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066;">blur</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: #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: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">''</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;">style</span>.<span style="color: #660066;">color</span> <span style="color: #339933;">=</span> inactive_color<span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> default_values<span style="color: #009900;">&#91;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">id</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</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><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>


<p>However, we don&#8217;t use jQuery at work, our entire site is based around <a href="http://www.prototypejs.org/">Prototype</a> and <a href="http://script.aculo.us/">script.aculo.us</a>, so I did a bit of butchering and here&#8217;s the code adapted to use Prototype:</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
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">/*
 * Written by Darren Oakley
 * http://hocuspokus.net
 */</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> active_color <span style="color: #339933;">=</span> <span style="color: #3366CC;">'#000'</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Colour of user provided text</span>
<span style="color: #003366; font-weight: bold;">var</span> inactive_color <span style="color: #339933;">=</span> <span style="color: #3366CC;">'#999'</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Colour of default text</span>
&nbsp;
Event.<span style="color: #660066;">observe</span><span style="color: #009900;">&#40;</span> window<span style="color: #339933;">,</span> <span style="color: #3366CC;">'load'</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> default_values <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Array<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    $$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;input.default-value&quot;</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>s<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        $<span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">setStyle</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> color<span style="color: #339933;">:</span> inactive_color <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        $<span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">observe</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>
            <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>default_values<span style="color: #009900;">&#91;</span>s.<span style="color: #660066;">id</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                default_values<span style="color: #009900;">&#91;</span>s.<span style="color: #660066;">id</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> s.<span style="color: #660066;">value</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>s.<span style="color: #660066;">value</span> <span style="color: #339933;">==</span> default_values<span style="color: #009900;">&#91;</span>s.<span style="color: #660066;">id</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                s.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">''</span><span style="color: #339933;">;</span>
                $<span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">setStyle</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> color<span style="color: #339933;">:</span> active_color <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;">&#40;</span>s<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">observe</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'blur'</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;">if</span> <span style="color: #009900;">&#40;</span>s.<span style="color: #660066;">value</span> <span style="color: #339933;">==</span> <span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                    $<span style="color: #009900;">&#40;</span>s<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">setStyle</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> color<span style="color: #339933;">:</span> inactive_color <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                    s.<span style="color: #660066;">value</span> <span style="color: #339933;">=</span> default_values<span style="color: #009900;">&#91;</span>s.<span style="color: #660066;">id</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</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><span style="color: #339933;">;</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><span style="color: #339933;">;</span></pre></td></tr></table></div>


<p>Now all you need to do is give your input text fields a unique id, and the class of &#8216;default-value&#8217;, then the script will take care of the rest.</p>
]]></content:encoded>
			<wfw:commentRss>http://hocuspokus.net/feeder/?FeederAction=clicked&amp;feed=Articles+%28RSS2%29&amp;seed=http%3A%2F%2Fhocuspokus.net%2F2008%2F05%2Fdefault-text-field-values-that-disappear-on-focus&amp;seed_title=Default+Text+Field+Values+That+Disappear+on%26%23160%3BFocus/feed</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->