<?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"
	>

<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>
	<pubDate>Thu, 21 Aug 2008 06:02:08 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.5</generator>
	<language>en</language>
			<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 [...]]]></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>
		</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>

		<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'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's Reset CSS we'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'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="syntax_hilite">
<div id="css-4">
<div class="css">* html #featured-image cite <span style="color: #66cc66;">&#123;</span><span style="color: #000000; font-weight: bold;">bottom</span>: -1px;<span style="color: #66cc66;">&#125;</span></div>
</div>
</div>
<p></p>
<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'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's min-height hack</a>, but throws a loop.</p>
<div class="syntax_hilite">
<div id="css-5">
<div class="css"><span style="color: #000000; font-weight: bold;">height</span>: 0px !important;<br />
<span style="color: #000000; font-weight: bold;">height</span> <span style="color: #808080; font-style: italic;">/**/</span>:13px;</div>
</div>
</div>
<p></p>
<p>I'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="syntax_hilite">
<div id="html-6">
<div class="html"><span style="color: #009900;"><a href="http://december.com/html/4/element/meta.html"><span style="color: #000000; font-weight: bold;">&lt;meta</span></a> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"viewport"</span> <span style="color: #000066;">content</span>=<span style="color: #ff0000;">"width=950"</span> /<span style="color: #000000; font-weight: bold;">&gt;</span></a></span></div>
</div>
</div>
<p></p>
<p>All in all, it's short and sweet code for a home page.  It's nice to see such clean code with an eye towards standards on a commercially successful site, many props to their programmers.  I'm scared to do my next in the series, because I'm 100% sure it won't be as nice of a read as Flickr was.</p>
<p>Technorati Tags: <a href="http://technorati.com/tag/Flickr" rel="tag">Flickr</a>, <a href="http://technorati.com/tag/CSS" rel="tag"> CSS</a>, <a href="http://technorati.com/tag/JavaScript" rel="tag"> JavaScript</a>, <a href="http://technorati.com/tag/HTML" rel="tag"> HTML</a>, <a href="http://technorati.com/tag/PNG" rel="tag"> PNG</a>, <a href="http://technorati.com/tag/Iphone" rel="tag"> Iphone</a>, <a href="http://technorati.com/tag/Meta" rel="tag"> Meta</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.zachleat.com/web/2008/03/30/code-like-the-big-boys-flickr/feed/</wfw:commentRss>
		</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 - Famous Speeches, Bible Verses, Famous Quotes, etc.), and then turn it into pseudocode.  The code must follow both the programming or markup language you're using and the rhyme as closely [...]]]></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 - Famous Speeches, Bible Verses, Famous Quotes, etc.), and then turn it into pseudocode.  The code must follow both the programming or markup language you'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="syntax_hilite">
