<?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>Tony Thomas &#187; JavaScript</title>
	<atom:link href="http://anthonygthomas.com/category/web-development/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://anthonygthomas.com</link>
	<description>Father to two, husband to one, web developer and musician.</description>
	<lastBuildDate>Fri, 27 Apr 2012 19:26:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Using Impress.js</title>
		<link>http://anthonygthomas.com/2012/03/09/using-impress-js/</link>
		<comments>http://anthonygthomas.com/2012/03/09/using-impress-js/#comments</comments>
		<pubDate>Fri, 09 Mar 2012 17:08:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://anthonygthomas.com/?p=678</guid>
		<description><![CDATA[Update: There is at least one WYSIWYG impress.js editor available now. I came across Impress.js a while back and I was, well, impressed. It makes sense to do presentations on the web, given the powerful animations and transitions available in modern browsers. Impress is sort of like Prezi improved. Improved because it takes advantage of [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Update:</strong> <a href="http://www.hsivaram.com/impressionist/alpha3/" onclick="pageTracker._trackPageview('/outgoing/www.hsivaram.com/impressionist/alpha3/?referer=');">There is at least one WYSIWYG impress.js editor available now</a>.</p>
<p>I came across <a href="http://bartaz.github.com/impress.js/#/bored" onclick="pageTracker._trackPageview('/outgoing/bartaz.github.com/impress.js/_/bored?referer=');">Impress.js</a> a while back and I was, well, <em>impressed</em>. It makes sense to do presentations on the web, given the powerful animations and transitions available in modern browsers. Impress is sort of like <a href="http://prezi.com/" onclick="pageTracker._trackPageview('/outgoing/prezi.com/?referer=');">Prezi</a> <em>improved</em>. Improved because it takes advantage of 3d animation. It does require some technical skill however. You need to know a bit about HTML5 and you have to be able to code a web page and write styles.</p>
<p>Right now you can only learn how to use Impress.js by reading the comments and experimenting. I thought it might be good to go through each of the features here to give a sense of it&#8217;s capabilities. If you&#8217;re interested, there aren&#8217;t really any insights here that you can&#8217;t find in the source.<span id="more-678"></span></p>
<p>The first thing is that you have to have a story to tell. Impress.js does nothing for you if you don&#8217;t have a narrative. So plan out what you want to say. Personally, write out what I want to say in any presentation in prose first. Just words. That way I can get a cohesive narrative going with good verbal transitions. Then I think about the visual stuff.</p>
<p>Assuming you know what you want to say, let&#8217;s move on.</p>
<p>First you&#8217;ll need to <a href="https://github.com/bartaz/impress.js" onclick="pageTracker._trackPageview('/outgoing/github.com/bartaz/impress.js?referer=');">download the JavaScript</a>. Next set up an HTML document with the HTML5 doctype. (Impress.js takes advantage of HTML5&#8242;S <code>data</code> attribute, so HTML5 is necessary.)</p>
<pre class="brush: xml; title: ; notranslate">&lt;!doctype html&gt;
&lt;html lang=&quot;en&quot;&gt;
&lt;head&gt;
    &lt;title&gt;Impress.js Presentation&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div id=&quot;impress&quot;&gt;
&lt;/div&gt;
&lt;!-- Put the script at the bottom --&gt;
&lt;script src=&quot;js/impress.js&quot;&gt;&lt;/script&gt;
&lt;script&gt;impress();&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p>The slides need to go into an element with the id of &#8220;impress.&#8221; It&#8217;s a div above, but it can be anything. The comments in the source also suggest adding the class, &#8220;impress-not-supported&#8221; to the <code>#impress</code> div. This class will be added if the browser does not support impress, but it&#8217;s good to have it there for browsers without JavaScript enabled. <code>impress-not-supported</code> allows you to provide a fallback message.</p>
<h3>Options</h3>
<p>Now things get interesting. Each slide should be within <code>#impress</code> and have a class of &#8220;step.&#8221; Positioning information is stored in <code>data</code> attributes. First off are the x and y coordinates. It&#8217;s important to note that we&#8217;re defining the x and y coordinates of the <em>center</em> of the element in question.</p>
<pre class="brush: xml; title: ; notranslate">&lt;div class=&quot;slide&quot; data-x=&quot;-1500&quot; data-y=&quot;-1000&quot;&gt;&lt;p&gt;Our first slide&lt;/p&gt;&lt;/div&gt;</pre>
<p>You can give you slides ids so you can link to a particular slide. Id&#8217;s are not required, however. If you don&#8217;t add them, impress.js will add a #step-N id to each element and append the hash to the url. While a hash syntax of <code>#/step-N</code> will still work, it&#8217;s better to use a standard hash like <code>#step-N</code> so that links will still work without JavaScript.</p>
<p>The next dimension we can control is scale:</p>
<pre class="brush: xml; title: ; notranslate">&lt;div id=&quot;title&quot; class=&quot;step&quot; data-x=&quot;0&quot; data-y=&quot;0&quot; data-scale=&quot;4&quot;&gt;&lt;p&gt;Slide content&lt;/p&gt;&lt;/div&gt;</pre>
<p>Note the <code>data-scale</code> attribute above. In this case, the slide is scaled down by a factor of 4, then scaled up to full-scale during the transition.</p>
<p>We can also control rotation:</p>
<pre class="brush: xml; title: ; notranslate">&lt;div id=&quot;its&quot; class=&quot;step&quot; data-x=&quot;850&quot; data-y=&quot;3000&quot; data-rotate=&quot;90&quot; data-scale=&quot;5&quot;&gt;&lt;p&gt;Slide Content&lt;/p&gt;</pre>
<p>For this, use <code>data-rotate</code>. In the example above, the slide is rotated 90 degrees.</p>
<p>And now we go 3d:</p>
<pre class="brush: xml; title: ; notranslate">&lt;div id=&quot;tiny&quot; class=&quot;step&quot; data-x=&quot;2825&quot; data-y=&quot;2325&quot; data-z=&quot;-3000&quot; data-rotate=&quot;300&quot; data-scale=&quot;1&quot;&gt;&lt;p&gt;Slide content.&lt;/p&gt;&lt;/div&gt;</pre>
<p>The <code>data-z</code> attribute above places this slide 3000 pixels away along the z-index.</p>
<p>Finally, we can control rotation along axes:</p>
<pre class="brush: xml; title: ; notranslate">&lt;div id=&quot;its-in-3d&quot; class=&quot;step&quot; data-x=&quot;6200&quot; data-y=&quot;4300&quot; data-z=&quot;-100&quot; data-rotate-x=&quot;-40&quot; data-rotate-y=&quot;10&quot; data-scale=&quot;2&quot;&gt;&lt;p&gt;</pre>
<p>Those are the options. I had a little fun creating a <a href="/impress/resume/">version of my r&eacute;sum&eacute;</a>. It&#8217;s pretty fun. I can also see some storytelling potential with this. Go forth and impress!<strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://anthonygthomas.com/2012/03/09/using-impress-js/" rel="bookmark" title="March 9, 2012">Using Impress.js</a></li>
<li><a href="http://anthonygthomas.com/2011/03/12/simple-rss-parsing-and-caching-using-php/" rel="bookmark" title="March 12, 2011">Simple RSS Parsing and Caching Using PHP</a></li>
<li><a href="http://anthonygthomas.com/2010/05/24/an-unexpected-problem-with-cakephp-and-email-elements/" rel="bookmark" title="May 24, 2010">An Unexpected Problem with CakePHP and Email Elements</a></li>
<li><a href="http://anthonygthomas.com/2008/12/10/use-functions-from-other-controllers-while-maintaining-mvc-architecture-in-cakephp/" rel="bookmark" title="December 10, 2008">Use Functions from Other Controllers While Maintaining MVC Architecture in CakePHP</a></li>
<li><a href="http://anthonygthomas.com/2009/07/22/simple-security-in-cakephp/" rel="bookmark" title="July 22, 2009">Simple Security in CakePHP</a></li>
</ul>
<p><!-- Similar Posts took 4.295 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://anthonygthomas.com/2012/03/09/using-impress-js/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fun With JQuery Tubular</title>
		<link>http://anthonygthomas.com/2012/03/03/fun-with-jquery-tubular/</link>
		<comments>http://anthonygthomas.com/2012/03/03/fun-with-jquery-tubular/#comments</comments>
		<pubDate>Sat, 03 Mar 2012 20:39:14 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://anthonygthomas.com/?p=670</guid>
		<description><![CDATA[I came across Sean McCambridge&#8217;s JQuery Tubular plugin a while back and I thought it would be fun to experiment with it. So I set up a little demo and I thought I&#8217;d walk through it here. I should say that it wasn&#8217;t until I came across Phil Plait&#8217;s amazing moon simulation that I was [...]]]></description>
			<content:encoded><![CDATA[<p>I came across <a href="http://www.seanmccambridge.com/" onclick="pageTracker._trackPageview('/outgoing/www.seanmccambridge.com/?referer=');">Sean McCambridge&#8217;s</a> <a href="http://www.seanmccambridge.com/tubular/" onclick="pageTracker._trackPageview('/outgoing/www.seanmccambridge.com/tubular/?referer=');">JQuery Tubular</a> plugin a while back and I thought it would be fun to experiment with it. <a href="/examples/tubular/tubular.html">So I set up a little demo</a> and I thought I&#8217;d walk through it here.</p>
<p>I should say that it wasn&#8217;t until I came across <a href="http://blogs.discovermagazine.com/badastronomy/2012/03/02/nasa-goddard-rocks-the-moon/" onclick="pageTracker._trackPageview('/outgoing/blogs.discovermagazine.com/badastronomy/2012/03/02/nasa-goddard-rocks-the-moon/?referer=');">Phil Plait&#8217;s amazing moon simulation</a> that I was inspired to build the demo.</p>
<p>I should also say that my example is completely unnecessary given Sean&#8217;s documentation. It&#8217;s really as simple as this:</p>
<pre class="brush: jscript; title: ; notranslate">$('body').tubular('someYTid','video'); // where someYTid is the YouTube ID and wrapper is your containing DIV.</pre>
<p>Once you have JQuery and JQuery Tubular linked in the head of your document and replace &#8216;someYTid&#8217; with the id of your YouTube video, it will just work. The rest is styling. In the interest of explaining things all in one place, I&#8217;ll walk through what I did.<span id="more-670"></span></p>
<p>First, you need to set up the JQuery Tubular plugin and dependencies in your document:</p>
<pre class="brush: xml; title: ; notranslate">&lt;script type=&quot;text/javascript&quot; src=&quot;https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js&quot;&gt;&lt;/script&gt;
&lt;!--[if lt IE 9]&gt;
&lt;script src=&quot;//html5shiv.googlecode.com/svn/trunk/html5.js&quot;&gt;&lt;/script&gt;
&lt;![endif]--&gt;
&lt;script type=&quot;text/javascript&quot; charset=&quot;utf-8&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/swfobject/2.1/swfobject.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; charset=&quot;utf-8&quot; src=&quot;js/jquery.tubular.js&quot;&gt;&lt;/script&gt;</pre>
<p>I&#8217;ve loaded JQuery using <a href="http://code.google.com/apis/libraries/devguide.html" onclick="pageTracker._trackPageview('/outgoing/code.google.com/apis/libraries/devguide.html?referer=');">Google&#8217;s CDN</a>, <a href="http://code.google.com/p/html5shiv/" onclick="pageTracker._trackPageview('/outgoing/code.google.com/p/html5shiv/?referer=');">HTML5 Shiv</a> (because I&#8217;m using the HTML5 Doctype), <a href="http://code.google.com/p/swfobject/" onclick="pageTracker._trackPageview('/outgoing/code.google.com/p/swfobject/?referer=');">SWFObject</a> and the JQuery Tubular plugin linked above.</p>
<p>Next I set up a few styles. First I load some Google-hosted fonts:</p>
<pre class="brush: xml; title: ; notranslate">&lt;link href='http://fonts.googleapis.com/css?family=Stardos+Stencil|Muli&amp;v2' rel='stylesheet' type='text/css'&gt;</pre>
<p>Then I added a few styles of my own. (This is the &#8220;style to taste&#8221; portion.)</p>
<pre class="brush: css; title: ; notranslate">/* Use Stardos Stencil for headings */
h1, h2, h3, h4, h5, h6 {
	font-family: 'Stardos Stencil', cursive;
	font-style: normal;
	font-weight: 400;
	font-size: 64px;
	text-transform: none;
	text-decoration: none;
	letter-spacing: 0em;
	word-spacing: 0em;
	line-height: 1.4;
}
/* links are white and bold */
a {
	color: #fff;
	font-weight: bold;
}
/* Give the body a black background and get rid of browser-default margins and padding */
body {
	background: #000;
	margin: 0;
	padding: 0;
}
/* Any text needs to use absolute positioning and have a high z-index to float above the background video */
h1 {
	color: #fff;
	font-size: 1.2em;
	font-weight: bold;
	position: absolute;
	right: 20px;
	top: 20px;
	z-index: 1000;
}
/* Use Muli for paragraphs and set up absolute positioning and high z-index */
p {
	color: #fff;
	font-family: 'Muli', sans-serif;
	font-style: normal;
	font-weight: 400;
	font-size: 13px;
	left: 20px;
	line-height: 1.4;
	position: absolute;
	word-spacing: 0em;
	text-decoration: none;
	text-transform: none;
	width: 150px;
	z-index: 1000;
}
/* Position paragraphs */
p#first {
	top: 20px;
}
p#last {
	top: 50px;
}
</pre>
<p>Next I set up the JavaScript. I really didn&#8217;t need anything besides the one line of JavaScript at the top of this post, but I wanted to add a few other fancy animations and hover effects. (You could do a lot of this w/ CSS animations/transitions, but that&#8217;s a topic for another post.)</p>
<pre class="brush: jscript; title: ; notranslate">$().ready(function()
{
    // Instantiate the tubular plugin to load the awesome moon video
    $('body').tubular('woTCsNNfYEE','video'); // where someYTid is the YouTube ID and wrapper is your containing DIV.

    // Fade the overlaid text after 5 seconds
    $('.fade').delay(5000).animate({
        opacity: .5
    }, 1000);

    // Add a hover effect to those same element that are faded above
    $('.fade').hover(function()
    // mousein
    {
        $(this).animate({opacity:1});},
    // mouseout
    function()
    {
        $(this).animate({opacity:.5});
    });
});</pre>
<p>That&#8217;s it. If you take a look at <a href="http://www.seanmccambridge.com/tubular/" onclick="pageTracker._trackPageview('/outgoing/www.seanmccambridge.com/tubular/?referer=');">Sean&#8217;s example</a>, there is more you an do to leverage SWFObject for controlling the video. Use cases for this plugin may be limited, but I can see lots of potential for neat page designs.<strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://anthonygthomas.com/2012/03/03/fun-with-jquery-tubular/" rel="bookmark" title="March 3, 2012">Fun With JQuery Tubular</a></li>
<li><a href="http://anthonygthomas.com/2010/02/08/introducing-the-baseline-development-wordpress-theme/" rel="bookmark" title="February 8, 2010">Introducing the Baseline Development WordPress Theme</a></li>
<li><a href="http://anthonygthomas.com/2010/02/16/baseline-theme-version-1-0-1/" rel="bookmark" title="February 16, 2010">Baseline Theme Version 1.0.1</a></li>
<li><a href="http://anthonygthomas.com/2011/05/17/new-theme/" rel="bookmark" title="May 17, 2011">New Theme</a></li>
<li><a href="http://anthonygthomas.com/2010/02/14/why-use-blueprint-and-the-960-grid-system-in-the-baseline-theme/" rel="bookmark" title="February 14, 2010">Why Use Blueprint and the 960 Grid System in the Baseline Theme?</a></li>
</ul>
<p><!-- Similar Posts took 4.381 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://anthonygthomas.com/2012/03/03/fun-with-jquery-tubular/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Responsive Images: Keep It Simple; Keep It Small</title>
		<link>http://anthonygthomas.com/2012/02/16/responsive-images-keep-it-simple-keep-it-small/</link>
		<comments>http://anthonygthomas.com/2012/02/16/responsive-images-keep-it-simple-keep-it-small/#comments</comments>
		<pubDate>Fri, 17 Feb 2012 01:58:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[responsive design]]></category>
		<category><![CDATA[responsive images]]></category>
		<category><![CDATA[web development]]></category>

		<guid isPermaLink="false">http://anthonygthomas.com/?p=630</guid>
		<description><![CDATA[There&#8217;s a lot of excitement about responsive design in the mobile web development world. One of the techniques used in responsive design is responsive or adaptive images. There are a handful of techniques out there including CSS fluid images, using overflow:hidden to crop images and using a combination of .htaccess settings and PHP to deliver [...]]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s a lot of excitement about responsive design in the mobile web development world. One of the techniques used in responsive design is responsive or adaptive images. There are a handful of techniques out there including CSS fluid images, using <a href="http://demo.solemone.de/overflow-image-with-vertical-centering-for-responsive-web-design/" onclick="pageTracker._trackPageview('/outgoing/demo.solemone.de/overflow-image-with-vertical-centering-for-responsive-web-design/?referer=');">overflow:hidden to crop images</a> and using <a href="http://adaptive-images.com/" onclick="pageTracker._trackPageview('/outgoing/adaptive-images.com/?referer=');">a combination of .htaccess settings and PHP to deliver device-specific images</a>.</p>
<p>The first two solutions are fairly simple, but ignore one problem: serving a larger-than-necessary image over a potentially slow network to a user who may have limitations on the amount of data they can receive. Keeping website size down is also important now because <a href="http://googlewebmastercentral.blogspot.com/2010/04/using-site-speed-in-web-search-ranking.html" onclick="pageTracker._trackPageview('/outgoing/googlewebmastercentral.blogspot.com/2010/04/using-site-speed-in-web-search-ranking.html?referer=');">Google is using site speed as a&nbsp;criterion&nbsp;for search rankings</a>. So, while I find the first two solutions interesting, I don&#8217;t think they&#8217;re the best we can do.<span id="more-630"></span></p>
<p>The adaptive image technique of routing image requests with a cookie and some Apache settings in an .htaccess file is also interesting. It too has limitations. First, it&#8217;s not for the faint of heart. If you don&#8217;t know your way around Apache directives, it might not be for you. It also relies on a PHP file. If you&#8217;re not using PHP, you&#8217;re out of luck. I&#8217;m no Apache expert, but I have some experience redirecting requests using .htaccess. Setup for adaptive images proved difficult because:</p>
<ol>
<li>I found it hard to incorporate the .htaccess settings alongside our other Apache directives that already exist.</li>
<li>I only needed responsive images for part of the site</li>
</ol>
<p>I freely admit that those limitations are mine and not anything fundamentally wrong with the method. If I were better with regular expressions, I probably could have gotten it going.</p>
<p>There is one limitation that is not taken into account: screen pixel density. A handful of Android phones have high resolution displays that defy how we typically understand pixels. The true resolution of the screen is 480 X 854 in this instance. Same for the iPhone 4. It has a pixel resolution of 640 X 960. No problem, right? Things get complicated when we use this meta tag:</p>
<pre class="brush: xml; title: ; notranslate">&lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0&quot;/&gt;</pre>
<p>That meta tag is extremely useful because it forces those high density screens to render text much like their normal-density counterparts. In practical terms, if the above meta tag is in the head of your web page, an iPhone 4 will report a resolution of 320 X 480 and render text accordingly&#8211;making it more readable.</p>
<p>Life is great at this point because without that meta information, text will render much differently on a handful of high pixel-density phones.</p>
<p>We run into problems when we need to get accurate pixel counts of the device in question. Now that I&#8217;ve got consistently readable text on a wide variety of devices, I suddenly have wildly inaccurate information on pixels that are relevant to rendering images. Now when I call:</p>
<pre class="brush: jscript; title: ; notranslate">h = screen.height;</pre>
<p>An iPhone 4 will tell me that the screen height is 480 pixels when, for the purpose of rendering images, it&#8217;s actually 960 pixels. No big deal, but if I&#8217;m using JavaScript to determine the screen size so I can load an appropriately sized image, it&#8217;s going to load one that&#8217;s designed for a 480 pixel-width screen and it&#8217;s going to look terrible if the user switches to landscape mode.</p>
<p>Worse yet, while the iPhone 4 has a pixel density of 2, the Motorola Droid has a pixel density of 1.5. We <em>could</em> do some user agent sniffing to accomodate this, but the mobile device market changes so rapidly it would be nearly impossible to keep up with. Web standards tell us to look for supported features, not specific devices. So no user agent sniffing.</p>
<p>Luckily WebKit offers an imperfect solution that just happens to work in all the high pixel-density devices I&#8217;m aware of as of now:</p>
<pre class="brush: jscript; title: ; notranslate">window.devicePixelRatio</pre>
<p>Now we can get the true number of pixels like so:</p>
<pre class="brush: jscript; title: ; notranslate">// Set the default directory to 320
	&quot;use strict&quot;;
	d = 320;

	// Get the screen height
	h = screen.height;

	// set the height for non webkit browsers
	height = h;

	// Get the pixel ratio
	r = window.devicePixelRatio;

	// if devicePixelRatio is supported, calculate the device height
	if (typeof r !== 'undefined')
	{
		// Calculate the true number of pixels on the screen
		height = h * r;
	}</pre>
<p>My technique is to save images at several common device heights (because height becomes width in landscape mode) and write the image tag using JavaScript, so the device gets the smallest possible image that will still look good on the screen. The full script looks like so:</p>
<pre class="brush: jscript; title: ; notranslate">/****
 * Loads different header images based on the device height and pixel density (for webkit browsers)
 * Height is used because at any time, the device could potentially be turned to landscape mode
 */

/**
 * @var string
 * vars for directory (d), height (h), pixel ratio (r) and height
 */
var d, h, r, height;

/*
* Bind these to pagecreate so they work with JQuery Mobile's automagic AJAX page loads
*/
$('#page-id').live('pagecreate', function(event)
{
	// Set the default directory to 320
	&quot;use strict&quot;;
	d = 320;

	// Get the screen height
	h = screen.height;

	// set the height for non webkit browsers
	height = h;

	// Get the pixel ratio
	r = window.devicePixelRatio;

	if (typeof r !== 'undefined')
	{
		// Calculate the true number of pixels on the screen
		height = h * r;
	}

	// Set the image directory accordingly
	if (height &lt;= 320)
	{
		// load 320 header
		d = 320;
	}
	// Probably the most common height for current smartphones
	else if (height &lt;= 480)
	{
		// load 480 header
		d = 480;
	}
	// Many Motorola &amp; HTC devices have an 800-pixel height
	else if (height &lt;= 800)
	{
		// load 800 header
		d = 800;
	}
	// iPhone 4 &amp; Droid
	else if (height &gt; 800)
	{
		// load 960 header
		d = 960;
	}

	$('a#header-home-link').html('&lt;img src=&quot;/images/mobile/' + d + '/header.png&quot; alt=&quot;This is alt text.&quot; id=&quot;logo&quot; class=&quot;logos&quot; /&gt;');
});</pre>
<p>When the page loads, <code>#header-home-link</code> is just a normal HTML link with no image tag at all, so no image is loaded until we&#8217;ve determined the device screen size and write in the image tag with JavaScript (JQuery).</p>
<p>This technique will only work on WebKit browsers since other browsers don&#8217;t support <code>devicePixelRatio</code> at this time. Fortunately, this falls firmly within progressive enhancement. It&#8217;s not ideal if another mobile browser loads a pixelated image, but it has no effect on how the page itself functions.</p>
<p>Aside: You may have noticed that this is all bound to a &#8216;pagecreate&#8217; event instead of the normal <code>ready()</code> method in JQuery. <a href="http://jquerymobile.com/test/docs/api/events.html" onclick="pageTracker._trackPageview('/outgoing/jquerymobile.com/test/docs/api/events.html?referer=');">That&#8217;s because I&#8217;m using JQuery Mobile in this instance</a>.</p>
<p>So there you have it. Detecting screen dimensions in pixels is fairly easy, but you do need to account for pixel density. While this approach is not perfect, it works well in most devices and as of now, no standard way of serving responsive images has emerged. This is as good as anything I&#8217;ve found.<strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://anthonygthomas.com/2012/02/16/responsive-images-keep-it-simple-keep-it-small/" rel="bookmark" title="February 16, 2012">Responsive Images: Keep It Simple; Keep It Small</a></li>
<li><a href="http://anthonygthomas.com/2012/04/22/media-queries-for-high-pixel-density-devices/" rel="bookmark" title="April 22, 2012">Media Queries for High Pixel-density Devices</a></li>
<li><a href="http://anthonygthomas.com/2012/02/28/one-site/" rel="bookmark" title="February 28, 2012">One Site</a></li>
<li><a href="http://anthonygthomas.com/2008/12/16/when-using-a-grid-layout-css-framework-do-the-math/" rel="bookmark" title="December 16, 2008">When Using a Grid Layout CSS Framework, Do the Math</a></li>
<li><a href="http://anthonygthomas.com/2008/04/11/transparency/" rel="bookmark" title="April 11, 2008">Transparency</a></li>
</ul>
<p><!-- Similar Posts took 4.628 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://anthonygthomas.com/2012/02/16/responsive-images-keep-it-simple-keep-it-small/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Baseline WordPress Theme Version 1.0.2</title>
		<link>http://anthonygthomas.com/2010/03/22/baseline-wordpress-theme-version-1-0-2/</link>
		<comments>http://anthonygthomas.com/2010/03/22/baseline-wordpress-theme-version-1-0-2/#comments</comments>
		<pubDate>Mon, 22 Mar 2010 17:34:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Baseline Theme]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[baseline theme]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://anthonygthomas.com/?p=430</guid>
		<description><![CDATA[I&#8217;ve uploaded a new version of the Baseline theme for WordPress development. The only change this time around is that I&#8217;m using wp_enqueue_script() to include WordPress&#8217; existing copy of JQuery. (Hat tip to Chris Coyier.) This seems like a significant enough change to merit a small version bump. I used the Baseline theme as a [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve uploaded a new version of the <a href="http://baseline.truetoneenterprises.com/" onclick="pageTracker._trackPageview('/outgoing/baseline.truetoneenterprises.com/?referer=');">Baseline theme for WordPress development</a>. The only change this time around is that I&#8217;m using <code><a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_script" onclick="pageTracker._trackPageview('/outgoing/codex.wordpress.org/Function_Reference/wp_enqueue_script?referer=');">wp_enqueue_script()</a></code> to include WordPress&#8217; existing copy of JQuery. (<a href="http://digwp.com/2009/06/including-jquery-in-wordpress-the-right-way/" onclick="pageTracker._trackPageview('/outgoing/digwp.com/2009/06/including-jquery-in-wordpress-the-right-way/?referer=');">Hat tip to Chris Coyier</a>.) This seems like a significant enough change to merit a small version bump.</p>
<p>I used the Baseline theme as a launching pad for this website. At least for me, it serves as a good starting point when you begin developing a brand new theme.</p>
<p>If you find this useful, you might be interested in checking outÂ <a href="http://digwp.com/2010/03/wordpress-functions-php-template-custom-functions/" onclick="pageTracker._trackPageview('/outgoing/digwp.com/2010/03/wordpress-functions-php-template-custom-functions/?referer=');">Jeff Starâ€™s functions.php template</a>.<strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://anthonygthomas.com/2010/03/22/baseline-wordpress-theme-version-1-0-2/" rel="bookmark" title="March 22, 2010">Baseline WordPress Theme Version 1.0.2</a></li>
<li><a href="http://anthonygthomas.com/2010/02/16/baseline-theme-version-1-0-1/" rel="bookmark" title="February 16, 2010">Baseline Theme Version 1.0.1</a></li>
<li><a href="http://anthonygthomas.com/2010/09/05/baseline-theme-version-1-1/" rel="bookmark" title="September 5, 2010">Baseline Theme Version 1.1</a></li>
<li><a href="http://anthonygthomas.com/2008/06/20/wow-acl-is-hard/" rel="bookmark" title="June 20, 2008">Wow. ACL is Hard</a></li>
<li><a href="http://anthonygthomas.com/2010/02/08/introducing-the-baseline-development-wordpress-theme/" rel="bookmark" title="February 8, 2010">Introducing the Baseline Development WordPress Theme</a></li>
</ul>
<p><!-- Similar Posts took 4.045 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://anthonygthomas.com/2010/03/22/baseline-wordpress-theme-version-1-0-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>No Flash Required</title>
		<link>http://anthonygthomas.com/2010/03/20/no-flash-required/</link>
		<comments>http://anthonygthomas.com/2010/03/20/no-flash-required/#comments</comments>
		<pubDate>Sat, 20 Mar 2010 17:30:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[css]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[web develop]]></category>

		<guid isPermaLink="false">http://anthonygthomas.com/?p=421</guid>
		<description><![CDATA[UPDATE II I just updated the theme of this site so: It uses even less JavaScript (all animations and transformations are done w/ CSS3 tranforms) It&#8217;s HTML5 More on both those points in a post soon. The upshot is that this post refers to a past theme and may be confusing. I just added a [...]]]></description>
			<content:encoded><![CDATA[<h3>UPDATE II</h3>
<p>I just updated the theme of this site so:</p>
<ol>
<li>It uses even less JavaScript (all animations and transformations are done w/ CSS3 tranforms)</li>
<li>It&#8217;s HTML5</li>
</ol>
<p>More on both those points in a post soon. The upshot is that this post refers to a past theme and may be confusing.</p>
<p><img class="alignleft size-full wp-image-422" title="Navigation" src="http://anthonygthomas.com/wp-content/uploads/2010/03/nav.jpg" alt="JPEF of the nav menu from anthonygthomas.com" width="284" height="95" />I just added a pretty sweet bit of eye candy to my nav menu using strictly CSS &amp; JQuery. <a href="http://net.tutsplus.com/tutorials/html-css-techniques/how-to-build-a-lava-lamp-style-navigation-menu/" onclick="pageTracker._trackPageview('/outgoing/net.tutsplus.com/tutorials/html-css-techniques/how-to-build-a-lava-lamp-style-navigation-menu/?referer=');">The method is here</a>. <a href="http://github.com/JeffreyWay/SpasticNav" onclick="pageTracker._trackPageview('/outgoing/github.com/JeffreyWay/SpasticNav?referer=');">The code is here</a>.</p>
<p>You do need to have a either a webKit or Mozilla browser for it to work properly. The point is that there are fewer and fewer things that Flash can do that can&#8217;t be done with HTML, JavaScript and CSS. In fact, just about every single bit of animation I&#8217;ve had done in Flash over the last couple of years could be recreated with JQuery &amp; CSS3.</p>
<h3>UPDATE</h3>
<p>Since I couldn&#8217;t get the z-index to function properly in Internet Explorer, I used <a href="http://api.jquery.com/jQuery.browser/" onclick="pageTracker._trackPageview('/outgoing/api.jquery.com/jQuery.browser/?referer=');">JQuery&#8217;s .browser property</a> so the function only runs in supported browsers&#8211;namely, Mozilla or WebKit. The function actually degraded fairly well, except for Internet Explorer&#8217;s buggy handling of z-index. For reference, I&#8217;ve included my version of the plug-in because it has this and other subtle variations.<span id="more-421"></span></p>
<pre class="brush: jscript; title: ; notranslate">(function($) {
	if ($.browser.webkit || $.browser.mozilla) {

		$.fn.spasticNav = function(options) {

			options = $.extend({
				overlap : 2,
				speed : 500,
				reset : 1500,
				color : '#BDD2FF',
				easing : 'easeOutExpo'
			}, options);

			return this.each(function() {

			 	var nav = $(this),
			 		currentPageItem = $('.current_page_item', nav),
			 		blob,
			 		reset;

			 	$('&lt;li id=&quot;blob&quot;&gt;&lt;/li&gt;').css({
			 		width : currentPageItem.outerWidth(),
			 		height : currentPageItem.outerHeight() + options.overlap,
			 		left : currentPageItem.position().left,
			 		top : currentPageItem.position().top - options.overlap / 2,
			 		backgroundColor : options.color
			 	}).appendTo(this);

				$('.current_page_item a').css('z-index', 1000);

			 	blob = $('#blob', nav);

				$('li:not(#blob)', nav).hover(function() {
					// mouse over
					clearTimeout(reset);
					blob.animate(
						{
							left : $(this).position().left,
							width : $(this).width()
						},
						{
							duration : options.speed,
							easing : options.easing,
							queue : false
						}
					);
				}, function() {
					// mouse out
					reset = setTimeout(function() {
						blob.animate({
							width : currentPageItem.outerWidth(),
							left : currentPageItem.position().left
						}, options.speed)
					}, options.reset);

				});

			}); // end each

		};

	}

})(jQuery);</pre>
<p><strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://anthonygthomas.com/2010/03/20/no-flash-required/" rel="bookmark" title="March 20, 2010">No Flash Required</a></li>
<li><a href="http://anthonygthomas.com/2011/05/17/new-theme/" rel="bookmark" title="May 17, 2011">New Theme</a></li>
<li><a href="http://anthonygthomas.com/2010/09/05/baseline-theme-version-1-1/" rel="bookmark" title="September 5, 2010">Baseline Theme Version 1.1</a></li>
<li><a href="http://anthonygthomas.com/2009/11/09/blueprint-taking-a-close-look-at-grid-css/" rel="bookmark" title="November 9, 2009">Blueprint: Taking a Close Look at grid.css</a></li>
<li><a href="http://anthonygthomas.com/2012/03/03/fun-with-jquery-tubular/" rel="bookmark" title="March 3, 2012">Fun With JQuery Tubular</a></li>
</ul>
<p><!-- Similar Posts took 4.116 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://anthonygthomas.com/2010/03/20/no-flash-required/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Display Form Fields Based on Selection Using JQuery</title>
		<link>http://anthonygthomas.com/2010/03/14/display-form-fields-based-on-selection-using-jquery/</link>
		<comments>http://anthonygthomas.com/2010/03/14/display-form-fields-based-on-selection-using-jquery/#comments</comments>
		<pubDate>Mon, 15 Mar 2010 02:59:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JQuery]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[html forms jquery]]></category>

		<guid isPermaLink="false">http://anthonygthomas.com/?p=395</guid>
		<description><![CDATA[This is a simple method of showing and hiding form elements based on the user&#8217;s selection. It&#8217;s based on this article with a couple of very minor changes. (Dare I say, improvements?) I&#8217;m going to assume you&#8217;ve already included the JQuery library so I won&#8217;t cover that here. I want to go straight to the [...]]]></description>
			<content:encoded><![CDATA[<p>This is a simple method of showing and hiding form elements based on the user&#8217;s selection. <a href="http://minneapolis.craigslist.org/ram/tag/1642880912.html" onclick="pageTracker._trackPageview('/outgoing/minneapolis.craigslist.org/ram/tag/1642880912.html?referer=');">It&#8217;s based on this article</a> with a couple of very minor changes. (Dare I say, improvements?) I&#8217;m going to assume you&#8217;ve already included the JQuery library so I won&#8217;t cover that here. I want to go straight to the code. (<a href="http://anthonygthomas.com/examples/jquery-display-forms.html">View the example page here</a>.)<span id="more-395"></span></p>
<p>First, the form:</p>
<pre class="brush: xml; title: ; notranslate">&lt;form id=&quot;ExampleForm&quot; method=&quot;post&quot; action=&quot;#&quot;&gt;
	&lt;fieldset&gt;
		&lt;legend&gt;Questionnaire&lt;/legend&gt;
		&lt;div class=&quot;input select&quot;&gt;
			&lt;label for=&quot;select1&quot;&gt;Choose 1 to make the next select list appear.&lt;/label&gt;
			&lt;select name=&quot;select1&quot; id=&quot;select1&quot;&gt;
				&lt;option value=&quot;&quot;&gt;(choose one)&lt;/option&gt;
				&lt;option value=&quot;0&quot;&gt;0&lt;/option&gt;
				&lt;option value=&quot;1&quot;&gt;1&lt;/option&gt;
				&lt;option value=&quot;2&quot;&gt;2&lt;/option&gt;
				&lt;option value=&quot;3&quot;&gt;3&lt;/option&gt;
				&lt;option value=&quot;4&quot;&gt;4&lt;/option&gt;
				&lt;option value=&quot;5&quot;&gt;5&lt;/option&gt;
				&lt;option value=&quot;6&quot;&gt;6&lt;/option&gt;
				&lt;option value=&quot;7&quot;&gt;7&lt;/option&gt;
			&lt;/select&gt;
		&lt;/div&gt;
		&lt;div class=&quot;hide&quot; id=&quot;hide1&quot;&gt;&lt;!-- this select box will be hidden at first --&gt;
			&lt;div class=&quot;input select&quot;&gt;
				&lt;label for=&quot;select2&quot;&gt;Select &quot;Yes&quot; to make the next option appear.&lt;/label&gt;
				&lt;select name=&quot;select2&quot; id=&quot;select2&quot;&gt;
					&lt;option value=&quot;&quot;&gt;(choose one)&lt;/option&gt;
					&lt;option value=&quot;1&quot;&gt;Yes&lt;/option&gt;
					&lt;option value=&quot;0&quot;&gt;No&lt;/option&gt;
					&lt;option value=&quot;3&quot;&gt;Don&amp;#039;t Know&lt;/option&gt;
				&lt;/select&gt;
			&lt;/div&gt;
		&lt;/div&gt;
		&lt;div class=&quot;hide&quot; id=&quot;hide2&quot;&gt; &lt;!-- this one will also be hidden at first. --&gt;
			&lt;div class=&quot;input select&quot;&gt;
				&lt;label for=&quot;select3&quot;&gt;This is the last question.&lt;/label&gt;
				&lt;select name=&quot;select3&quot; id=&quot;select3&quot;&gt;
					&lt;option value=&quot;&quot;&gt;(choose one)&lt;/option&gt;
					&lt;option value=&quot;0&quot;&gt;0&lt;/option&gt;
					&lt;option value=&quot;1&quot;&gt;1&lt;/option&gt;
					&lt;option value=&quot;2&quot;&gt;2 to 5&lt;/option&gt;
					&lt;option value=&quot;3&quot;&gt;6 to 10&lt;/option&gt;
					&lt;option value=&quot;4&quot;&gt;&amp;gt;10&lt;/option&gt;
				&lt;/select&gt;
			&lt;/div&gt;
		&lt;/div&gt;
	&lt;/fieldset&gt;
	&lt;div class=&quot;submit&quot;&gt;
		&lt;input type=&quot;submit&quot; value=&quot;Save Answers&quot; /&gt;
	&lt;/div&gt;
&lt;/form&gt;</pre>
<p>Now make sure your &#8220;hide&#8221; css class is hidden:</p>
<pre class="brush: css; title: ; notranslate">.hide
{

	display:none;

}</pre>
<p>Now with the wonderful elegance of JQuery, we&#8217;ll tell the browser to display the hidden divs based on the user&#8217;s selection:</p>
<pre class="brush: jscript; title: ; notranslate">$(document).ready(function(){
	$(&quot;#select1&quot;).change(function(){

		if ($(this).val() == &quot;1&quot; ) {

			$(&quot;#hide1&quot;).slideDown(&quot;fast&quot;); //Slide Down Effect

		} else {

			$(&quot;#hide1&quot;).slideUp(&quot;fast&quot;);	//Slide Up Effect

		}
	});

	$(&quot;#select2&quot;).change(function(){

		if ($(this).val() == &quot;1&quot; ) {

			$(&quot;#hide2&quot;).slideDown(&quot;fast&quot;); //Slide Down Effect

		} else {

			$(&quot;#hide2&quot;).slideUp(&quot;fast&quot;);	//Slide Up Effect

		}
	});
});</pre>
<p>Let&#8217;s look at what&#8217;s happening here. First, we have a form with select boxes with ids &#8220;select1&#8243;, &#8220;select2&#8243; and &#8220;select3&#8243;. The last two are hidden by enclosing them in a div with our &#8220;hide&#8221; class. (Incidentally, Blueprint provides a &#8220;hide&#8221; class for you if you use that framework.)</p>
<p>Next we tell JQuery that as soon as &#8220;select1&#8243; is changed, we need to evaluate the new value. In this case, if the new value is &#8220;1&#8243;, we want to display the div with the id &#8220;hide1&#8243; <a href="http://api.jquery.com/slideDown/" onclick="pageTracker._trackPageview('/outgoing/api.jquery.com/slideDown/?referer=');">using JQuery&#8217;s slideDown effect</a>. We do this with <a href="http://api.jquery.com/change/" onclick="pageTracker._trackPageview('/outgoing/api.jquery.com/change/?referer=');">JQuery&#8217;s change event</a>.</p>
<pre class="brush: jscript; title: ; notranslate">$(&quot;#select1&quot;).change(function(){ // when #select1 changes

		if ($(this).val() == &quot;1&quot; ) { // see if the new value is &quot;1&quot;

			$(&quot;.hide1&quot;).slideDown(&quot;fast&quot;); // if it is &quot;1&quot;, display the .hide1 div with the slideDown effect

		} else {

			$(&quot;.hide1&quot;).slideUp(&quot;fast&quot;);	//otherwise, hide it with the slideUp effect

		}
	});</pre>
<p>Once &#8220;select2&#8243; is displayed, we can evaluate it to see if we need to display &#8220;select3&#8243; which is in a div with a &#8220;hide&#8221; class and &#8220;hide2&#8243; id.</p>
<pre class="brush: jscript; title: ; notranslate">$(&quot;#select2&quot;).change(function(){ // once select2 is changed

		if ($(this).val() == &quot;1&quot; ) { // see if the new value is &quot;1&quot;

			$(&quot;.hide2&quot;).slideDown(&quot;fast&quot;); // if it is, display the hide2 div using slideDown

		} else {

			$(&quot;.hide2&quot;).slideUp(&quot;fast&quot;);	// otherwise hide it using slideUp

		}
	});</pre>
<p>Remarkably simple really. <a href="http://anthonygthomas.com/examples/jquery-display-forms.html">Review the working example and code here</a>.</p>
<p><strong>Update (March 15, 2010)</strong></p>
<p>You also could show/hide a single form element by id rather than enclose them in a div. I enclosed them in a div 1.) so I could hide the label and 2.) because in my application where I use this solution, I&#8217;m actually hiding a whole group of fields.</p>
<h3>Resources</h3>
<ul>
<li><a href="http://api.jquery.com/change/" onclick="pageTracker._trackPageview('/outgoing/api.jquery.com/change/?referer=');">JQuery change() Event</a></li>
<li><a href="http://api.jquery.com/val/" onclick="pageTracker._trackPageview('/outgoing/api.jquery.com/val/?referer=');">JQuery val()</a></li>
<li><a href="http://api.jquery.com/slideDown/" onclick="pageTracker._trackPageview('/outgoing/api.jquery.com/slideDown/?referer=');">JQuery slideDown Effect</a></li>
<li><a href="http://api.jquery.com/slideUp/" onclick="pageTracker._trackPageview('/outgoing/api.jquery.com/slideUp/?referer=');">JQuery slideUp Effect</a></li>
</ul>
<p><strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://anthonygthomas.com/2010/03/14/display-form-fields-based-on-selection-using-jquery/" rel="bookmark" title="March 14, 2010">Display Form Fields Based on Selection Using JQuery</a></li>
<li><a href="http://anthonygthomas.com/2010/02/14/why-use-blueprint-and-the-960-grid-system-in-the-baseline-theme/" rel="bookmark" title="February 14, 2010">Why Use Blueprint and the 960 Grid System in the Baseline Theme?</a></li>
<li><a href="http://anthonygthomas.com/2009/07/22/simple-security-in-cakephp/" rel="bookmark" title="July 22, 2009">Simple Security in CakePHP</a></li>
<li><a href="http://anthonygthomas.com/2011/04/18/css-scaffolding/" rel="bookmark" title="April 18, 2011">CSS Scaffolding</a></li>
<li><a href="http://anthonygthomas.com/2011/05/17/new-theme/" rel="bookmark" title="May 17, 2011">New Theme</a></li>
</ul>
<p><!-- Similar Posts took 4.318 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://anthonygthomas.com/2010/03/14/display-form-fields-based-on-selection-using-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introducing the Baseline Development WordPress Theme</title>
		<link>http://anthonygthomas.com/2010/02/08/introducing-the-baseline-development-wordpress-theme/</link>
		<comments>http://anthonygthomas.com/2010/02/08/introducing-the-baseline-development-wordpress-theme/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 01:53:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blueprint Framework]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[wordpress]]></category>
		<category><![CDATA[themes]]></category>

		<guid isPermaLink="false">http://anthonygthomas.com/?p=233</guid>
		<description><![CDATA[I&#8217;ve come up with some habits that I&#8217;ve developed from building themes for WordPress over the years. One, is to start with a nearly blank style sheet. I also like to hook in several JavaScript libraries and CSS frameworks from the start to take advantage of things like JQuery, Blueprint&#8217;s CSS reset and Superfish menus. [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve come up with some habits that I&#8217;ve developed from building themes for WordPress over the years. One, is to start with a nearly blank style sheet. I also like to hook in several JavaScript libraries and CSS frameworks from the start to take advantage of things like JQuery, Blueprint&#8217;s CSS reset and Superfish menus.<span id="more-233"></span></p>
<p>I&#8217;ve decided to build and release an XHTML 1.0 version and release it as a springboard for others who may want to take advantage of the same sets of tools. The theme isn&#8217;t much to look at (that&#8217;s the point), but it includes:</p>
<ul>
<li><a href="http://blueprintcss.org/" onclick="pageTracker._trackPageview('/outgoing/blueprintcss.org/?referer=');">Blueprint CSS framework</a></li>
<li><a href="http://blueprintcss.org/" onclick="pageTracker._trackPageview('/outgoing/blueprintcss.org/?referer=');"></a><a href="http://960.gs/" onclick="pageTracker._trackPageview('/outgoing/960.gs/?referer=');">960 Grid System</a></li>
<li><a href="http://960.gs/" onclick="pageTracker._trackPageview('/outgoing/960.gs/?referer=');"></a><a href="http://jquery.com/" onclick="pageTracker._trackPageview('/outgoing/jquery.com/?referer=');">JQuery 1.4.0</a></li>
<li><a href="http://jqueryui.com/" onclick="pageTracker._trackPageview('/outgoing/jqueryui.com/?referer=');">JQuery UI 1.7.1</a></li>
<li><a href="http://jquery.com/" onclick="pageTracker._trackPageview('/outgoing/jquery.com/?referer=');"></a><a href="http://users.tpg.com.au/j_birch/plugins/superfish/" onclick="pageTracker._trackPageview('/outgoing/users.tpg.com.au/j_birch/plugins/superfish/?referer=');">Superfish JQuery menu</a> (with <a href="http://cherne.net/brian/resources/jquery.hoverIntent.html" onclick="pageTracker._trackPageview('/outgoing/cherne.net/brian/resources/jquery.hoverIntent.html?referer=');">HoverIntent.js</a>)</li>
<li><a href="http://code.google.com/p/ie7-js/" onclick="pageTracker._trackPageview('/outgoing/code.google.com/p/ie7-js/?referer=');">IE8 JavaScript Library</a></li>
<li><a href="http://users.tpg.com.au/j_birch/plugins/superfish/" onclick="pageTracker._trackPageview('/outgoing/users.tpg.com.au/j_birch/plugins/superfish/?referer=');"></a>Widget-enabled sidebar</li>
<li><a href="http://wpcandy.com/articles/easier-theme-development-with-the-sample-post-collection.html" onclick="pageTracker._trackPageview('/outgoing/wpcandy.com/articles/easier-theme-development-with-the-sample-post-collection.html?referer=');">Test Content file from WP-Candy</a></li>
<li><a href="http://validator.w3.org/check?uri=http%3A%2F%2Fbaseline.truetoneenterprises.com%2F" onclick="pageTracker._trackPageview('/outgoing/validator.w3.org/check?uri=http_3A_2F_2Fbaseline.truetoneenterprises.com_2F&amp;referer=');">Valid XHTML 1.0</a></li>
</ul>
<p><a href="http://baseline.truetoneenterprises.com" onclick="pageTracker._trackPageview('/outgoing/baseline.truetoneenterprises.com?referer=');">More information here</a>.</p>
<p>If you want to use all of these tools, you&#8217;re all set. If you want to use a few, it&#8217;s just a matter of removing them from header.php.</p>
<p>First off, I really like Blueprint&#8217;s browser reset, so I wanted to include that here. I also like the flexibility the 960 Grid System offers in terms of column width. As a result, I&#8217;ve included them both.</p>
<pre class="brush: php; first-line: 9; html-script: true; title: ; notranslate">&lt;link rel=&quot;stylesheet&quot; href=&quot;&lt;?php bloginfo('stylesheet_directory'); ?&gt;/blueprint/screen.css&quot; type=&quot;text/css&quot; media=&quot;screen, projection&quot; /&gt;
&lt;link rel=&quot;stylesheet&quot; href=&quot;&lt;?php bloginfo('stylesheet_directory'); ?&gt;/960.css&quot; type=&quot;text/css&quot; media=&quot;screen, projection&quot; /&gt;
&lt;link rel=&quot;stylesheet&quot; href=&quot;&lt;?php bloginfo('stylesheet_directory'); ?&gt;/blueprint/print.css&quot; type=&quot;text/css&quot; media=&quot;print&quot; /&gt;</pre>
<p>If you don&#8217;t wish to use any of these, simply remove them from header.php. Next up is the Superfish CSS:</p>
<pre class="brush: php; first-line: 12; html-script: true; title: ; notranslate">&lt;link rel=&quot;stylesheet&quot; href=&quot;&lt;?php bloginfo('stylesheet_directory'); ?&gt;/superfish/css/superfish.css&quot; type=&quot;text/css&quot; media=&quot;screen, projection&quot; /&gt;</pre>
<p>You must keep this if you&#8217;re using Superfish. If you&#8217;re not going to use Superfish, you should remove these lines too:</p>
<pre class="brush: php; first-line: 29; html-script: true; title: ; notranslate">&lt;script type=&quot;text/javascript&quot; src=&quot;&lt;?php bloginfo('stylesheet_directory'); ?&gt;/superfish/js/superfish.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;&lt;?php bloginfo('stylesheet_directory'); ?&gt;/superfish/js/hoverIntent.js&quot;&gt;&lt;/script&gt;</pre>
<pre class="brush: jscript; first-line: 32; html-script: true; title: ; notranslate">&lt;script type=&quot;text/javascript&quot;&gt;

    $(document).ready(function() {
        $('ul.sf-menu').superfish();
    });

&lt;/script&gt;</pre>
<p>Next is Blueprint&#8217;s Internet Explorer CSS reset:</p>
<pre class="brush: php; first-line: 13; html-script: true; title: ; notranslate">&lt;!--[if IE]&gt;
&lt;link rel=&quot;stylesheet&quot; href=&quot;&lt;?php bloginfo('stylesheet_directory'); ?&gt;/blueprint/ie.css&quot; type=&quot;text/css&quot; media=&quot;screen, projection&quot; /&gt;
&lt;![endif] --&gt;</pre>
<p>I&#8217;ve also had good luck using the IE8 JavaScript library, so that&#8217;s included next:</p>
<pre class="brush: xml; first-line: 17; title: ; notranslate">&lt;!--[if lt IE 8]&gt;
&lt;script src=&quot;http://ie7-js.googlecode.com/svn/version/2.0(beta3)/IE8.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;![endif]--&gt;</pre>
<p>Then JQuery and JQuery UI libraries:</p>
<pre class="brush: xml; first-line: 21; title: ; notranslate">&lt;script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4.0/jquery.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/jquery-ui.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;</pre>
<p>That&#8217;s it. All the frameworks and libraries are loaded. If you don&#8217;t think you&#8217;ll need any one of them, you can just take them out. WARNING: The layout of the columns does rely on the 960 Grid System CSS file. If you take that out of the head the columns won&#8217;t work and you&#8217;ll break the layout.</p>
<p>Otherwise this should give you a good start that will allow you to take advantage of tons of cool JQuery stuff and leverages a very popular CSS Grid System for laying out columns. It should be easy to modify this theme to fit your own design.</p>
<p><a href="http://baseline.truetoneenterprises.com" onclick="pageTracker._trackPageview('/outgoing/baseline.truetoneenterprises.com?referer=');">Download the theme here</a>.<strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://anthonygthomas.com/2010/02/08/introducing-the-baseline-development-wordpress-theme/" rel="bookmark" title="February 8, 2010">Introducing the Baseline Development WordPress Theme</a></li>
<li><a href="http://anthonygthomas.com/2008/11/23/incorporating-blueprint-css-into-your-new-wordpress-theme/" rel="bookmark" title="November 23, 2008">Incorporating Blueprint CSS Into Your New WordPress Theme</a></li>
<li><a href="http://anthonygthomas.com/2010/02/16/baseline-theme-version-1-0-1/" rel="bookmark" title="February 16, 2010">Baseline Theme Version 1.0.1</a></li>
<li><a href="http://anthonygthomas.com/2008/11/26/getting-blueprint-css-javascript-libraries-into-your-cakephp-layout/" rel="bookmark" title="November 26, 2008">Getting Blueprint CSS &#038; JavaScript Libraries Into Your CakePHP Layout</a></li>
<li><a href="http://anthonygthomas.com/2008/11/22/blueprint-css-readme-file/" rel="bookmark" title="November 22, 2008">Blueprint CSS Readme File</a></li>
</ul>
<p><!-- Similar Posts took 4.428 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://anthonygthomas.com/2010/02/08/introducing-the-baseline-development-wordpress-theme/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Getting Blueprint CSS &amp; JavaScript Libraries Into Your CakePHP Layout</title>
		<link>http://anthonygthomas.com/2008/11/26/getting-blueprint-css-javascript-libraries-into-your-cakephp-layout/</link>
		<comments>http://anthonygthomas.com/2008/11/26/getting-blueprint-css-javascript-libraries-into-your-cakephp-layout/#comments</comments>
		<pubDate>Wed, 26 Nov 2008 19:55:58 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Blueprint Framework]]></category>
		<category><![CDATA[CakePHP]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[web development]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[libraries]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://anthonygthomas.com/?p=59</guid>
		<description><![CDATA[Updated 12/3/2008 The other day I wrote about getting the Blueprint CSS framework into your WordPress theme. If you&#8217;re developing in CakePHP, it&#8217;s even easier to link multiple style sheets and JavaScript libraries to your layout file. &#60;?php $css = array('blueprint/screen', 'blueprint/ie', 'style'); $jslibraries = array('prototype', 'scriptaculous', 'jquery'); echo $html-&#62;css('blueprint/print', 'stylesheet', 'media="print"'); echo $html-&#62;css($css, 'stylesheet', [...]]]></description>
			<content:encoded><![CDATA[<p>Updated 12/3/2008</p>
<p>The other day I wrote about <a href="http://anthonygthomas.com/2008/11/23/incorporating-blueprint-css-into-your-new-wordpress-theme/">getting the Blueprint CSS framework into your WordPress theme</a>. If you&#8217;re developing in <a href="http://cakephp.org" onclick="pageTracker._trackPageview('/outgoing/cakephp.org?referer=');">CakePHP</a>, it&#8217;s even easier to link multiple style sheets and JavaScript libraries to your <a href="http://book.cakephp.org/view/96/Layouts" onclick="pageTracker._trackPageview('/outgoing/book.cakephp.org/view/96/Layouts?referer=');">layout file</a>.</p>
<p><code>&lt;?php</code></p>
<p><code>$css = array('blueprint/screen', 'blueprint/ie', 'style');<br />
$jslibraries = array('prototype', 'scriptaculous', 'jquery');</code><code><span style="text-decoration: line-through;"><br />
</span>echo $html-&gt;css('blueprint/print', 'stylesheet', 'media="print"');</code><code><br />
echo $html-&gt;css($css, 'stylesheet', 'media=â€screen, projectionâ€');<br />
echo $javascript-&gt;link($jslibraries);</code><br />
<code>?&gt;</code></p>
<p>Let&#8217;s take these one at a time.</p>
<p><code>$css = array('blueprint/screen', 'blueprint/ie', 'style');</code></p>
<p><a href="http://book.cakephp.org/view/205/HTML" onclick="pageTracker._trackPageview('/outgoing/book.cakephp.org/view/205/HTML?referer=');">CakePHP&#8217;s html helper</a> will load any css file you specify. First, make sure the css files are in <code>app/webroot/css</code>. Then put any css files you want to link to your layout in an array like I have above. You might have noticed that I didn&#8217;t include print in my array. That&#8217;s because we want to add an media=&#8221;print&#8221; as a separate attribute that the other style sheets won&#8217;t have.</p>
<p>Once they&#8217;re loaded into your array, simply put <code>echo $html-&gt;css($css);</code> in the head of your layout. The output will be:<br />
<code>&lt;link rel="stylesheet" type="text/css" href="/app/webroot/css/blueprint/screen.css" /&gt;<br />
&lt;link rel="stylesheet" type="text/css" href="/app/webroot/css/blueprint/ie.css" /&gt;<br />
&lt;link rel="stylesheet" type="text/css" href="/app/webroot/css/style.css" /&gt;</code></p>
<p>We still haven&#8217;t linked our print style sheet. Make sure you link the print style sheet above the others so they override it. We can add <code>media="print"</code> by putting this into our layout head:</p>
<p><code>echo $html-&gt;css('blueprint/print', 'stylesheet', 'media="print"');</code></p>
<p>So now:</p>
<p><code>$css = array('blueprint/screen', 'blueprint/ie', 'style');<br />
</code><code>echo $html-&gt;css('blueprint/print', 'stylesheet', 'media="print"');</code><code><br />
</code><code>echo $html-&gt;css($css, 'stylesheet', 'media=â€screen, projectionâ€');</code></p>
<p>Results in:</p>
<p><code>&lt;link rel="stylesheet" type="text/css" href="/cvp-msi/https/app/webroot/css/blueprint/print.css" media="print" /&gt;<br />
&lt;link rel="stylesheet" type="text/css" href="/cvp-msi/https/app/webroot/css/blueprint/screen.css" media="screen, projection" /&gt;<br />
&lt;link rel="stylesheet" type="text/css" href="/cvp-msi/https/app/webroot/css/blueprint/ie.css" media="screen, projection" /&gt;<br />
&lt;link rel="stylesheet" type="text/css" href="/cvp-msi/https/app/webroot/css/style.css" media="screen, projection" /&gt;</code></p>
<p>Two things to note. In <code>$html-&gt;css($path, $attributes)</code>, the first argument is the path from <code>app/webroot/css</code>. The second argument is html attributes.</p>
<p>Linking JavaScript libraries is very similar.</p>
<p><code>$jslibraries = array('prototype', 'scriptaculous', 'jquery');</code></p>
<p>This will link to <code>prototype.js</code>, <code>scriptaculous.js</code> and <code>jquery.js</code> respectively as long as there in <code>app/webroot/js</code>.</p>
<p>Put <code>echo $javascript-&gt;link($jslibraries);</code> into the head of your layout and you&#8217;re done. You have all three JavaScript libraries at your disposal.</p>
<p>Other good resources:</p>
<ul>
<li><a href="http://book.cakephp.org/view/181/Core-Helpers" onclick="pageTracker._trackPageview('/outgoing/book.cakephp.org/view/181/Core-Helpers?referer=');">CakePHP Core Helpers</a></li>
<li><a href="http://book.cakephp.org/view/27/Developing-with-CakePHP" onclick="pageTracker._trackPageview('/outgoing/book.cakephp.org/view/27/Developing-with-CakePHP?referer=');">Developing With CakePHP</a></li>
<li><a href="http://api.cakephp.org/class_javascript_helper.html#cab1eb59cacd608ec02e79cfd8710094" onclick="pageTracker._trackPageview('/outgoing/api.cakephp.org/class_javascript_helper.html_cab1eb59cacd608ec02e79cfd8710094?referer=');">CakePHP API JavaScript link Helper</a></li>
<li><a href="http://api.cakephp.org/class_html_helper.html#b8e7fe2bca7be4c25f9a660038131f00" onclick="pageTracker._trackPageview('/outgoing/api.cakephp.org/class_html_helper.html_b8e7fe2bca7be4c25f9a660038131f00?referer=');">CakePHP API CSS link Helper</a></li>
</ul>
<p><strong>Similar Posts:</strong>
<ul class="similar-posts">
<li><a href="http://anthonygthomas.com/2008/11/26/getting-blueprint-css-javascript-libraries-into-your-cakephp-layout/" rel="bookmark" title="November 26, 2008">Getting Blueprint CSS &#038; JavaScript Libraries Into Your CakePHP Layout</a></li>
<li><a href="http://anthonygthomas.com/2008/11/23/incorporating-blueprint-css-into-your-new-wordpress-theme/" rel="bookmark" title="November 23, 2008">Incorporating Blueprint CSS Into Your New WordPress Theme</a></li>
<li><a href="http://anthonygthomas.com/2010/02/08/introducing-the-baseline-development-wordpress-theme/" rel="bookmark" title="February 8, 2010">Introducing the Baseline Development WordPress Theme</a></li>
<li><a href="http://anthonygthomas.com/2010/02/16/baseline-theme-version-1-0-1/" rel="bookmark" title="February 16, 2010">Baseline Theme Version 1.0.1</a></li>
<li><a href="http://anthonygthomas.com/2008/11/22/blueprint-css-readme-file/" rel="bookmark" title="November 22, 2008">Blueprint CSS Readme File</a></li>
</ul>
<p><!-- Similar Posts took 4.439 ms --></p>
]]></content:encoded>
			<wfw:commentRss>http://anthonygthomas.com/2008/11/26/getting-blueprint-css-javascript-libraries-into-your-cakephp-layout/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

