<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Web 3.0, 6 Bladed Razors, 7 Minute Abs &#187; CSS</title>
	<atom:link href="http://www.zachleat.com/web/category/css/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.zachleat.com/web</link>
	<description></description>
	<lastBuildDate>Fri, 30 Jul 2010 01:59:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>Faking Onload for Link Elements</title>
		<link>http://www.zachleat.com/web/2010/07/29/load-css-dynamically/</link>
		<comments>http://www.zachleat.com/web/2010/07/29/load-css-dynamically/#comments</comments>
		<pubDate>Fri, 30 Jul 2010 01:50:24 +0000</pubDate>
		<dc:creator>Zach Leatherman</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[YUI]]></category>

		<guid isPermaLink="false">http://www.zachleat.com/web/?p=733</guid>
		<description><![CDATA[Or, I Am Dynamically Loaded CSS (and So Can You!) Dynamic resource loading is one of the keys to have a performance happy web application. There are generally three different criteria we must address when making a request: cross domain security policies, asynchronous/synchronous (will it block the host page while loading), and whether or not [...]]]></description>
			<content:encoded><![CDATA[<p>Or, <strong>I Am Dynamically Loaded CSS (and So Can You!)</strong></p>
<p>Dynamic resource loading is one of the keys to have a performance happy web application.  There are generally three different criteria we must address when making a request: cross domain security policies, asynchronous/synchronous (will it block the host page while loading), and whether or not events are triggered when the request completes.</p>
<p>If the resource and host page are on the same domain, obviously <code>XMLHttpRequest</code> works the best.  We can control whether or not the resource is loaded asynchronously or synchronously, and we know exactly when it gets done.</p>
<p>If the resource and host page are on different domains (increasingly more common with CDN&#8217;s), our options narrow. Loading the JavaScript is a solved problem, just use the <code>onload</code> event on the <code>&lt;script&gt;</code> tag and you&#8217;re good to go (<code>onreadystatechange</code> for IE).  But CSS is more complicated.</p>
<table>
<thead>
<tr>
<th>Resource</th>
<th>Method</th>
<th>Option for (a)synchronous</th>
<th>Event</th>
</tr>
</thead>
<tbody>
<tr>
<td>JavaScript/CSS Same Domain</td>
<td><code>XMLHttpRequest</code></td>
<td>Both</td>
<td><code>onreadystatechange</code></td>
</tr>
<tr>
<td>JavaScript Different Domain</td>
<td><code>&lt;script&gt;</code></td>
<td>Synchronous</td>
<td><code>onload</code><br />
<code>onreadystatechange</code> for IE</td>
</tr>
<tr>
<td>CSS  Different Domain</td>
<td><code>&lt;link&gt;</code></td>
<td>Asynchronous</td>
<td><em>This is what this blog post is about</em></td>
</tr>
</tbody>
</table>
<h2>Existing Solutions</h2>
<p>In all of the library source code I evaluated, Internet Explorer didn&#8217;t cause any issues.  It fires both the <code>onload</code> and <code>onreadystatechange</code> events for <code>&lt;link&gt;</code> nodes.  Obviously this is ideal behavior, and IE got it right. But what about Firefox and Safari/Chrome?</p>
<h3>YUI 2.8.1 and 3.1.1</h3>
<p><a href="http://github.com/yui/yui3/blob/master/build/yui/get.js#L311">Original Source</a></p>

<div class="wp_syntax"><div class="code"><pre class="js" style="font-family:monospace;">// FireFox does not support the onload event for link nodes, so there is
// no way to make the css requests synchronous. This means that the css 
// rules in multiple files could be applied out of order in this browser
// if a later request returns before an earlier one.  Safari too.
if ((ua.webkit || ua.gecko) &amp;&amp; q.type === &quot;css&quot;) {
    _next(id, url);
}</pre></div></div>

<p>I wouldn&#8217;t be surprised if the commit log there was from Bon Jovi; that code is living on a prayer.</p>
<h3>LazyLoad</h3>
<p><a href="http://github.com/rgrove/lazyload/blob/master/lazyload.js#L283">Original Source</a></p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// Gecko and WebKit don't support the onload event on link nodes. In</span>
<span style="color: #006600; font-style: italic;">// WebKit, we can poll for changes to document.styleSheets to figure out</span>
<span style="color: #006600; font-style: italic;">// when stylesheets have loaded, but in Gecko we just have to finish</span>
<span style="color: #006600; font-style: italic;">// after a brief delay and hope for the best.</span>
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>ua.<span style="color: #660066;">webkit</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    p.<span style="color: #660066;">urls</span><span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> node.<span style="color: #660066;">href</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// resolve relative URLs (or polling won't work)</span>
    poll<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
    setTimeout<span style="color: #009900;">&#40;</span>_finish<span style="color: #339933;">,</span> <span style="color: #CC0000;">50</span> <span style="color: #339933;">*</span> len<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Better, closer, warmer.  This includes a nice method for working with webkit browsers.  The poll method compares <code>document.styleSheets</code>, since Webkit has the nice option of only appending to the styleSheets object when the styleSheet has successfully loaded.</p>
<p>So we have working solutions for IE and Safari/Chrome. The only unsolved piece of the puzzle here is Firefox.</p>
<p><a href="http://wonko.com/post/how-to-prevent-yui-get-race-conditions">This post</a> from the same author as LazyLoad also describes another solution which involves modifying the source CSS and polling against it.  But that&#8217;s not really ideal. Can we do better?</p>
<h2>Solution</h2>
<p>Here&#8217;s what I came up with (using jQuery for brevity, note that this solution <strong>only fixes Firefox</strong>, and does not incorporate the above already solved solutions):</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> url <span style="color: #339933;">=</span> <span style="color: #3366CC;">'css.php'</span><span style="color: #339933;">;</span>
    id <span style="color: #339933;">=</span> <span style="color: #3366CC;">'dynamicCss'</span> <span style="color: #339933;">+</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">new</span> Date<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'&lt;style/&gt;'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
    id<span style="color: #339933;">:</span> id<span style="color: #339933;">,</span>
    type<span style="color: #339933;">:</span> <span style="color: #3366CC;">'text/css'</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'@import url('</span> <span style="color: #339933;">+</span> url <span style="color: #339933;">+</span> <span style="color: #3366CC;">')'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">appendTo</span><span style="color: #009900;">&#40;</span>document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'head'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> poll<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">var</span> sheets <span style="color: #339933;">=</span> document.<span style="color: #660066;">styleSheets</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">var</span> j<span style="color: #339933;">=</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> k<span style="color: #339933;">=</span>sheets.<span style="color: #660066;">length</span><span style="color: #339933;">;</span> j<span style="color: #339933;">&lt;</span>k<span style="color: #339933;">;</span> j<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>sheets<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">ownerNode</span>.<span style="color: #660066;">id</span> <span style="color: #339933;">==</span> id<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                sheets<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">cssRules</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
        <span style="color: #006600; font-style: italic;">// If you made it here, success!</span>
        <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'success!'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">catch</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #006600; font-style: italic;">// Keep polling</span>
        window.<span style="color: #660066;">setTimeout</span><span style="color: #009900;">&#40;</span>poll<span style="color: #339933;">,</span> <span style="color: #CC0000;">50</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
window.<span style="color: #660066;">setTimeout</span><span style="color: #009900;">&#40;</span>poll<span style="color: #339933;">,</span> <span style="color: #CC0000;">50</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h3><a href="http://zachleat.com/javascript/loadcss/load.html">See this demo in action.</a> (Firefox only)</h3>
<p><br/><br />
<strong>Update</strong>: After much joy and celebration, I have discovered that an approach similar to the above was written by Oleg Slobodskoi in his <a href="http://plugins.jquery.com/files/jquery.xLazyLoader.js.txt">xLazyLoader</a> plugin for jQuery.  It shouldn&#8217;t be surprising that two independent developers might reach the same solution, and is just more proof that software patents are stupid. :)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zachleat.com/web/2010/07/29/load-css-dynamically/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS 3 Text: A Tale of writing-mode Woe</title>
		<link>http://www.zachleat.com/web/2010/02/12/css3-text-writing-mode/</link>
		<comments>http://www.zachleat.com/web/2010/02/12/css3-text-writing-mode/#comments</comments>
		<pubDate>Sat, 13 Feb 2010 04:45:54 +0000</pubDate>
		<dc:creator>Zach Leatherman</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Web Browsers]]></category>

		<guid isPermaLink="false">http://www.zachleat.com/web/?p=496</guid>
		<description><![CDATA[After reading an interesting article on using the writing-mode CSS property to display vertical text (I&#8217;m always interested in how to abuse what browsers currently support into something new and exciting), I decided to look into this writing-mode property and see what opportunities it might present. Generally when exploring a development opportunity, I tend to [...]]]></description>
			<content:encoded><![CDATA[<p>After reading an interesting article on using the <a href="http://www.thecssninja.com/css/real-text-rotation-with-css">writing-mode CSS property</a> to display vertical text (I&#8217;m always interested in how to abuse what browsers currently support into something new and exciting), I decided to look into this <code>writing-mode</code> property and see what opportunities it might present.</p>
<p>Generally when exploring a development opportunity, I tend to prioritize my adventures towards things that are supported in Internet Explorer first.  This often has the biggest cross-browser payoff, since the other browser vendors tend to have a quicker draw than the Microsoft Team.  However, surprisingly enough, this <code>writing-mode</code> study proved the opposite to be true.  It seems very interesting that Microsoft has decided to implement a portion of the CSS 3 specification, given its general stance of moving slower than an iceberg to avoid &#8220;breaking the web.&#8221;  But I, for one, welcome our new choose-your-own-adventure standards loving overlords.</p>
<p>As far as my tests go, the only browser to support the <code><a href="http://www.w3.org/TR/2003/CR-css3-text-20030514/#writing-mode">writing-mode</a></code> property at all is Internet Explorer, which was very surprising.  At it&#8217;s heart, though, <code>writing-mode</code> is just shorthand for two other properties: <code><a href="http://www.w3.org/TR/2003/CR-css3-text-20030514/#direction">direction</a></code> and <code><a href="http://www.w3.org/TR/2003/CR-css3-text-20030514/#block-progression">block-progression</a></code>.  Luckily, <strong>Firefox, Safari, Chrome and IE back through at least version 6 support the <code><a href="https://developer.mozilla.org/en/CSS/direction">direction</a></code> property</strong> and have proprietary options for rotation, which <strong>allows for emulation of a few of the unsupported <code>writing-mode</code>&#8216;s</strong>, but not all of them.  The missing piece of <code>writing-mode</code> emulation belongs to the <code>block-progression</code> property, which isn&#8217;t supported by anyone, and would allow elements to flow reverse vertically (start at the bottom of a block and flow upwards).</p>
<p><em>It&#8217;s important to note that while <a href="http://blogs.msdn.com/ie/archive/2009/05/29/the-css-corner-writing-mode.aspx">IE8 has really set the bar for implementation here</a> and has chosen to support <code>writing-mode: lr-bt</code> and <code>writing-mode: rl-bt</code>, they aren&#8217;t used to display any known language text.  They&#8217;re just included for completeness, and aren&#8217;t a part of the <a href="http://www.w3.org/TR/2003/CR-css3-text-20030514/">W3C CSS 3 Text Module specification.</a></em></p>
<h2><a href="http://zachleat.com/test/writing-mode/">View the Demo / Test Page</a></h2>
<h2>Compatibility Table</h2>
<style type="text/css">
#compatibility td { font-family: Verdana; }
#compatibility td.yes { background-color: #00882D; color: #fff; }
#compatibility td.no { background-color: #CB000F; color: #fff; }
#compatibility td.emulate { background-color: #40A662; color: #fff; }</p>
</style>
<table id="compatibility">
<thead>
<tr>
<th rowspan="2">writing-mode</th>
<th colspan="3">Internet Explorer<br/>(Trident)</th>
<th>Mozilla Firefox<br/>(Gecko)</th>
<th>Apple Safari<br/>(Webkit)</th>
<th>Google Chrome<br/>(Webkit)</th>
</tr>
<tr>
<th>6</th>
<th>7</th>
<th>8</th>
<th>3.6</th>
<th>4</th>
<th>4</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>lr-tb</code></td>
<td class="yes">yes</td>
<td class="yes">yes</td>
<td class="yes">yes</td>
<td class="yes">yes</td>
<td class="yes">yes</td>
<td class="yes">yes</td>
</tr>
<tr>
<td><code>rl-tb</code></td>
<td class="emulate">emulatable</td>
<td class="yes">yes</td>
<td class="yes">yes</td>
<td class="emulate">emulatable</td>
<td class="emulate">emulatable</td>
<td class="emulate">emulatable</td>
</tr>
<tr style="background-color: #eee;">
<td><code>lr-bt</code></td>
<td class="no">no</td>
<td class="no">no</td>
<td class="yes">yes</td>
<td class="no">no</td>
<td class="no">no</td>
<td class="no">no</td>
</tr>
<tr style="background-color: #eee;">
<td><code>rl-bt</code></td>
<td class="no">no</td>
<td class="no">no</td>
<td class="yes">yes</td>
<td class="no">no</td>
<td class="no">no</td>
<td class="no">no</td>
</tr>
<tr>
<td><code>tb-lr</code></td>
<td class="no">no</td>
<td class="no">no</td>
<td class="yes">yes</td>
<td class="no">no</td>
<td class="no">no</td>
<td class="no">no</td>
</tr>
<tr>
<td><code>tb-rl</code></td>
<td class="yes">yes</td>
<td class="yes">yes</td>
<td class="yes">yes</td>
<td class="emulate">emulatable</td>
<td class="emulate">emulatable</td>
<td class="emulate">emulatable</td>
</tr>
<tr>
<td><code>bt-lr</code></td>
<td class="no">no</td>
<td class="no">no</td>
<td class="yes">yes</td>
<td class="no">no</td>
<td class="no">no</td>
<td class="no">no</td>
</tr>
<tr>
<td><code>bt-rl</code></td>
<td class="emulate">emulatable</td>
<td class="yes">yes</td>
<td class="yes">yes</td>
<td class="emulate">emulatable</td>
<td class="emulate">emulatable</td>
<td class="emulate">emulatable</td>
</tr>
</tbody>
</table>
<h2>CSS Code for Emulation</h2>
<table>
<thead>
<tr>
<th>writing-mode</th>
<th>CSS</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>lr-tb</code></td>
<td>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">// Default</pre></div></div>

</td>
</tr>
<tr>
<td><code>rl-tb</code></td>
<td>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">direction</span><span style="color: #00AA00;">:</span> rtl<span style="color: #00AA00;">;</span></pre></div></div>

</td>
</tr>
<tr style="background-color: #eee;">
<td><code>lr-bt</code></td>
<td>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">// Not possible using W3C spec</pre></div></div>

</td>
</tr>
<tr style="background-color: #eee;">
<td><code>rl-bt</code></td>
<td>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">// Not possible using W3C spec</pre></div></div>

</td>
</tr>
<tr>
<td><code>tb-lr</code></td>
<td>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">// Not possible using W3C spec</pre></div></div>

</td>
</tr>
<tr>
<td><code>tb-rl</code></td>
<td>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">-webkit-transform<span style="color: #00AA00;">:</span> rotate<span style="color: #00AA00;">&#40;</span>90deg<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
-moz-transform<span style="color: #00AA00;">:</span> rotate<span style="color: #00AA00;">&#40;</span>90deg<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
filter<span style="color: #00AA00;">:</span> progid<span style="color: #3333ff;">:DXImageTransform</span><span style="color: #6666ff;">.Microsoft</span>.BasicImage<span style="color: #00AA00;">&#40;</span>rotation<span style="color: #00AA00;">=</span><span style="color: #cc66cc;">1</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span></pre></div></div>

</td>
</tr>
<tr>
<td><code>bt-lr</code></td>
<td>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">// Not possible using W3C spec</pre></div></div>

</td>
</tr>
<tr>
<td><code>bt-rl</code></td>
<td>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">direction</span><span style="color: #00AA00;">:</span> rtl<span style="color: #00AA00;">;</span>
-webkit-transform<span style="color: #00AA00;">:</span> rotate<span style="color: #00AA00;">&#40;</span>90deg<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
-moz-transform<span style="color: #00AA00;">:</span> rotate<span style="color: #00AA00;">&#40;</span>90deg<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
filter<span style="color: #00AA00;">:</span> progid<span style="color: #3333ff;">:DXImageTransform</span><span style="color: #6666ff;">.Microsoft</span>.BasicImage<span style="color: #00AA00;">&#40;</span>rotation<span style="color: #00AA00;">=</span><span style="color: #cc66cc;">1</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span></pre></div></div>

</td>
</tr>
</tbody>
</table>
<h2>Conclusion</h2>
<p>Given that <strong>4 of the 6 known writing modes are available</strong> or available through CSS emulation means we&#8217;re in pretty good shape on the internationalization front.  Consulting the Microsoft provided table for common use cases, we&#8217;re only in trouble when trying to use the &#8220;Mongolian script writing system&#8221; and an &#8220;Arabic script block quote embedded in Mongolian script document.&#8221;</p>
<p>In some far fetched fantasy-world legacy application where a page may use tables for layout, I could see an application team possibly using the <code>direction</code> property to redistribute the tables for a print stylesheet.  But that certainly wouldn&#8217;t be a common use case, since using CSS for layouts is going to give you much more flexibility in that regard.  If you can think of any other off the wall uses for <code>writing-mode</code> or <code>direction</code>, I&#8217;d love to hear them!</p>
<h2>Related</h2>
<ul>
<li>Very <a href="http://fantasai.inkedblade.net/style/discuss/vertical-text/#logical">complete article on CSS 3 writing-mode</a>, including some <code>direction</code> properties that don&#8217;t exist in the specification (like <code>ttb</code>, <code>ltr-ttb</code>, and <code>ltr-btt</code>)</li>
<li><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=writing-mode">Bugzilla Bug for writing-mode in Firefox</a></li>
<li>As of the time of this writing, I was unable to find any results for writing-mode on the Webkit bug tracker.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.zachleat.com/web/2010/02/12/css3-text-writing-mode/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>The &#8220;24&#8243; Clock on ALARMd</title>
		<link>http://www.zachleat.com/web/2010/01/24/the-24-clock-on-alarmd/</link>
		<comments>http://www.zachleat.com/web/2010/01/24/the-24-clock-on-alarmd/#comments</comments>
		<pubDate>Sun, 24 Jan 2010 07:37:52 +0000</pubDate>
		<dc:creator>Zach Leatherman</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[Alarmd]]></category>
		<category><![CDATA[font-face]]></category>

		<guid isPermaLink="false">http://www.zachleat.com/web/?p=465</guid>
		<description><![CDATA[If you&#8217;re only using @font-face for titles and text, you&#8217;re missing out on a whole wealth of use cases that have yet to be explored. For instance, I created a very simple 7 Segment Display Numeric font to be used for a skin on alarmd.com and changed the color using nothing but CSS to create [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;re only using @font-face for titles and text, you&#8217;re missing out on a whole <a href="http://www.zachleat.com/web/2010/01/03/css-sprites-using-font-face/">wealth of use cases</a> that have yet to be explored.  For instance, I created a very simple <a href="http://fontstruct.fontshop.com/fontstructions/show/282059">7 Segment Display Numeric font</a> to be used for a skin on <a href="http://www.alarmd.com/">alarmd.com</a> and changed the color using nothing but CSS to create the &#8220;24&#8243; Clock (true fans will note that the actual font is italic and <a href="http://www.panopticist.com/2006/05/there_is_something_weird_going_on_with_the_clock_on_24.php">has a serif on the 1</a>).  Nonetheless, this is just another useful application of @font-face.</p>
<p>Take a look at the <a href="http://www.fontsquirrel.com/fonts/list/style/Dingbat">Dingbats section on fontsquirrel</a> to get your brain going in the same direction.</p>
<p><img src="http://www.zachleat.com/web/wp-content/uploads/2010/01/Screen-shot-2010-01-24-at-1.22.39-AM.png" alt="" title="Screenshot of the 24 Clock on alarmd.com"/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.zachleat.com/web/2010/01/24/the-24-clock-on-alarmd/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>DIY Webdings &#8211; CSS Sprites using @font-face</title>
		<link>http://www.zachleat.com/web/2010/01/03/css-sprites-using-font-face/</link>
		<comments>http://www.zachleat.com/web/2010/01/03/css-sprites-using-font-face/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 00:48:29 +0000</pubDate>
		<dc:creator>Zach Leatherman</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[css-sprites]]></category>
		<category><![CDATA[font-face]]></category>

		<guid isPermaLink="false">http://www.zachleat.com/web/?p=433</guid>
		<description><![CDATA[Almost everyone knows the Webdings font or its sibling Wingdings. Even if you don&#8217;t, chances are pretty good that it&#8217;s installed on your system. Webdings is a symbol font designed in 1997 as a response to the need of Web designers for a fast and easy method of incorporating graphics in their pages. &#8230; Webdings [...]]]></description>
			<content:encoded><![CDATA[<p>Almost everyone knows the Webdings font or its sibling Wingdings.  Even if you don&#8217;t, chances are pretty good that it&#8217;s installed on your system.</p>
<blockquote><p>Webdings is a symbol font designed in 1997 as a response to the need of Web designers for a fast and easy method of incorporating graphics in their pages.<br />
&#8230;</p>
<p>Webdings is ideal for enriching the appearance of a Web page. Because it’s a font, it can be installed on the user’s system, (or embedded in the document itself) is fully scaleable [sic] and quick to render. It’s a perfect way of including graphics on your site without making users wait for lots of graphic files to download.</p>
<p> &#8211; Source <a href="http://www.microsoft.com/typography/fonts/family.aspx?FID=5">Microsoft Typography</a></p></blockquote>
<p>Microsoft was onto something here, and there is a nice parallel that can be drawn between the font and a CSS sprite: namely that multiple images are stored under the guise of a single HTTP request.  So, why not create our own font and use it as a CSS sprite?  Each character in the font (glyph) will be a single image in the sprite.</p>
<h2>Why is this awesome?</h2>
<ul>
<li>We can <strong>change the color</strong> of our font using nothing but CSS <code>color</code>.  This is a big one.  We don&#8217;t have to have separate images for hover states!  And if we want to change the color scheme, there are no new images to generate and we don&#8217;t have to make any changes to the font to do so.</li>
<li>Don&#8217;t have to monkey around with difficult to maintain CSS positioning code.</li>
<li>Fonts scale, graphics don&#8217;t.  Zooming in on a graphic will result in a pixelated image, but fonts will be smooth like a 6 blade razor shave.  Try zooming on the demo file below.</li>
</ul>
<h2>Why is this not awesome?</h2>
<ul>
<li>Font glyphs can only contain one color.</li>
<li>May experience the Flash of unstyled text (FOUT) while the font is loading.</li>
<li>Extra markup required for IE6 and IE7.  While @font-face is supported in all non-extinct versions of IE, each @font-face sprite requires a corresponding text character on the screen.  For instance, <code>&lt;span style="font-family: MyCustomFont;"&gt;A&lt;/span&gt;</code>, the A is required to display the @font-face Sprite stored under the A glyph.<br/><br />
Luckily, in most browsers we can inject a character using CSS :after/:before and the <code>content</code> property.  Unfortunately, this is <a href="http://www.quirksmode.org/css/beforeafter_content.html">not supported in IE6 or IE7</a>.  I haven&#8217;t investigated whether or not this might be solved using other means (CSS expressions) yet.</li>
<li>Safari asks for permission to use the font with a scary popup box, which I assume is a security precaution gleaned from the Windows Vista playbook.</li>
</ul>
<h2>Demo</h2>
<p>The following <a href="http://jquery-ui.googlecode.com/svn/trunk/tests/static/icons.html">jQuery UI Icons</a> are currently used in jQuery UI and are stored in <a href="http://jqueryui.com/themeroller/images/?new=888888&#038;w=256&#038;h=240&#038;f=png&#038;fltr[]=rcd|256&#038;fltr[]=mask|icons/icons.png">one big CSS sprite</a>.</p>
<p>It was pretty trivial to create <a href="http://fontstruct.fontshop.com/fontstructions/show/jquery_ui_icons_1">a font</a> with a subset of the jQuery UI icons (only the first 20, just a proof of concept here) using the wonderful <a href="http://fontstruct.fontshop.com/">FontStruct</a> utility.  Then, I took the TTF generated by FontStruct and plugged it into the completely lovely <a href="http://www.fontsquirrel.com/fontface/generator">FontSquirrel @font-face Kit Generator</a>.  That gave me everything I needed for a fully cross-browser test.</p>
<ul>
<li><a href="http://www.zachleat.com/test/fonts/font.html" style="font-size: 160%; font-weight: bold;">View the Demo</a></li>
</ul>
<p>Let me know what you think!</p>
<div style="font-size: 80%">
Successfully tested on:</p>
<ul>
<li>Google Chrome 4 (Mac)</li>
<li>Safari 4 (Mac)</li>
<li>Firefox 3.5 (Mac and Windows)</li>
<li>Internet Explorer 8</li>
<li>With documented limitations above:
<ul>
<li>Internet Explorer 6</li>
<li>Internet Explorer 7 (Compatibility Mode in IE8)</li>
</ul>
</li>
</ul>
<p>Does not work on (no @font-face support):</p>
<ul>
<li>Google Chrome 3 and prior</li>
<li>Firefox 3 and prior</li>
</ul>
</div>
<p>Read more about <a href="http://paulirish.com/2009/bulletproof-font-face-implementation-syntax/">@font-face support from Paul Irish</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zachleat.com/web/2010/01/03/css-sprites-using-font-face/feed/</wfw:commentRss>
		<slash:comments>28</slash:comments>
		</item>
		<item>
		<title>20000 Leagues Under the API: YouTube JavaScript</title>
		<link>http://www.zachleat.com/web/2008/04/05/20000-leagues-under-the-api-youtube-javascript/</link>
		<comments>http://www.zachleat.com/web/2008/04/05/20000-leagues-under-the-api-youtube-javascript/#comments</comments>
		<pubDate>Sun, 06 Apr 2008 03:47:33 +0000</pubDate>
		<dc:creator>Zach Leatherman</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Reviews]]></category>
		<category><![CDATA[Youtube]]></category>

		<guid isPermaLink="false">http://www.zachleat.com/web/?p=120</guid>
		<description><![CDATA[Today, children, we&#8217;ll be exploring the wonderful world of the official JavaScript API published by YouTube a few weeks ago. I read a few interesting posts on the subject when it first came out, and it&#8217;s been on my list of things to explore for the next (and hopefully last) version of Alarmd. This isn&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>Today, children, we&#8217;ll be exploring the wonderful world of the official JavaScript API published by YouTube a few weeks ago.  I read a <a href="http://apiblog.youtube.com/2008/03/something-to-write-home-about.html">few</a> <a href="http://blogoscoped.com/archive/2008-03-14-n11.html">interesting</a> <a href="http://www.wait-till-i.com/2008/03/12/video-captioning-made-easy-with-the-youtube-javascript-api/">posts</a> on the subject when it first came out, and it&#8217;s been on my list of things to explore for the next (and hopefully last) version of <a href="http://www.alarmd.com/">Alarmd</a>. This isn&#8217;t going to be a long post so much as a laundry list of points worth mentioning and limitations there-of regarding the API itself.</p>
<ol>
<li>If you want to change videos dynamically by loading a new video into an existing player, you must use the Chromeless player (which requires an API key).  The loadVideoById() method is only available in the Chromeless player.  Whatever you do, don&#8217;t try to dynamically destroy and create a new player, this will cause JavaScript errors in Internet Explorer (although not Firefox).</li>
<li>CSS properties: When the player has the css <code>display: none</code> applied, it will not play.  When the css <code>visibility: hidden</code> is applied, the video will still play, but will not be shown on the screen.  If you wanted a headless player, like what the music search engine <a href="http://humanized.com/weblog/2007/11/13/songza-launch/">Songza</a> does, you&#8217;d want to take this approach.  Word of warning, there&#8217;s some tricky shit going on when you try to dynamically change these properties on a player and run commands on the player at the same time (or close to the same).  For instance, I got into a sticky situation where I&#8217;d try to show the player and load a new video into the player in the same method.  I had to separate these with a timeout to get both to run without error.</li>
<li>To load, you must play.  Unfortunately, I wanted to pre-load the video without actually playing the video.  This is unsupported.  To handle this, I had to play, then pause after a timeout (using window.setTimeout).  Not the prettiest, but it seems to work.  Obviously the API in this case has very low cohesion, as the loadVideoById method ALSO plays the video, not simply doing ONLY what the method name suggests.</li>
<li>Forcing a global? When the player first loads after you&#8217;ve used the SWFObject embedSWF() command, it will call the function onYouTubePlayerReady(), which you can&#8217;t customize.  It must be that function name, and it must be in the global namespace.  Keep in mind that onYouTubePlayerReady() is called every time the player is shown (when it was otherwise hidden using the css <code>display: none</code>)</li>
</ol>
<p>Unfortunately, there is some voodoo going on here that I don&#8217;t fully understand.  I&#8217;m not a flash guru, nor have I ever claimed to be.  But there have been a few bugs in my experience with the API that have led me to believe that it&#8217;s not quite there yet.  Maybe my use cases were a bit unique, but they weren&#8217;t that extreme.  I should be able to hide and show the player without error.  I should be able to destroy the player without error.  I should be able to load a video without playing it.</p>
<p>But hey, it works.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zachleat.com/web/2008/04/05/20000-leagues-under-the-api-youtube-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Code Like the Big Boys: Flickr</title>
		<link>http://www.zachleat.com/web/2008/03/30/code-like-the-big-boys-flickr/</link>
		<comments>http://www.zachleat.com/web/2008/03/30/code-like-the-big-boys-flickr/#comments</comments>
		<pubDate>Mon, 31 Mar 2008 04:04:29 +0000</pubDate>
		<dc:creator>Zach Leatherman</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Reviews]]></category>
		<category><![CDATA[Flickr]]></category>
		<category><![CDATA[PNG]]></category>

		<guid isPermaLink="false">http://www.zachleat.com/web/?p=119</guid>
		<description><![CDATA[Code like the Big Boys is a series of posts about code solutions used by major websites. What can we learn from these professional websites to use in our own code? JavaScript Looking at the source code of the Flickr home page is actually pretty strange. For one, there is only one JavaScript source code [...]]]></description>
			<content:encoded><![CDATA[<p><em>Code like the Big Boys is a series of posts about code solutions used by major websites.  What can we learn from these professional websites to use in our own code?</em></p>
<p><strong>JavaScript</strong></p>
<p>Looking at the source code of the Flickr home page is actually pretty strange.  For one, there is only one JavaScript source code file (other than the advertising scripts), a solution for <a href="http://webfx.eae.net/dhtml/pngbehavior/pngbehavior.html">PNG Alpha Transparency in Internet Explorer</a>, included as an <a href="http://msdn2.microsoft.com/en-us/library/ms531018(VS.85).aspx">HTML Component</a>.  The source for the PNG Behavior script (credit to Erik Arvidsson) is unchanged, with the exception of the removal of some extraneous comments, but curiously enough no whitespace removed (a suggestion to save them a few bucks in bandwidth).  Looking at their HTML source, they seem to emphasize whitespace and readability over bandwidth savings, which seems fine to me.  At least their visitors (you and I) can more easily learn something from their code.</p>
<p><strong>CSS</strong><br />
They&#8217;ve taken the same route as one of the tips from <a href="http://snook.ca/archives/html_and_css/top_css_tips/">Jonathan Snook</a>, and declared all styles for an element on a single line.  They use your standard css to reset to a base starting point, much like YUI&#8217;s Reset CSS we&#8217;re all familiar with.  One interesting declaration I noticed prominently inside of their CSS was the .Butt css class, declared on their primary Search form button.  I&#8217;m curious to know the semantic meaning behind that one.</p>
<p>They use the <a href="http://www.info.com.ph/~etan/w3pantheon/style/starhtmlbug.html">tan hack</a> as well to isolate a CSS declaration for IE browsers:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #00AA00;">*</span> html <span style="color: #cc00cc;">#featured-image</span> cite <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">bottom</span><span style="color: #00AA00;">:</span> <span style="color: #933;">-1px</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>This is to workaround for an IE limitation to absolutely positioning content at the bottom of a relatively positioned div, in this case the black box containing the credits (or citation, hence the cite tag) inside of the feature image.</p>
<p><img src="http://www.zachleat.com/web/wp-content/uploads/2008/03/flickr_cite.jpg" alt="Flickr Citation Tag" title="flickr_cite" width="500" height="230" class="alignnone size-full wp-image-118" /></p>
<p>Another interesting CSS Hack they&#8217;ve employed involves the line-height for &lt;a&gt; tags containing Unicode characters to select different languages.  It starts out like <a href="http://www.dustindiaz.com/min-height-fast-hack/">Dustin Diaz&#8217;s min-height hack</a>, but throws a loop.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">0px</span> !important<span style="color: #00AA00;">;</span>
<span style="color: #000000; font-weight: bold;">height</span> <span style="color: #808080; font-style: italic;">/**/</span><span style="color: #00AA00;">:</span><span style="color: #933;">13px</span><span style="color: #00AA00;">;</span></pre></div></div>

<p>I&#8217;m not familiar with the <code>/**/</code> syntax, and would really appreciate any information someone has on what platform this is targeting.  A comment would be nice!</p>
<p><strong>HTML</strong></p>
<p>Standard here, and they have some nice meta tags for the I-phone:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;meta name=&quot;viewport&quot; content=&quot;width=950&quot; /&gt;</pre></div></div>

<p>All in all, it&#8217;s short and sweet code for a home page.  It&#8217;s nice to see such clean code with an eye towards standards on a commercially successful site, many props to their programmers.  I&#8217;m scared to do my next in the series, because I&#8217;m 100% sure it won&#8217;t be as nice of a read as Flickr was.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zachleat.com/web/2008/03/30/code-like-the-big-boys-flickr/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Nursery Rhyme Code Poem [CSS]</title>
		<link>http://www.zachleat.com/web/2007/10/27/nursery-rhyme-code-poem-css/</link>
		<comments>http://www.zachleat.com/web/2007/10/27/nursery-rhyme-code-poem-css/#comments</comments>
		<pubDate>Sat, 27 Oct 2007 14:04:41 +0000</pubDate>
		<dc:creator>Zach Leatherman</dc:creator>
				<category><![CDATA[Artistic]]></category>
		<category><![CDATA[CSS]]></category>
		<category><![CDATA[Code Poem]]></category>
		<category><![CDATA[Nursery Rhymes]]></category>

		<guid isPermaLink="false">http://www.zachleat.com/web/2007/10/27/nursery-rhyme-code-poem-css/</guid>
		<description><![CDATA[Code Poems are fun! The trick is to take a nursery rhyme (but really, it could be any commonplace work of writing &#8211; Famous Speeches, Bible Verses, Famous Quotes, etc.), and then turn it into pseudocode. The code must follow both the programming or markup language you&#8217;re using and the rhyme as closely as possible. [...]]]></description>
			<content:encoded><![CDATA[<p>Code Poems are fun!  The trick is to take a <a href="http://en.wikipedia.org/wiki/List_of_nursery_rhymes_in_English">nursery rhyme</a> (but really, it could be any commonplace work of writing &#8211; Famous Speeches, Bible Verses, Famous Quotes, etc.), and then turn it into pseudocode.  The code must follow both the programming or markup language you&#8217;re using and the rhyme as closely as possible.  See how precise you can make your rhyme fit.  I accept critiques and suggestions for improving me rhyme code (or you could just rewrite my rhyme as you see fit).</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#theChurch</span> <span style="color: #00AA00;">&#123;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#theChurch</span> <span style="color: #cc00cc;">#theSteeple</span> <span style="color: #00AA00;">&#123;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#theChurch</span> .door<span style="color: #00AA00;">&#91;</span>state<span style="color: #00AA00;">=</span><span style="color: #ff0000;">&quot;open&quot;</span><span style="color: #00AA00;">&#93;</span> <span style="color: #6666ff;">.people</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">visibility</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">visible</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#theChurch</span> <span style="color: #cc00cc;">#theParson</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">none</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#theChurch</span> <span style="color: #00AA00;">&gt;</span> <span style="color: #6666ff;">.upstairs</span> <span style="color: #cc00cc;">#theParson</span><span style="color: #3333ff;">:active </span><span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#theChurch</span> <span style="color: #cc00cc;">#theParson</span><span style="color: #00AA00;">:</span>lang<span style="color: #00AA00;">&#40;</span>prayers<span style="color: #00AA00;">&#41;</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">block</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>

<p><em>The above code poem is released under the BSD license.</em> To use in production environment without error, do not include an element with an id attribute of &#8220;theChurch&#8221;. Obviously I&#8217;m kidding, don&#8217;t use this code. Not even for enterprise software.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zachleat.com/web/2007/10/27/nursery-rhyme-code-poem-css/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Phing to automate JavaScript and CSS Minimization</title>
		<link>http://www.zachleat.com/web/2007/08/11/using-phing-to-automate-javascript-and-css-minimization/</link>
		<comments>http://www.zachleat.com/web/2007/08/11/using-phing-to-automate-javascript-and-css-minimization/#comments</comments>
		<pubDate>Sat, 11 Aug 2007 06:33:53 +0000</pubDate>
		<dc:creator>Zach Leatherman</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[csstidy]]></category>
		<category><![CDATA[Packer]]></category>
		<category><![CDATA[Phing]]></category>

		<guid isPermaLink="false">http://www.zachleat.com/web/2007/08/11/using-phing-to-automate-javascript-and-css-minimization/</guid>
		<description><![CDATA[This article may be too advanced for beginner programmers. Unfortunately, I will not support any code that I do not write (in this case), so if you have troubles installing some of the packages required below, please see the authors of the problem code. Thank you. PHING! Party on Wayne. Party on Garth! If you&#8217;ve [...]]]></description>
			<content:encoded><![CDATA[<p><em>This article may be too advanced for beginner programmers.  Unfortunately, I will not support any code that I do not write (in this case), so if you have troubles installing some of the packages required below, please see the authors of the problem code.  Thank you.</em></p>
<p>PHING!  <a href="http://en.wikipedia.org/wiki/Wayne%27s_World">Party on Wayne.  Party on Garth!</a></p>
<p>If you&#8217;ve never used Phing, it&#8217;s an automation tool for PHP that is a port of Java&#8217;s ANT Build tool.  But it&#8217;s not just for building (obviously, that&#8217;d be silly).  You can hook all kinds of tasks into Phing: unit tests for your PHP code (you&#8217;re doing test driven development, aren&#8217;t you?), building your documentation, etc.  But today, let&#8217;s look at automation of my favorite front end development tasks: packing (minimizing) our JavaScript and CSS.</p>
<p>To do this, I&#8217;m going to hook you up with two Filters for Phing that will use the <a href="http://joliclic.free.fr/php/javascript-packer/en/">PHP port of Dean Edwards JavaScript Packer</a>, and the PHP class <a href="http://csstidy.sourceforge.net/">CSSTidy</a>.</p>
<p>Here&#8217;s what you&#8217;ll be responsible for:</p>
<ol>
<li>Download both CSSTidy and the PHP port of Packer using the links above.</li>
<li>Download Phing if you don&#8217;t already have it, and install it.  Note the following change I had to make to my Phing \bin\phing.bat file to get it working: Change <code>set PHP_CLASSPATH="%PHING_HOME%\classes"</code> to remove the quotes: <code>set PHP_CLASSPATH=%PHING_HOME%\classes</code></li>
<li>Download the two Filters I made for Phing: <strong><a href="/Projects/phing/JSPackerFilter.phps">JSPackerFilter.phps</a></strong> and <strong><a href="/Projects/phing/CssTidyFilter.phps">CssTidyFilter.phps</a></strong>, change the extensions to .php and copy into your phing directory \classes\phing\filters\</li>
<li>Change the path in the include_once declaration at the top of each of the files to point to the csstidy and packer libraries you downloaded above:
<pre language="php">
include_once "C:\Lib\packer.php-1.0\class.JavaScriptPacker.php";
</pre>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #b1b100;">include_once</span> <span style="color: #0000ff;">&quot;C:\Lib\csstidy-1.3\class.csstidy.php&quot;</span><span style="color: #339933;">;</span></pre></div></div>

</li>
<li>Get a working build file set up to point the directories your project is using.  Here is a sample I made:

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;project</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;testProject&quot;</span> <span style="color: #000066;">default</span>=<span style="color: #ff0000;">&quot;pack-all&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;pack-all&quot;</span> <span style="color: #000066;">depends</span>=<span style="color: #ff0000;">&quot;pack-javascript,pack-css&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;pack-javascript&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;copy</span> <span style="color: #000066;">todir</span>=<span style="color: #ff0000;">&quot;./Web/js&quot;</span> <span style="color: #000066;">overwrite</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fileset</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">&quot;../Web/js&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;include</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;*.js&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/fileset<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filterchain<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filterreader</span> <span style="color: #000066;">classname</span>=<span style="color: #ff0000;">&quot;phing.filters.JSPackerFilter&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
				  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;encoding&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;62&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><span style="color: #808080; font-style: italic;">&lt;!-- 0,10,62,95 or 'None', 'Numeric', 'Normal', 'High ASCII'. --&gt;</span>
				  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;fastDecode&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><span style="color: #808080; font-style: italic;">&lt;!-- include the fast decoder in the packed result --&gt;</span>
				  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;specialCharacters&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span><span style="color: #808080; font-style: italic;">&lt;!-- have you flagged your private and local variables in the script --&gt;</span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/filterreader<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/filterchain<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/copy<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;pack-css&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;copy</span> <span style="color: #000066;">todir</span>=<span style="color: #ff0000;">&quot;./Web/css&quot;</span> <span style="color: #000066;">overwrite</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fileset</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">&quot;../Web/css&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;include</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;*.css&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/fileset<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filterchain<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;filterreader</span> <span style="color: #000066;">classname</span>=<span style="color: #ff0000;">&quot;phing.filters.CssTidyFilter&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
					<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;remove_last_;&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
					<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;preserveCss&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;false&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
					<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;param</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;template&quot;</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">&quot;high_compression&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
				<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/filterreader<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
			<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/filterchain<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/copy<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/target<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/project<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Templates for CssTidy include: low_compression, default, high_compression (declarations are limited to one line apiece), highest_compression (everything is put on one line).</p>
<p>The above build file is set up to work with the following directory structure:</p>
<ul>
<li>Build
<ul>
<li>Web
<ul>
<li>css</li>
<li>js</li>
</ul>
</li>
<li><strong>build.xml</strong></li>
</ul>
</li>
<li>Web
<ul>
<li>css</li>
<li>js</li>
</ul>
</li>
</ul>
<p>Files are copied from the source in /Web to the /Build/Web directory.  I hope that you can see from the build.xml file above that the target directory is specified in the copy tag, todir attribute.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;copy</span> <span style="color: #000066;">todir</span>=<span style="color: #ff0000;">&quot;./Web/js&quot;</span> <span style="color: #000066;">overwrite</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span></pre></div></div>

<p>and the source directory is specified in the fileset tag, dir attribute.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>fileset dir<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;../Web/css&quot;</span><span style="color: #339933;">&gt;</span>
	<span style="color: #339933;">&lt;</span>include <span style="color: #000066;">name</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;*.css&quot;</span> <span style="color: #339933;">/&gt;</span>
<span style="color: #339933;">&lt;/</span>fileset<span style="color: #339933;">&gt;</span></pre></div></div>

</li>
</ol>
<p>And then, all you need to do is navigate to the directory holding your build.xml and run the phing command (if you have phing in your path. If not, you can use an absolute link to phing, for example c:\software\phing\bin\phing).  Your minimized javascript and css will be in the Build directory!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zachleat.com/web/2007/08/11/using-phing-to-automate-javascript-and-css-minimization/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Enlarging your YUI DataTable in 30 Seconds or Less!</title>
		<link>http://www.zachleat.com/web/2007/06/07/enlarging-your-yui-datatable-in-30-seconds-or-less/</link>
		<comments>http://www.zachleat.com/web/2007/06/07/enlarging-your-yui-datatable-in-30-seconds-or-less/#comments</comments>
		<pubDate>Fri, 08 Jun 2007 02:51:08 +0000</pubDate>
		<dc:creator>Zach Leatherman</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Interface Design]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Expandable]]></category>
		<category><![CDATA[Grid]]></category>
		<category><![CDATA[YUI]]></category>

		<guid isPermaLink="false">http://www.zachleat.com/web/2007/06/07/enlarging-your-yui-datatable-in-30-seconds-or-less/</guid>
		<description><![CDATA[Please note that this post has been updated to the new version of YUI, 2.3.0 in an article called &#8220;Enlarging your YUI DataTable in 29 Seconds or Less!&#8221; Do you want to fit more content onto your DataTable, but don&#8217;t know how? Do you wish that you had fewer columns, or more horizontal screen-estate? Well [...]]]></description>
			<content:encoded><![CDATA[<p><b>Please note that this post has been updated to the new version of YUI, 2.3.0 in an article called <a href="http://www.zachleat.com/web/2007/08/28/enlarging-your-yui-datatable-in-29-seconds-or-less/">&#8220;Enlarging your YUI DataTable in 29 Seconds or Less!&#8221;</a></b></p>
<p>Do you want to fit more content onto your DataTable, but don&#8217;t know how?  Do you wish that you had fewer columns, or more horizontal screen-estate?  Well now you can enlarge your table easily with these simple functions!  Instead of adding more information into additional columns, we have used our patented method of not actually patenting anything to bring you a secret formula that will allow you to dynamically insert rows into your table, designed for holding additional, non-constrained customizable content!</p>
<p>Do you mean to tell me that your formula will give that special lady in your life the DataTable that she has always wanted?</p>
<p>Of course!  In fact, we guarantee this DataTable to satisfy all of the women you know and don&#8217;t know in the world or we&#8217;ll give you a full refund of the purchase price!</p>
<p>Wow! How does it work?</p>
<p><a href="http://www.zachleat.com/Projects/valdi/__test_yui_datatable_expandable.html"></p>
<p>Click here for an example!</p>
<p><img src='http://www.zachleat.com/web/wp-content/uploads/2007/06/datatable.gif' alt='Normal DataTable' /></p>
<p><img src='http://www.zachleat.com/web/wp-content/uploads/2007/06/datatableexpanded.gif' alt='Expanded DataTable' /><br />
</a></p>
<p>When you click on a row in the DataTable, it inserts a child row beneath the row with an HTML string passed in to populate the dynamic content.  When you click on the parent row or the new row that was inserted, the content disappears!  It&#8217;s that easy!  You don&#8217;t have to apply any gross awful smelling creams, or take any large horse-sized pills for this to work!  You literally only use the following code to do it:</p>
<p>Usage Code:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> myDataTable <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> YAHOO.<span style="color: #660066;">widget</span>.<span style="color: #660066;">DataTable</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;myContainer&quot;</span><span style="color: #339933;">,</span>myColumnSet<span style="color: #339933;">,</span>myDataSource<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
myDataTable.<span style="color: #660066;">subscribe</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;cellClickEvent&quot;</span><span style="color: #339933;">,</span> myDataTable.<span style="color: #660066;">onEventSelectRow</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// make sure you're firing the row selection event</span>
myDataTable.<span style="color: #660066;">subscribe</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;cellClickEvent&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span> e <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #003366; font-weight: bold;">var</span> myCustomHtml <span style="color: #339933;">=</span> <span style="color: #3366CC;">'Hello, this is my expanded content.&lt;br /&gt;:-)&lt;br /&gt;'</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// generate the string, could use an ajax call if you wanted.</span>
   YAHOO.<span style="color: #660066;">ymod</span>.<span style="color: #660066;">datatable</span>.<span style="color: #660066;">clickAndExpand</span>.<span style="color: #660066;">call</span><span style="color: #009900;">&#40;</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> e<span style="color: #339933;">,</span> myCustomHtml <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// if you do use an ajax call, this function returns a reference to the newly created div that you can put the ajax results into.</span>
<span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Library Code:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">YAHOO.<span style="color: #003366; font-weight: bold;">namespace</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'YAHOO.ymod.datatable'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
YAHOO.<span style="color: #660066;">ymod</span>.<span style="color: #660066;">datatable</span>.<span style="color: #660066;">clickAndExpand</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span> e<span style="color: #339933;">,</span> expandedHtml <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> selectedRows <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">getSelectedRows</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> selectedRows.<span style="color: #660066;">length</span> <span style="color: #339933;">&gt;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">hasClass</span><span style="color: #009900;">&#40;</span> selectedRows<span style="color: #009900;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'ymod-expandedData'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span> selectedRows<span style="color: #009900;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#93;</span>.<span style="color: #660066;">previousSibling</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'expanded'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			selectedRows<span style="color: #009900;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#93;</span>.<span style="color: #660066;">parentNode</span>.<span style="color: #660066;">removeChild</span><span style="color: #009900;">&#40;</span> selectedRows<span style="color: #009900;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span>YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">hasClass</span><span style="color: #009900;">&#40;</span> selectedRows<span style="color: #009900;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'ymod-expanded'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003366; font-weight: bold;">var</span> newRow <span style="color: #339933;">=</span> document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'tr'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003366; font-weight: bold;">var</span> newCell <span style="color: #339933;">=</span> document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'td'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003366; font-weight: bold;">var</span> newDiv <span style="color: #339933;">=</span> document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'div'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span> newDiv<span style="color: #339933;">,</span> <span style="color: #3366CC;">'ymod-expandedDataContent'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> expandedHtml <span style="color: #339933;">!=</span> <span style="color: #003366; font-weight: bold;">null</span> <span style="color: #009900;">&#41;</span> newDiv.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> expandedHtml<span style="color: #339933;">;</span>
			newCell.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span> newDiv <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			newCell.<span style="color: #660066;">colSpan</span> <span style="color: #339933;">=</span> selectedRows<span style="color: #009900;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#93;</span>.<span style="color: #660066;">childNodes</span>.<span style="color: #660066;">length</span><span style="color: #339933;">;</span>
			newRow.<span style="color: #660066;">appendChild</span><span style="color: #009900;">&#40;</span> newCell <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>		
			YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span> newRow<span style="color: #339933;">,</span> <span style="color: #3366CC;">'ymod-expandedData'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">hasClass</span><span style="color: #009900;">&#40;</span> selectedRows<span style="color: #009900;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'yui-dt-odd'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span> newRow<span style="color: #339933;">,</span> <span style="color: #3366CC;">'yui-dt-odd'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span> YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">hasClass</span><span style="color: #009900;">&#40;</span> selectedRows<span style="color: #009900;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'yui-dt-even'</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span> newRow<span style="color: #339933;">,</span> <span style="color: #3366CC;">'yui-dt-even'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span> selectedRows<span style="color: #009900;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'ymod-expanded'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			selectedRows<span style="color: #009900;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#93;</span>.<span style="color: #660066;">parentNode</span>.<span style="color: #660066;">insertBefore</span><span style="color: #009900;">&#40;</span> newRow<span style="color: #339933;">,</span> selectedRows<span style="color: #009900;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#93;</span>.<span style="color: #660066;">nextSibling</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Event</span>.<span style="color: #660066;">addListener</span><span style="color: #009900;">&#40;</span> newRow<span style="color: #339933;">,</span> <span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span> e <span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				YAHOO.<span style="color: #660066;">ymod</span>.<span style="color: #660066;">datatable</span>.<span style="color: #660066;">collapseRow</span><span style="color: #009900;">&#40;</span> <span style="color: #000066; font-weight: bold;">this</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Event</span>.<span style="color: #660066;">stopEvent</span><span style="color: #009900;">&#40;</span> e <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span> selectedRows<span style="color: #009900;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'yui-dt-selected'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Event</span>.<span style="color: #660066;">stopEvent</span><span style="color: #009900;">&#40;</span> e <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">return</span> newDiv<span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
			selectedRows<span style="color: #009900;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#93;</span>.<span style="color: #660066;">parentNode</span>.<span style="color: #660066;">removeChild</span><span style="color: #009900;">&#40;</span> selectedRows<span style="color: #009900;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#93;</span>.<span style="color: #660066;">nextSibling</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span> selectedRows<span style="color: #009900;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'ymod-expanded'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span> selectedRows<span style="color: #009900;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'yui-dt-selected'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Event</span>.<span style="color: #660066;">stopEvent</span><span style="color: #009900;">&#40;</span> e <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// pass in the expanded content, NOT the parent row.</span>
YAHOO.<span style="color: #660066;">ymod</span>.<span style="color: #660066;">datatable</span>.<span style="color: #660066;">collapseRow</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span> row <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span> row.<span style="color: #660066;">previousSibling</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'ymod-expanded'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span> row.<span style="color: #660066;">previousSibling</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'yui-dt-selected'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	row.<span style="color: #660066;">parentNode</span>.<span style="color: #660066;">removeChild</span><span style="color: #009900;">&#40;</span> row <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Customize the CSS, if desired.</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.yui-dt-table</span> tr<span style="color: #6666ff;">.ymod-expandedData</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#bdcede</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">cursor</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">pointer</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.yui-dt-table</span> tr<span style="color: #6666ff;">.ymod-expandedData</span> td <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">padding-right</span><span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding-bottom</span><span style="color: #00AA00;">:</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">white-space</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">normal</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">visible</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.yui-dt-table</span> tr<span style="color: #6666ff;">.ymod-expanded</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#bdcede</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.yui-dt-table</span> tr<span style="color: #6666ff;">.ymod-expanded</span> td <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">border-bottom</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.yui-dt-table</span> div<span style="color: #6666ff;">.ymod-expandedDataContent</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span> <span style="color: #cc00cc;">#f4f4f4</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span> <span style="color: #933;">1px</span> <span style="color: #993333;">inset</span> <span style="color: #cc00cc;">#aaa</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">white-space</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">normal</span><span style="color: #00AA00;">;</span> zoom<span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">1</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>You might even want to put a little + and &#8211; into the first column of each row to give a visual cue that there is more information for display available on click.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zachleat.com/web/2007/06/07/enlarging-your-yui-datatable-in-30-seconds-or-less/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>YUI DataTable and You: Making the Marriage Work</title>
		<link>http://www.zachleat.com/web/2007/04/30/yui-datatable-and-you-making-the-marriage-work/</link>
		<comments>http://www.zachleat.com/web/2007/04/30/yui-datatable-and-you-making-the-marriage-work/#comments</comments>
		<pubDate>Mon, 30 Apr 2007 22:48:09 +0000</pubDate>
		<dc:creator>Zach Leatherman</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[DataTable]]></category>
		<category><![CDATA[Grid]]></category>
		<category><![CDATA[YUI]]></category>

		<guid isPermaLink="false">http://www.zachleat.com/web/2007/04/30/yui-datatable-and-you-making-the-marriage-work/</guid>
		<description><![CDATA[The DataTable/Grid Component, the ball and chain of GUI components. It doesn&#8217;t let you go out and instantiate beers to create a inebriated subclass of yourself with your friends on Friday night. It makes you do household garbage collection during the last minute of your favorite sporting event. And you&#8217;d think it would die before [...]]]></description>
			<content:encoded><![CDATA[<p>The DataTable/Grid Component, the ball and chain of GUI components.  It doesn&#8217;t let you go out and instantiate beers to create a inebriated subclass of yourself with your friends on Friday night.  It makes you do household garbage collection during the last minute of your favorite sporting event.  And you&#8217;d think it would die before it would ever encapsulate your private class member.  Just to warn you, the previous sentence was not safe for work.</p>
<p>Earlier I published an article entitled <a href="/web/2007/04/04/problems-with-yui-datatable/">Problems with the YUI DataTable</a>.  Now we&#8217;re going to work out those problems together, through better communication and more effective problem solving techniques.  We&#8217;re going to save your marriage.</p>
<p>Earlier I had stated that there were a few problems with the DataTable, in its current form.  Let&#8217;s review (but not play the blame game).</p>
<ul>
<li>Bug #1: Table headers weren&#8217;t lining up correctly in Firefox (personal ignorance on Box Models)</li>
<li>Bug #2: Single Select bug where multiple rows were being selected when column was sorted (All browsers, Sortable and SingleSelect Tables)</li>
<li>Bug #3: Header displayed out of document flow when the window was resized (IE6, Scrollable Tables)</li>
<li>Bug #4: Content was being displayed approximately 60-70 pixels inside the bottom table boundary. (Firefox, Scrollable Tables) Note the position of the &#8216;Top&#8217; links in the test document below.</li>
<li>Bug #5: More of a limitation than a bug, the DataTable does not allow a fixed width table with horizontal overflow.  Say you have a table that you have fixed column widths for, but if the width of the real estate available for the table is less than this minimum, the table should overflow with a scroll bar, but at the same time showing the column headers if you scroll vertically.  A picture is better:<br />
<img src='/web/wp-content/uploads/2007/04/yui-datatable1.gif' alt='Scrollable' /></li>
</ul>
<p>See the following <a href="http://www.zachleat.com/Projects/valdi/__test_yui_datatable_original.html">test document</a> for relevant table tests. (Note that for the purposes of testing, I&#8217;ve decided to test all combinations of the Top 3 DataTable features: scrolling, nested table headers, and sorting)</p>
<p>Just like your favorite professor, now I&#8217;m going to post the <strong>Solutions</strong>:</p>
<p>Bug #1: What is your Box Model?</p>
<p>Use the following JavaScript code to tell if you&#8217;re in Standards Mode or Quirks Mode:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span> document.<span style="color: #660066;">compatMode</span><span style="color: #339933;">==</span><span style="color: #3366CC;">'CSS1Compat'</span> <span style="color: #339933;">?</span> <span style="color: #3366CC;">'Standards Mode'</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">'Quirks Mode'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Standards mode forces your document into using the W3C Box Model, which is currently the standard.  The W3C Box Model means any width declarations you make in your CSS code will not include padding, border, or margins.  So if you put padding on your table cells and headers, it will need <em>to be added on separately to the total width of your table</em>.</p>
<p>Bug #2: Someone has posted the solution on the <a href="http://sourceforge.net/tracker/index.php?func=detail&#038;aid=1701632&#038;group_id=165715&#038;atid=836476">Sourceforge Bug Tracker here</a>.  (This is included in the DataTable javascript file below)</p>
<p>Bug #3, #4, and #5: I have produced an alternate DataTable file that fixes these bugs using JavaScript code.  All lines that were added or changed are commented with //ADDED or //CHANGED</p>
<p>Developed in and last tested with YUI version 2.2.2.</p>
<p>Download it here:<br />
Full (169 KB): <a href='http://www.zachleat.com/web/wp-content/uploads/2007/04/ymod-datatable-beta.js' title='ymod-datatable-beta.js'>ymod-datatable-beta.js</a><br />
Minimized using <a href="http://www.crockford.com/javascript/jsmin.html">JSMIN</a> (67 KB): <a href='http://www.zachleat.com/web/wp-content/uploads/2007/04/ymod-datatable-beta-min.js' title='ymod-datatable-beta-min.js'>ymod-datatable-beta-min.js</a></p>
<p>The original and minimized YUI DataTable files are 166 KB and 66 KB respectively.</p>
<p>See the <a href="/Projects/valdi/__test_yui_datatable_fluid.html">fluid width DataTables in action here</a>.</p>
<p>A few notes on doing a fixed width DataTable using the code provided above.  The total width of the table body must be 16px less than the width of the header, if you have vertical scrolling (to account for the scrollbar).  So, if the total width of your header is 800px, the total width of your body must be 784px (put the last table cell as 16px smaller).</p>
<p>Here&#8217;s the CSS to go along with a horizontal scrolling DataTable:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.yui-dt-table</span> th<span style="color: #00AA00;">,</span> <span style="color: #6666ff;">.yui-dt-table</span> td <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span> <span style="color: #933;">2px</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">2px</span> <span style="color: #933;">5px</span><span style="color: #00AA00;">;</span> <span style="color: #000000; font-weight: bold;">vertical-align</span><span style="color: #00AA00;">:</span> <span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.yui-dt-table</span> th<span style="color: #00AA00;">,</span> <span style="color: #6666ff;">.yui-dt-table</span> tr<span style="color: #6666ff;">.yui-dt-first</span> td <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">100px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span> <span style="color: #808080; font-style: italic;">/* table header and only the first row (for drag and drop) */</span>
<span style="color: #6666ff;">.ymod-scrollingBody</span> <span style="color: #6666ff;">.yui-dt-table</span> tr<span style="color: #6666ff;">.yui-dt-first</span> td<span style="color: #6666ff;">.yui-dt-last</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">84px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span> <span style="color: #808080; font-style: italic;">/* last table cell (for crappy scrollbar problem) */</span>
<span style="color: #6666ff;">.yui-dt-table</span> <span style="color: #6666ff;">.yui-dt-even</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.yui-dt-table</span> <span style="color: #6666ff;">.yui-dt-odd</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#e0dfe0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.yui-dt-table</span> <span style="color: #6666ff;">.yui-dt-selected</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#bdcede</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.yui-dt-table</span> thead <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">background-color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#933</span><span style="color: #00AA00;">;</span>color<span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#fff</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.yui-dt-table</span> th a <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">color</span><span style="color: #00AA00;">:</span><span style="color: #cc00cc;">#fff</span> ! important<span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.ymod-scrollingHeader</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;"><span style="color: #cc66cc;">100</span>%</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">20px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">relative</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.ymod-nestedHeaders</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">40px</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* gotta set this manually, unfortunately */</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.ymod-scrollingHeader</span> table <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">absolute</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">top</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.ymod-scrollingBody</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;"><span style="color: #cc66cc;">100</span>%</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">160px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.ymod-scrollingHeader</span> table <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">800px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span> <span style="color: #808080; font-style: italic;">/* Set your widths! */</span>
<span style="color: #6666ff;">.ymod-scrollingBody</span> table <span style="color: #00AA00;">&#123;</span> <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">784px</span><span style="color: #00AA00;">;</span> <span style="color: #00AA00;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.zachleat.com/web/2007/04/30/yui-datatable-and-you-making-the-marriage-work/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>I-Frame Shims or How I Learned to Stop Worrying and Love the Bomb</title>
		<link>http://www.zachleat.com/web/2007/04/24/adventures-in-i-frame-shims-or-how-i-learned-to-love-the-bomb/</link>
		<comments>http://www.zachleat.com/web/2007/04/24/adventures-in-i-frame-shims-or-how-i-learned-to-love-the-bomb/#comments</comments>
		<pubDate>Tue, 24 Apr 2007 21:51:55 +0000</pubDate>
		<dc:creator>Zach Leatherman</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Web Browsers]]></category>
		<category><![CDATA[Internet Explorer]]></category>

		<guid isPermaLink="false">http://www.zachleat.com/web/2007/04/24/adventures-in-i-frame-shims-or-how-i-learned-to-love-the-bomb/</guid>
		<description><![CDATA[So again, I show up late to the party. IE7 is already out, but my target customers are still using IE6. So today, boys and girls, we&#8217;re going to discover the magical world of using I-Frame shims to hide those bleeding heart select boxes from showing through our layered elements. Typically, when creating an I-Frame [...]]]></description>
			<content:encoded><![CDATA[<p>So again, I show up late to the party.  IE7 is already out, but my target customers are still using IE6.  So today, boys and girls, we&#8217;re going to discover the magical world of using I-Frame shims to hide those bleeding heart select boxes from showing through our layered elements.</p>
<p>Typically, when creating an I-Frame shim, you&#8217;re going to create the i-frame dynamically using document.createElement.  Let&#8217;s start out with some successful code.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> iframeShim <span style="color: #339933;">=</span> document.<span style="color: #660066;">createElement</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'iframe'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
iframeShim.<span style="color: #660066;">setAttribute</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'src'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'javascript:&quot;&quot;;'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
iframeShim.<span style="color: #660066;">setAttribute</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">'frameBorder'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'0'</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Now for some caveats you might have encountered with code not matching the above:</p>
<p><strong>I-Frame frameBorder attribute</strong><br />
Are you trying to get rid of that nasty i-frame border in Internet Explorer 6 (IE6)?  Tried CSS properties?  Tried setting the frameBorder attribute?  It turns out that when setting the frameBorder attribute, the name of the attribute is case sensitive.  Using frameborder will not work correctly, but using frameBorder (with a capital B) will give the desired result.  [Source: <a href="http://www.visible-form.com/blog/createelement-and-events-and-iframe-borders/">FlashApe</a>]</p>
<p><strong>HTTPS and I-Frame src attribute</strong><br />
Is your page hosted on a secure domain (https instead of just http)?  Is the dynamically created iframe causing the following error message in Internet Explorer?</p>
<p><em>This page contains both secure and nonsecure items.  Do you want to display the nonsecure items?</em></p>
<p>Some have suggested that changing the src attribute to point to a blank html page with no content is the solution, but that&#8217;s an extra http request on your page that is unnecessary.  Others have suggested that that changing the src attribute to javascript:false works.  It does, in fact, but writes the text &#8216;false&#8217; to your iframe content.  Others have suggested javascript:void(0) as your src attribute value [Source: <a href="http://ewbi.blogs.com/develops/2004/07/ie_iframe_and_h.html">ewbi.develops</a>], but some Internet Explorer clients still have secure and nonsecure items alert popup.  I have not figured out the factors that separate these Internet Explorer clients.  </p>
<p><strong>Update</strong>: <del datetime="2008-12-02T05:19:37+00:00">The correct solution is in face setting &#8220;javascript:false;document.write(&#8220;&#8221;);&#8221; as your src value, as I found in the <a href="http://malsup.com/jquery/block/">jQuery BlockUI</a> plugin.  This is a silver bullet fix that will avoid all the problems I have encountered.</del></p>
<p><strong>Update Again</strong>: I have revisited this problem and it looks like (as mentioned in the comments) there is a problem with the solution presented in the first update (infinite load).  After researching some DOMContentLoaded solutions, I thought to try the &#8220;//:&#8221; source they were attempting for their deferred script source.  Alas, it didn&#8217;t work.  However, <code>javascript:"";</code> <strong>does work</strong>, so the above solution has been modified.  Keep in mind, the whole point of this solution is to <strong>avoid</strong> an additional unnecessary HTTP request.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zachleat.com/web/2007/04/24/adventures-in-i-frame-shims-or-how-i-learned-to-love-the-bomb/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Google Using YUI Grids CSS</title>
		<link>http://www.zachleat.com/web/2007/04/05/google-using-yui-grids-css/</link>
		<comments>http://www.zachleat.com/web/2007/04/05/google-using-yui-grids-css/#comments</comments>
		<pubDate>Thu, 05 Apr 2007 16:33:22 +0000</pubDate>
		<dc:creator>Zach Leatherman</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Reviews]]></category>
		<category><![CDATA[CSS Grids]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Licensing]]></category>
		<category><![CDATA[YUI]]></category>

		<guid isPermaLink="false">http://www.zachleat.com/web/2007/04/05/google-using-yui-grids-css/</guid>
		<description><![CDATA[Head over to the Google Homepage. Log In using your Google Account. Make sure you&#8217;re at your Personalized Homepage. Take a look at the source CSS file ig.css included on the page. There are a few peculiar lines of code that I recognized from another source, the Yahoo User Interface Grids CSS file. Yahoo has [...]]]></description>
			<content:encoded><![CDATA[<p>Head over to the <a href="http://www.google.com/ig?hl=en">Google Homepage</a>.  Log In using your Google Account.  Make sure you&#8217;re at your <a href="http://www.google.com/ig?hl=en">Personalized Homepage</a>.  Take a look at the source CSS file <a href="http://www.google.com/ig/f/tB22vfBbv0g/ig.css">ig.css</a> included on the page.  There are a few peculiar lines of code that I recognized from another source, the Yahoo User Interface Grids CSS file.  Yahoo has provided a set of standard CSS definitions under the BSD license that allow a developer to easily make fluid or fixed width column layouts.  And on the Google Personalized Homepage, there are the following class definitions:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#modules</span> <span style="color: #6666ff;">.yui-b</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">static</span><span style="color: #00AA00;">;</span>display<span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>margin<span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">1em</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>float<span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>width<span style="color: #00AA00;">:</span><span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>overflow<span style="color: #00AA00;">:</span><span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.yui-gb</span> <span style="color: #6666ff;">.yui-u</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>margin-<span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;"><span style="color: #cc66cc;">2</span>%</span><span style="color: #00AA00;">;*</span><span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span><span style="color: #933;"><span style="color: #cc66cc;">1.895</span>%</span><span style="color: #00AA00;">;</span>width<span style="color: #00AA00;">:</span><span style="color: #933;"><span style="color: #cc66cc;">32</span>%</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.yui-gb</span> div<span style="color: #6666ff;">.first</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#modules</span><span style="color: #00AA00;">,</span><span style="color: #6666ff;">.yui-gb</span><span style="color: #00AA00;">&#123;</span>zoom<span style="color: #00AA00;">:</span><span style="color: #cc66cc;">1</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>This code includes identical Class names taken from the <a href="http://developer.yahoo.com/yui/grids/">Yahoo User Interface library Grids CSS</a> component.  Here is the source in the <a href="http://yui.yahooapis.com/2.2.0/build/grids/grids-min.css">grids.css</a> file from Yahoo (truncated for simplicity).</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#yui-main</span> <span style="color: #6666ff;">.yui-b</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">static</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.yui-t7</span> <span style="color: #cc00cc;">#yui-main</span> <span style="color: #6666ff;">.yui-b</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>margin<span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">1em</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#yui-main</span> <span style="color: #6666ff;">.yui-b</span> <span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>width<span style="color: #00AA00;">:</span><span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.yui-gb</span> <span style="color: #6666ff;">.yui-u</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>margin-<span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;"><span style="color: #cc66cc;">2</span>%</span><span style="color: #00AA00;">;*</span><span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span><span style="color: #933;"><span style="color: #cc66cc;">1.895</span>%</span><span style="color: #00AA00;">;</span>width<span style="color: #00AA00;">:</span><span style="color: #933;"><span style="color: #cc66cc;">32</span>%</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.yui-gb</span> div<span style="color: #6666ff;">.first</span><span style="color: #00AA00;">&#123;</span><span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#bd</span><span style="color: #00AA00;">,</span><span style="color: #6666ff;">.yui-gb</span><span style="color: #00AA00;">&#123;</span>zoom<span style="color: #00AA00;">:</span><span style="color: #cc66cc;">1</span><span style="color: #00AA00;">;</span><span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Obviously, it&#8217;s the same code, with a few minor differences.</p>
<p><img src='http://www.zachleat.com/web/wp-content/uploads/2007/04/yuigrids-google1.jpg' alt='Screenshot proof' /></p>
<p>The interesting thing to note is that the YUI Grids CSS source code is licensed under a <a href="http://developer.yahoo.com/yui/license.html">BSD license</a>, which includes the following provisions:</p>
<blockquote><p>Redistributions of source code must retain the above copyright notice, this list of conditions and the<br />
following disclaimer.</p></blockquote>
<p>The copyright notice they&#8217;re referring to is not included anywhere on the Google Personalized Homepage (and would seem to be a violation of the license).  Now this may seem like a small infraction when we&#8217;re just talking about 4 lines of CSS code.  But really, if they think the code is good enough that they will use it in such a prominent way and not write it from scratch using their own means, they should follow the licensing agreements stipulated.</p>
<p><strong>Update</strong><br />
Google has added the BSD license statement and attribution to Yahoo in their CSS file (<a href="http://www.google.com/ig/f/tB22vfBbv0g/ig.css">ig.css</a>):</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/* ===============BEGIN BSD LICENSED PORTION============= */</span>
<span style="color: #808080; font-style: italic;">/*
Copyright (c) 2007, Yahoo! Inc. All rights reserved.
Code licensed under the BSD License:
http://developer.yahoo.net/yui/license.txt
version: 2.2.0
*/</span>
&nbsp;
<span style="color: #cc00cc;">#modules</span> <span style="color: #6666ff;">.yui-b</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span><span style="color: #993333;">static</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #cc66cc;">0</span> <span style="color: #933;">1em</span> <span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span><span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.yui-gb</span> <span style="color: #6666ff;">.yui-u</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span><span style="color: #933;"><span style="color: #cc66cc;">2</span>%</span><span style="color: #00AA00;">;</span>
  <span style="color: #00AA00;">*</span><span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span><span style="color: #933;"><span style="color: #cc66cc;">1.895</span>%</span><span style="color: #00AA00;">;</span>
  <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;"><span style="color: #cc66cc;">32</span>%</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.yui-gb</span> div<span style="color: #6666ff;">.first</span> <span style="color: #00AA00;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">margin-left</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#modules</span><span style="color: #00AA00;">,</span><span style="color: #6666ff;">.yui-gb</span> <span style="color: #00AA00;">&#123;</span>
  zoom<span style="color: #00AA00;">:</span><span style="color: #cc66cc;">1</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #808080; font-style: italic;">/* ===============END BSD LICENSED PORTION============= */</span></pre></div></div>

<p>Sorry to everyone visiting the page for the extra millisecond or two it will take to load these comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.zachleat.com/web/2007/04/05/google-using-yui-grids-css/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Problems with YUI DataTable</title>
		<link>http://www.zachleat.com/web/2007/04/04/problems-with-yui-datatable/</link>
		<comments>http://www.zachleat.com/web/2007/04/04/problems-with-yui-datatable/#comments</comments>
		<pubDate>Wed, 04 Apr 2007 22:52:41 +0000</pubDate>
		<dc:creator>Zach Leatherman</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[Interface Design]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Reviews]]></category>
		<category><![CDATA[DataTable]]></category>
		<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[Grid]]></category>
		<category><![CDATA[YUI]]></category>

		<guid isPermaLink="false">http://www.zachleat.com/web/2007/04/04/problems-with-yui-datatable/</guid>
		<description><![CDATA[If you have read anything I&#8217;ve written before or know me at all, you know that my go-to JavaScript library is the one and only YUI. So obviously, when I was looking around for a Grid (or as YUI jargon goes, a DataTable), naturally I&#8217;m going to turn to YUI compatible components. First, I looked [...]]]></description>
			<content:encoded><![CDATA[<p>If you have read anything I&#8217;ve written before or know me at all, you know that my go-to JavaScript library is the one and only YUI.  So obviously, when I was looking around for a Grid (or as YUI jargon goes, a DataTable), naturally I&#8217;m going to turn to YUI compatible components.  First, I looked at Jack Slocum&#8217;s EXT, which has a nice looking Grid component that had a lot of features I wouldn&#8217;t need, but I didn&#8217;t really want to take a 0.5 MB hit for the limited feature set I was requiring.  Adding the YUI DataTable would only tack on approximately 70-75 KB of additional download.  So first, let me establish what I&#8217;m going for:</p>
<p><strong>Minimum Feature Set</strong>:</p>
<ul>
<li>Client-Side Sorting: I don&#8217;t want it to do an XMLHttpRequest to sort the data, I want it to be done all clientside.</li>
<li>Simple inline editing: Edit a field in the table right there on the table.  I hadn&#8217;t established what types of data I would need to edit yet.</li>
<li>Data Sources: load from a native JavaScript array or a XMLHttpRequest returning XML or JSON.</li>
<li>Data Type Sort Algorithms: at the very minimum different sorting algorithms for numeric columns and string columns.</li>
<li>Hierarchical Columns: group column headers together under a parent header.</li>
<li>Easily customizable: must be able to customize the look and feel of the grid easily using CSS and not by editing Javascript.</li>
<li>Header Freeze: If I have overflow on my table vertically causing a scroll bar, I want the table headers to remain shown at the top of the table while I scroll from top to bottom.</li>
<li>Custom Cell Rendering: I have the data I&#8217;m loading, but I want to change how it looks when it is rendered to the table.  Common for date formatting.</li>
</ul>
<p><strong>Luxury Feature Set</strong>:</p>
<ul>
<li>Resizeable Columns: change the width of a column by dragging on the column header&#8217;s right border.</li>
<li>Movable Columns: dragging a column will cause it to be moved on the table (TIBCO General Interface supports this).</li>
<li>Custom Sort Algorithm: write my own algorithm to specify how data is sorted, or provide a way to do multi-column sorting (sort within one column, ties are sorted by another column, and so on).</li>
<li>Dynamic Paging (don&#8217;t make me click numbered links, load the data automatically when I scroll) both on the client (dynamically insert only what I&#8217;m looking at and remove what I&#8217;ve scrolled past) and using the server (load more data through an XMLHttpRequest)</li>
<li>Column Freeze: if the table is going to scroll horizontally, allow the developer to freeze a column or multiple columns so that they are shown when scrolling from left to right.</li>
</ul>
<p><strong>Evaluation of Options</strong>: How does the YUI DataTable stack up?</p>
<p>Basic Items: Client-Side Sorting, Simple inline editing, Data Sources, Data Type Sort Algorithms (<em>stock types not yet implemented out of the box</em>), Hierarchical Columns, Header Freeze (<em>buggy</em>), Custom Cell Rendering, and is easily customizable with CSS.</p>
<p>Luxury Items: Resizeable Columns, Movable Columns (<em>not supported</em>), Custom Sort Algorithms are supported (you can right your own Data Type Sort Algorithms with this feature), Dynamic Paging (manually, not dynamic), Column Freeze (<em>not supported</em>)</p>
<p>Problems:</p>
<ul>
<li>Any sort of fixed width table is going to be problematic.  Putting a fixed width on the table causes the table headers to be misaligned with the associated table data.  It&#8217;s a mess.  The only viable option here is to let the table do it&#8217;s own width calculations.  You can&#8217;t even set the column widths manually using the {width} variable as suggested when using a fixed width table.</li>
<li>Data Type Sort Algorithms supposedly work from the column type, but this feature is documented in the code as being a TODO.  All columns are sorted by a string datatype, meaning that if your column is numeric and you had the following rows: { 3, 7, 40 }, the sort result would be { 3, 40, 7 }.</li>
<li>Header Freeze was problematic.  Implementing the {scrollable=true} feature as recommended by the documentation causes the table headers to be misaligned with the data in a fixed width table.</li>
<li>Paging uses the old school numbers method.  This wasn&#8217;t a deal breaker, since I classified this feature as a luxury item.</li>
</ul>
<p>Granted, the DataTable in it&#8217;s current form is a beta component, but that 0.5 MB ExtJS hit is looking pretty nice right now.</p>
<p><strong>Minor Update</strong>: to do a fixed width table that will overflow horizontally, this is the method you can use:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">div<span style="color: #cc00cc;">#dataTableId</span> <span style="color: #00AA00;">&#123;</span> <span style="color: #808080; font-style: italic;">/* change this to whatever id you're using to hold the dataTable */</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">520px</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* put in your own fixed width */</span>
	overflow-x<span style="color: #00AA00;">:</span><span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
	overflow-y<span style="color: #00AA00;">:</span><span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.yui-dt-headtext</span><span style="color: #00AA00;">,</span> <span style="color: #6666ff;">.yui-dt-headcontainer</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">position</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">static</span><span style="color: #00AA00;">;</span> <span style="color: #808080; font-style: italic;">/* without this declaration, the headers weren't horizontally scrolling with the data in IE6 */</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.zachleat.com/web/2007/04/04/problems-with-yui-datatable/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
	</channel>
</rss>