<div id="css-8">
<div class="css"><span style="color: #cc00cc;">#theChurch <span style="color: #66cc66;">&#123;</span></span><span style="color: #66cc66;">&#125;</span><br />
#theChurch <span style="color: #cc00cc;">#theSteeple <span style="color: #66cc66;">&#123;</span></span><span style="color: #66cc66;">&#125;</span><br />
#theChurch .door<span style="color: #66cc66;">&#91;</span>state=<span style="color: #ff0000;">"open"</span><span style="color: #66cc66;">&#93;</span> <span style="color: #6666ff;">.people </span><span style="color: #66cc66;">&#123;</span> <span style="color: #000000; font-weight: bold;">visibility</span>: <span style="color: #993333;">visible</span>; <span style="color: #66cc66;">&#125;</span><br />
#theChurch <span style="color: #cc00cc;">#theParson <span style="color: #66cc66;">&#123;</span></span> <span style="color: #000000; font-weight: bold;">display</span>: <span style="color: #993333;">none</span>; <span style="color: #66cc66;">&#125;</span><br />
#theChurch&gt; <span style="color: #6666ff;">.upstairs </span>#theParson<span style="color: #3333ff;">:active </span><span style="color: #66cc66;">&#123;</span> <span style="color: #000000; font-weight: bold;">display</span>: <span style="color: #993333;">block</span>; <span style="color: #66cc66;">&#125;</span><br />
#theChurch #theParson:lang<span style="color: #66cc66;">&#40;</span>prayers<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #000000; font-weight: bold;">display</span>: <span style="color: #993333;">block</span>; <span style="color: #66cc66;">&#125;</span></div>
</div>
</div>
<p></p>
<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 "theChurch". Obviously I'm kidding, don't use this code. Not even for enterprise software.</p>
<p>Technorati Tags: <a href="http://technorati.com/tag/CSS" rel="tag">CSS</a>, <a href="http://technorati.com/tag/poem" rel="tag"> poem</a>, <a href="http://technorati.com/tag/code+poem" rel="tag"> code poem</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.zachleat.com/web/2007/10/27/nursery-rhyme-code-poem-css/feed/</wfw:commentRss>
		</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 [...]]]></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've never used Phing, it's an automation tool for PHP that is a port of Java's ANT Build tool.  But it's not just for building (obviously, that'd be silly).  You can hook all kinds of tasks into Phing: unit tests for your PHP code (you're doing test driven development, aren't you?), building your documentation, etc.  But today, let's look at automation of my favorite front end development tasks: packing (minimizing) our JavaScript and CSS.</p>
<p>To do this, I'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's what you'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'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:
<div class="syntax_hilite">
<div id="php-14">
<div class="php"><span style="color:#616100;">include_once</span> <span style="color:#FF0000;">"C:<span style="color:#000099; font-weight:bold;">\L</span>ib<span style="color:#000099; font-weight:bold;">\p</span>acker.php-1.0<span style="color:#000099; font-weight:bold;">\c</span>lass.JavaScriptPacker.php"</span>;</div>
</div>
</div>
<p></p>
<div class="syntax_hilite">
<div id="php-15">
<div class="php"><span style="color:#616100;">include_once</span> <span style="color:#FF0000;">"C:<span style="color:#000099; font-weight:bold;">\L</span>ib<span style="color:#000099; font-weight:bold;">\c</span>sstidy-1.3<span style="color:#000099; font-weight:bold;">\c</span>lass.csstidy.php"</span>;</div>
</div>
</div>
<p>
</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="syntax_hilite">
<div id="xml-16">
<div class="xml"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;</span>?xml <span style="color: #000066;">version</span>=<span style="color: #ff0000;">"1.0"</span>?<span style="font-weight: bold; color: black;">&gt;</span></span><br />
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;project</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"testProject"</span> <span style="color: #000066;">default</span>=<span style="color: #ff0000;">"pack-all"</span><span style="font-weight: bold; color: black;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"pack-all"</span> <span style="color: #000066;">depends</span>=<span style="color: #ff0000;">"pack-javascript,pack-css"</span><span style="font-weight: bold; color: black;">/&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"pack-javascript"</span><span style="font-weight: bold; color: black;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;copy</span> <span style="color: #000066;">todir</span>=<span style="color: #ff0000;">"./Web/js"</span> <span style="color: #000066;">overwrite</span>=<span style="color: #ff0000;">"true"</span><span style="font-weight: bold; color: black;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;fileset</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">"../Web/js"</span><span style="font-weight: bold; color: black;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;include</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"*.js"</span> <span style="font-weight: bold; color: black;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/fileset<span style="font-weight: bold; color: black;">&gt;</span></span></span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;filterchain<span style="font-weight: bold; color: black;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;filterreader</span> <span style="color: #000066;">classname</span>=<span style="color: #ff0000;">"phing.filters.JSPackerFilter"</span><span style="font-weight: bold; color: black;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;param</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"encoding"</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"62"</span><span style="font-weight: bold; color: black;">/&gt;</span></span><span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!-- 0,10,62,95 or 'None', 'Numeric', 'Normal', 'High ASCII'. --&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;param</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"fastDecode"</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"true"</span><span style="font-weight: bold; color: black;">/&gt;</span></span><span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!-- include the fast decoder in the packed result --&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;param</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"specialCharacters"</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"false"</span><span style="font-weight: bold; color: black;">/&gt;</span></span><span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!-- have you flagged your private and local variables in the script --&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/filterreader<span style="font-weight: bold; color: black;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/filterchain<span style="font-weight: bold; color: black;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/copy<span style="font-weight: bold; color: black;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/target<span style="font-weight: bold; color: black;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;target</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"pack-css"</span><span style="font-weight: bold; color: black;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;copy</span> <span style="color: #000066;">todir</span>=<span style="color: #ff0000;">"./Web/css"</span> <span style="color: #000066;">overwrite</span>=<span style="color: #ff0000;">"true"</span><span style="font-weight: bold; color: black;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;fileset</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">"../Web/css"</span><span style="font-weight: bold; color: black;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;include</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"*.css"</span> <span style="font-weight: bold; color: black;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/fileset<span style="font-weight: bold; color: black;">&gt;</span></span></span></p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;filterchain<span style="font-weight: bold; color: black;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;filterreader</span> <span style="color: #000066;">classname</span>=<span style="color: #ff0000;">"phing.filters.CssTidyFilter"</span><span style="font-weight: bold; color: black;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;param</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"remove_last_;"</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"true"</span><span style="font-weight: bold; color: black;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;param</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"preserveCss"</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"false"</span><span style="font-weight: bold; color: black;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;param</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"template"</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"high_compression"</span><span style="font-weight: bold; color: black;">/&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/filterreader<span style="font-weight: bold; color: black;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/filterchain<span style="font-weight: bold; color: black;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/copy<span style="font-weight: bold; color: black;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/target<span style="font-weight: bold; color: black;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/project<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</div>
</div>
<p></p>
<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="syntax_hilite">
<div id="xml-17">
<div class="xml"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;copy</span> <span style="color: #000066;">todir</span>=<span style="color: #ff0000;">"./Web/js"</span> <span style="color: #000066;">overwrite</span>=<span style="color: #ff0000;">"true"</span><span style="font-weight: bold; color: black;">&gt;</span></span></div>
</div>
</div>
<p></p>
<p>and the source directory is specified in the fileset tag, dir attribute.</p>
<div class="syntax_hilite">
<div id="xml-18">
<div class="xml"><span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;fileset</span> <span style="color: #000066;">dir</span>=<span style="color: #ff0000;">"../Web/css"</span><span style="font-weight: bold; color: black;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;include</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"*.css"</span> <span style="font-weight: bold; color: black;">/&gt;</span></span><br />
<span style="color: #009900;"><span style="font-weight: bold; color: black;">&lt;/fileset<span style="font-weight: bold; color: black;">&gt;</span></span></span></div>
</div>
</div>
<p>
</copy></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>
<p>Technorati Tags: <a href="http://technorati.com/tag/Phing" rel="tag">Phing</a>, <a href="http://technorati.com/tag/Packer" rel="tag"> Packer</a>, <a href="http://technorati.com/tag/csstidy" rel="tag"> csstidy</a>, <a href="http://technorati.com/tag/JavaScript" rel="tag"> JavaScript</a>, <a href="http://technorati.com/tag/CSS" rel="tag"> CSS</a>, <a href="http://technorati.com/tag/PHP" rel="tag"> PHP</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.zachleat.com/web/2007/08/11/using-phing-to-automate-javascript-and-css-minimization/feed/</wfw:commentRss>
		</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 "Enlarging your YUI DataTable in 29 Seconds or Less!"
Do you want to fit more content onto your DataTable, but don't know how?  Do you wish that you had fewer columns, or more horizontal screen-estate?  [...]]]></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/">"Enlarging your YUI DataTable in 29 Seconds or Less!"</a></b></p>
<p>Do you want to fit more content onto your DataTable, but don'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't know in the world or we'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's that easy!  You don'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="syntax_hilite">
<div id="javascript-22">
<div class="javascript"><span style="color: #003366; font-weight: bold;">var</span> myDataTable = <span style="color: #003366; font-weight: bold;">new</span> YAHOO.<span style="color: #006600;">widget</span>.<span style="color: #006600;">DataTable</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"myContainer"</span>,myColumnSet,myDataSource<span style="color: #66cc66;">&#41;</span>;&nbsp; <br />
myDataTable.<span style="color: #006600;">subscribe</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"cellClickEvent"</span>, myDataTable.<span style="color: #006600;">onEventSelectRow</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #009900; font-style: italic;">// make sure you're firing the row selection event</span><br />
myDataTable.<span style="color: #006600;">subscribe</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"cellClickEvent"</span>, <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span> e <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp;<span style="color: #003366; font-weight: bold;">var</span> myCustomHtml = <span style="color: #3366CC;">'Hello, this is my expanded content.&lt;br /&gt;:-)&lt;br /&gt;'</span>; <span style="color: #009900; font-style: italic;">// generate the string, could use an ajax call if you wanted.</span><br />
&nbsp; &nbsp;YAHOO.<span style="color: #006600;">ymod</span>.<span style="color: #006600;">datatable</span>.<span style="color: #006600;">clickAndExpand</span>.<span style="color: #006600;">call</span><span style="color: #66cc66;">&#40;</span> <span style="color: #000066; font-weight: bold;">this</span>, e, myCustomHtml <span style="color: #66cc66;">&#41;</span>; <span style="color: #009900; 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><br />
<span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;</div>
</div>
</div>
<p></p>
<p>Library Code:</p>
<div class="syntax_hilite">
<div id="javascript-23">
<div class="javascript">YAHOO.<span style="color: #003366; font-weight: bold;">namespace</span><span style="color: #66cc66;">&#40;</span> <span style="color: #3366CC;">'YAHOO.ymod.datatable'</span> <span style="color: #66cc66;">&#41;</span>;<br />
YAHOO.<span style="color: #006600;">ymod</span>.<span style="color: #006600;">datatable</span>.<span style="color: #006600;">clickAndExpand</span> = <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span> e, expandedHtml <span style="color: #66cc66;">&#41;</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> selectedRows = <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #006600;">getSelectedRows</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span><span style="color: #66cc66;">&#40;</span> selectedRows.<span style="color: #006600;">length</span>&gt; <span style="color: #CC0000;">0</span> <span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span><span style="color: #66cc66;">&#40;</span> YAHOO.<span style="color: #006600;">util</span>.<span style="color: #006600;">Dom</span>.<span style="color: #006600;">hasClass</span><span style="color: #66cc66;">&#40;</span> selectedRows<span style="color: #66cc66;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #66cc66;">&#93;</span>, <span style="color: #3366CC;">'ymod-expandedData'</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; YAHOO.<span style="color: #006600;">util</span>.<span style="color: #006600;">Dom</span>.<span style="color: #006600;">removeClass</span><span style="color: #66cc66;">&#40;</span> selectedRows<span style="color: #66cc66;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">previousSibling</span>, <span style="color: #3366CC;">'expanded'</span> <span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; selectedRows<span style="color: #66cc66;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">parentNode</span>.<span style="color: #006600;">removeChild</span><span style="color: #66cc66;">&#40;</span> selectedRows<span style="color: #66cc66;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #66cc66;">&#93;</span> <span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #66cc66;">&#40;</span> !YAHOO.<span style="color: #006600;">util</span>.<span style="color: #006600;">Dom</span>.<span style="color: #006600;">hasClass</span><span style="color: #66cc66;">&#40;</span> selectedRows<span style="color: #66cc66;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #66cc66;">&#93;</span>, <span style="color: #3366CC;">'ymod-expanded'</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> newRow = document.<span style="color: #006600;">createElement</span><span style="color: #66cc66;">&#40;</span> <span style="color: #3366CC;">'tr'</span> <span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> newCell = document.<span style="color: #006600;">createElement</span><span style="color: #66cc66;">&#40;</span> <span style="color: #3366CC;">'td'</span> <span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> newDiv = document.<span style="color: #006600;">createElement</span><span style="color: #66cc66;">&#40;</span> <span style="color: #3366CC;">'div'</span> <span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; YAHOO.<span style="color: #006600;">util</span>.<span style="color: #006600;">Dom</span>.<span style="color: #006600;">addClass</span><span style="color: #66cc66;">&#40;</span> newDiv, <span style="color: #3366CC;">'ymod-expandedDataContent'</span> <span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span><span style="color: #66cc66;">&#40;</span> expandedHtml != <span style="color: #003366; font-weight: bold;">null</span> <span style="color: #66cc66;">&#41;</span> newDiv.<span style="color: #006600;">innerHTML</span> = expandedHtml;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; newCell.<span style="color: #006600;">appendChild</span><span style="color: #66cc66;">&#40;</span> newDiv <span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; newCell.<span style="color: #006600;">colSpan</span> = selectedRows<span style="color: #66cc66;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">childNodes</span>.<span style="color: #006600;">length</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; newRow.<span style="color: #006600;">appendChild</span><span style="color: #66cc66;">&#40;</span> newCell <span style="color: #66cc66;">&#41;</span>;&nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; YAHOO.<span style="color: #006600;">util</span>.<span style="color: #006600;">Dom</span>.<span style="color: #006600;">addClass</span><span style="color: #66cc66;">&#40;</span> newRow, <span style="color: #3366CC;">'ymod-expandedData'</span> <span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span><span style="color: #66cc66;">&#40;</span> YAHOO.<span style="color: #006600;">util</span>.<span style="color: #006600;">Dom</span>.<span style="color: #006600;">hasClass</span><span style="color: #66cc66;">&#40;</span> selectedRows<span style="color: #66cc66;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #66cc66;">&#93;</span>, <span style="color: #3366CC;">'yui-dt-odd'</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> YAHOO.<span style="color: #006600;">util</span>.<span style="color: #006600;">Dom</span>.<span style="color: #006600;">addClass</span><span style="color: #66cc66;">&#40;</span> newRow, <span style="color: #3366CC;">'yui-dt-odd'</span> <span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #66cc66;">&#40;</span> YAHOO.<span style="color: #006600;">util</span>.<span style="color: #006600;">Dom</span>.<span style="color: #006600;">hasClass</span><span style="color: #66cc66;">&#40;</span> selectedRows<span style="color: #66cc66;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #66cc66;">&#93;</span>, <span style="color: #3366CC;">'yui-dt-even'</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#41;</span> YAHOO.<span style="color: #006600;">util</span>.<span style="color: #006600;">Dom</span>.<span style="color: #006600;">addClass</span><span style="color: #66cc66;">&#40;</span> newRow, <span style="color: #3366CC;">'yui-dt-even'</span> <span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; YAHOO.<span style="color: #006600;">util</span>.<span style="color: #006600;">Dom</span>.<span style="color: #006600;">addClass</span><span style="color: #66cc66;">&#40;</span> selectedRows<span style="color: #66cc66;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #66cc66;">&#93;</span>, <span style="color: #3366CC;">'ymod-expanded'</span> <span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; selectedRows<span style="color: #66cc66;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">parentNode</span>.<span style="color: #006600;">insertBefore</span><span style="color: #66cc66;">&#40;</span> newRow, selectedRows<span style="color: #66cc66;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">nextSibling</span> <span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; YAHOO.<span style="color: #006600;">util</span>.<span style="color: #006600;">Event</span>.<span style="color: #006600;">addListener</span><span style="color: #66cc66;">&#40;</span> newRow, <span style="color: #3366CC;">'click'</span>, <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span> e <span style="color: #66cc66;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; YAHOO.<span style="color: #006600;">ymod</span>.<span style="color: #006600;">datatable</span>.<span style="color: #006600;">collapseRow</span><span style="color: #66cc66;">&#40;</span> <span style="color: #000066; font-weight: bold;">this</span> <span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; YAHOO.<span style="color: #006600;">util</span>.<span style="color: #006600;">Event</span>.<span style="color: #006600;">stopEvent</span><span style="color: #66cc66;">&#40;</span> e <span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; YAHOO.<span style="color: #006600;">util</span>.<span style="color: #006600;">Dom</span>.<span style="color: #006600;">removeClass</span><span style="color: #66cc66;">&#40;</span> selectedRows<span style="color: #66cc66;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #66cc66;">&#93;</span>, <span style="color: #3366CC;">'yui-dt-selected'</span> <span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; YAHOO.<span style="color: #006600;">util</span>.<span style="color: #006600;">Event</span>.<span style="color: #006600;">stopEvent</span><span style="color: #66cc66;">&#40;</span> e <span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> newDiv;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; selectedRows<span style="color: #66cc66;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">parentNode</span>.<span style="color: #006600;">removeChild</span><span style="color: #66cc66;">&#40;</span> selectedRows<span style="color: #66cc66;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">nextSibling</span> <span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; YAHOO.<span style="color: #006600;">util</span>.<span style="color: #006600;">Dom</span>.<span style="color: #006600;">removeClass</span><span style="color: #66cc66;">&#40;</span> selectedRows<span style="color: #66cc66;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #66cc66;">&#93;</span>, <span style="color: #3366CC;">'ymod-expanded'</span> <span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; YAHOO.<span style="color: #006600;">util</span>.<span style="color: #006600;">Dom</span>.<span style="color: #006600;">removeClass</span><span style="color: #66cc66;">&#40;</span> selectedRows<span style="color: #66cc66;">&#91;</span> <span style="color: #CC0000;">0</span> <span style="color: #66cc66;">&#93;</span>, <span style="color: #3366CC;">'yui-dt-selected'</span> <span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; YAHOO.<span style="color: #006600;">util</span>.<span style="color: #006600;">Event</span>.<span style="color: #006600;">stopEvent</span><span style="color: #66cc66;">&#40;</span> e <span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><br />
<span style="color: #66cc66;">&#125;</span>;</p>
<p><span style="color: #009900; font-style: italic;">// pass in the expanded content, NOT the parent row.</span><br />
YAHOO.<span style="color: #006600;">ymod</span>.<span style="color: #006600;">datatable</span>.<span style="color: #006600;">collapseRow</span> = <span style="color: #003366; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span> row <span style="color: #66cc66;">&#41;</span><br />
<span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; YAHOO.<span style="color: #006600;">util</span>.<span style="color: #006600;">Dom</span>.<span style="color: #006600;">removeClass</span><span style="color: #66cc66;">&#40;</span> row.<span style="color: #006600;">previousSibling</span>, <span style="color: #3366CC;">'ymod-expanded'</span> <span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; YAHOO.<span style="color: #006600;">util</span>.<span style="color: #006600;">Dom</span>.<span style="color: #006600;">removeClass</span><span style="color: #66cc66;">&#40;</span> row.<span style="color: #006600;">previousSibling</span>, <span style="color: #3366CC;">'yui-dt-selected'</span> <span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; row.<span style="color: #006600;">parentNode</span>.<span style="color: #006600;">removeChild</span><span style="color: #66cc66;">&#40;</span> row <span style="color: #66cc66;">&#41;</span>;<br />
<span style="color: #66cc66;">&#125;</span>;</div>
</div>
</div>
<p></p>
<p>Customize the CSS, if desired.</p>
<div class="syntax_hilite">
<div id="code-24">
<div class="code">.<span style="">yui</span>-dt-table tr.<span style="">ymod</span>-expandedData <span style="color:#006600; font-weight:bold;">&#123;</span> background-color: #bdcede; cursor: pointer; <span style="color:#006600; font-weight:bold;">&#125;</span><br />
.<span style="">yui</span>-dt-table tr.<span style="">ymod</span>-expandedData td <span style="color:#006600; font-weight:bold;">&#123;</span> padding-right: 5px; padding-bottom: 5px; white-space: normal; overflow: visible; <span style="color:#006600; font-weight:bold;">&#125;</span><br />
.<span style="">yui</span>-dt-table tr.<span style="">ymod</span>-expanded <span style="color:#006600; font-weight:bold;">&#123;</span> background-color: #bdcede; <span style="color:#006600; font-weight:bold;">&#125;</span><br />
.<span style="">yui</span>-dt-table tr.<span style="">ymod</span>-expanded td <span style="color:#006600; font-weight:bold;">&#123;</span> border-bottom: <span style="color:#800000;">0</span>; <span style="color:#006600; font-weight:bold;">&#125;</span><br />
.<span style="">yui</span>-dt-table div.<span style="">ymod</span>-expandedDataContent <span style="color:#006600; font-weight:bold;">&#123;</span> background-color: #f4f4f4; border: 1px inset #aaa; padding: 2px 5px; white-space: normal; zoom: <span style="color:#800000;">1</span>; overflow: hidden; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</div>
</div>
<p></p>
<p>You might even want to put a little + and - into the first column of each row to give a visual cue that there is more information for display available on click.</p>
<p>Technorati Tags: <a href="http://technorati.com/tag/YUI" rel="tag">YUI</a>, <a href="http://technorati.com/tag/DataTable" rel="tag"> DataTable</a>, <a href="http://technorati.com/tag/Grid" rel="tag"> Grid</a>, <a href="http://technorati.com/tag/YUI+DataTable" rel="tag"> YUI DataTable</a></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>
		</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[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'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'd think it [...]]]></description>
			<content:encoded><![CDATA[<p>The DataTable/Grid Component, the ball and chain of GUI components.  It doesn'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'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're going to work out those problems together, through better communication and more effective problem solving techniques.  We'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's review (but not play the blame game).</p>
<ul>
<li>Bug #1: Table headers weren'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 'Top' 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'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'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're in Standards Mode or Quirks Mode:</p>
<div class="syntax_hilite">
<div id="javascript-27">
<div class="javascript"><span style="color: #000066;">alert</span><span style="color: #66cc66;">&#40;</span> document.<span style="color: #006600;">compatMode</span>==<span style="color: #3366CC;">'CSS1Compat'</span> ? <span style="color: #3366CC;">'Standards Mode'</span> : <span style="color: #3366CC;">'Quirks Mode'</span> <span style="color: #66cc66;">&#41;</span>;</div>
</div>
</div>
<p></p>
<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's the CSS to go along with a horizontal scrolling DataTable:</p>
<div class="syntax_hilite">
<div id="code-28">
<div class="code">.<span style="">yui</span>-dt-table th, .<span style="">yui</span>-dt-table td <span style="color:#006600; font-weight:bold;">&#123;</span> padding: 2px <span style="color:#800000;">0</span> 2px 5px; vertical-align: top; <span style="color:#006600; font-weight:bold;">&#125;</span><br />
.<span style="">yui</span>-dt-table th, .<span style="">yui</span>-dt-table tr.<span style="">yui</span>-dt-first td <span style="color:#006600; font-weight:bold;">&#123;</span> width: 100px; <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#008000;">/* table header and only the first row (for drag and drop) */</span><br />
.<span style="">ymod</span>-scrollingBody .<span style="">yui</span>-dt-table tr.<span style="">yui</span>-dt-first td.<span style="">yui</span>-dt-last <span style="color:#006600; font-weight:bold;">&#123;</span> width: 84px; <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#008000;">/* last table cell (for crappy scrollbar problem) */</span><br />
.<span style="">yui</span>-dt-table .<span style="">yui</span>-dt-even <span style="color:#006600; font-weight:bold;">&#123;</span>background-color:#fff;<span style="color:#006600; font-weight:bold;">&#125;</span><br />
.<span style="">yui</span>-dt-table .<span style="">yui</span>-dt-odd <span style="color:#006600; font-weight:bold;">&#123;</span>background-color:#e0dfe0;<span style="color:#006600; font-weight:bold;">&#125;</span><br />
.<span style="">yui</span>-dt-table .<span style="">yui</span>-dt-selected <span style="color:#006600; font-weight:bold;">&#123;</span>background-color:#bdcede;<span style="color:#006600; font-weight:bold;">&#125;</span><br />
.<span style="">yui</span>-dt-table thead <span style="color:#006600; font-weight:bold;">&#123;</span>background-color:#933;color:#fff;<span style="color:#006600; font-weight:bold;">&#125;</span><br />
.<span style="">yui</span>-dt-table th a <span style="color:#006600; font-weight:bold;">&#123;</span>color:#fff ! important;<span style="color:#006600; font-weight:bold;">&#125;</span><br />
.<span style="">ymod</span>-scrollingHeader <span style="color:#006600; font-weight:bold;">&#123;</span><br />
&nbsp; &nbsp; width: <span style="color:#800000;">100</span>%;<br />
&nbsp; &nbsp; height: 20px;<br />
&nbsp; &nbsp; overflow: hidden;<br />
&nbsp; &nbsp; position: relative;<br />
<span style="color:#006600; font-weight:bold;">&#125;</span><br />
.<span style="">ymod</span>-nestedHeaders <span style="color:#006600; font-weight:bold;">&#123;</span><br />
&nbsp; &nbsp; height: 40px; <span style="color:#008000;">/* gotta set this manually, unfortunately */</span><br />
<span style="color:#006600; font-weight:bold;">&#125;</span><br />
.<span style="">ymod</span>-scrollingHeader table <span style="color:#006600; font-weight:bold;">&#123;</span><br />
&nbsp; &nbsp; position: absolute;<br />
&nbsp; &nbsp; top: <span style="color:#800000;">0</span>;<br />
&nbsp; &nbsp; left: <span style="color:#800000;">0</span>;<br />
<span style="color:#006600; font-weight:bold;">&#125;</span><br />
.<span style="">ymod</span>-scrollingBody <span style="color:#006600; font-weight:bold;">&#123;</span><br />
&nbsp; &nbsp; width: <span style="color:#800000;">100</span>%;<br />
&nbsp; &nbsp; overflow: auto;<br />
&nbsp; &nbsp; height: 160px;<br />
<span style="color:#006600; font-weight:bold;">&#125;</span><br />
.<span style="">ymod</span>-scrollingHeader table <span style="color:#006600; font-weight:bold;">&#123;</span> width: 800px; <span style="color:#006600; font-weight:bold;">&#125;</span> <span style="color:#008000;">/* Set your widths! */</span><br />
.<span style="">ymod</span>-scrollingBody table <span style="color:#006600; font-weight:bold;">&#123;</span> width: 784px; <span style="color:#006600; font-weight:bold;">&#125;</span></div>
</div>
</div>
<p></p>
<p>Technorati Tags: <a href="http://technorati.com/tag/JennyHanDonnelly" rel="tag">JennyHanDonnelly</a>, <a href="http://technorati.com/tag/YUI" rel="tag"> YUI</a>, <a href="http://technorati.com/tag/DataTable" rel="tag"> DataTable</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.zachleat.com/web/2007/04/30/yui-datatable-and-you-making-the-marriage-work/feed/</wfw:commentRss>
		</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'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 [...]]]></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'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're going to create the i-frame dynamically using document.createElement.  Let's start out with some successful code.</p>
<div class="syntax_hilite">
<div id="javascript-30">
<div class="javascript"><span style="color: #003366; font-weight: bold;">var</span> iframeShim = document.<span style="color: #006600;">createElement</span><span style="color: #66cc66;">&#40;</span> <span style="color: #3366CC;">'iframe'</span> <span style="color: #66cc66;">&#41;</span>;<br />
iframeShim.<span style="color: #006600;">setAttribute</span><span style="color: #66cc66;">&#40;</span> <span style="color: #3366CC;">'src'</span>, <span style="color: #3366CC;">'javascript:false;document.write(”&quot;);'</span> <span style="color: #66cc66;">&#41;</span>;<br />
iframeShim.<span style="color: #006600;">setAttribute</span><span style="color: #66cc66;">&#40;</span> <span style="color: #3366CC;">'frameBorder'</span>, <span style="color: #3366CC;">'0'</span> <span style="color: #66cc66;">&#41;</span>;</div>
</div>
</div>
<p></p>
<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'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 'false' 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>: The correct solution is in face setting "javascript:false;document.write(”");" 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.</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>
		</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[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'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 [...]]]></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'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="syntax_hilite">
<div id="code-34">
<div class="code">#modules .<span style="">yui</span>-b<span style="color:#006600; font-weight:bold;">&#123;</span>position:static;display:block;margin:<span style="color:#800000;">0</span> <span style="color:#800000;">0</span> 1em <span style="color:#800000;">0</span>;float:none;width:auto;overflow:hidden;<span style="color:#006600; font-weight:bold;">&#125;</span><br />
.<span style="">yui</span>-gb .<span style="">yui</span>-u<span style="color:#006600; font-weight:bold;">&#123;</span>float:left;margin-left:<span style="color:#800000;">2</span>%;*margin-left:<span style="color:#800000;">1</span>.<span style="color:#800000;">895</span>%;width:<span style="color:#800000;">32</span>%;<span style="color:#006600; font-weight:bold;">&#125;</span><br />
.<span style="">yui</span>-gb div.<span style="">first</span><span style="color:#006600; font-weight:bold;">&#123;</span>margin-left:<span style="color:#800000;">0</span>;<span style="color:#006600; font-weight:bold;">&#125;</span><br />
#modules,.<span style="">yui</span>-gb<span style="color:#006600; font-weight:bold;">&#123;</span>zoom:<span style="color:#800000;">1</span>;<span style="color:#006600; font-weight:bold;">&#125;</span></div>
</div>
</div>
<p></p>
<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="syntax_hilite">
<div id="code-35">
<div class="code">#yui-main .<span style="">yui</span>-b<span style="color:#006600; font-weight:bold;">&#123;</span>position:static;<span style="color:#006600; font-weight:bold;">&#125;</span><br />
.<span style="">yui</span>-t7 #yui-main .<span style="">yui</span>-b <span style="color:#006600; font-weight:bold;">&#123;</span><br />
&nbsp; &nbsp; display:block;margin:<span style="color:#800000;">0</span> <span style="color:#800000;">0</span> 1em <span style="color:#800000;">0</span>;<br />
<span style="color:#006600; font-weight:bold;">&#125;</span><br />
#yui-main .<span style="">yui</span>-b <span style="color:#006600; font-weight:bold;">&#123;</span>float:none;width:auto;<span style="color:#006600; font-weight:bold;">&#125;</span><br />
.<span style="">yui</span>-gb .<span style="">yui</span>-u<span style="color:#006600; font-weight:bold;">&#123;</span>float:left;margin-left:<span style="color:#800000;">2</span>%;*margin-left:<span style="color:#800000;">1</span>.<span style="color:#800000;">895</span>%;width:<span style="color:#800000;">32</span>%;<span style="color:#006600; font-weight:bold;">&#125;</span><br />
.<span style="">yui</span>-gb div.<span style="">first</span><span style="color:#006600; font-weight:bold;">&#123;</span>margin-left:<span style="color:#800000;">0</span>;<span style="color:#006600; font-weight:bold;">&#125;</span><br />
#bd,.<span style="">yui</span>-gb<span style="color:#006600; font-weight:bold;">&#123;</span>zoom:<span style="color:#800000;">1</span>;<span style="color:#006600; font-weight:bold;">&#125;</span></div>
</div>
</div>
<p></p>
<p>Obviously, it'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'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'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="syntax_hilite">
<div id="code-36">
<div class="code"><span style="color:#008000;">/* ===============BEGIN BSD LICENSED PORTION============= */</span><br />
<span style="color:#008000;">/*<br />
Copyright (c) 2007, Yahoo! Inc. All rights reserved.<br />
Code licensed under the BSD License:<br />
http://developer.yahoo.net/yui/license.txt<br />
version: 2.2.0<br />
*/</span></p>
<p>#modules .<span style="">yui</span>-b <span style="color:#006600; font-weight:bold;">&#123;</span><br />
&nbsp; position:static;<br />
&nbsp; display:block;<br />
&nbsp; margin:<span style="color:#800000;">0</span> <span style="color:#800000;">0</span> 1em <span style="color:#800000;">0</span>;<br />
&nbsp; float:none;<br />
&nbsp; width:auto;<br />
&nbsp; overflow:hidden;<br />
<span style="color:#006600; font-weight:bold;">&#125;</span><br />
.<span style="">yui</span>-gb .<span style="">yui</span>-u <span style="color:#006600; font-weight:bold;">&#123;</span><br />
&nbsp; float:left;<br />
&nbsp; margin-left:<span style="color:#800000;">2</span>%;<br />
&nbsp; *margin-left:<span style="color:#800000;">1</span>.<span style="color:#800000;">895</span>%;<br />
&nbsp; width:<span style="color:#800000;">32</span>%;<br />
<span style="color:#006600; font-weight:bold;">&#125;</span><br />
.<span style="">yui</span>-gb div.<span style="">first</span> <span style="color:#006600; font-weight:bold;">&#123;</span><br />
&nbsp; margin-left:<span style="color:#800000;">0</span>;<br />
<span style="color:#006600; font-weight:bold;">&#125;</span><br />
#modules,.<span style="">yui</span>-gb <span style="color:#006600; font-weight:bold;">&#123;</span><br />
&nbsp; zoom:<span style="color:#800000;">1</span>;<br />
<span style="color:#006600; font-weight:bold;">&#125;</span><br />
<span style="color:#008000;">/* ===============END BSD LICENSED PORTION============= */</span></div>
</div>
</div>
<p>
Sorry to everyone visiting the page for the extra millisecond or two it will take to load these comments.</p>
<p>Technorati Tags: <a href="http://technorati.com/tag/YUI" rel="tag">YUI</a>, <a href="http://technorati.com/tag/Grids" rel="tag"> Grids</a>, <a href="http://technorati.com/tag/CSS" rel="tag"> CSS</a>, <a href="http://technorati.com/tag/Licensing" rel="tag"> Licensing</a>, <a href="http://technorati.com/tag/Google" rel="tag"> Google</a>, <a href="http://technorati.com/tag/Yahoo" rel="tag"> Yahoo</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.zachleat.com/web/2007/04/05/google-using-yui-grids-css/feed/</wfw:commentRss>
		</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[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'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'm going to turn to YUI compatible components.  First, [...]]]></description>
			<content:encoded><![CDATA[<p>If you have read anything I'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'm going to turn to YUI compatible components.  First, I looked at Jack Slocum's EXT, which has a nice looking Grid component that had a lot of features I wouldn't need, but I didn'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'm going for:</p>
<p><strong>Minimum Feature Set</strong>:</p>
<ul>
<li>Client-Side Sorting: I don'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'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'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'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't make me click numbered links, load the data automatically when I scroll) both on the client (dynamically insert only what I'm looking at and remove what I'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's a mess.  The only viable option here is to let the table do it's own width calculations.  You can'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't a deal breaker, since I classified this feature as a luxury item.</li>
</ul>
<p>Granted, the DataTable in it'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="syntax_hilite">
<div id="code-38">
<div class="code">div#dataTableId <span style="color:#006600; font-weight:bold;">&#123;</span> <span style="color:#008000;">/* change this to whatever id you're using to hold the dataTable */</span><br />
&nbsp; &nbsp; width:520px; <span style="color:#008000;">/* put in your own fixed width */</span><br />
&nbsp; &nbsp; overflow-x:auto;<br />
&nbsp; &nbsp; overflow-y:hidden;<br />
<span style="color:#006600; font-weight:bold;">&#125;</span><br />
.<span style="">yui</span>-dt-headtext, .<span style="">yui</span>-dt-headcontainer <span style="color:#006600; font-weight:bold;">&#123;</span><br />
&nbsp; &nbsp; position: static; <span style="color:#008000;">/* without this declaration, the headers weren't horizontally scrolling with the data in IE6 */</span><br />
<span style="color:#006600; font-weight:bold;">&#125;</span></div>
</div>
</div>
<p></p>
<p>Technorati Tags: <a href="http://technorati.com/tag/YUI" rel="tag">YUI</a>, <a href="http://technorati.com/tag/DataTable" rel="tag"> DataTable</a>, <a href="http://technorati.com/tag/Grid" rel="tag"> Grid</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.zachleat.com/web/2007/04/04/problems-with-yui-datatable/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
