<?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>Amazing Coder &#187; JavaScript</title>
	<atom:link href="http://amazingcoder.com/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://amazingcoder.com</link>
	<description>Coding tips and tricks.</description>
	<lastBuildDate>Sat, 30 May 2009 10:16:08 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Adding &#8220;Readability&#8221; to your web site easily.</title>
		<link>http://amazingcoder.com/2009/04/02/adding-readability-to-your-web-site-easily/</link>
		<comments>http://amazingcoder.com/2009/04/02/adding-readability-to-your-web-site-easily/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 17:50:51 +0000</pubDate>
		<dc:creator>Daniel Matthews</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[post]]></category>
		<category><![CDATA[readability]]></category>
		<category><![CDATA[reading]]></category>
		<category><![CDATA[tag]]></category>
		<category><![CDATA[text]]></category>
		<category><![CDATA[website]]></category>

		<guid isPermaLink="false">http://amazingcoder.com/?p=340</guid>
		<description><![CDATA[Web pages these days are all cluttered up with images, ads and videos, and it can be difficult to see through all that to the actual meat-and-potatoes of the page - the article. So much so that you miss things, and sometimes just give up reading through because the text size is too small, or the colours of the site mess with your eyes.

This quick tutorial will show you how to add a quick link to your site so that users can display your blog articles, help pages, or anything you want in a lovely, readable format. And it does so without the need for a new stylesheet.]]></description>
			<content:encoded><![CDATA[<p>Reading through twitter I stumbled across <a href="http://twitter.com/adactio/status/1370314821">this</a> tweet from Clearleft's Jeremy Keith. He mentioned a bookmarklet that adds readability to your site through removing distracting elements and increasing text size.</p>
<p>So i thought...well, why can't i add this bookmarklet to my site?, in case people want to read the articles that I've written without visual distraction. So I did, and you can see it on any of the single post pages on <a href="http://thepixeldistrict.com">my site.</a><br />
<img class="alignnone" style="margin-top: 10px; margin-bottom: 10px;" src="http://thepixeldistrict.com/amazingcoder/readability/bookmarksmall.png" alt="The Bookmark On My Site" width="257" height="35" /></p>
<p><span id="more-340"></span></p>
<p>It's really simple, just go to the <a href="http://lab.arc90.com/experiments/readability/">Arc90 Readability Bookmarklet Generator</a> and pick your settings, then right click on the bookmarklet, and select "copy link" or "copy link address", then all you have to do is set up a div with the text of your choice in it:</p>
<pre class="">&lt;div id="readability"&gt;&lt;p&gt;&lt;a href=" "&gt;Make This Post More Readable&lt;/a&gt;&lt;/p&gt;&lt;/div&gt;</pre>
<p>And set up some style rules in your CSS file for that DIV:</p>
<pre class=""> #readability {
background-image: url(images/readability.png);
background-position: 12px left;
background-repeat: no-repeat;
padding: 5px 5px 5px 24px;
}</pre>
<p>And then simply paste in the link from the bookmarklet into the 'href' field of your link:</p>
<pre class="">javascript:(function(){readStyle='style-novel';readSize='size-large';readMargin='margin-medium';_readability_script=document.createElement('SCRIPT');_readability_script.type='text/javascript';_readability_script.src='http://lab.arc90.com/experiments/readability/js/readability.js?x='+(Math.random());document.getElementsByTagName('head')[0].appendChild(_readability_script);_readability_css=document.createElement('LINK');_readability_css.rel='stylesheet';_readability_css.href='http://lab.arc90.com/experiments/readability/css/readability.css';_readability_css.type='text/css';document.getElementsByTagName('head')[0].appendChild(_readability_css);_readability_print_css=document.createElement('LINK');_readability_print_css.rel='stylesheet';_readability_print_css.href='http://lab.arc90.com/experiments/readability/css/readability-print.css';_readability_print_css.media='print';_readability_print_css.type='text/css';document.getElementsByTagName('head')[0].appendChild(_readability_print_css);})();</pre>
<p>And you're done! don't forget to download the book icon (if you want it) from <a href="http://thepixeldistrict.com/amazingcoder/readability/readability.png">here</a>, the icon is from the awesome <a href="http://www.famfamfam.com/lab/icons/silk/">famfamfam silk icon set</a>. Don't forget to adjust the path to it in the CSS I gave you.</p>
<p>And the results speak for themselves, here is an article from the guardian before using readability:<br />
<a href="http://thepixeldistrict.com/amazingcoder/readability/before.png"><br />
<img src="http://thepixeldistrict.com/amazingcoder/readability/before.png" alt="Before Readability" width="450" /></a><br />
And After:<br />
<a href="http://thepixeldistrict.com/amazingcoder/readability/after.png"><br />
<img src="http://thepixeldistrict.com/amazingcoder/readability/after.png" alt="After Readability" width="450" /></a></p>
<p>So there! now your posts are more readable there's no excuse not to be writing top-notch content! Don't forget that you can style this to look like whatever you want! Enjoy...</p>
<h4>A Note On Browser Compatibility</h4>
<p>I can't see anything on the official website with regard to this, but i'd assume that it's fairly exclusive to modern browsers, and in the case of the IE's you should probably see it working with IE7+, but i can't verify that. But it should be fine in your Safari's, your Firefox's and your google Chrome's, as well as any other browser that is up to date.</p>
]]></content:encoded>
			<wfw:commentRss>http://amazingcoder.com/2009/04/02/adding-readability-to-your-web-site-easily/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>jQuery &#8211; Javascript For The Rest Of Us</title>
		<link>http://amazingcoder.com/2009/02/27/jquery-javascript-for-the-rest-of-us/</link>
		<comments>http://amazingcoder.com/2009/02/27/jquery-javascript-for-the-rest-of-us/#comments</comments>
		<pubDate>Fri, 27 Feb 2009 16:09:59 +0000</pubDate>
		<dc:creator>Daniel Matthews</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[colour]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Designer]]></category>
		<category><![CDATA[effects]]></category>
		<category><![CDATA[fade]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[js]]></category>
		<category><![CDATA[movement]]></category>
		<category><![CDATA[paragraph]]></category>
		<category><![CDATA[skills]]></category>

		<guid isPermaLink="false">http://amazingcoder.com/?p=247</guid>
		<description><![CDATA[Javascript is an amazing scripting language, but it can take a long time to learn properly, and even then, it can take a long time to script out long winded pieces of code to achieve even the most basic of actions.

That’s where jQuery comes in, it’s a framework that is heavily based around CSS, and it’s easy to learn, even for people who don’t have a mind for scripting.

So i present to you an introduction to the basic principles of writing code with jQuery, and the sort of things you can do with just two snippets.]]></description>
			<content:encoded><![CDATA[<p>jQuery is a freely available, extremely extensible library of javascript actions, effects and more, and is written with it’s own API of sorts, that means that instead of writing lots and lots of standard javascript code, you can use a shorthand version that reduces the time you spend writing code, but produces some awesome effects.</p>
<p>The best part is that it works tightly with CSS, so if you’re a designer, you already have about 80% of the skills needed to program actions in jQuery!<span id="more-247"></span></p>
<h4>Why jQuery?</h4>
<p>Because it’s probably the most widely used and widely extended javascript library around, a lot of people seem to know it, so support is usually not far away, and in my personal opinion, i think it’s the most intuitive to designers.</p>
<h4>Ready?</h4>
<p>Ok then, let’s get started...</p>
<p>Firstly, copy the below code into a blank HTML document, this is the basic page structure that we’re going to work with, and a little bit of CSS in the head section to control what certain elements on the page look like.</p>
<pre class="">
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<span> </span>"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"&gt;
&lt;head&gt;
<span> </span>&lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"/&gt;
<span> </span>&lt;title&gt;jQuery!&lt;/title&gt;
<span> </span>
<span> </span>
<span> </span>
<span> </span>&lt;style type="text/css"&gt;
<span> </span>
<span> </span>p.ourParagraph {
<span> </span>padding:10px;
<span> </span>border:5px solid #947d5f;
<span> </span>background-color: #d3b287;
<span> </span>width:500px;
<span> </span>margin-left: auto;
<span> </span>margin-right: auto;
<span> </span>margin-top:50px;
<span> </span>color:#fff;
<span> </span>}
<span> </span>
<span> </span>&lt;/style&gt;
<span> </span>&lt;/head&gt;
&lt;body&gt;
&lt;a class="showParagraph" href="#"&gt;Show The Paragraph&lt;/a&gt; |
&lt;a class="manipulateCSS" href="#"&gt;Manipulate The CSS&lt;/a&gt; |
&lt;a class="reset" href="#"&gt;Reset Everything&lt;/a&gt;
&lt;p class="ourParagraph" id="main"&gt;Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus, metus&lt;/p&gt;
&lt;p class="ourParagraph"&gt;Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus, metus&lt;/p&gt;
<span> </span>
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>You’ll notice there are two paragraph elements, both have a class name “ourParagraph” applied to them, which is why they look the same, but the top one has an ID attribute as well, more about why later.</p>
<p><a href="http://amazingcoder.com/wp-content/uploads/2009/02/screenshot1.png"><img class="size-medium wp-image-270 alignnone" src="http://amazingcoder.com/wp-content/uploads/2009/02/screenshot1-288x300.png" alt="screenshot1" width="288" height="300" /></a></p>
<p>Remember to save your HTML file in the root folder of your site, and make sure the path to jQuery is correct in the script tag.</p>
<h4>Including jQuery on your site...</h4>
<p>You’ll need to head over to the jQuery web site and download the latest release, don’t worry too much about the compression options, just use the default setting (production).</p>
<p>Then you’ll need to place jQuery either in the root folder of your site, or in a “js” or “javascript” folder, i’ve chosen the former. You then insert this snippet of code into the top of your page:</p>
<pre class="">&lt;script type="text/javascript" src="js/jquery-1.2.6.min.js"&gt;&lt;/script&gt;</pre>
<p>Of course, the “src” path will depend on where you chose to store your jQuery file, so adjust accordingly.</p>
<h4>(Document).Ready?</h4>
<p>The first thing I'm going to go over is using the document ready function. This checks to see if the DOM is loaded and ready to be played with using javascript.</p>
<pre class="">
$(document).ready(function() {
/* Anything you want to happen when you load the page goes here */
});
</pre>
<p>Then inside this little command, you can tell the script to hide any elements with the class of “ourParagraph” (which we have two of). You do this by looking for elements similar to the way you would with CSS:</p>
<pre class="">
$(document).ready(function() {
/* Tell it to hide any elements with a class of “ourParagraph” */
$(“.ourParagraph”).hide();
});
</pre>
<p>Now refresh your page, you should see the two brown-backgrounded paragraphs dissapear, if it works, congratulations, you just wrote some jQuery, if not, make sure that you’ve typed everything correctly (don’t copy and paste or it’ll never stick in your head!), and also check that you’ve included your jQuery library file correctly, and that it’s in the right place.</p>
<p>Now let’s just take a look at what we just did...</p>
<pre class="">
// We said “when the page is ready to be manipulated:
$(document).ready(
// Do this:
function () {
// Take this element:
$(“.ourParagraph”)
// And Hide it:
.hide();
// Then we close up the loose ends:
});
</pre>
<p>There, simple. And this is the style of coding for most of jQuery’s effects and interactions with your page.</p>
<h4>Let’s get the paragraph back...</h4>
<p>Notice there’s a link element in there with a class of “showParagraph”? well we’re going to use that class to tell jQuery to show the paragraphs again when the link is clicked. So, inside you’re document ready function, insert this code:</p>
<pre class="">
$(“.showParagraph”).click(function() {
$(“.ourParagraph”).show();
});
</pre>
<p>This is simply doing the opposite of our .hide() piece of code, but doing it only when we click the link, not straight away when the document is ready. You should now be able to refresh the page, click the “show the paragraph” link, and they will both pop into view.</p>
<p>Note that the link elements in our page have a value of href=”#”, this is the most basic way of creating a link that doesn’t navigate to any page when clicked on, but can still be used to manipulate things with javascript.</p>
<h4>Adjusting CSS, without refreshing the page!</h4>
<p>This is one of the coolest features of jQuery is it’s shorthand for adjusting CSS properties of page elements. We’re going to target a specific element in the page, one of the paragraphs, which is why i attached an ID to one of them.</p>
<pre class="">
/* when you click the <a> with the class “manipulateCSS”... */
$(“.manipulateCSS”).click(function() {</a>
<a>/*Target the paragraph with ID “main” and adjust the following CSS properties */</a>
<a>$("#main").css({'background-color' : 'red', 'width' : '200px'});</a>
<a>/* Close up the loose ends */
});
</pre>
<p></a></p>
<p><a>This will adjust one of the paragraphs’ widths and background colour. Refresh your page and see for yourself! You should see the first paragraph element turn red and get thinner.</a></p>
<p><a href="http://amazingcoder.com/wp-content/uploads/2009/02/screenshot2.png"><img class="size-medium wp-image-271 alignnone" src="http://amazingcoder.com/wp-content/uploads/2009/02/screenshot2-300x208.png" alt="screenshot2" width="300" height="208" /></a></p>
<p><a>The possibilities for this interaction are endless! you can adjust where things are on the page, change their typography, and make things bigger, all from one command in jQuery.</a></p>
<p><a></a></p>
<p><a></a></p>
<p><a> </a></p>
<p><a></a></p>
<p><a></a></p>
<p><a></a></p>
<p><a></a></p>
<p><a> </a></p>
<p><a></a></p>
<p><a></a></p>
<p><a></a></p>
<p><a></a></p>
<p><a> </a></p>
<p><a></a></p>
<p><a></p>
<h4>Now to reset everything...</h4>
<p>Just quickly, as a final piece of functionality to this tutorial, combine the two pieces of code from before to create a simple reset function that will hide the paragraphs and reset the CSS of the manipulated paragraph back to what it was before:</p>
<pre class="">
/* When we click the link with class “reset” */
$(".reset").click(function() {
/* Hide the paragraphs */
$(".ourParagraph").hide();
/* Reset the css back to normal */
$(".ourParagraph").css({'background-color' : '#d3b287', 'width' : '500px'});
/* close up the loose ends */
});
</pre>
<p>There we go, refresh your page and click through the links in order, and you get a nice sequence of events. Hidden, show, manipulate, reset.</p>
<p>So that pretty much wraps up this very basic tutorial on using jQuery, remember to head over to the jQuery website where they have a lot of great tutorials, and you can also read the documentation, in which you’ll find the effects, which are the most fun part of jQuery <img src='http://amazingcoder.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>So enjoy, and please let me know how I could improve this tutorial, constructive criticism only please.</p>
<p></a></p>
<p><a>You can download the files for this tutorial </a><a href="http://amazingcoder.com/wp-content/uploads/2009/02/jquery-tutorial-finished-product.zip">here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://amazingcoder.com/2009/02/27/jquery-javascript-for-the-rest-of-us/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
