<?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>SixCrayons &#187; jQuery</title>
	<atom:link href="http://sixcrayons.com/tag/jquery/feed/" rel="self" type="application/rss+xml" />
	<link>http://sixcrayons.com</link>
	<description>non-toxic designing</description>
	<lastBuildDate>Mon, 12 Apr 2010 14:33:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Designer to Developer, Taking the Plunge</title>
		<link>http://sixcrayons.com/2009/09/22/designer-to-developer-taking-the-plunge/</link>
		<comments>http://sixcrayons.com/2009/09/22/designer-to-developer-taking-the-plunge/#comments</comments>
		<pubDate>Tue, 22 Sep 2009 12:05:52 +0000</pubDate>
		<dc:creator>benjamin</dc:creator>
				<category><![CDATA[Design]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Designer]]></category>
		<category><![CDATA[Developer]]></category>
		<category><![CDATA[Html]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://sixcrayons.com/?p=598</guid>
		<description><![CDATA[Most designers be it, fashion, architecture, graphic or web designers are born with a natural eye for design. It&#8217;s something that is with you [...]]]></description>
			<content:encoded><![CDATA[<p class="first">Most designers be it, fashion, architecture, graphic or web designers are born with a natural eye for design. It&#8217;s something that is with you from the day you were born, an instinct to make the world a prettier place, but how many fashion designers take to the catwalk and how many architects put on a hard hat and start building a wall? Not many, yet in the competitive world of the web, designers these days are expected to know all things, html, css, javascript, php, asp the list goes on&#8230;</p>
<p><img class="alignleft size-full wp-image-674" src="http://sixcrayons.com/files/2009/09/plunge4.jpg" alt="plunge4" width="250" height="224" /></p>
<p>As daunting as it may sound for even the most seasoned of web designers, web development is just another beast to tame and it can honestly be quite fun at the same time!</p>
<p>I decided to take this step several years ago. I was faced with a predicament. I could put together all these lovely looking designs but who was I going to get to turn it into a fully fledged website for the whole world to see? I certainly couldn&#8217;t afford to pay anyone. I was faced with a challenge, how was I going to learn about heads, body&#8217;s, positions, heights, widths, tables, no tables&#8230; yes I&#8217;m talking about front end web development!</p>
<p>This article will give you my recommended first steps to becoming an designer/developer all rounder. Something that is very attractive to prospective employers or if you freelance, hey, you get to keep the full hourly rate! You can say goodbye to outsourcing!</p>
<h3 class="title">Slicing PSD’s.</h3>
<p>This is your starting motor to building a website. You&#8217;ve got your design but at the moment its a raw format you need to cut up your design into several different images. This process is made very easy with the Photoshop slicing tool. There are many resources out there to help you but I recommend you follow this tutorial: <a href="http://www.bolducpress.com/tutorials/from-photoshop-to-html/">From Photoshop to HTML</a></p>
<h3 class="title">HTML</h3>
<p>HTML is the foundation of every website. Although this markup may look daunting to the untrained eye. Its a simple and user friendly language (if you can call it that). Not only is it easy to get to grips with but there are more resources than you can shake a stick at on the internet to help you along the way.</p>
<p>When I was first learning HTML I found experimenting, as with many things is the best way to learn. HTML can be quite flexible in many browsers meaning that it wont keel over and die if you don&#8217;t close a tag here or there.</p>
<p>Here is a selection of recommended resources to get you going:</p>
<ul>
<li><a href="http://www.w3schools.com/htmL/">W3 Schools HTML Tutorial</a></li>
<li><a href="http://www.quackit.com/html/tutorial/">Quackit.com HTML Tutorial</a></li>
</ul>
<p>Also here are some interesting articles on the up-and-coming HTML 5. For those of you who don&#8217;t know, HTML 5 is going to be the latest release of standard markup by WHATWG:</p>
<ul>
<li><a href="http://www.smashingmagazine.com/2009/08/04/designing-a-html-5-layout-from-scratch/">HTML 5 from Scratch</a></li>
<li><a href="http://www.smashingmagazine.com/2009/07/06/html-5-cheat-sheet-pdf/">HTML 5 Cheet Sheet</a></li>
</ul>
<p></br></p>
<h3 class="title">Semantic Markup</h3>
<p>You may hear many people ask you, dude, is your markup table-less? Well if you&#8217;re going to try and master HTML in this day and age then its probably worth readying up on this!</p>
<p>This is really part and parcel of today&#8217;s web, but if you don&#8217;t already know then why not take a moment to read up about it: <a href="http://en.wikipedia.org/wiki/Span_and_div">SPAN and DIV Wiki</a></p>
<h3 class="title">CSS</h3>
<p>Way back in the dot com boom all websites where sliced with html using tables. This made websites very large in size and even more difficult to view and update the source code and single styles such as links were very difficult to update. CSS bought all the different styles into one place which allowed one style to be shared by many pages. Beware though, each different browser can render CSS in a slightly different ways resulting in many hours swearing at a screen and pulling your hair out. Earlier versions of Internet Explorer are the biggest offenders with a campaign to get the last 14% of the browsers market share making the rounds on social networks recently: <a href="http://mashable.com/2009/08/04/ie6-no-more/">IE 6 no more</a></p>
<p>Here are some recommended resources on CSS:</p>
<ul>
<li><a href="http://www.w3schools.com/css/">W3 Schools CSS Tutorials</a></li>
<li><a href="http://www.subcide.com/tutorials/csslayout/index.aspx">Subcide CSS Layout Tutorial</a></li>
</ul>
<p>Once you’ve got these core skills under you&#8217;re belt, you will be on your way to becoming an all rounder! If your still hungry or maybe already know all these languages, I recommend you try learning something like jQuery and/or PHP.</p>
<p>Here are some great resources:</p>
<p><strong>jQuery:</strong></p>
<ul>
<li><a href="http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery">Getting Started with jQuery</a></li>
<li><a href="http://jqueryfordesigners.com/">jQuery for Designers</a></li>
</ul>
<p><strong>PHP:</strong></p>
<ul>
<li><a href="http://uk3.php.net/tut.php">PHP Getting Started</a></li>
<li><a href="http://devzone.zend.com/article/627">PHP 101</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://sixcrayons.com/2009/09/22/designer-to-developer-taking-the-plunge/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A simple jQuery input hint plug-in</title>
		<link>http://sixcrayons.com/2009/09/10/a-simple-jquery-input-hint-plug-in/</link>
		<comments>http://sixcrayons.com/2009/09/10/a-simple-jquery-input-hint-plug-in/#comments</comments>
		<pubDate>Thu, 10 Sep 2009 15:02:44 +0000</pubDate>
		<dc:creator>steve</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[hint]]></category>
		<category><![CDATA[input]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[plugin]]></category>

		<guid isPermaLink="false">http://sixcrayons.com/?p=319</guid>
		<description><![CDATA[A popular feature that can be found lot of web sites is the pre-population of form fields. When focusing on the input the default [...]]]></description>
			<content:encoded><![CDATA[<p class="first">A popular feature that can be found lot of web sites is the <strong>pre-population of form fields</strong>. When focusing on the input the default value is removed and when losing focus is replaced if the field value is left empty .</p>
<p>This tutorial will take you through the process of developing <strong>a simple jQuery input hint</strong> in an unobtrusive manner, allowing the form to function as expected when JavaScript is not enabled.</p>
<h3>Step One</h3>
<p>Before we start on the plug-in itself, we need some basic HTML defining our form.</p>
<pre>&lt;form method="get" action=""&gt;
	&lt;input type="text" value="" title="Search..." name="s" id="s" /&gt;
	&lt;input type="submit" value="Search" /&gt;
&lt;/form&gt;</pre>
<h3>Step Two</h3>
<p>The first stage of plug-in creation is setting up the <strong>basic plug-in structure</strong>. I tend to stick to the custom aliasing method as this will prevent conflicts with other libraries or frameworks and still allow us to make use of the &#8220;$&#8221; alias.</p>
<p>To achieve this, we execute an anonymous function, passing jQuery through and using &#8220;$&#8221; as the alias (although this could be any variable name), creating the fn and then enable chaining by looping through and returning each matched element.</p>
<pre>(function($) {
	$.fn.inputHint = function() {
		return this.each(function() {
			//...
		});
	};
})(jQuery);</pre>
<p>You can read more about plug-in authoring on the <a href="http://docs.jquery.com/Plugins/Authoring">jQuery site</a>.</p>
<h3>Step Three</h3>
<p>This plug-in is going to allow the default value to be defined by either passing it in as a set value or fetching the value from the title attribute of the input.</p>
<p>To achieve the first method we are going to use the <a href="http://docs.jquery.com/Utilities/jQuery.extend">extend method</a>, allowing us to globally set and re-define the customisations such as the hint value to use.</p>
<p>Here we take the globally defined values from the <strong>$.fn.inputHint.settings</strong> object and over-ride them with any values passed in by the <strong>callerSettings</strong> object. (Although we are using a deep / recursive merge in the example, it&#8217;s not totally necessary for this plug-in in it&#8217;s current state.)</p>
<pre>(function($) {
	$.fn.inputHint = function(callerSettings) {
		var settings = $.extend(true, {}, $.fn.inputHint.settings, callerSettings);
		return this.each(function() {
			//...
		});
	};
	$.fn.inputHint.settings = {
		value: false,
		className: false
	};
})(jQuery);</pre>
<h3>Step Four</h3>
<p>Now that we can define any custom options, let&#8217;s move on to actually doing something useful.</p>
<p>We need the ability to set the value of the input to the predefined value if the input is empty and clear the default value when the input receives focus.</p>
<p>Setting the default value if the input is empty:</p>
<pre>$(this).blur(function() {
	$(this).val($(this).val() == '' ? settings.value : $(this).val());
});</pre>
<p>Clearing the default value  on focus:</p>
<pre>$(this).focus(function() {
	$(this).val($(this).val() == settings.value ? '' : $(this).val());
});</pre>
<p>If we added these two events to our plug-in directly, it would look as follows:</p>
<pre>(function($) {
	$.fn.inputHint = function(callerSettings) {
		var settings = $.extend(true, {}, $.fn.inputHint.settings, callerSettings);
		return this.each(function() {
			$(this).blur(function() {
				$(this).val($(this).val() == '' ? settings.value : $(this).val());
			});
			$(this).focus(function() {
				$(this).val($(this).val() == settings.value ? '' : $(this).val());
			});
		});
	};
	$.fn.inputHint.settings = {
		value: false,
		className: false
	};
})(jQuery);</pre>
<p>We should however make use the chaining ability to cut down the amount of code we need to write.</p>
<p>The following introduces a couple of additions to go alongside the chaining, including the triggering of the blur event that will fire when the page loads and set the default value if necessary.</p>
<p>Here we have also included the ability to take the default value from the title attribute instead of the settings array <em>(see variable v)</em>.</p>
<pre>$.fn.inputHint = function(callerSettings) {
	var settings = $.extend(true, {}, $.fn.inputHint.settings, callerSettings);
	return this.each(function() {
		var n = $(this), v = settings.value || $(this).attr('title');
		n.focus(function() {
			n.val(n.val() == v ? '' : n.val());
		})
		.blur(function() {
			n.val(n.val() == '' ? v : n.val());
		})
		.blur();
	});
};</pre>
<p>Using what has been written so far will provide us with a working version, but there are a few additions.</p>
<p>We should unset the default value when the form is submitted, as most back end scripts will be checking against an empty value. This can be achieved by checking the existence of a parent form and unsetting the default value on submission by triggering the focus event.</p>
<p>The second addition is the ability to add and remove a class name to the input,  so we can set a style when the default value is present and a class name is defined <em>(see addClass and removeClass)</em>.</p>
<h3>Step Five: The Completed Plug-in:</h3>
<pre>(function($) {
	$.fn.inputHint = function(callerSettings) {
		var settings = $.extend(true, {}, $.fn.inputHint.settings, callerSettings);
		return this.each(function() {
			var n = $(this), v = settings.value || $(this).attr('title'), f = $(this.form);
			n.focus(function() {
				n.val(n.val() == v ? '' : n.val())
					.removeClass(settings.className);
			})
			.blur(function() {
				n.val(n.val() == '' ? v : n.val())
					.addClass(settings.className);
			})
			.blur();
			if (f) {
				f.submit(function(e) {
					n.trigger('focus');
				});
			}
		});
	};
	$.fn.inputHint.settings = {
		value: false,
		className: false
	};
})(jQuery);</pre>
<p>To make the whole effect work, add either of the following snippets to your page or script.<br />
The first will attempt to use the title attribute as there are no custom settings.</p>
<pre>$(function() {
	$('#s').inputHint();
});</pre>
<p>The second specifies a defined hint value and a class to add to the input when the hint is visible, which are passed through in the settings object.</p>
<pre>$(function() {
	$('#s').inputHint({
		value: "Search",
		className: 'faded'
	});
});</pre>
<p>You should place the plug-in inside a file called jquery.inputHint.js and include this file in your page, this conforms to the jQuery <a href="http://docs.jquery.com/Plugins/Authoring">plug-in author guidelines</a> (&#8220;Name your file jquery.[insert name of plugin].js&#8221;).</p>
<h3><strong>Additional Notes</strong></h3>
<p>This is just one method of achieving an input hint, an alternative method would be to use the the label tag instead of input and set the hint value based on this, or even place the label tag itself on top of the input.</p>
]]></content:encoded>
			<wfw:commentRss>http://sixcrayons.com/2009/09/10/a-simple-jquery-input-hint-plug-in/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

