<?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>MikeBobiney.com &#187; code</title>
	<atom:link href="http://www.mikebobiney.com/tag/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.mikebobiney.com</link>
	<description>Tales from a Mac-toting software craftsman.</description>
	<lastBuildDate>Mon, 26 Dec 2011 20:01:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
<cloud domain='www.mikebobiney.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
		<item>
		<title>Creating a login form with jQuery</title>
		<link>http://www.mikebobiney.com/2008/08/20/creating-a-login-form-with-jquery/</link>
		<comments>http://www.mikebobiney.com/2008/08/20/creating-a-login-form-with-jquery/#comments</comments>
		<pubDate>Wed, 20 Aug 2008 11:30:29 +0000</pubDate>
		<dc:creator>Mike Bobiney</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[demo]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.mikebobiney.com/?p=241</guid>
		<description><![CDATA[Creating a login (or any form for that matter) can be trickier than it looks. After all how difficult can two text boxes a button and some labels be? There are different ways to accomplish this task, some using more proper semantically correct markup techniques than others. This example will attempt to give a real [...]]]></description>
			<content:encoded><![CDATA[<p>Creating a login (or any form for that matter) can be trickier than it looks.  After all how difficult can two text boxes a button and some labels be?  There are different ways to accomplish this task, some using more proper <a href="http://en.wikipedia.org/wiki/Semantic_Web" target="_blank">semantically</a> correct markup techniques than others.  This example will attempt to give a real world case of how easy it can be to target elements contained inside the form with minimal scripting using the jQuery framework.</p>
<p>We&#8217;ll first start out with some html markup, notice the lack of css class attributes or JavaScript event handlers present.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;fieldset&gt;
	&lt;legend&gt;Log In&lt;/legend&gt;
	&lt;p id=&quot;loginResult&quot;&gt;Invalid login.. try again.&lt;/p&gt;
	&lt;form id=&quot;login&quot; method=&quot;post&quot;&gt;
		&lt;dl&gt;
			&lt;dt&gt;&lt;label for=&quot;username&quot;&gt;Username:&lt;/label&gt;&lt;/dt&gt;
			&lt;dd&gt;&lt;input id=&quot;username&quot; type=&quot;text&quot; /&gt;&lt;/dd&gt;
			&lt;dt&gt;&lt;label for=&quot;password&quot;&gt;Password:&lt;/label&gt;&lt;/dt&gt;
			&lt;dd&gt;&lt;input id=&quot;password&quot; type=&quot;text&quot; /&gt;&lt;/dd&gt;
		&lt;/dl&gt;
		&lt;p&gt;&lt;input type=&quot;submit&quot; value=&quot;Login&quot; /&gt;&lt;/p&gt;
	&lt;/form&gt;
	&lt;small&gt;u:username / p:password&lt;/small&gt;
&lt;/fieldset&gt;
</pre>
<p>The next step we take is to target each element down the list and assign it a css class.  We do this by using <a href="/index.php?p=167">jQuery&#8217;s element specific selectors</a> <strong>:text</strong> and <strong>:submit</strong>.</p>
<pre class="brush: jscript; title: ; notranslate">
	$(function(){
		$('form#login :text').addClass('inputTextbox');
		$('form#login :submit').addClass('inputSubmitBtn');
	});
</pre>
<p>Next, we&#8217;ll add the event handler for the submit button by using <strong>.click()</strong>. To make things easier on ourselves we could always shorten our code by <a href="/index.php?p=167">chaining</a> the click event at the end of our submit button selector which was already defined in the previous step.</p>
<pre class="brush: jscript; title: ; notranslate">
$('form#login :submit').addClass('inputSubmitBtn').click(function() {
     // click event code
}
</pre>
<p>Throw in an animation for good measure to display a message for invalid attempts and you&#8217;re good to go.  Here is the full JavaScript code we&#8217;re working with.</p>
<pre class="brush: jscript; title: ; notranslate">
		$(function(){
			$('form#login :text').addClass('inputTextbox');
			$('form#login :submit').addClass('inputSubmitBtn').click(function(){
				if($('#username').val() != &quot;username&quot; || $('#password').val() != &quot;password&quot;)
				{
					for(i=0;i&lt;5;i++)
						$(&quot;#loginResult&quot;).animate({opacity: 'toggle'}, 500 );	

					$(&quot;#loginResult&quot;).fadeIn(500);
					return false;
				};
			});
	    });
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.mikebobiney.com/2008/08/20/creating-a-login-form-with-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery Framework First Impressions</title>
		<link>http://www.mikebobiney.com/2008/08/06/jquery-framework-first-impressions/</link>
		<comments>http://www.mikebobiney.com/2008/08/06/jquery-framework-first-impressions/#comments</comments>
		<pubDate>Wed, 06 Aug 2008 12:21:46 +0000</pubDate>
		<dc:creator>Mike Bobiney</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[framework]]></category>
		<category><![CDATA[impression]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://www.mikebobiney.com/?p=97</guid>
		<description><![CDATA[Javascript frameworks come in a variety of flavors, they&#8217;ll typically encapsulate common practices that web developers frequently use in their sites. With the three dominant mainstream browsers (FF3, IE7, Safari and potentially even more) to worry about, each with a slightly different technique to program for, it can be a good practice to use a [...]]]></description>
			<content:encoded><![CDATA[<p>Javascript frameworks come in a variety of flavors, they&#8217;ll typically encapsulate common practices that web developers frequently use in their sites.  With the three dominant mainstream browsers (FF3, IE7, Safari and potentially even more) to worry about, each with a slightly different technique to program for, it can be a good practice to use a tested framework which works across the board and remove the overhead associated with testing common methods. </p>
<p>The framework which I&#8217;ve come to grow quite fond of lately is called jQuery. JQuery is best described as a type of web designers toy box that focuses on separating content from functionality.  So what do I mean by this?</p>
<p>Here is an example setup for a jQuery project.</p>
<img src="http://www.mikebobiney.com/wp-content/uploads/2008/08/jquerydiagram.jpg" alt="Sample jQuery Page Structure" width="415" height="299" class="size-full wp-image-104" />
<pre class="brush: jscript; title: ; notranslate">
$(document).ready(function(){
   $(&quot;#Button1&quot;).click(function(event){
	alert(&quot;Say Something&quot;);
 });
});
</pre>
<p>Whats nice about jQuery is that the footprint is relatively small at 54k or less, and if you prefer there is a file hosted from the <a href="http://code.google.com/apis/ajaxlibs/documentation/index.html#jquery" target="_blank">Google API website</a> which you can link to directly inside of your page.  In fact you&#8217;ll find that many tasks require a minimal amount of code to achieve some impressive results.</p>
<pre class="brush: jscript; title: ; notranslate">
// Resize lightbox on button click

$(document).ready(function(){
   $(&quot;#Button1&quot;).click(function(){
      $(&quot;#lightbox&quot;).animate({
          width: &quot;1000px&quot;,
          height: &quot;400px&quot;,
          fontSize: &quot;3em&quot;
      });
   });
});
</pre>
<p>Those familiar with object oriented programming will be glad to know that jQuery also supports chainability as in this example.</p>
<pre class="brush: jscript; title: ; notranslate">
$(&quot;a&quot;).addClass(&quot;test&quot;).show().html(&quot;foo&quot;);
</pre>
<p>The jQuery framework is becoming increasingly popular among many high profile sites such as Netflix, NBC and Dell to name a few.  Even the Microsoft development community is taking notice as their next update of Visual Studio will be providing jQuery code completion within the software itself.</p>
<p>For more information on jQuery you can visit their website: <a href="http://jquery.com/" target="_blank">http://jquery.com/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.mikebobiney.com/2008/08/06/jquery-framework-first-impressions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

