<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title><![CDATA[Richard Baker's blog]]></title>
  <link href="http://rwbaker.com/atom.xml" rel="self"/>
  <link href="http://rwbaker.com/"/>
  <updated>2013-01-20T23:48:11-05:00</updated>
  <id>http://rwbaker.com/</id>
  <author>
    <name><![CDATA[Richard Baker]]></name>
    
  </author>
  <generator uri="http://octopress.org/">Octopress</generator>

  
  <entry>
    <title type="html"><![CDATA[JavaScript: Modules versus Classes]]></title>
    <link href="http://rwbaker.com/articles/javascript-modules-versus-classes/"/>
    <updated>2012-11-25T20:24:00-05:00</updated>
    <id>http://rwbaker.com/articles/javascript-modules-versus-classes</id>
    <content type="html"><![CDATA[<p>Someone recently emailed asking:</p>

<blockquote>
  <p>What’s the difference between modules and classes in es.next?</p>
</blockquote>

<p>After a few minutes of typing out a reply, I figured I might as well post it here.</p>

<!-- more -->

<p>ES.next / ES-Harmony is the next version of JavaScript. The goal of this new version is to be a better language for writing complex applications and libraries. In my opinion this also comes with a lot more complexities in the language itself; time will tell.</p>

<h2 id="tldrtldr"><a href="http://en.wikipedia.org/wiki/Wikipedia:Too_long;_didn't_read">TL;DR</a></h2>

<p>In ES-Harmony, a module is a chunk of code that is loaded only when needed. A class is a way you structure/write your code.</p>

<h2 id="modules">Modules</h2>

<p>A module is a self-contained script to be loaded when needed. This can be helpful if you’d only like to load some scripts if the user’s browser has certain features, such as geolocation.</p>

<p>Check out <a href="http://wiki.ecmascript.org/doku.php?id=harmony:modules">Modules</a> and <a href="http://wiki.ecmascript.org/doku.php?id=harmony:module_loaders">Module loaders</a> documentation.</p>

<h3 id="using-modules-today">Using Modules Today</h3>

<p>Today we can use modules with a variety of libraries such as <a href="http://requirejs.org/">RequireJS</a>, <a href="https://github.com/cujojs/curl">curl.js</a>, <a href="http://labjs.com/">LABjs</a>, and <a href="http://yepnopejs.com/">yepnopejs</a>.</p>

<p><strong>RequireJS</strong> and <strong>curl.js</strong> both use the <a href="https://github.com/amdjs/amdjs-api/wiki/AMD">Asynchronous Module Definition (AMD)</a> API for their modules. AMD is based on the <code>define()</code> function that allows you to name your module, list any dependencies (which will also be asynchronously loaded), and fire off an instantiation function if needed.</p>

<p><strong>LABjs</strong> and <strong>yepnopejs</strong> focus on file loading rather than modules — that means you manage the dependencies yourself. It also means your scripts don’t have to follow a specific pattern. Yepnope can also conditionally load CSS files.</p>

<h2 id="classes">Classes</h2>
<p>Classes are one of the ways you can structure your code. In current JavaScript (ECMAScript 5), you’d probably use a function or an object literal (more on using <a href="http://www.phpied.com/3-ways-to-define-a-javascript-class/">classes in <em>current</em> JavaScript</a>). For example:</p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
<span class="line-number">4</span>
<span class="line-number">5</span>
<span class="line-number">6</span>
<span class="line-number">7</span>
<span class="line-number">8</span>
<span class="line-number">9</span>
<span class="line-number">10</span>
<span class="line-number">11</span>
<span class="line-number">12</span>
<span class="line-number">13</span>
<span class="line-number">14</span>
<span class="line-number">15</span>
<span class="line-number">16</span>
<span class="line-number">17</span>
<span class="line-number">18</span>
<span class="line-number">19</span>
<span class="line-number">20</span>
<span class="line-number">21</span>
<span class="line-number">22</span>
</pre></td><td class="code"><pre><code class="javascript"><span class="line"><span class="c1">// define a new type SkinnedMesh and a constructor for it</span>
</span><span class="line"><span class="kd">function</span> <span class="nx">SkinnedMesh</span><span class="p">(</span><span class="nx">geometry</span><span class="p">,</span> <span class="nx">materials</span><span class="p">)</span> <span class="p">{</span>
</span><span class="line">  <span class="c1">// call the superclass constructor</span>
</span><span class="line">  <span class="nx">THREE</span><span class="p">.</span><span class="nx">Mesh</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="k">this</span><span class="p">,</span> <span class="nx">geometry</span><span class="p">,</span> <span class="nx">materials</span><span class="p">);</span>
</span><span class="line">
</span><span class="line">  <span class="c1">// initialize instance properties</span>
</span><span class="line">  <span class="k">this</span><span class="p">.</span><span class="nx">identityMatrix</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">THREE</span><span class="p">.</span><span class="nx">Matrix4</span><span class="p">();</span>
</span><span class="line">  <span class="k">this</span><span class="p">.</span><span class="nx">bones</span> <span class="o">=</span> <span class="p">[];</span>
</span><span class="line">  <span class="k">this</span><span class="p">.</span><span class="nx">boneMatrices</span> <span class="o">=</span> <span class="p">[];</span>
</span><span class="line">  <span class="p">...</span>
</span><span class="line"><span class="p">};</span>
</span><span class="line">
</span><span class="line"><span class="c1">// inherit behavior from Mesh</span>
</span><span class="line"><span class="nx">SkinnedMesh</span><span class="p">.</span><span class="nx">prototype</span> <span class="o">=</span> <span class="nb">Object</span><span class="p">.</span><span class="nx">create</span><span class="p">(</span><span class="nx">THREE</span><span class="p">.</span><span class="nx">Mesh</span><span class="p">.</span><span class="nx">prototype</span><span class="p">);</span>
</span><span class="line"><span class="nx">SkinnedMesh</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">constructor</span> <span class="o">=</span> <span class="nx">SkinnedMesh</span><span class="p">;</span>
</span><span class="line">
</span><span class="line"><span class="c1">// define an overridden update() method</span>
</span><span class="line"><span class="nx">SkinnedMesh</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">update</span> <span class="o">=</span> <span class="kd">function</span><span class="p">(</span><span class="nx">camera</span><span class="p">)</span> <span class="p">{</span>
</span><span class="line">  <span class="p">...</span>
</span><span class="line">  <span class="c1">// call base version of same method</span>
</span><span class="line">  <span class="nx">THREE</span><span class="p">.</span><span class="nx">Mesh</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">update</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span><span class="k">this</span><span class="p">);</span>
</span><span class="line"><span class="p">};</span>
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p>In ES-Harmony, you’d actually define a new class like so:</p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
<span class="line-number">4</span>
<span class="line-number">5</span>
<span class="line-number">6</span>
<span class="line-number">7</span>
<span class="line-number">8</span>
<span class="line-number">9</span>
<span class="line-number">10</span>
<span class="line-number">11</span>
<span class="line-number">12</span>
<span class="line-number">13</span>
<span class="line-number">14</span>
<span class="line-number">15</span>
</pre></td><td class="code"><pre><code class="javascript"><span class="line"><span class="kr">class</span> <span class="nx">SkinnedMesh</span> <span class="kr">extends</span> <span class="nx">THREE</span><span class="p">.</span><span class="nx">Mesh</span> <span class="p">{</span>
</span><span class="line">  <span class="nx">constructor</span><span class="p">(</span><span class="nx">geometry</span><span class="p">,</span> <span class="nx">materials</span><span class="p">)</span> <span class="p">{</span>
</span><span class="line">    <span class="kr">super</span><span class="p">(</span><span class="nx">geometry</span><span class="p">,</span> <span class="nx">materials</span><span class="p">);</span>
</span><span class="line">
</span><span class="line">    <span class="kr">public</span> <span class="nx">identityMatrix</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">THREE</span><span class="p">.</span><span class="nx">Matrix4</span><span class="p">();</span>
</span><span class="line">    <span class="kr">public</span> <span class="nx">bones</span> <span class="o">=</span> <span class="p">[];</span>
</span><span class="line">    <span class="kr">public</span> <span class="nx">boneMatrices</span> <span class="o">=</span> <span class="p">[];</span>
</span><span class="line">    <span class="p">...</span>
</span><span class="line">  <span class="p">}</span>
</span><span class="line">
</span><span class="line">  <span class="nx">update</span><span class="p">(</span><span class="nx">camera</span><span class="p">)</span> <span class="p">{</span>
</span><span class="line">    <span class="p">...</span>
</span><span class="line">    <span class="kr">super</span><span class="p">.</span><span class="nx">update</span><span class="p">();</span>
</span><span class="line">  <span class="p">}</span>
</span><span class="line"><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p>Big changes, right? Read the latest <a href="http://wiki.ecmascript.org/doku.php?id=harmony:classes">classes documentation</a> on the ECMAScript.org wiki.</p>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Responsive Web]]></title>
    <link href="http://rwbaker.com/articles/responsive-web/"/>
    <updated>2012-11-15T23:12:00-05:00</updated>
    <id>http://rwbaker.com/articles/responsive-web</id>
    <content type="html"><![CDATA[<p><a href="http://bradfrostweb.com/">Brad Frost</a> talked about Responsive vs. Separate Sites during one of Google’s Monthly Mobile Web Hangouts.</p>

<p>One part of his presentation had a great point on the argument of mobile web applications instead of native applications. Watch this section of his presentation starting at 13:36:</p>

<!-- more -->

<iframe width="640" height="360" src="http://www.youtube.com/embed/SVPJcw5-WNc#t=816" frameborder="0" allowfullscreen=""></iframe>

<p><a href="http://youtu.be/SVPJcw5-WNc?t=13m36s">Chrome Mobile Monthly: Responsive vs Separate Sites</a></p>

<p>Here is Luke’s post Brad was referencing: <a href="http://www.lukew.com/ff/entry.asp?1646">Two Months of Device Diversity</a>. Thirty-three devices released in two months, 20 of which are ‘mobile’ devices. I bet testers get tired just thinking about that!</p>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Tips For Building A UX Team]]></title>
    <link href="http://rwbaker.com/articles/building-a-ux-team/"/>
    <updated>2012-11-14T20:30:00-05:00</updated>
    <id>http://rwbaker.com/articles/building-a-ux-team</id>
    <content type="html"><![CDATA[<p><a href="http://www.uie.com/articles/who_is_on_the_ux_team/">Who is on the UX team</a>:</p>

<blockquote>
  <p>When we talk to executives about building out their user experience teams, the first question we’re asked is “who should be on the team?” To answer this question, we studied two types of UX teams: those that are successful at delivering great designs and those that struggle at it. We wanted to see what was different about each type of UX team’s make up.</p>
</blockquote>

<p>This article has some great tidbits on how to foster a great UX team:</p>

<!-- more -->

<ul>
  <li>Think of your team as more than just the individuals in your <em>nuclear design team</em>. The extended design team could include anyone who made decisions that inevitably affected the outcome of the design and the experience of the users.</li>
  <li>Focus on skills, not roles or job titles.</li>
  <li>Monitor the team to identify the individuals who could benefit from training.</li>
  <li>Teams are more successful when in the same location; they have a higher bandwidth communication path.</li>
</ul>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[New Digs]]></title>
    <link href="http://rwbaker.com/articles/new-digs/"/>
    <updated>2012-11-12T00:44:00-05:00</updated>
    <id>http://rwbaker.com/articles/new-digs</id>
    <content type="html"><![CDATA[<p>Last year around this time I converted my blog to <a href="https://github.com/mojombo/jekyll">Jekyll</a>/<a href="http://octopress.org/">Octopress</a>; I actually quite liked <a href="http://brandonmathis.com/">Brandon Mathis’</a> default theme to I opted to keep it, however now it’s finally time for a more original theme. I wanted something simple that focused more on content, hoping that in-turn it’ll help me write more content. Only time will tell.</p>

<!-- more -->

<p>In the past month I’ve been evaluating static-site generators as a replacement for Jekyll/Octopress:</p>

<ul>
  <li>First I tried <a href="http://ringce.com/hyde">Hyde</a> (since my day-job involves lots of Python and Django) but noticed it was no longer in development.</li>
  <li>Then I found the <a href="https://github.com/hyde/hyde">New Hyde</a> but there just wasn’t enough documentation for me to get anywhere.</li>
  <li>Next I tried plain vanilla <a href="https://github.com/mojombo/jekyll">Jekyll</a> but found myself adding lots of plugins.</li>
  <li>Then I tried <a href="http://jekyllbootstrap.com">Jekyll Bootstrap</a> but didn’t care for it’s non-plugin system, and that the author has already moved onto a <a href="http://ruhoh.com">new replacement project</a>.</li>
  <li>Finally I settled back on <a href="http://octopress.org/">Octopress</a>, where I should have never left.</li>
</ul>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Ad Hoc Provisioning with Sencha Touch]]></title>
    <link href="http://rwbaker.com/articles/ad-hoc-provisioning-with-sencha-touch/"/>
    <updated>2012-03-22T07:47:00-04:00</updated>
    <id>http://rwbaker.com/articles/ad-hoc-provisioning-with-sencha-touch</id>
    <content type="html"><![CDATA[<p>I’ve been making good progress with my mobile app, now it’s it’s time to show it to a few testers.  With this being my first app, I was a bit lost on to go about ad hoc app provisioning. The [sencha touch guide][guide] had a few sentences about it, but it just wasn’t working for me. With ST2 being such s new framework, there wasn’t much on the forums either. After a few wasted hours, I finally got it…</p>

<!-- more -->

<h2 id="creating-the-provisioning-profile">Creating the Provisioning Profile</h2>

<ol>
  <li>Add device to the iOS Dev Center’s Devices section using it’s UDID</li>
  <li>Create/modify the provisioning profile at Provisioning &gt; Distribution tab</li>
  <li>Select the specific devices for the Provisioning profile</li>
  <li>Save the profile.</li>
  <li>The profile will now have a status of ‘pending’</li>
  <li>Click on Devices on the side and verify the device is being used in at least 1 profile</li>
  <li>Go back to Provisioning &gt; Distribution, the profile should be ready for download</li>
  <li>In the actions column, click ‘Download’ and copy the file to <code>[sencha project folder]/build/package/</code>. It will have a file extension of <code>*.mobileprovision</code>.</li>
  <li>Edit the packager.json file and make sure it has the config item below with the correct path to the provisioning file:</li>
</ol>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
<span class="line-number">4</span>
<span class="line-number">5</span>
<span class="line-number">6</span>
</pre></td><td class="code"><pre><code class="bash"><span class="line">/**
</span><span class="line"> * @cfg <span class="o">{</span>String<span class="o">}</span> provisionProfile
</span><span class="line"> * This is only needed to specify a Provision Profile to be used
</span><span class="line"> * http://docs.sencha.com/touch/2-0/#!/guide/native_packaging
</span><span class="line"> */
</span><span class="line"> <span class="s2">&quot;provisionProfile&quot;</span>:<span class="s2">&quot;build/package/JaxDisaster_Ad_Hoc_Provisioning_Profile.mobileprovision&quot;</span>,
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p>The provisioning profile should also be sent along with the Ad Hoc app you send to the beta tester.</p>

<h2 id="certificate">Certificate</h2>
<ol>
  <li>Now, go to Certificates &gt; Distribution and download the certificate that coincides with your Provisioning Profile.</li>
  <li>Click and drag that certificate onto the Xcode icon in the Doc (OS X only). Close the certificate window once it pops up.</li>
  <li>Copy the cer file to <code>[sencha project folder]/build/package/</code></li>
  <li>Edit the packager.json file and make sure it has the config item below with the correct path to the certificate file:</li>
</ol>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
<span class="line-number">4</span>
<span class="line-number">5</span>
<span class="line-number">6</span>
</pre></td><td class="code"><pre><code class="bash"><span class="line">/**
</span><span class="line"> * @cfg <span class="o">{</span>String<span class="o">}</span> certificatePath
</span><span class="line"> * This is the location of your certificate.
</span><span class="line"> * This is required when you are developing <span class="k">for </span>Android or you are developing on Windows.
</span><span class="line"> */
</span><span class="line"><span class="s2">&quot;certificatePath&quot;</span>:<span class="s2">&quot;build/package/ios_distribution.cer&quot;</span>,
</span></code></pre></td></tr></table></div></figure></notextile></div>

<h2 id="build">Build</h2>

<ol>
  <li>In the terminal, at the project folder, type: <code>sencha app build native</code></li>
  <li>The native app will be in <code>[sencha project folder]/build/package/</code></li>
  <li>Zip the native app up, along with the mobileprovision file and deliver to your beta tester</li>
</ol>

<h2 id="installing">Installing</h2>

<p>Installing the app must be done on the computer the device syncs with.</p>

<ol>
  <li>Plug the device into the computer and open iTunes</li>
  <li>Make sure the sync setting sync settings in the App tab are set to sync apps to that computer</li>
  <li>Do a full device sync and backup</li>
  <li>Right click on the device in the left sidebar and click ‘Transfer Purchases from [device name]’</li>
  <li>Drag the mobileprovision and application file (unzipped) and drop on top of the iTunes icon in the dock</li>
  <li>In the Apps tab, find the application in the list and make sure it’s checked.</li>
  <li>Do a full sync and the application will transfer over</li>
</ol>

<h2 id="links">Links</h2>

<ul>
  <li>[UDID][UDID]</li>
  <li>[iOS App to find your UDID][ios]</li>
</ul>

<p>[guide]:
[UDID]:http://www.innerfence.com/howto/find-iphone-unique-device-identifier-udid
[ios]:http://itunes.apple.com/app/ad-hoc-helper/id285691333?mt=8</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Scaling Images in Sencha Touch 2]]></title>
    <link href="http://rwbaker.com/articles/scaling-images-in-sencha-touch-2/"/>
    <updated>2012-03-02T08:08:00-05:00</updated>
    <id>http://rwbaker.com/articles/scaling-images-in-sencha-touch-2</id>
    <content type="html"><![CDATA[<p>I need to show a <a href="http://www.srh.noaa.gov/images/fxc/jax/graphicast/image12.jpg">map of the current weather conditions</a> in my <a href="http://www.sencha.com/products/touch/">Sencha Touch 2</a> app—this image is published daily by the NOAA. It needs to be a block element—not full screen but large enough for the user to see it. <!-- more --></p>

<p><a href="http://www.srh.noaa.gov/images/fxc/jax/graphicast/image12.jpg"><img class="left" src="http://www.srh.noaa.gov/images/fxc/jax/graphicast/image12.jpg" width="400" title="Today's weather for Jacksonville Florida" /></a> What I want is a panel where the width takes all available space (for varying screen sizes) and the height fits to the content, in this case an image. That means I don’t want to set a fixed height or width. After all, the beauty of Sencha Touch is to build for <strong>all</strong> smartphones, which have a wide-range of resolutions and bit-depth.</p>

<div class="clear"></div>

<h2 id="standard-extimg">Standard Ext.Img:</h2>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
<span class="line-number">4</span>
<span class="line-number">5</span>
<span class="line-number">6</span>
<span class="line-number">7</span>
<span class="line-number">8</span>
<span class="line-number">9</span>
<span class="line-number">10</span>
<span class="line-number">11</span>
<span class="line-number">12</span>
<span class="line-number">13</span>
<span class="line-number">14</span>
<span class="line-number">15</span>
</pre></td><td class="code"><pre><code class="javascript"><span class="line"><span class="nx">Ext</span><span class="p">.</span><span class="nx">define</span><span class="p">(</span><span class="s1">&#39;App.view.Main&#39;</span><span class="p">,</span> <span class="p">{</span>
</span><span class="line">    <span class="nx">extend</span>  <span class="o">:</span> <span class="s1">&#39;Ext.Panel&#39;</span><span class="p">,</span>
</span><span class="line">
</span><span class="line">    <span class="nx">config</span>  <span class="o">:</span> <span class="p">{</span>
</span><span class="line">        <span class="nx">styleHtmlContent</span>    <span class="o">:</span> <span class="kc">true</span><span class="p">,</span>
</span><span class="line">
</span><span class="line">        <span class="nx">items</span> <span class="o">:</span> <span class="p">[</span>
</span><span class="line">            <span class="p">{</span>   <span class="c1">//      National Weather Service Weather map</span>
</span><span class="line">                <span class="nx">xtype</span>   <span class="o">:</span> <span class="s1">&#39;image&#39;</span><span class="p">,</span>
</span><span class="line">                <span class="nx">src</span>     <span class="o">:</span> <span class="s1">&#39;http://www.srh.noaa.gov/images/fxc/jax/graphicast/image12.jpg&#39;</span><span class="p">,</span>
</span><span class="line">                <span class="nx">height</span>  <span class="o">:</span> <span class="mi">300</span>
</span><span class="line">            <span class="p">}</span>
</span><span class="line">        <span class="p">]</span>
</span><span class="line">    <span class="p">}</span>
</span><span class="line"><span class="p">});</span>
</span></code></pre></td></tr></table></div></figure></notextile></div>
<p><img class="right" src="http://rwbaker.com/images/posts/scaling-images-in-sencha-touch-2/ext-image.png" title="Image using Ext.Img" /> As you can see, the whole image doesn’t fit in the panel and Sencha isn’t going to scale it. Notice I had to set a height of <code>300</code>, otherwise, the image wouldn’t show at all (unless you use the <code>hbox</code> or <code>vbox</code> or <code>fit</code> layout modes, which I’m not).</p>

<div class="clear"></div>

<h2 id="css-to-the-rescue-almost">CSS to the Rescue… (almost)</h2>

<p>CSS3 introduced the handy <code>background-size</code> property. <code>cover</code> will scale the image down to fit the element, and <code>contain</code> sill scale the image up to fill the element. Great. So I went back to the standard panel, added a CSS class, and put <code>background-size</code> to work.</p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
<span class="line-number">4</span>
</pre></td><td class="code"><pre><code class="javascript"><span class="line"><span class="p">{</span>   <span class="c1">//      National Weather Service Weather map</span>
</span><span class="line">    <span class="nx">xtype</span>   <span class="o">:</span> <span class="s1">&#39;panel&#39;</span><span class="p">,</span>
</span><span class="line">    <span class="nx">cls</span>     <span class="o">:</span> <span class="s1">&#39;my-image-class&#39;</span>
</span><span class="line"><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p>… except we still need to set a fixed height on the panel for the image to show.</p>

<p>(<a href="https://developer.mozilla.org/en/CSS/background-size">More on background-size at Mozilla’s Developer Network</a>)</p>

<h2 id="rd-attempt">3rd Attempt</h2>

<p>My biggest problem was having the height of the panel adjust to the image. I figured the best way to fix that was to put an <code>&lt;img&gt;</code> tag in the panel… old school style.</p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
<span class="line-number">4</span>
</pre></td><td class="code"><pre><code class="javascript"><span class="line"><span class="p">{</span>   <span class="c1">//      National Weather Service Weather map</span>
</span><span class="line">    <span class="nx">xtype</span>   <span class="o">:</span> <span class="s1">&#39;panel&#39;</span><span class="p">,</span>
</span><span class="line">    <span class="nx">html</span>    <span class="o">:</span> <span class="s1">&#39;&lt;img src=&quot;http://www.srh.noaa.gov/images/fxc/jax/graphicast/image12.jpg&quot; /&gt;&#39;</span>
</span><span class="line"><span class="p">}</span>
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p><img class="left" src="http://rwbaker.com/images/posts/scaling-images-in-sencha-touch-2/image-tag.png" title="Image using a img tag inside a panel" /> We’re getting there. The panel height is being driven by the content, but that image is just too dang big.</p>

<div class="clear"></div>

<p>After a little big of searching, I saw Ethan Marcotte’s post on <a href="http://unstoppablerobotninja.com/entry/fluid-images">Fluid Images</a>. All of his research settled on a idea from <a href="http://clagnut.com/sandbox/imagetest3/">Richard Rutter</a>:</p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
</pre></td><td class="code"><pre><code class="css"><span class="line"><span class="nt">img</span> <span class="p">{</span> <span class="k">max-width</span><span class="o">:</span> <span class="m">100</span><span class="o">%</span><span class="p">;</span> <span class="p">}</span>
</span></code></pre></td></tr></table></div></figure></notextile></div>
<div class="clear"></div>

<p><img class="right" src="http://rwbaker.com/images/posts/scaling-images-in-sencha-touch-2/finalproduct.png" title="Image using a img tag inside a panel with max-width" /> Come on… <em>seriously</em>? That’s it? That won’t work. Way too simple. Where are the hacks, exceptions, or ‘works in nightly only’ disclaimers? It won’t even scale proportionally! Nope… <strong>it works</strong>. Of course IE has it’s issues, but we’re not deploying this app on Windows Phone 7, so it’s not a big deal.</p>

<div class="clear"></div>

<h2 id="rounded-corners">Rounded Corners</h2>

<p><img class="left" src="http://rwbaker.com/images/posts/scaling-images-in-sencha-touch-2/image-corner.png" title="Image rounded corner progression" /> You might have noticed that my panels have rounded corners. Initially my image corners were not being clipped properly by the parent’s rounded corners, even with <code>overlflow:hidden</code>. Turns out there is a <a href="https://bugs.webkit.org/show_bug.cgi?id=54189">WebKit bug</a> for elements using <code>position:relative</code> (which Sencha Touch uses heavily) and <code>border-radius</code> content clipping.</p>

<p>Using <code>border-radius: inherit</code> doesn’t seem to do any good. The easiest fix is to give the image the same <code>border-radius</code> and set the parent container’s <code>background:transparent</code> to avoid any fringing.</p>

<p>And that’s how I wasted a day displaying one image.</p>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Rails CMSes]]></title>
    <link href="http://rwbaker.com/articles/rails-cmses/"/>
    <updated>2012-02-19T00:55:00-05:00</updated>
    <id>http://rwbaker.com/articles/rails-cmses</id>
    <content type="html"><![CDATA[<p>Ruby on Rails content management systems are a bit disappointing.</p>

<p><strong>Refinery CMS</strong> looks great on the surface. It has a decent selection of modules and a strong group of developers behind it. But its UI is too simple if you expect to use it for any type of content other than plain pages.</p>

<p>For example, once you install the Blog add-on, to add a blog post, you just add a regular page and set the ‘Parent page’ to ‘Blog’. First, that’s not a very intuitive method of adding a blog post—I’d expect to see ‘Add blog post’ or something similar. Secondly, when I have 200 pages and 1,000 blog posts, that tree will be a mess.</p>

<p><strong>Locomotive CMS</strong> is nice as well; and if you’re lucky, the demo might be working. A brief look at their features shows they have custom content types—key for any flexible CMS. Finally a CMS with some beef to it! Now, lets hop on over to their blog and … it’s a Tumbler-powered blog. Really? A CMS site that’s not using the CMS? Yikes. Moving on…</p>

<p><strong>Radiant CMS</strong> was probably the first mainstream Rails CMS. But just as the tagline says, it’s a CMS intended for smaller teams or smaller collections of data. By all accounts it looks like a great CMS, but I wouldn’t want to be locked into it if the site could grow.</p>

<p>Everything else looks to be half-finished projects or frameworks for rolling your own CMS as part of a custom application. This is a bit frustrating as I often have website projects that evolve over the years into custom applications. Without a solid ruby CMS to start with, I often start with a PHP CMS then try to decipher when the right time is to break away from the CMS and move into a custom rails app, rather than just adding on and incorporating the CMS into the larger project.</p>

<p>Oh well, the hunt continues.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Installing Rails]]></title>
    <link href="http://rwbaker.com/articles/basics-of-starting-with-rails/"/>
    <updated>2012-02-18T12:25:00-05:00</updated>
    <id>http://rwbaker.com/articles/basics-of-starting-with-rails</id>
    <content type="html"><![CDATA[<p>The basic commands to get Ruby on Rails up and running quickly:<!-- more --></p>

<p><strong>Install Latest Version of Rails</strong></p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
</pre></td><td class="code"><pre><code class="bash"><span class="line">sudo gem install rails
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p><strong>Install Specific Version of Rails</strong></p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
</pre></td><td class="code"><pre><code class="bash"><span class="line">sudo gem install rails --version 3.0
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p><strong>Update Rails</strong></p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
</pre></td><td class="code"><pre><code class="bash"><span class="line">sudo gem update rails
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p><strong>Rolling Back to Previous Version of Rails</strong></p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
</pre></td><td class="code"><pre><code class="bash"><span class="line">sudo gem uninstall rails
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p>You’ll then see something like this:</p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
<span class="line-number">4</span>
<span class="line-number">5</span>
<span class="line-number">6</span>
<span class="line-number">7</span>
</pre></td><td class="code"><pre><code class="bash"><span class="line">Select gem to uninstall:
</span><span class="line"> 1. rails-3.0.0
</span><span class="line"> 2. rails-3.0.5
</span><span class="line"> 3. rails-3.0.11
</span><span class="line"> 4. rails-3.1.1
</span><span class="line"> 5. rails-3.2.1
</span><span class="line"> 6. All versions
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p>Type the number of the version you’d like to uninstall and hit enter, and away it goes.</p>

<h2 id="rvm">RVM</h2>

<p>If you need specific ruby/rails environments for various projects, then you should be using <a href="http://beginrescueend.com/">RVM</a> and <a href="http://beginrescueend.com/gemsets/basics/">named gem sets</a>.</p>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[2011: Year in Review]]></title>
    <link href="http://rwbaker.com/articles/year-in-review/"/>
    <updated>2012-01-01T17:55:00-05:00</updated>
    <id>http://rwbaker.com/articles/year-in-review</id>
    <content type="html"><![CDATA[<p>2011 was a crazy year for the world. For Laura and I, 2011 was a very busy year filled with hospitals, construction projects, and lifestyle changes.</p>

<!-- more -->

<ol>
  <li>
    <p><strong>January</strong> brought a new driveway for our house, which meant our <a href="http://www.flickr.com/photos/rwbaker/collections/72157622671345682/">longtime construction project</a> was soon coming to a close.</p>
  </li>
  <li>
    <p>We were also able to retrieve and scan all my wife’s medical files from Ohio for her original brain injury 13 years ago. This proved very helpful as the records showed the doctors <em>then</em> found the same brain abnormality our current doctors just found. Proof surgery was the right track.</p>
  </li>
  <li>
    <p><strong>February</strong> Laura and I started following the Paleo diet in hopes to clean our her system from all the ineffective anti-seizure drugs she’s been taking for the past few years. Surprisingly, this also decreased her seizures by 75%! Normally she would have a cluster of seizures every month, without fail. On the diet, clusters came every 2 to 4 months.</p>
  </li>
  <li>
    <p><strong>March</strong> launched ChefDave.org’s site membership using the <a href="http://www.membrr.com/">Membrr</a> / <a href="http://www.opengateway.net/">OpenGateway</a> and <a href="http://www.solspace.com/software/detail/user">Solspace’s User</a> plugins. This is also the time when my love of ExpressionEngine started falling apart due to various issues.</p>
  </li>
  <li>
    <p>Also in March I bought a road bike after I sheared off my pedal arm on my Raleigh hybrid. Though time in 2011 been scarce, I hope to get back into cycling soon.</p>
  </li>
  <li>
    <p><strong>April</strong> saw the final piece of <a href="http://coj.net/">COJ.net</a> go live. This wrapped up a year-long conversion and redesign project of the 30,000 page site.</p>
  </li>
  <li>
    <p>In <strong>May</strong> we finally finished the outside construction on our house, completing the addition of my wife’s workshop and my (albeit unplanned) office. This major project included demolishing the existing one car garage and replacing it with a 30x30 garage with AC, 220v and 3 phase power. It’s the dream workshop of almost any woodworker. Now we start the inside of the house and shop.</p>
  </li>
  <li>
    <p>In <strong>June</strong> my garden was in full swing. The bell peppers and cucumbers were great producers, and my watermelon plants were full of blooms. I planted 11 watermelon plants total which meant about 66 square-feet of vines—but no watermelons actually came to fruition. I will try again, though, with only one or two plants this time.</p>
  </li>
  <li>
    <p><strong>June</strong> was also the last month my wife had <em>any</em> seizures. From July to November was the longest stretch of no meds and no seizures. All from dieting alone. This was great, but also added additional stress without knowing when a cluster of seizures could strike.</p>
  </li>
  <li>
    <p>I converted rwbaker.com to WordPress using the Briefed WooTheme.</p>
  </li>
  <li>
    <p>At the end of <strong>August</strong> <a href="http://www.coj.net/mayor.aspx">Jacksonville Mayor’s new blog</a> went live. It was a very rushed and fast-paced project and I even <a href="http://rwbaker.com/blog/2011/08/24/kentico-content-slider-with-cropped-thumbnails/ (Kentico Content Slider with Cropped Thumbnails)">learned a few things</a>.</p>
  </li>
  <li>
    <p><strong>September</strong> I rewrote the API for ChefDave.org, making it more flexible and removing a big bottleneck when requesting a lot of data. This also lays the groundwork for larger system-wide changes down the road.</p>
  </li>
  <li>
    <p>In <strong>October</strong> my mother-in-law finished her battle with breast cancer.</p>
  </li>
  <li>
    <p><strong>November</strong> Laura had a right temporal lobectomy to hopefully put an end to her partial complex seizures. Every seizure wipes Laura’s long and short term memory—she doesn’t know who I am, doesn’t recognize our house, etc. Surgery took exactly 3 hours, and they were even able to reuse the incision from her first craniotomy. She was awake within one hour, and walking around in five. Two months post-op and no seizures so far.</p>
  </li>
  <li>
    <p>I converted rwbaker.com to Octopress/Jekyll after my WordPress install was hacked and made a mess of my server. I love the static platform though, and it’s a great way to get started in Ruby and SASS.</p>
  </li>
  <li>
    <p>For <strong>December</strong>, Christmas was in Ohio this year, which  gave us a great opportunity to take up the truck and fill it full of lumber for Laura’s new shop. The holidays, quality family time, and October fresh in our minds gave us time to reflect on the year and where we are in life.</p>
  </li>
  <li>
    <p>December marks 6 months my wife has <em>continuously</em> known me, the longest stretch in our 10 years together.</p>
  </li>
</ol>

<p>Hopefully 2012 will bring a lot of changes for Laura and I. Some big, some fun, and perhaps even a scary one or two. On the personal side of things, I want to branch out more with Node.js, Ruby on Rails and iOS development, and maybe even start a new side project.</p>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Boycotting GoDaddy]]></title>
    <link href="http://rwbaker.com/articles/boycott-godaddy/"/>
    <updated>2011-12-29T11:10:00-05:00</updated>
    <id>http://rwbaker.com/articles/boycott-godaddy</id>
    <content type="html"><![CDATA[<p>I’m boycotting <a href="http://www.thedomains.com/2011/10/31/godaddy-likes-the-e-parasite-bill-techdirt-com-rips-them/">GoDaddy because they support</a> the Stop Online Piracy Act (SOPA,
H.R. 3261), and the Protect IP Act (PIPA, S. 968). These bills sound good from the titles,
but are broadly worded to allow the government to takedown websites for almost any reason.
Feeling the pressure from the interwebs,
<a href="http://www.godaddy.com/newscenter/release-view.aspx?news_item_id=380">GoDaddy officially renounced support for SOPA</a>, but there was no mention of PIPA.</p>

<p>GoDaddy sells domains for cheap, and in return, I look past their horrible control panel,
<a href="http://videos.godaddy.com/godaddy_media.aspx?ci=13336">cheap advertising campaigns</a>, and <a href="http://mashable.com/2011/03/31/godaddy-ceo-elephant/">ridiculous animal abuse</a>. No more; I’ve
finally moved my 16 domains to Namecheap. I suggest you do
the same and move your domains a responsible company like <a href="http://www.namecheap.com?aff=15970">Namecheap</a> or <a href="http://www.dreamhost.com/r.cgi?628456">Dreamhost</a> (both affiliate links).</p>

<p>And to read more about SOPA, <a href="http://www.alistapart.com/articles/say-no-to-sopa/">Jeffery Zeldman has written a great piece on SOPA</a> and what it
could mean for our industry.</p>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Arguments vs Arrays]]></title>
    <link href="http://rwbaker.com/articles/arguments-vs-arrays/"/>
    <updated>2011-11-25T23:29:00-05:00</updated>
    <id>http://rwbaker.com/articles/arguments-vs-arrays</id>
    <content type="html"><![CDATA[<p>I saw a job posting that illustrated the JavaScript/ECMAScript knowledge-level the
candidate needed with:</p>

<blockquote>
  <p>can you figure out whether you’re working with an array or arguments list without the
use of 3rd party code?</p>
</blockquote>

<p>I was intrigued, because I didn’t know the answer.</p>

<!-- more -->

<p>Two ways (of many, I’m sure) to determine the type of JavaScript Object you’re working with is by
using <code>instaceof</code> or <code>Object.prototype.toString</code></p>

<h2 id="instaceof">instaceof</h2>

<p>Instaceof will give you a boolean response. It’s useful to determine if you’re working
with a specific kind of object.</p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
<span class="line-number">4</span>
<span class="line-number">5</span>
<span class="line-number">6</span>
<span class="line-number">7</span>
</pre></td><td class="code"><pre><code class="javascript"><span class="line"><span class="kd">function</span> <span class="nx">bob</span><span class="p">(</span><span class="nx">one</span><span class="p">,</span> <span class="nx">two</span><span class="p">,</span> <span class="nx">three</span><span class="p">)</span> <span class="p">{</span>
</span><span class="line">	<span class="kd">var</span> <span class="nx">x</span> <span class="o">=</span> <span class="nx">arguments</span><span class="p">;</span>
</span><span class="line">	<span class="kd">var</span> <span class="nx">y</span> <span class="o">=</span> <span class="p">[];</span>
</span><span class="line">
</span><span class="line">	<span class="nx">console</span><span class="p">.</span><span class="nx">log</span> <span class="p">(</span> <span class="nx">x</span> <span class="k">instanceof</span> <span class="nb">Array</span> <span class="p">);</span> <span class="c1">//false</span>
</span><span class="line">	<span class="nx">console</span><span class="p">.</span><span class="nx">log</span> <span class="p">(</span> <span class="nx">y</span> <span class="k">instanceof</span> <span class="nb">Array</span> <span class="p">);</span> <span class="c1">//true</span>
</span><span class="line"><span class="p">};</span>
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p>Instanceof evaluates to true if the object inherits from the class’s prototype:</p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
</pre></td><td class="code"><pre><code class="javascript"><span class="line"><span class="kd">var</span> <span class="nx">p</span> <span class="o">=</span> <span class="k">new</span> <span class="nx">Person</span><span class="p">(</span><span class="s2">&quot;Richard&quot;</span><span class="p">);</span>
</span><span class="line"><span class="nx">p</span> <span class="k">instanceof</span> <span class="nx">Person</span> <span class="c1">//true</span>
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p>This evaluates to true since p inherits from Person.prototype. It’s worth noting that
using the <code>new</code> keyword is imperative.</p>

<p><code>Arguments</code> is not a valid instanceof object, so we can only use this to tell if we’re
dealing with an Array or something else.</p>

<h2 id="objectprototypetostring">Object.prototype.toString</h2>

<p>Calling this returns the type of object</p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
<span class="line-number">4</span>
<span class="line-number">5</span>
<span class="line-number">6</span>
<span class="line-number">7</span>
</pre></td><td class="code"><pre><code class="javascript"><span class="line"><span class="kd">function</span> <span class="nx">bob</span><span class="p">(</span><span class="nx">one</span><span class="p">,</span> <span class="nx">two</span><span class="p">,</span> <span class="nx">three</span><span class="p">)</span> <span class="p">{</span>
</span><span class="line">	<span class="kd">var</span> <span class="nx">x</span> <span class="o">=</span> <span class="nx">arguments</span><span class="p">;</span>
</span><span class="line">	<span class="kd">var</span> <span class="nx">y</span> <span class="o">=</span> <span class="p">[];</span>
</span><span class="line">
</span><span class="line">	<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span> <span class="nb">Object</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">toString</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span> <span class="nx">x</span> <span class="p">)</span> <span class="p">);</span> <span class="c1">//[object Arguments]</span>
</span><span class="line">	<span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span> <span class="nb">Object</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">toString</span><span class="p">.</span><span class="nx">call</span><span class="p">(</span> <span class="nx">y</span> <span class="p">)</span> <span class="p">);</span> <span class="c1">//[object Array]</span>
</span><span class="line"><span class="p">};</span>
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p>You could then use <code>indexOf</code> or <code>search</code> to check for ‘Arguments’ or ‘Array’.</p>

<p>Without a doubt, there are other ways to do this in JavaScript. That’s what makes it fun—you’re never done learning.</p>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Site Changes]]></title>
    <link href="http://rwbaker.com/articles/site-changes/"/>
    <updated>2011-11-21T14:31:00-05:00</updated>
    <id>http://rwbaker.com/articles/site-changes</id>
    <content type="html"><![CDATA[<p>A new year is coming, so it’s time for a new site. Welcome.</p>

<!--more-->

<h2 id="history">History</h2>

<p>This site has gone through a number of changes. Static files &gt; Dreamweaver templates &gt; Textpattern &gt; Static &gt; ExpressionEngine &gt; Static &gt; WordPress. In all that time, I never found a publishing system I cared for. Then, I found Jekyll.</p>

<p><a href="http://jekyllrb.com/">Jekyll</a> is a rails application that allows you to maintain your site in individual HTML or Markdown files and generates a static site. Mix that with <a href="http://octopress.org/">Octopress</a> and you have a find publishing system. One that fits quite well for me.</p>

<h2 id="changes">Changes</h2>

<p>Soon I’ll be moving all my links over to Pinboard. They were once on <a href="http://delicious.com/rwbakercom">Delicious</a>, then Yahoo! goofed things up, so I tried posting links to this site. Though, it just didn’t fit. I’m not sure if I’ll move the Delicious links over, or just start fresh. Perhaps I’ll move just a few…</p>

<p>This site will now be mostly long-format posts and code snippets. Hopefully I keep that going.</p>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Submit Form with JavaScript]]></title>
    <link href="http://rwbaker.com/articles/submit-form-with-javascript/"/>
    <updated>2011-10-18T16:04:00-04:00</updated>
    <id>http://rwbaker.com/articles/submit-form-with-javascript</id>
    <content type="html"><![CDATA[<p>Recently I was asked how submit a form with JavaScript… and I didn’t have a solid answer
for them. The shame! So, like a teacher having the class write ‘I will not talk in class’
over and over as punishment, here are a few various ways to submit a basic form in
JavaScript.</p>

<!--more-->

<h2 id="the-standard-form-submit">The Standard Form Submit</h2>

<p>Here is the basic form we’re working with:</p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span>Standard Form Submit</span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
<span class="line-number">4</span>
<span class="line-number">5</span>
<span class="line-number">6</span>
<span class="line-number">7</span>
<span class="line-number">8</span>
<span class="line-number">9</span>
<span class="line-number">10</span>
<span class="line-number">11</span>
</pre></td><td class="code"><pre><code class="html"><span class="line"><span class="nt">&lt;html&gt;&lt;body&gt;</span>
</span><span class="line"><span class="nt">&lt;form</span> <span class="na">name=</span><span class="s">&quot;submit_with_button&quot;</span> <span class="na">action=</span><span class="s">&quot;success.html&quot;</span><span class="nt">&gt;</span>
</span><span class="line">	<span class="nt">&lt;fieldset&gt;</span>
</span><span class="line">		<span class="nt">&lt;legend&gt;</span>Submit form with button<span class="nt">&lt;/legend&gt;</span>
</span><span class="line">		<span class="nt">&lt;label</span> <span class="na">for=</span><span class="s">&quot;email&quot;</span><span class="nt">&gt;</span>Email Address<span class="nt">&lt;/label&gt;</span>
</span><span class="line">		<span class="nt">&lt;input</span> <span class="na">type=</span><span class="s">&quot;text&quot;</span> <span class="na">id=</span><span class="s">&quot;email&quot;</span> <span class="na">name=</span><span class="s">&quot;email&quot;</span> <span class="nt">/&gt;</span>
</span><span class="line">		<span class="nt">&lt;input</span> <span class="na">type=</span><span class="s">&quot;submit&quot;</span> <span class="na">value=</span><span class="s">&quot;Submit&quot;</span> <span class="nt">/&gt;</span>
</span><span class="line">		<span class="nt">&lt;p&gt;</span>Standard method with a submit button<span class="nt">&lt;/p&gt;</span>
</span><span class="line">	<span class="nt">&lt;/fieldset&gt;</span>
</span><span class="line"><span class="nt">&lt;/form&gt;</span>
</span><span class="line"><span class="nt">&lt;/body&gt;&lt;/html&gt;</span>
</span></code></pre></td></tr></table></div></figure></notextile></div>

<h2 id="submit-with-a-javascript-function">Submit with a JavaScript Function</h2>

<p>In this example we call a JavaScript function from the link, and that function
submits the form. This method is fine, but it’s generally <a href="http://en.wikipedia.org/wiki/Unobtrusive_JavaScript (Wikipedia: Unobtrusive JavaScript)">bad form</a> to put
JavaScript functions in a link’s href.</p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span>Submit with a JavaScript Function</span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
<span class="line-number">4</span>
<span class="line-number">5</span>
<span class="line-number">6</span>
<span class="line-number">7</span>
<span class="line-number">8</span>
<span class="line-number">9</span>
<span class="line-number">10</span>
<span class="line-number">11</span>
<span class="line-number">12</span>
<span class="line-number">13</span>
<span class="line-number">14</span>
<span class="line-number">15</span>
</pre></td><td class="code"><pre><code class="html"><span class="line"><span class="nt">&lt;html&gt;&lt;body&gt;</span>
</span><span class="line"><span class="nt">&lt;form</span> <span class="na">name=</span><span class="s">&quot;submit_with_js&quot;</span> <span class="na">action=</span><span class="s">&quot;success.html&quot;</span><span class="nt">&gt;</span>
</span><span class="line">	<span class="nt">&lt;fieldset&gt;</span>
</span><span class="line">		<span class="nt">&lt;legend&gt;</span>Submit form with JavaScript<span class="nt">&lt;/legend&gt;</span>
</span><span class="line">		<span class="nt">&lt;label</span> <span class="na">for=</span><span class="s">&quot;email&quot;</span><span class="nt">&gt;</span>Email Address<span class="nt">&lt;/label&gt;</span>
</span><span class="line">		<span class="nt">&lt;input</span> <span class="na">type=</span><span class="s">&quot;text&quot;</span> <span class="na">id=</span><span class="s">&quot;email&quot;</span> <span class="na">name=</span><span class="s">&quot;email_js&quot;</span> <span class="nt">/&gt;</span>
</span><span class="line">		<span class="nt">&lt;a</span> <span class="na">id=</span><span class="s">&quot;submit_js&quot;</span> <span class="na">href=</span><span class="s">&quot;javascript: submitform()&quot;</span><span class="nt">&gt;</span>Submit<span class="nt">&lt;/a&gt;</span>
</span><span class="line">	<span class="nt">&lt;/fieldset&gt;</span>
</span><span class="line">	<span class="nt">&lt;script&gt;</span>
</span><span class="line">		<span class="kd">function</span> <span class="nx">submitform</span><span class="p">()</span> <span class="p">{</span>
</span><span class="line">			<span class="nb">document</span><span class="p">.</span><span class="nx">submit_with_js</span><span class="p">.</span><span class="nx">submit</span><span class="p">();</span>
</span><span class="line">		<span class="p">};</span>
</span><span class="line">	<span class="nt">&lt;/script&gt;</span>
</span><span class="line"><span class="nt">&lt;/form&gt;</span>
</span><span class="line"><span class="nt">&lt;/body&gt;&lt;/html&gt;</span>
</span></code></pre></td></tr></table></div></figure></notextile></div>

<h2>Submit with jQuery</h2>

<p>This method still depends on the action tag, but just triggers the <code>submit()</code>
function. Use <code>return false</code> to stop the link being executed.</p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span>Submit with jQuery</span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
<span class="line-number">4</span>
<span class="line-number">5</span>
<span class="line-number">6</span>
<span class="line-number">7</span>
<span class="line-number">8</span>
<span class="line-number">9</span>
<span class="line-number">10</span>
<span class="line-number">11</span>
<span class="line-number">12</span>
<span class="line-number">13</span>
<span class="line-number">14</span>
<span class="line-number">15</span>
<span class="line-number">16</span>
<span class="line-number">17</span>
</pre></td><td class="code"><pre><code class="html"><span class="line"><span class="nt">&lt;html&gt;&lt;body&gt;</span>
</span><span class="line"><span class="nt">&lt;form</span> <span class="na">name=</span><span class="s">&quot;submit_with_jquery&quot;</span> <span class="na">action=</span><span class="s">&quot;success.html&quot;</span><span class="nt">&gt;</span>
</span><span class="line">	<span class="nt">&lt;fieldset&gt;</span>
</span><span class="line">		<span class="nt">&lt;legend&gt;</span>Submit form with jQuery<span class="nt">&lt;/legend&gt;</span>
</span><span class="line">		<span class="nt">&lt;label</span> <span class="na">for=</span><span class="s">&quot;email&quot;</span><span class="nt">&gt;</span>Email Address<span class="nt">&lt;/label&gt;</span>
</span><span class="line">		<span class="nt">&lt;input</span> <span class="na">type=</span><span class="s">&quot;text&quot;</span> <span class="na">id=</span><span class="s">&quot;email&quot;</span> <span class="na">name=</span><span class="s">&quot;email_jquery&quot;</span> <span class="nt">/&gt;</span>
</span><span class="line">		<span class="nt">&lt;a</span> <span class="na">id=</span><span class="s">&quot;submit_jquery&quot;</span> <span class="na">href=</span><span class="s">&quot;#&quot;</span><span class="nt">&gt;</span>Submit<span class="nt">&lt;/a&gt;</span>
</span><span class="line">	<span class="nt">&lt;/fieldset&gt;</span>
</span><span class="line">	<span class="nt">&lt;script </span><span class="na">src=</span><span class="s">&quot;http://code.jquery.com/jquery-latest.js&quot;</span><span class="nt">&gt;&lt;/script&gt;</span>
</span><span class="line">	<span class="nt">&lt;script&gt;</span>
</span><span class="line">		<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#submit_jquery&#39;</span><span class="p">).</span><span class="nx">click</span><span class="p">(</span><span class="kd">function</span><span class="p">(){</span>
</span><span class="line">			<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;form[name=&quot;submit_with_jquery&quot;]&#39;</span><span class="p">).</span><span class="nx">submit</span><span class="p">();</span>
</span><span class="line">			<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
</span><span class="line">		<span class="p">});</span>
</span><span class="line">	<span class="nt">&lt;/script&gt;</span>
</span><span class="line"><span class="nt">&lt;/form&gt;</span>
</span><span class="line"><span class="nt">&lt;/body&gt;&lt;/html&gt;</span>
</span></code></pre></td></tr></table></div></figure></notextile></div>

<h2 id="submit-with-jquery-ajax">Submit with jQuery AJAX</h2>

<p>Using the jQuery post function here (a subset of <code>$.ajax()</code>), we submit the form
asynchronously and return back any resulting data. In this example I’m
returning back the success message in an alert. I’m also using
<code>javascript:void(0)</code> in the submit link href rather than a #. This
way, even if the link is executed, the URL isn’t modified and the page doesn’t
jump.</p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span>AJAX Form Submit</span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
<span class="line-number">4</span>
<span class="line-number">5</span>
<span class="line-number">6</span>
<span class="line-number">7</span>
<span class="line-number">8</span>
<span class="line-number">9</span>
<span class="line-number">10</span>
<span class="line-number">11</span>
<span class="line-number">12</span>
<span class="line-number">13</span>
<span class="line-number">14</span>
<span class="line-number">15</span>
<span class="line-number">16</span>
<span class="line-number">17</span>
<span class="line-number">18</span>
<span class="line-number">19</span>
<span class="line-number">20</span>
<span class="line-number">21</span>
<span class="line-number">22</span>
<span class="line-number">23</span>
<span class="line-number">24</span>
<span class="line-number">25</span>
</pre></td><td class="code"><pre><code class="html"><span class="line"><span class="nt">&lt;html&gt;&lt;body&gt;</span>
</span><span class="line"><span class="nt">&lt;form</span> <span class="na">name=</span><span class="s">&quot;submit_with_jquery_ajax&quot;</span> <span class="na">action=</span><span class="s">&quot;success.html&quot;</span><span class="nt">&gt;</span>
</span><span class="line">	<span class="nt">&lt;fieldset&gt;</span>
</span><span class="line">		<span class="nt">&lt;legend&gt;</span>Submit form with jQuery AJAX<span class="nt">&lt;/legend&gt;</span>
</span><span class="line">		<span class="nt">&lt;label</span> <span class="na">for=</span><span class="s">&quot;email&quot;</span><span class="nt">&gt;</span>Email Address<span class="nt">&lt;/label&gt;</span>
</span><span class="line">		<span class="nt">&lt;input</span> <span class="na">type=</span><span class="s">&quot;text&quot;</span> <span class="na">id=</span><span class="s">&quot;email&quot;</span> <span class="na">name=</span><span class="s">&quot;email_ajax&quot;</span> <span class="nt">/&gt;</span>
</span><span class="line">		<span class="nt">&lt;a</span> <span class="na">id=</span><span class="s">&quot;submit_ajax&quot;</span> <span class="na">href=</span><span class="s">&quot;javascript:void(0)&quot;</span><span class="nt">&gt;</span>Submit<span class="nt">&lt;/a&gt;</span>
</span><span class="line">	<span class="nt">&lt;/fieldset&gt;</span>
</span><span class="line">	<span class="nt">&lt;script </span><span class="na">src=</span><span class="s">&quot;http://code.jquery.com/jquery-latest.js&quot;</span><span class="nt">&gt;&lt;/script&gt;</span>
</span><span class="line">	<span class="nt">&lt;script&gt;</span>
</span><span class="line">		<span class="nx">$</span><span class="p">(</span><span class="s1">&#39;#submit_ajax&#39;</span><span class="p">).</span><span class="nx">click</span><span class="p">(</span><span class="kd">function</span><span class="p">(){</span>
</span><span class="line">			<span class="c1">//Grab action from the form if it&#39;s there</span>
</span><span class="line">			<span class="k">if</span> <span class="p">(</span> <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;form[name=&quot;submit_with_jquery_ajax&quot;]&#39;</span><span class="p">).</span><span class="nx">attr</span><span class="p">(</span><span class="s1">&#39;action&#39;</span><span class="p">)</span> <span class="p">)</span> <span class="p">{</span>
</span><span class="line">				<span class="nx">myAction</span> <span class="o">=</span> <span class="nx">$</span><span class="p">(</span><span class="s1">&#39;form[name=&quot;submit_with_jquery_ajax&quot;]&#39;</span><span class="p">).</span><span class="nx">attr</span><span class="p">(</span><span class="s1">&#39;action&#39;</span><span class="p">);</span>
</span><span class="line">			<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
</span><span class="line">				<span class="nx">myAction</span> <span class="o">=</span> <span class="s1">&#39;success.html&#39;</span><span class="p">;</span>
</span><span class="line">			<span class="p">};</span>
</span><span class="line">			<span class="nx">$</span><span class="p">.</span><span class="nx">post</span><span class="p">(</span><span class="nx">myAction</span><span class="p">,</span> <span class="kd">function</span><span class="p">(</span><span class="nx">data</span><span class="p">)</span> <span class="p">{</span>
</span><span class="line">				<span class="nx">alert</span><span class="p">(</span><span class="nx">data</span><span class="p">);</span>
</span><span class="line">			<span class="p">});</span>
</span><span class="line">			<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
</span><span class="line">		<span class="p">});</span>
</span><span class="line">	<span class="nt">&lt;/script&gt;</span>
</span><span class="line"><span class="nt">&lt;/form&gt;</span>
</span><span class="line"><span class="nt">&lt;/body&gt;&lt;/html&gt;</span>
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p>You can <a href="https://github.com/rwbaker/Snippets/tree/master/form%20submit (Download examples from Github)">download all these examples from Github</a></p>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[AJAX Control Toolkit Calendar Default Style]]></title>
    <link href="http://rwbaker.com/articles/ajax-control-toolkit-calendar-default-style/"/>
    <updated>2011-09-15T16:12:00-04:00</updated>
    <id>http://rwbaker.com/articles/ajax-control-toolkit-calendar-default-style</id>
    <content type="html"><![CDATA[<p>The default style for the AJAX Control Toolkit Calendar leaves a bit more to be
desired. This is a basic calendar style with all the documentation needed to
customize it.</p>

<!--more-->

<p><img src="http://rwbaker.com/images/posts/calendar-comparison-final.gif (Calendar comparison)" alt="Comparison of the default calendar, my theme, and the original jQuery Redmond theme" /></p>

<p>This calendar theme is an imageless version of the <a href="http://jqueryui.com/themeroller/#ffDefault=Lucida+Grande,+Lucida+Sans,+Arial,+sans-serif&amp;fwDefault=bold&amp;fsDefault=1.1em&amp;cornerRadius=5px&amp;bgColorHeader=5c9ccc&amp;bgTextureHeader=12_gloss_wave.png&amp;bgImgOpacityHeader=55&amp;borderColorHeader=4297d7&amp;fcHeader=ffffff&amp;iconColorHeader=d8e7f3&amp;bgColorContent=fcfdfd&amp;bgTextureContent=06_inset_hard.png&amp;bgImgOpacityContent=100&amp;borderColorContent=a6c9e2&amp;fcContent=222222&amp;iconColorContent=469bdd&amp;bgColorDefault=dfeffc&amp;bgTextureDefault=02_glass.png&amp;bgImgOpacityDefault=85&amp;borderColorDefault=c5dbec&amp;fcDefault=2e6e9e&amp;iconColorDefault=6da8d5&amp;bgColorHover=d0e5f5&amp;bgTextureHover=02_glass.png&amp;bgImgOpacityHover=75&amp;borderColorHover=79b7e7&amp;fcHover=1d5987&amp;iconColorHover=217bc0&amp;bgColorActive=f5f8f9&amp;bgTextureActive=06_inset_hard.png&amp;bgImgOpacityActive=100&amp;borderColorActive=79b7e7&amp;fcActive=e17009&amp;iconColorActive=f9bd01&amp;bgColorHighlight=fbec88&amp;bgTextureHighlight=01_flat.png&amp;bgImgOpacityHighlight=55&amp;borderColorHighlight=fad42e&amp;fcHighlight=363636&amp;iconColorHighlight=2e83ff&amp;bgColorError=fef1ec&amp;bgTextureError=02_glass.png&amp;bgImgOpacityError=95&amp;borderColorError=cd0a0a&amp;fcError=cd0a0a&amp;iconColorError=cd0a0a&amp;bgColorOverlay=aaaaaa&amp;bgTextureOverlay=01_flat.png&amp;bgImgOpacityOverlay=0&amp;opacityOverlay=30&amp;bgColorShadow=aaaaaa&amp;bgTextureShadow=01_flat.png&amp;bgImgOpacityShadow=0&amp;opacityShadow=30&amp;thicknessShadow=8px&amp;offsetTopShadow=-8px&amp;offsetLeftShadow=-8px&amp;cornerRadiusShadow=8px&quot;">jQuery UI Redmond calendar</a>
and uses the basic CSS documentation from the <a href="http://www.asp.net/ajaxlibrary/AjaxControlToolkitSampleSite/calendar/calendar.aspx">toolkit documentation</a>.</p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span>AJAX Control Toolkit Calendar Style (ajax_calendar.css)</span> <a href="http://rwbaker.com/assets/examples/ajax_calendar.css">download</a></figcaption>
 <div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
<span class="line-number">4</span>
<span class="line-number">5</span>
<span class="line-number">6</span>
<span class="line-number">7</span>
<span class="line-number">8</span>
<span class="line-number">9</span>
<span class="line-number">10</span>
<span class="line-number">11</span>
<span class="line-number">12</span>
<span class="line-number">13</span>
<span class="line-number">14</span>
<span class="line-number">15</span>
<span class="line-number">16</span>
<span class="line-number">17</span>
<span class="line-number">18</span>
<span class="line-number">19</span>
<span class="line-number">20</span>
<span class="line-number">21</span>
<span class="line-number">22</span>
<span class="line-number">23</span>
<span class="line-number">24</span>
<span class="line-number">25</span>
<span class="line-number">26</span>
<span class="line-number">27</span>
<span class="line-number">28</span>
<span class="line-number">29</span>
<span class="line-number">30</span>
<span class="line-number">31</span>
<span class="line-number">32</span>
<span class="line-number">33</span>
<span class="line-number">34</span>
<span class="line-number">35</span>
<span class="line-number">36</span>
<span class="line-number">37</span>
<span class="line-number">38</span>
<span class="line-number">39</span>
<span class="line-number">40</span>
<span class="line-number">41</span>
<span class="line-number">42</span>
<span class="line-number">43</span>
<span class="line-number">44</span>
<span class="line-number">45</span>
<span class="line-number">46</span>
<span class="line-number">47</span>
<span class="line-number">48</span>
<span class="line-number">49</span>
<span class="line-number">50</span>
<span class="line-number">51</span>
<span class="line-number">52</span>
<span class="line-number">53</span>
<span class="line-number">54</span>
<span class="line-number">55</span>
<span class="line-number">56</span>
<span class="line-number">57</span>
<span class="line-number">58</span>
<span class="line-number">59</span>
<span class="line-number">60</span>
<span class="line-number">61</span>
<span class="line-number">62</span>
<span class="line-number">63</span>
<span class="line-number">64</span>
<span class="line-number">65</span>
<span class="line-number">66</span>
<span class="line-number">67</span>
<span class="line-number">68</span>
<span class="line-number">69</span>
<span class="line-number">70</span>
<span class="line-number">71</span>
<span class="line-number">72</span>
<span class="line-number">73</span>
<span class="line-number">74</span>
<span class="line-number">75</span>
<span class="line-number">76</span>
<span class="line-number">77</span>
<span class="line-number">78</span>
<span class="line-number">79</span>
<span class="line-number">80</span>
<span class="line-number">81</span>
<span class="line-number">82</span>
<span class="line-number">83</span>
<span class="line-number">84</span>
<span class="line-number">85</span>
<span class="line-number">86</span>
<span class="line-number">87</span>
<span class="line-number">88</span>
<span class="line-number">89</span>
<span class="line-number">90</span>
<span class="line-number">91</span>
<span class="line-number">92</span>
<span class="line-number">93</span>
</pre></td><td class="code"><pre><code class="css"><span class="line"><span class="c">/* Ajax Control Toolkit Calendar */</span>
</span><span class="line">
</span><span class="line"><span class="c">/*	The outer rectangular container that supplies the border around the calendar element. </span>
</span><span class="line"><span class="c">	Child Css classes: .ajax__calendar_header,.ajax__calendar_body,.ajax__calendar_footer. */</span>
</span><span class="line"><span class="nc">.ajax__calendar_container</span>		<span class="p">{</span><span class="k">background-color</span><span class="o">:</span><span class="m">#fff</span><span class="p">;</span> <span class="k">border</span><span class="o">:</span><span class="k">solid</span> <span class="m">1px</span> <span class="m">#a6c9e2</span> <span class="cp">!important</span><span class="p">;}</span>
</span><span class="line">
</span><span class="line">	<span class="c">/*	A container element that holds the next and previous arrows and the title of the current view. </span>
</span><span class="line"><span class="c">		Child Css classes: .ajax__calendar_prev, .ajax__calendar_title, .ajax__calendar_next. */</span>
</span><span class="line">	<span class="nc">.ajax__calendar_header</span>		<span class="p">{</span><span class="k">background-color</span><span class="o">:</span><span class="m">#87b6d9</span><span class="p">;</span> <span class="k">margin-bottom</span><span class="o">:</span><span class="m">5px</span><span class="p">;}</span>
</span><span class="line">
</span><span class="line">		<span class="c">/* 	An element that displays the arrow to view the previous set of data in the view(previous month/year/decade).</span>
</span><span class="line"><span class="c">			Child Css classes: none. */</span>
</span><span class="line">		<span class="nc">.ajax__calendar_prev</span>	<span class="p">{}</span>
</span><span class="line">
</span><span class="line">		<span class="c">/* 	An element that displays the title of the current view (month name, year, decade). </span>
</span><span class="line"><span class="c">			Child Css classes: none. */</span>
</span><span class="line">		<span class="nc">.ajax__calendar_title</span>	<span class="p">{</span><span class="k">height</span><span class="o">:</span><span class="m">20px</span><span class="p">;</span> <span class="k">color</span><span class="o">:</span><span class="m">#fff</span><span class="p">;</span> <span class="k">line-height</span><span class="o">:</span><span class="m">1.7em</span><span class="p">;}</span>
</span><span class="line">		<span class="nc">.ajax__calendar_hover</span> <span class="nc">.ajax__calendar_title</span> <span class="p">{</span><span class="k">color</span><span class="o">:</span><span class="m">#eee</span> <span class="cp">!important</span><span class="p">;}</span>
</span><span class="line">
</span><span class="line">		<span class="c">/* 	An element that displays the arrow to view the previous set of data in the view (previous month/year/decade). </span>
</span><span class="line"><span class="c">			Child Css classes: none. */</span>
</span><span class="line">		<span class="nc">.ajax__calendar_next</span>	<span class="p">{}</span>
</span><span class="line">		
</span><span class="line">		<span class="nc">.ajax__calendar_prev</span><span class="o">,</span><span class="nc">.ajax__calendar_next</span>
</span><span class="line">								<span class="p">{</span><span class="k">background-color</span><span class="o">:</span><span class="m">#dce6f4</span><span class="p">;</span> <span class="k">height</span><span class="o">:</span><span class="m">20px</span> <span class="cp">!important</span><span class="p">;</span> <span class="k">color</span><span class="o">:</span><span class="m">#fff</span> <span class="cp">!important</span><span class="p">;}</span>
</span><span class="line">
</span><span class="line">	<span class="c">/*	A container element that holds the days, months, and years panes. Also provides a fixed rectangle with hidden overflow that is used for transitioning between views (next/previous month, or days/months/years).</span>
</span><span class="line"><span class="c">		Child Css class: .ajax__calendar_days, .ajax__calendar_months, .ajax__calendar_years. */</span>
</span><span class="line">	<span class="nc">.ajax__calendar_body</span>		<span class="p">{}</span>
</span><span class="line">
</span><span class="line">		<span class="c">/* 	A container element that holds the layout for the days in a month. </span>
</span><span class="line"><span class="c">			Child Css classes: .ajax__calendar_dayname, .ajax__calendar_day */</span>
</span><span class="line">		<span class="nc">.ajax__calendar_days</span>	<span class="p">{}</span>
</span><span class="line">		<span class="nc">.ajax__calendar_days</span> <span class="nt">table</span> <span class="nt">thead</span> <span class="nt">tr</span> <span class="nt">td</span>
</span><span class="line">								<span class="p">{</span><span class="k">background-color</span><span class="o">:</span><span class="m">#fff</span><span class="p">;</span> <span class="k">color</span><span class="o">:</span><span class="m">#000</span><span class="p">;</span> <span class="k">font-weight</span><span class="o">:</span><span class="k">bold</span><span class="p">;}</span>
</span><span class="line">		
</span><span class="line">
</span><span class="line">			<span class="c">/* 	An element that displays the short name of the day of the week. </span>
</span><span class="line"><span class="c">				Child Css classes: none. */</span>
</span><span class="line">			<span class="nc">.ajax__calendar_dayname</span>
</span><span class="line">								<span class="p">{</span><span class="k">border</span><span class="o">:</span><span class="m">0</span> <span class="cp">!important</span><span class="p">;}</span>
</span><span class="line">
</span><span class="line">			<span class="c">/*	An element that displays the day of the month. </span>
</span><span class="line"><span class="c">				Child Css classes: none */</span>
</span><span class="line">			<span class="nc">.ajax__calendar_day</span>	<span class="p">{</span><span class="k">border</span><span class="o">:</span><span class="m">1px</span> <span class="k">solid</span> <span class="m">#c5dbec</span> <span class="cp">!important</span><span class="p">;</span> <span class="k">background</span><span class="o">:</span><span class="m">#eaf4fd</span><span class="p">;</span> <span class="k">margin</span><span class="o">:</span><span class="m">1px</span> <span class="cp">!important</span><span class="p">;</span> <span class="k">height</span><span class="o">:</span><span class="m">15px</span> <span class="cp">!important</span><span class="p">;</span> <span class="k">width</span><span class="o">:</span><span class="m">16px</span> <span class="cp">!important</span><span class="p">;}</span>
</span><span class="line">
</span><span class="line">		<span class="c">/*  A container element that holds the layout for the months in a year. </span>
</span><span class="line"><span class="c">			Child Css classes: .ajax__calendar_month. */</span>
</span><span class="line">		<span class="nc">.ajax__calendar_months</span>	<span class="p">{}</span>
</span><span class="line">
</span><span class="line">			<span class="c">/* 	An element that displays the month of the year. </span>
</span><span class="line"><span class="c">				Child Css classes: none */</span>
</span><span class="line">			<span class="nc">.ajax__calendar_month</span>
</span><span class="line">								<span class="p">{}</span>
</span><span class="line">								
</span><span class="line">			<span class="nc">.ajax__calendar_month</span><span class="o">,</span> <span class="nc">.ajax__calendar_day</span> <span class="p">{</span><span class="k">color</span><span class="o">:</span><span class="m">#2e6e9e</span><span class="p">;</span> <span class="k">font-weight</span><span class="o">:</span><span class="k">bold</span><span class="p">;</span> <span class="p">}</span>
</span><span class="line">
</span><span class="line">		<span class="c">/* 	A container element that holds the layout for the years in a decade. </span>
</span><span class="line"><span class="c">			Child Css classes: .ajax__calendar_year. */</span>
</span><span class="line">		<span class="nc">.ajax__calendar_years</span>	<span class="p">{}</span>
</span><span class="line">
</span><span class="line">			<span class="c">/* 	An element that displays the year in a decade. </span>
</span><span class="line"><span class="c">				Child Css classes: none */</span>
</span><span class="line">			<span class="nc">.ajax__calendar_year</span><span class="p">{}</span>
</span><span class="line">
</span><span class="line"><span class="c">/*  A container element that holds the current date. </span>
</span><span class="line"><span class="c">	Child Css classes: .ajax__calendar_today. */</span>
</span><span class="line"><span class="nc">.ajax__calendar_footer</span>			<span class="p">{</span><span class="k">border-top</span><span class="o">:</span><span class="m">1px</span> <span class="k">solid</span> <span class="m">#c5dbec</span> <span class="cp">!important</span><span class="p">;</span> <span class="k">line-height</span><span class="o">:</span><span class="m">1.2em</span><span class="p">;}</span>
</span><span class="line">
</span><span class="line">	<span class="c">/* 	An element that displays the current date. </span>
</span><span class="line"><span class="c">		Child Css classes: none. */</span>
</span><span class="line">	<span class="nc">.ajax__calendar_today</span>		<span class="p">{</span><span class="k">border</span><span class="o">:</span><span class="m">1px</span> <span class="k">solid</span> <span class="m">#c5dbec</span><span class="p">;</span> <span class="k">background-color</span><span class="o">:</span><span class="m">#e1effb</span><span class="p">;}</span>
</span><span class="line">
</span><span class="line"><span class="c">/* 	This is applied to an element in the DOM above a day, month or year and is used to apply CSS attributes that show a hover state. </span>
</span><span class="line"><span class="c">	Child Css classes: .ajax__calendar_day, .ajax__calendar_month, .ajax__calendar_year */</span>
</span><span class="line"><span class="nc">.ajax__calendar_hover</span>			<span class="p">{}</span>
</span><span class="line"><span class="nt">td</span><span class="nc">.ajax__calendar_hover</span> <span class="nt">div</span>		<span class="p">{</span><span class="k">background</span><span class="o">:</span><span class="m">#d2e6f5</span> <span class="cp">!important</span><span class="p">;</span> <span class="k">border</span><span class="o">:</span><span class="m">1px</span> <span class="k">solid</span> <span class="m">#79b7e7</span> <span class="cp">!important</span><span class="p">;}</span>
</span><span class="line">
</span><span class="line"><span class="c">/* 	This is applied to an element in the DOM above a day, month or year and is used to apply CSS attributes that show the currently selected value. </span>
</span><span class="line"><span class="c">	Child Css classes: .ajax__calendar_day, .ajax__calendar_month, .ajax__calendar_year. */</span>
</span><span class="line"><span class="nc">.ajax__calendar_active</span>			<span class="p">{}</span>
</span><span class="line"><span class="nt">td</span><span class="nc">.ajax__calendar_active</span> <span class="nt">div</span>	<span class="p">{</span><span class="k">background</span><span class="o">:</span><span class="m">#fbec88</span> <span class="cp">!important</span><span class="p">;</span> <span class="k">border</span><span class="o">:</span><span class="m">1px</span> <span class="k">solid</span> <span class="m">#fad42e</span> <span class="cp">!important</span><span class="p">;}</span>
</span><span class="line">
</span><span class="line">
</span><span class="line"><span class="c">/* 	This is applied to an element in the DOM above a day or year that is outside of the current view (day not in the visible month, year not in the visible decade). </span>
</span><span class="line"><span class="c">	Child Css classes: .ajax__calendar_day, .ajax__calendar_year. */</span>
</span><span class="line"><span class="nc">.ajax__calendar_other</span>			<span class="p">{}</span>
</span><span class="line">
</span><span class="line"><span class="nc">.ajax__calendar_other</span> <span class="nc">.ajax__calendar_day</span>
</span><span class="line">								<span class="p">{</span><span class="k">font-weight</span><span class="o">:</span><span class="k">normal</span> <span class="cp">!important</span><span class="p">;</span> <span class="k">color</span><span class="o">:</span><span class="m">#bbb</span> <span class="cp">!important</span><span class="p">;</span> <span class="k">border</span><span class="o">:</span><span class="m">1px</span> <span class="k">solid</span> <span class="m">#eee</span> <span class="cp">!important</span><span class="p">;}</span>
</span><span class="line">
</span><span class="line"><span class="nc">.ajax__calendar_hover.ajax__calendar_other</span> <span class="nc">.ajax__calendar_day</span>
</span><span class="line">								<span class="p">{</span><span class="k">background</span><span class="o">:</span><span class="m">#efefef</span> <span class="cp">!important</span><span class="p">;</span> <span class="k">color</span><span class="o">:</span><span class="m">#aaa</span> <span class="cp">!important</span><span class="p">;</span> <span class="k">border</span><span class="o">:</span><span class="m">1px</span> <span class="k">solid</span> <span class="m">#ddd</span> <span class="cp">!important</span><span class="p">;}</span>
</span></code></pre></td></tr></table></div></figure></notextile></div>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Kentico content slider with cropped thumbnails]]></title>
    <link href="http://rwbaker.com/articles/kentico-content-slider-with-cropped-thumbnails/"/>
    <updated>2011-08-24T12:41:00-04:00</updated>
    <id>http://rwbaker.com/articles/kentico-content-slider-with-cropped-thumbnails</id>
    <content type="html"><![CDATA[<p>I had a need to build a content slideshow with thumbnail pagination. In this
project, <a href="http://www.kentico.com/">Kentico</a> is our CMS of choice.</p>

<p>In the existing website, users can upload images of any-size and aspect-ratio,
and then we resize the image in the Transformation. Our pager thumbnails need to
be square; a string of mixed-size images doesn’t look quite right. But
unfortunately Kentico doesn’t provide a way to crop images on the fly. Luckily,
CSS can help.</p>

<!--more-->

<h2 id="carousel-html-wrapper">Carousel HTML Wrapper</h2>

<p>Here is the basic carousel wrapper with a blank UL pager to get things started:</p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span>Carousel HTML Wrapper</span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
<span class="line-number">4</span>
<span class="line-number">5</span>
<span class="line-number">6</span>
<span class="line-number">7</span>
</pre></td><td class="code"><pre><code class="html"><span class="line"><span class="nt">&lt;div</span> <span class="na">class=</span><span class="s">&quot;grid_content featured carousel-wrapper&quot;</span><span class="nt">&gt;</span>
</span><span class="line">     <span class="nt">&lt;div</span> <span class="na">class=</span><span class="s">&quot;carousel&quot;</span><span class="nt">&gt;</span>
</span><span class="line">          <span class="c">&lt;!-- content repeater generating our slides. Uses the transformation below --&gt;</span>
</span><span class="line">     <span class="nt">&lt;/div&gt;</span>
</span><span class="line">     <span class="nt">&lt;ul</span> <span class="na">id=</span><span class="s">&quot;pager&quot;</span> <span class="na">class=</span><span class="s">&quot;plain&quot;</span><span class="nt">&gt;&lt;/ul&gt;</span>
</span><span class="line">     <span class="nt">&lt;div</span> <span class="na">class=</span><span class="s">&quot;clear&quot;</span><span class="nt">&gt;&lt;/div&gt;</span>
</span><span class="line"><span class="nt">&lt;/div&gt;</span>
</span></code></pre></td></tr></table></div></figure></notextile></div>

<h2 id="css">CSS</h2>

<p>Our pager is an unordered list with a link and a span.  The link has the
pagination action attached so it. The span has a fixed size of 50x50—this
is desired size of our thumbnails. The thumbnail image is set as the background
of the span, centered, then the span will crop off the rest of the image. We now
have square thumbnails.</p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span>Thumbnail Style</span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
<span class="line-number">4</span>
<span class="line-number">5</span>
<span class="line-number">6</span>
</pre></td><td class="code"><pre><code class="css"><span class="line"><span class="nc">.carousel</span><span class="o">~</span><span class="nf">#pager</span> <span class="nt">li</span>                 <span class="p">{</span><span class="k">float</span><span class="o">:</span><span class="k">left</span> <span class="cp">!important</span><span class="p">;</span> <span class="k">margin</span><span class="o">:</span><span class="m">0</span> <span class="m">20px</span> <span class="m">0</span> <span class="m">0</span><span class="p">;</span> <span class="k">overflow</span><span class="o">:</span><span class="k">hidden</span><span class="p">;</span> <span class="p">}</span>
</span><span class="line"><span class="nc">.carousel</span><span class="o">~</span><span class="nf">#pager</span> <span class="nt">a</span>                  <span class="p">{</span><span class="k">padding</span><span class="o">:</span><span class="m">3px</span><span class="p">;</span> <span class="k">border</span><span class="o">:</span><span class="m">1px</span> <span class="k">solid</span> <span class="m">#ccc</span><span class="p">;}</span>
</span><span class="line"><span class="nc">.carousel</span><span class="o">~</span><span class="nf">#pager</span> <span class="nt">a</span> <span class="nc">.thumbnail</span>       <span class="p">{</span><span class="k">background-position</span><span class="o">:</span><span class="m">50</span><span class="o">%</span> <span class="m">50</span><span class="o">%</span><span class="p">;</span> <span class="k">background-repeat</span><span class="o">:</span><span class="k">no-repeat</span><span class="p">;}</span>
</span><span class="line"><span class="nc">.carousel</span><span class="o">~</span><span class="nf">#pager</span> <span class="nt">a</span><span class="o">,</span>
</span><span class="line"><span class="nc">.carousel</span><span class="o">~</span><span class="nf">#pager</span> <span class="nt">a</span> <span class="nc">.thumbnail</span>       <span class="p">{</span><span class="k">width</span><span class="o">:</span><span class="m">50px</span><span class="p">;</span> <span class="k">height</span><span class="o">:</span><span class="m">50px</span><span class="p">;</span> <span class="k">display</span><span class="o">:</span><span class="k">block</span><span class="p">;}</span>
</span><span class="line"><span class="nc">.carousel</span><span class="o">~</span><span class="nf">#pager</span> <span class="nt">li</span><span class="nc">.activeSlide</span> <span class="nt">a</span>	<span class="p">{</span><span class="k">background</span><span class="o">:</span><span class="m">#fff</span><span class="p">;}</span>
</span></code></pre></td></tr></table></div></figure></notextile></div>

<h2 id="kentico-transformations">Kentico Transformations</h2>

<p>The <code>thumbnail()</code> function is responsible for creating our ‘cropped’ thumbnail
for the carousel pager. This is actually really simple—just grab the image
use a <code>maxSideSide</code> of 50.  The CSS above takes care of the ‘cropping’.</p>

<p>We’re using the BlogPostTeaser image object for testing, even though we only
need the image URL. It turns out Kentico’s <code>IfEmpty()</code> function isn’t all that
reliable, and often <code>&lt;%# IfEmpty ("BlogPostTeaser", "",
GetFileURL("BlogPostTeaser")) %&gt;</code> will result in
<code>/getattachment/00000000-0000-0000-0000-000000000000/Post-Title.aspx</code> (the URL
of a non-existent image).</p>

<p>Kentico’s <code>CMSAbstractTransformation.Eval()</code> function returns an object, while
<code>CMSAbstractTransformation.GetFileURL()</code> returns a string. Our function
parameters must be declared accordingly and converted for comparison.</p>

<p>The carousel JavaScript generates the pagination HTML, so we’re just storing the
thumbnail path in the summary so our JavaScript and pick it up when needed.</p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span>Kentico Transformation</span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
<span class="line-number">4</span>
<span class="line-number">5</span>
<span class="line-number">6</span>
<span class="line-number">7</span>
<span class="line-number">8</span>
<span class="line-number">9</span>
<span class="line-number">10</span>
<span class="line-number">11</span>
<span class="line-number">12</span>
<span class="line-number">13</span>
<span class="line-number">14</span>
<span class="line-number">15</span>
<span class="line-number">16</span>
<span class="line-number">17</span>
<span class="line-number">18</span>
<span class="line-number">19</span>
<span class="line-number">20</span>
<span class="line-number">21</span>
<span class="line-number">22</span>
<span class="line-number">23</span>
<span class="line-number">24</span>
<span class="line-number">25</span>
<span class="line-number">26</span>
<span class="line-number">27</span>
<span class="line-number">28</span>
<span class="line-number">29</span>
<span class="line-number">30</span>
<span class="line-number">31</span>
<span class="line-number">32</span>
<span class="line-number">33</span>
<span class="line-number">34</span>
<span class="line-number">35</span>
<span class="line-number">36</span>
<span class="line-number">37</span>
</pre></td><td class="code"><pre><code class="csharp"><span class="line"><span class="p">&lt;</span><span class="n">script</span> <span class="n">runat</span><span class="p">=</span><span class="s">&quot;server&quot;</span><span class="p">&gt;</span>
</span><span class="line">    <span class="k">public</span> <span class="k">static</span> <span class="kt">string</span> <span class="nf">videoTest</span><span class="p">(</span><span class="kt">object</span> <span class="n">BlogPostTeaser</span><span class="p">,</span> <span class="kt">string</span> <span class="n">BlogPostTeaserURL</span><span class="p">,</span> <span class="kt">object</span> <span class="n">BlogPostTeaserAltText</span><span class="p">,</span> <span class="kt">object</span> <span class="n">BlogPostVideo</span><span class="p">)</span>
</span><span class="line">    <span class="p">{</span>
</span><span class="line">		<span class="p">...</span>
</span><span class="line">    <span class="p">}</span>
</span><span class="line">
</span><span class="line">    <span class="k">public</span> <span class="k">static</span> <span class="kt">string</span> <span class="nf">thumbnail</span><span class="p">(</span><span class="kt">object</span> <span class="n">BlogPostTeaser</span><span class="p">,</span> <span class="kt">string</span> <span class="n">BlogPostTeaserURL</span><span class="p">)</span>
</span><span class="line">    <span class="p">{</span>
</span><span class="line">        <span class="c1">//Check the image object to see if it&#39;s an actual image or not.</span>
</span><span class="line">        <span class="c1">//If no image, default to the &#39;standard&#39; thumb.</span>
</span><span class="line">        <span class="kt">string</span> <span class="n">teaser</span> <span class="p">=</span> <span class="n">Convert</span><span class="p">.</span><span class="n">ToString</span><span class="p">(</span><span class="n">BlogPostTeaser</span><span class="p">);</span>
</span><span class="line">        <span class="k">if</span> <span class="p">(</span><span class="n">teaser</span> <span class="p">!=</span> <span class="s">&quot;&quot;</span><span class="p">)</span>
</span><span class="line">        <span class="p">{</span>
</span><span class="line">            <span class="k">return</span> <span class="n">BlogPostTeaserURL</span> <span class="p">+</span> <span class="s">&quot;?height=50&quot;</span><span class="p">;</span>
</span><span class="line">
</span><span class="line">        <span class="p">}</span>
</span><span class="line">        <span class="k">else</span>
</span><span class="line">        <span class="p">{</span>
</span><span class="line">            <span class="k">return</span> <span class="s">&quot;/App_Themes/coj/images/coj-thumb.png&quot;</span><span class="p">;</span>
</span><span class="line">        <span class="p">}</span>
</span><span class="line">    <span class="p">}</span>
</span><span class="line"><span class="p">&lt;/</span><span class="n">script</span><span class="p">&gt;</span>
</span><span class="line">
</span><span class="line"><span class="p">&lt;</span><span class="n">div</span> <span class="n">class</span><span class="p">=</span><span class="s">&quot;carouselTransformation&quot;</span><span class="p">&gt;</span>
</span><span class="line">    <span class="p">&lt;%</span><span class="err">#</span> <span class="n">videoTest</span><span class="p">(</span><span class="n">Eval</span><span class="p">(</span><span class="s">&quot;BlogPostTeaser&quot;</span><span class="p">),</span> <span class="n">GetFileUrl</span><span class="p">(</span><span class="s">&quot;BlogPostTeaser&quot;</span><span class="p">),</span> <span class="n">Eval</span><span class="p">(</span><span class="s">&quot;BlogPostVideo&quot;</span><span class="p">),</span> <span class="n">Eval</span><span class="p">(</span><span class="s">&quot;BlogPostVideo&quot;</span><span class="p">))%&gt;</span>
</span><span class="line">    <span class="p">&lt;</span><span class="n">div</span> <span class="n">class</span><span class="p">=</span><span class="s">&quot;title&quot;</span><span class="p">&gt;</span>
</span><span class="line">        <span class="p">&lt;</span><span class="n">a</span> <span class="n">href</span><span class="p">=</span><span class="s">&quot;&lt;%# GetDocumentUrl() %&gt;&quot;</span><span class="p">&gt;</span>
</span><span class="line">            <span class="p">&lt;%</span><span class="err">#</span><span class="n">Eval</span><span class="p">(</span><span class="s">&quot;BlogPostTitle&quot;</span><span class="p">)%&gt;</span>
</span><span class="line">        <span class="p">&lt;/</span><span class="n">a</span><span class="p">&gt;</span>
</span><span class="line">    <span class="p">&lt;/</span><span class="n">div</span><span class="p">&gt;</span>
</span><span class="line">    <span class="p">&lt;</span><span class="n">div</span> <span class="n">class</span><span class="p">=</span><span class="s">&quot;date&quot;</span><span class="p">&gt;</span>
</span><span class="line">        <span class="p">&lt;%</span><span class="err">#</span><span class="n">GetDateTime</span><span class="p">(</span><span class="s">&quot;BlogPostDate&quot;</span><span class="p">,</span> <span class="s">&quot;MMMM dd, yyyy&quot;</span><span class="p">)%&gt;</span>
</span><span class="line">    <span class="p">&lt;/</span><span class="n">div</span><span class="p">&gt;</span>
</span><span class="line">    <span class="p">&lt;</span><span class="n">div</span> <span class="n">class</span><span class="p">=</span><span class="s">&quot;summary&quot;</span> <span class="n">thumbnail</span><span class="p">=</span><span class="s">&quot;&lt;%# thumbnail(Eval(&quot;</span><span class="n">BlogPostTeaser</span><span class="s">&quot;), GetFileUrl(&quot;</span><span class="n">BlogPostTeaser</span><span class="s">&quot;)) %&gt;&quot;</span><span class="p">&gt;</span>
</span><span class="line">        <span class="p">&lt;%</span><span class="err">#</span> <span class="n">LimitLength</span><span class="p">(</span><span class="n">Eval</span><span class="p">(</span><span class="s">&quot;BlogPostSummary&quot;</span><span class="p">),</span><span class="m">350</span><span class="p">,</span><span class="s">&quot;...&quot;</span><span class="p">)</span> <span class="p">%&gt;</span>
</span><span class="line">    <span class="p">&lt;/</span><span class="n">div</span><span class="p">&gt;</span>
</span><span class="line"><span class="p">&lt;/</span><span class="n">div</span><span class="p">&gt;</span>
</span></code></pre></td></tr></table></div></figure></notextile></div>

<h2 id="javascript">Javascript</h2>

<p>The carousel is built on the <a href="http://jquery.malsup.com/cycle/">Cycle jQuery plugin</a>. The pagination is
generated by a callback function in the carousel function. In this function we
grab the thumbnail URL and generate the pager LI and set the thumbnail as the
background of the span.  Our CSS above takes care of the rest.</p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span>Carousel</span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
<span class="line-number">4</span>
<span class="line-number">5</span>
<span class="line-number">6</span>
<span class="line-number">7</span>
<span class="line-number">8</span>
<span class="line-number">9</span>
<span class="line-number">10</span>
<span class="line-number">11</span>
<span class="line-number">12</span>
<span class="line-number">13</span>
<span class="line-number">14</span>
<span class="line-number">15</span>
<span class="line-number">16</span>
<span class="line-number">17</span>
<span class="line-number">18</span>
<span class="line-number">19</span>
<span class="line-number">20</span>
<span class="line-number">21</span>
<span class="line-number">22</span>
<span class="line-number">23</span>
<span class="line-number">24</span>
<span class="line-number">25</span>
<span class="line-number">26</span>
<span class="line-number">27</span>
<span class="line-number">28</span>
<span class="line-number">29</span>
<span class="line-number">30</span>
<span class="line-number">31</span>
<span class="line-number">32</span>
<span class="line-number">33</span>
<span class="line-number">34</span>
<span class="line-number">35</span>
</pre></td><td class="code"><pre><code class="javascript"><span class="line"><span class="nx">$</span><span class="p">(</span><span class="nb">document</span><span class="p">).</span><span class="nx">ready</span><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
</span><span class="line">
</span><span class="line">    <span class="nx">jQuery</span><span class="p">.</span><span class="nx">dom</span> <span class="o">=</span> <span class="nx">jQuery</span><span class="p">(</span><span class="nb">document</span><span class="p">);</span>
</span><span class="line">
</span><span class="line">    <span class="kd">var</span> <span class="nx">$carousel</span> <span class="o">=</span> <span class="nx">jQuery</span><span class="p">.</span><span class="nx">dom</span><span class="p">.</span><span class="nx">find</span><span class="p">(</span><span class="s1">&#39;.carousel&#39;</span><span class="p">);</span>
</span><span class="line">    <span class="k">if</span> <span class="p">(</span><span class="nx">$carousel</span><span class="p">.</span><span class="nx">length</span><span class="p">)</span> <span class="p">{</span>
</span><span class="line">
</span><span class="line">          <span class="nx">$carousel</span><span class="p">.</span><span class="nx">cycle</span><span class="p">({</span>
</span><span class="line">            <span class="nx">fx</span><span class="o">:</span> <span class="s1">&#39;fade&#39;</span><span class="p">,</span>
</span><span class="line">            <span class="nx">speed</span><span class="o">:</span> <span class="mi">300</span><span class="p">,</span>
</span><span class="line">            <span class="nx">timeout</span><span class="o">:</span> <span class="mi">10000</span><span class="p">,</span>
</span><span class="line">            <span class="nx">pager</span><span class="o">:</span> <span class="s1">&#39;#pager&#39;</span><span class="p">,</span>
</span><span class="line">            <span class="nx">pause</span><span class="o">:</span> <span class="mi">1</span><span class="p">,</span>
</span><span class="line">            <span class="nx">cleartypeNoBg</span><span class="o">:</span> <span class="kc">true</span><span class="p">,</span>
</span><span class="line">
</span><span class="line">            <span class="c1">// A callback function that creates a thumbnail to use as pager anchor</span>
</span><span class="line">            <span class="nx">pagerAnchorBuilder</span><span class="o">:</span> <span class="kd">function</span><span class="p">(</span><span class="nx">idx</span><span class="p">,</span> <span class="nx">slide</span><span class="p">)</span> <span class="p">{</span>
</span><span class="line">
</span><span class="line">				<span class="cm">/* 	Find your image inside the individual slide.</span>
</span><span class="line"><span class="cm">					In this case, I generate a scaled image on the server and store the path in an attribute */</span>
</span><span class="line">				<span class="kd">var</span> <span class="nx">slideImg</span> <span class="o">=</span> <span class="nx">jQuery</span><span class="p">(</span><span class="nx">slide</span><span class="p">).</span><span class="nx">children</span><span class="p">(</span><span class="s2">&quot;.summary&quot;</span><span class="p">).</span><span class="nx">attr</span><span class="p">(</span><span class="s1">&#39;thumbnail&#39;</span><span class="p">);</span>
</span><span class="line">
</span><span class="line">				<span class="cm">/*  If there is no image associated with the story, use a standard thumbnail</span>
</span><span class="line"><span class="cm">					This is also handled in our Kentico Transformation, so this is only a backup */</span>
</span><span class="line">				<span class="k">if</span> <span class="p">(</span><span class="nx">slideImg</span> <span class="o">==</span> <span class="kc">undefined</span><span class="p">)</span> <span class="p">{</span>
</span><span class="line">					<span class="nx">slideImg</span> <span class="o">=</span> <span class="s2">&quot;/App_Themes/site/images/thumb.png&quot;</span><span class="p">;</span>
</span><span class="line">				<span class="p">};</span>
</span><span class="line">
</span><span class="line">                <span class="cm">/*	Our thumbnails are 50x50, but our image might not be square.</span>
</span><span class="line"><span class="cm">					Setting the image as the background lets the element crop the image */</span>
</span><span class="line">                <span class="k">return</span> <span class="s1">&#39;&lt;li&gt;&lt;a href=&quot;#&quot;&gt;&lt;span class=&quot;thumbnail&quot; style=&quot;background-image:url(&#39;</span><span class="o">+</span> <span class="nx">slideImg</span> <span class="o">+</span><span class="s1">&#39;);&quot;&gt;&lt;/span&gt;&lt;/a&gt;&lt;/li&gt;&#39;</span><span class="p">;</span>
</span><span class="line">            <span class="p">}</span>
</span><span class="line">        <span class="p">});</span>
</span><span class="line">     <span class="p">});</span>
</span><span class="line"><span class="p">});</span>
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p>** UPDATE ** The project is now live, so you can take a look at the thumbnails
in action: <a href="http://www.coj.net/mayor.aspx">Jacksonville’s Mayor’s new blog</a></p>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[JavaScript falsy values]]></title>
    <link href="http://rwbaker.com/articles/javascript-falsy-values/"/>
    <updated>2011-08-18T08:26:00-04:00</updated>
    <id>http://rwbaker.com/articles/javascript-falsy-values</id>
    <content type="html"><![CDATA[<table class="styled fullwidth">
	<thead>
		<tr>
			<th>Value</th>
			<th>Type</th>
		</tr>
	</thead>
	<tbody>
		<tr>
			<td>0</td>
			<td>Number</td>
		</tr>
		<tr>
			<td>NaN (not a number)</td>
			<td>Number</td>
		</tr>
		<tr>
			<td>&#8221;</td>
			<td>String</td>
		</tr>
		<tr>
			<td>false</td>
			<td>Boolean</td>
		</tr>
		<tr>
			<td>null</td>
			<td>Object</td>
		</tr>
		<tr>
			<td>undefined</td>
			<td>Undefined</td>
		</tr>
	</tbody>
</table>

<p><cite>Table taken from <a href="http://www.amazon.com/gp/product/0596517742/ref=as_li_ss_tl?ie=UTF8&amp;tag=rwbakercom-20&amp;linkCode=as2&amp;camp=217145&amp;creative=399369&amp;creativeASIN=0596517742">Douglas Crockford’s JavaScript: The Good Parts</a></cite></p>

<h2 id="undefined">Undefined</h2>

<p>Undefined is the absence of a value, not an empty value.</p>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[JavaScript double equal vs. triple equal]]></title>
    <link href="http://rwbaker.com/articles/javascript-double-equal-vs-triple-equal/"/>
    <updated>2011-08-16T17:26:00-04:00</updated>
    <id>http://rwbaker.com/articles/javascript-double-equal-vs-triple-equal</id>
    <content type="html"><![CDATA[<p><a href="http://www.amazon.com/gp/product/0596517742/ref=as_li_ss_tl?ie=UTF8&amp;tag=rwbakercom-20&amp;linkCode=as2&amp;camp=217145&amp;creative=399369&amp;creativeASIN=0596517742">Douglas Crockford’s Javascript: The Good Parts</a>:</p>

<blockquote>
  <p>JavaScript has two sets of equality operators: <code>===</code> and <code>!==</code>, and their evil
twins <code>==</code> and <code>!=</code>. The good ones work the way you would expect. If the two
operands are of the same type and have the same value, then <code>===</code> produces true
and <code>!==</code> produces false. The evil twins do the right thing when the operands
are of the same type, but if they are of different types, they attempt to
coerce the values. The rules by which they do that are complicated and
unmemorable.</p>
</blockquote>

<h2 id="double-equals-">Double Equals (==)</h2>

<p>Double equals (<code>==</code>) will try to convert the 2nd half to the same type as the first half
of the expression.</p>

<p><code>string == number</code> will result in a comparison to <code>string == string</code> after the conversion.</p>

<h2 id="triple-equals-">Triple Equals (===)</h2>

<p>Triple equals <code>===</code> is just a straight comparison, regardless of type.</p>

<p>Using <code>===</code> is not any quicker if the types are the same. If types are not the
same, <code>===</code> will be quicker because it won’t try to do the conversion.</p>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Ruby Static Blog Engine]]></title>
    <link href="http://rwbaker.com/articles/ruby-static-blog-engine/"/>
    <updated>2011-07-26T00:04:00-04:00</updated>
    <id>http://rwbaker.com/articles/ruby-static-blog-engine</id>
    <content type="html"><![CDATA[<p>A static site is an interesting idea. Fairly hassle free, handles high-traffic well, and a much lower chance of getting hacked. However, they’re a nightmare to manage if you want any sort of consistent look. But maybe not.</p>

<p><a href="https://github.com/mojombo/jekyll (Jekyll on Github)">Jekyll</a> (Github) is a Ruby project for generating and maintaining a static site or blog.</p>

<p><a href="http://octopress.org/ (Octopress for Jekyll)">Octopress</a> gives you templates and some fancy plugins that make the engine quite a bit more friendlier.  Now all of a sudden, a static blog is looking very doable.</p>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[First-child vs Adjacent Selector]]></title>
    <link href="http://rwbaker.com/articles/first-child-vs-adjacent-selector/"/>
    <updated>2011-07-23T22:12:00-04:00</updated>
    <id>http://rwbaker.com/articles/first-child-vs-adjacent-selector</id>
    <content type="html"><![CDATA[<p>Here is a typical way one might use <code>:first-child</code>: first you apply the image
to all links in the list, then you remove it from the first one.</p>

<!--more-->

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
<span class="line-number">3</span>
<span class="line-number">4</span>
</pre></td><td class="code"><pre><code class="css"><span class="line"><span class="nf">#nav</span> <span class="nt">li</span> <span class="nt">a</span>
</span><span class="line"><span class="p">{</span><span class="k">background</span><span class="o">:</span><span class="sx">url(images/nav-sub-div.png)</span> <span class="m">0</span> <span class="m">0</span> <span class="k">repeat-x</span><span class="p">;}</span>
</span><span class="line"><span class="nf">#nav</span> <span class="nt">li</span><span class="nd">:first-child</span> <span class="nt">a</span>
</span><span class="line"><span class="p">{</span><span class="k">background-image</span><span class="o">:</span><span class="k">transparent</span><span class="p">;}</span>
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p>However, using the <a href="http://www.w3.org/TR/CSS2/selector.html#adjacent-selectors">Adjacent Siblings Selector</a>, you can streamline it:</p>

<div class="bogus-wrapper"><notextile><figure class="code"><figcaption><span></span></figcaption><div class="highlight"><table><tr><td class="gutter"><pre class="line-numbers"><span class="line-number">1</span>
<span class="line-number">2</span>
</pre></td><td class="code"><pre><code class="css"><span class="line"><span class="nf">#nav</span> <span class="nt">li</span> <span class="o">+</span> <span class="nt">li</span> <span class="nt">a</span>
</span><span class="line"><span class="p">{</span><span class="k">background</span><span class="o">:</span><span class="sx">url(images/nav-sub-div.png)</span> <span class="m">0</span> <span class="m">0</span> <span class="k">repeat-x</span><span class="p">;}</span>
</span></code></pre></td></tr></table></div></figure></notextile></div>

<p>The + selector applies the style to any LI that immediately follows an LI,
which obviously rules out the first item. A simple solution, often overlooked.</p>

<h2 id="compatibility">Compatibility</h2>

<table class="styled fullwidth comparison" summary="Table shows the browser compatability for the adjacent selector and first-child pseudo class">
	<tbody>
		<tr>
			<th />
			<th colspan="3"><abbr title="Internet Explorer">IE</abbr></th>
			<th colspan="2">Firefox</th>
			<th colspan="2">Safari</th>
			<th colspan="2">Opera</th>
			<th>Chrome</th>
		</tr>
		<tr>
			<td>Version</td>
			<td>7.0</td>
			<td>8.0</td>
			<td>9.0</td>
			<td>2.0</td>
			<td>3.5</td>
			<td>3.1</td>
			<td>4.0</td>
			<td>9.2</td>
			<td>9.5</td>
			<td>2.0</td>
		</tr>
		<tr>
			<td>+</td>
			<td class="buggy">Buggy</td>
			<td class="full">Full</td>
			<td class="full">Full</td>
			<td class="full">Full</td>
			<td class="full">Full</td>
			<td class="buggy">Buggy</td>
			<td class="buggy">Buggy</td>
			<td class="buggy">Buggy</td>
			<td class="full">Full</td>
			<td class="full">Full</td>
		</tr>
		<tr>
			<td>:first-child</td>
			<td class="buggy">Buggy</td>
			<td class="buggy">Buggy</td>
			<td class="full">Full</td>
			<td class="buggy">Buggy</td>
			<td class="full">Full</td>
			<td class="buggy">Buggy</td>
			<td class="full">Full</td>
			<td class="buggy">Buggy</td>
			<td class="full">Full</td>
			<td class="full">Full</td>
		</tr>
	</tbody>
</table>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Web Standards Curriculum]]></title>
    <link href="http://rwbaker.com/articles/web-standards-curriculum/"/>
    <updated>2011-07-15T21:03:00-04:00</updated>
    <id>http://rwbaker.com/articles/web-standards-curriculum</id>
    <content type="html"><![CDATA[<p>The Opera Web Standards Curriculum has been adopted as the official W3C Web
Standards Curriculum. Whether you’re a teacher, student, or just filling holes
in your knowledge-base, this <em>free</em> content has a lot of good information
there.</p>

<blockquote>
  <p>What follows is a list of all the articles within the web standards
curriculum, which will give you an essential grounding in HTML5, CSS,
JavaScript, accessibility, and the other topics you need to be a modern web
developer/designer. Reading them in order makes the most sense, but they are
written to work individually, so you can dip in and out as it suits you, if
you need to hone individual skills.
<cite><a href="http://www.w3.org/wiki/Web_Standards_Curriculum">Web Standards Curriculum</a></cite></p>
</blockquote>

]]></content>
  </entry>
  
</feed>
