<?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>Garrick Cheung</title>
	<atom:link href="http://www.garrickcheung.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.garrickcheung.com</link>
	<description>Sharing what I know and learn about CSS, MooTools, Javascript, PHP and etc.</description>
	<lastBuildDate>Wed, 28 Apr 2010 02:52:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>MooTools 1.3 Beta!!</title>
		<link>http://www.garrickcheung.com/uncategorized/mootools-1-3-beta/</link>
		<comments>http://www.garrickcheung.com/uncategorized/mootools-1-3-beta/#comments</comments>
		<pubDate>Wed, 28 Apr 2010 02:52:47 +0000</pubDate>
		<dc:creator>Garrick</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.garrickcheung.com/?p=369</guid>
		<description><![CDATA[MooTools 1.3 Beta was just released. You can check out the blog entry for all the details. I&#8217;ll let you in on one thing that&#8217;s in it. Slick. Oh yeah, I&#8217;m still alive, if you were wondering..]]></description>
			<content:encoded><![CDATA[<p><a href="http://mootools.net/blog/2010/04/27/mootools-1-3-beta-1/">MooTools 1.3 Beta</a> was just released. You can check out the blog entry for all the details. I&#8217;ll let you in on one thing that&#8217;s in it. Slick.</p>
<p>Oh yeah, I&#8217;m still alive, if you were wondering.. <img src='http://www.garrickcheung.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.garrickcheung.com/uncategorized/mootools-1-3-beta/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Building on David Walshes MooTools Tip: Event.stop</title>
		<link>http://www.garrickcheung.com/mootools/mootools-tip-event-stop/</link>
		<comments>http://www.garrickcheung.com/mootools/mootools-tip-event-stop/#comments</comments>
		<pubDate>Wed, 30 Dec 2009 02:56:45 +0000</pubDate>
		<dc:creator>Garrick</dc:creator>
				<category><![CDATA[MooTools]]></category>

		<guid isPermaLink="false">http://www.garrickcheung.com/?p=362</guid>
		<description><![CDATA[David Walsh shared a tip on how he handles firing events on an element without user input to trigger the event. I&#8217;m going to build on that by sharing how I would handle it. Problem The issue is that usually an event is added and the default behavior is disabled. 1 2 3 4 $&#40;'myLink'&#41;.addEvent&#40;'click',function&#40;e&#41; [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://davidwalsh.name/mootools-event-stop">David Walsh shared a tip</a> on how he handles firing events on an element without user input to trigger the event. I&#8217;m going to build on that by sharing how I would handle it.<span id="more-362"></span></p>
<h3>Problem</h3>
<p>The issue is that usually an event is added and the default behavior is disabled.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'myLink'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addEvent</span><span style="color: #009900;">&#40;</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>
    e.<span style="color: #000066;">stop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #006600; font-style: italic;">//do stuff</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>And if you just so happen to need to trigger the event manually, like so:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'myLink'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fireEvent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'click'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>You&#8217;ll get an error that the stop method doesn&#8217;t exist. This is because you&#8217;re just firing the function and an event argument is not being passed into the function.</p>
<p>Now, lets say you have a class and you wanted to manually execute a method that&#8217;s being attached to an event. An error would also occur in this case.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> myClass <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> <span style="color: #003366; font-weight: bold;">Class</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #006600; font-style: italic;">// ... some code here..</span>
&nbsp;
    <span style="color: #006600; font-style: italic;">// the click event function that is attached..</span>
    clicky<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>
        e.<span style="color: #000066;">stop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #006600; font-style: italic;">//.. do some clicky stuff</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// create instance of class</span>
<span style="color: #003366; font-weight: bold;">var</span> instance_of_myClass <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> myClass<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// firing clicky function</span>
instance_of_myClass.<span style="color: #660066;">clicky</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// results in error because stop() does not exist</span></pre></td></tr></table></div>

<h3>Solution</h3>
<p>Here&#8217;s how you can solve both problems, and I learned this from <a href="http://keetology.com/">Mark Obcena</a>. This is very useful if you don&#8217;t want to modify the classes code or extend it. Pass in a dummy object with an empty stop function:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// this will fire the click event without an issue</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'myLink'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">fireEvent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span><span style="color: #000066;">stop</span><span style="color: #339933;">:</span>$empty<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// this too will fire the clicky function on the instance without an issue</span>
instance_of_myClass.<span style="color: #660066;">clicky</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #000066;">stop</span><span style="color: #339933;">:</span>$empty<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Tada! Thanks David and Mark!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.garrickcheung.com/mootools/mootools-tip-event-stop/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Announcing: MooTools Forge!</title>
		<link>http://www.garrickcheung.com/mootools/announcing-mootools-forge/</link>
		<comments>http://www.garrickcheung.com/mootools/announcing-mootools-forge/#comments</comments>
		<pubDate>Thu, 10 Dec 2009 21:24:01 +0000</pubDate>
		<dc:creator>Garrick</dc:creator>
				<category><![CDATA[MooTools]]></category>

		<guid isPermaLink="false">http://www.garrickcheung.com/?p=359</guid>
		<description><![CDATA[Exciting news! MooTools has just announced their plugin repository, MooTools Forge! It&#8217;s hooked into GitHub and it&#8217;s open sourced. How awesome! Check out all the details from the MooTools blog!]]></description>
			<content:encoded><![CDATA[<p>Exciting news! <a href="http://mootools.net">MooTools</a> has just announced their plugin repository, <a href="http://mootools.net/forge/">MooTools Forge</a>! It&#8217;s hooked into <a href="http://www.github.com">GitHub</a> and it&#8217;s open sourced. How awesome!</p>
<p>Check out all the details from the <a href="http://mootools.net/blog/2009/12/10/the-official-mootools-plugins-repository-is-here/">MooTools blog</a>!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.garrickcheung.com/mootools/announcing-mootools-forge/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Released: MooTools 1.2.3</title>
		<link>http://www.garrickcheung.com/mootools/released-mootools-123/</link>
		<comments>http://www.garrickcheung.com/mootools/released-mootools-123/#comments</comments>
		<pubDate>Fri, 19 Jun 2009 22:18:15 +0000</pubDate>
		<dc:creator>Garrick</dc:creator>
				<category><![CDATA[MooTools]]></category>

		<guid isPermaLink="false">http://www.garrickcheung.com/?p=349</guid>
		<description><![CDATA[I&#8217;m excited to tell you that MooTools 1.2.3 has been released today! It&#8217;s mainly bug fixes and updates. One major change is compatibility with other frameworks. Like the MooTools-Dev team, I do not advise using more than one framework. But if you have to.. then you have to. See below for a list of changes, [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m excited to tell you that <a href="http://mootools.net/blog/2009/06/19/mootools-123-released/" target="_blank">MooTools 1.2.3</a> has been released today! It&#8217;s mainly bug fixes and updates. One major change is compatibility with other frameworks. Like the MooTools-Dev team, I do not advise using more than one framework. But if you have to.. then you have to. See below for a list of changes, straight from the cows mouth!<span id="more-349"></span></p>
<p><strong>Core</strong></p>
<ul>
<li>Element: MooTools compatibility mode: the $ function is only defined if no pre-existing $ function is found. If an existing $ function is found, you can use document.id()</li>
<li>Element: changed internal instances of $ to document.id</li>
<li>Core: fix for server-side MS JScript 5.x; makes MooTools more friendly for server side programming</li>
<li>Class: Class doesn’t require Browser, removed from scripts.json</li>
<li>Element: Fixes for set/get Property</li>
<li>Element.Dimensions: fix for webkit body.scrollTop inconsistency, getBoundingClientRect used whenever possible (not just for Trident), renaming element.position to element.setPosition; adding docs for the method; alias is included in-line for compatibility</li>
<li>Hash: Hash extend no longer uses the window if no arguments supplied</li>
<li>Request: clearing Request readystate before calling success or failure;</li>
<li>Selectors: Added :enabled pseudoselector, was in the Docs but not implemented.</li>
<li>Docs: Fixed docs headers for first-child, last-child, and only-child.</li>
<li>Internal: UnitTester test suite is now a git submodule</li>
<li>Numerous small fixes, speed improvements, documentation tweaks, etc.</li>
</ul>
<p><strong>More</strong></p>
<ul>
<li>Per the change in -core, $ is no longer used (uses document.id instead)</li>
<li>Element.Measure: trying cssText solution for Element.expose (again).</li>
<li>Element.Forms: swapping feature detection for browser support per</li>
<li>Date: Massive refactoring of Date.js and Date.Extras.js</li>
<li>Drag.Move: Fixing drag with grid issues</li>
<li>IframeShim: altering zindex assignment in IframeShim to better ensure that it’s always underneath the shimmed element, updating Iframeshim’s empty document creation; fixes https issues in IE6</li>
<li>FormValidator: reworking formvalidator scroll-to logic to be a little more efficient</li>
<li>OverText: preventing overtext from focusing on inputs except when they are interacted with (so OverText.update() does not focus an input);now stops polling when elements are hidden (when polling is enabled)</li>
<li>Fx.Scroll: adding scrollIntoView method &#8211; scrolls an element so that it is completely visible; if below the view, scrolls down until it is at the bottom of the screen, if above, scrolls up until it is at the top.</li>
<li>JSONP: was calling (the deprecated) this.request instead of this.send during retries</li>
<li>URI: Adding set(‘data’, obj) to set</li>
<li>Assets: adding error callback for Assets.images</li>
<li>Tips: removing dependency for Element.Measure for Tips; updating CSS class name in OverText</li>
<li>Numerous small fixes, speed improvements, documentation tweaks, etc.</li>
</ul>
<p>Great job MooTools-Dev team!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.garrickcheung.com/mootools/released-mootools-123/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Search Stylesheet Selectors with MooTools</title>
		<link>http://www.garrickcheung.com/css/search-stylesheet-selectors-with-mootools/</link>
		<comments>http://www.garrickcheung.com/css/search-stylesheet-selectors-with-mootools/#comments</comments>
		<pubDate>Fri, 12 Jun 2009 22:30:52 +0000</pubDate>
		<dc:creator>Garrick</dc:creator>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[MooTools]]></category>
		<category><![CDATA[selector]]></category>

		<guid isPermaLink="false">http://www.garrickcheung.com/?p=340</guid>
		<description><![CDATA[You should already know that MooTools has Fx.Morph, that allows you to animate multiple css properties on an element and you can also pass it a selector string so you don&#8217;t have to type out all of the properties. Well, you can also pull these properties by using an undocumented method in MooTools, as I [...]]]></description>
			<content:encoded><![CDATA[<p>You should already know that MooTools has Fx.Morph, that allows you to animate multiple css properties on an element and you can also pass it a selector string so you don&#8217;t have to type out all of the properties.</p>
<p>Well, you can also pull these properties by using an undocumented method in MooTools, as I just learned from <a href="http://keetology.com/" target="_blank">Mark Obcena</a>. How? It&#8217;s very simple as you will see.<span id="more-340"></span></p>
<h3>Code</h3>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> selector_rules <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Fx.<span style="color: #660066;">CSS</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">search</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.some_class'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #006600; font-style: italic;">// returns an object with camelCase key's</span></pre></td></tr></table></div>

<p>See, isn&#8217;t that simple? Keep in mind that this doesn&#8217;t give you every single property. In my tests of running this code with Firebug on <a href="http://www.gamespot.com" target="_blank">GameSpot.com</a>, font-family and overflow properties were missing in the returned object when it clearly shows up in Firebug&#8217;s CSS panel.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.garrickcheung.com/css/search-stylesheet-selectors-with-mootools/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MooTools TextOverlay Class</title>
		<link>http://www.garrickcheung.com/mootools/textoverlay-class/</link>
		<comments>http://www.garrickcheung.com/mootools/textoverlay-class/#comments</comments>
		<pubDate>Tue, 19 May 2009 06:55:50 +0000</pubDate>
		<dc:creator>Garrick</dc:creator>
				<category><![CDATA[MooTools]]></category>
		<category><![CDATA[MoreSimple]]></category>

		<guid isPermaLink="false">http://www.garrickcheung.com/?p=328</guid>
		<description><![CDATA[Some classes I&#8217;ve come across do a lot and are inflexible. I&#8217;ve seen some that are semantically incorrect when it comes to creating/using elements that the user has no control over. So I&#8217;ve been mulling over the idea of rewriting/cleaning/correcting some of these classes that I come across in hopes to make them flexible and [...]]]></description>
			<content:encoded><![CDATA[<p>Some classes I&#8217;ve come across do a lot and are inflexible. I&#8217;ve seen some that are semantically incorrect when it comes to creating/using elements that the user has no control over. So I&#8217;ve been mulling over the idea of rewriting/cleaning/correcting some of these classes that I come across in hopes to make them flexible and simple. Well, I decided to have a go at it, obviously</p>
<p>I understand it&#8217;s like re-inventing the wheel. But in order to improve, we should always scrutinize work because a better solution may be available.</p>
<p>Here&#8217;s my first attempt, with the MooTools class, TextOverlay. If you look closely, it&#8217;s MooTools-More OverText modified to give the user more options.<span id="more-328"></span></p>
<h3>What&#8217;s the Difference?</h3>
<p>You must be wondering what&#8217;s different between the two. Well, I felt that positioning of the element should be handled by css, so I removed the reposition method. In OverText, the text-overlaying was created for you with MooTools and the default element was a &#8216;div&#8217; with &#8216;label&#8217; as your option.  I did away with that and you now can either pass in an existing DOM element, or create one on the fly (though you&#8217;ll need to inject it into the DOM yourself). OverText &#8216;show&#8217; and &#8216;hide&#8217; methods explicitly call&#8217;s the text-overlay&#8217;s show/hide methods and then fires custom events &#8216;textShow&#8217; and &#8216;textHide&#8217;. I decided to give the user flexibility by removing the explicit call&#8217;s to the text-overlay&#8217;s and only firing the custom events.</p>
<h3>Example</h3>
<p>The HTML, CSS, and JavaScript below is an example of how to set things up.</p>
<p><strong>HTML</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code"><pre class="html" style="font-family:monospace;">&lt;div class=&quot;container&quot;&gt;
    &lt;form id=&quot;textoverlay_test&quot; name=&quot;textoverlay_test&quot; action=&quot;&quot; method=&quot;post&quot;&gt;
        &lt;fieldset&gt;
            &lt;legend&gt;&lt;/legend&gt;
            &lt;div class=&quot;fields&quot;&gt;
                &lt;input id=&quot;first_name&quot; type=&quot;text&quot; name=&quot;first_name&quot; value=&quot;&quot; /&gt;
                &lt;label for=&quot;first_name&quot;&gt;First Name&lt;/label&gt;
            &lt;/div&gt;
            &lt;div class=&quot;fields&quot;&gt;
                &lt;input type=&quot;text&quot; name=&quot;last_name&quot; value=&quot;&quot; /&gt;
                &lt;label for=&quot;last_name&quot;&gt;Last Name&lt;/label&gt;
            &lt;/div&gt;
        &lt;/fieldset&gt;
    &lt;/form&gt;
&lt;/div&gt;</pre></td></tr></table></div>

<p><strong>CSS</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.container</span> <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">500px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
input<span style="color: #00AA00;">,</span> label <span style="color: #00AA00;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">border</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</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;">font</span><span style="color: #00AA00;">:</span><span style="color: #933;">11px</span> arial<span style="color: #00AA00;">,</span> veranda<span style="color: #00AA00;">,</span> helvetica<span style="color: #00AA00;">,</span> <span style="color: #993333;">sans-serif</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">16px</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">line-height</span><span style="color: #00AA00;">:</span><span style="color: #933;">16px</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: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span> <span style="color: #933;">5px</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;">100</span>%</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
label <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: #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: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">-16px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
<span style="color: #6666ff;">.fields</span> <span style="color: #00AA00;">&#123;</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;">solid</span> <span style="color: #cc00cc;">#333</span><span style="color: #00AA00;">;</span>
    <span style="color: #000000; font-weight: bold;">margin-bottom</span><span style="color: #00AA00;">:</span><span style="color: #933;">10px</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;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p><strong>JavaScript</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">window.<span style="color: #660066;">addEvent</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'domready'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> input<span style="color: #339933;">,</span> label<span style="color: #339933;">,</span> fields <span style="color: #339933;">=</span> $$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'#textoverlay_test .fields'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">item</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #003366; font-weight: bold;">new</span> TextOverlay<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">item</span>.<span style="color: #660066;">getElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'input'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">item</span>.<span style="color: #660066;">getElement</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'label'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #009900;">&#123;</span>
            onTextHide<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>element<span style="color: #339933;">,</span> text<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                text.<span style="color: #660066;">setStyle</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'display'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'none'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'hide'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//added to differentiate from default textHide event</span>
            <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
            onTextShow<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>element<span style="color: #339933;">,</span> text<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
                text.<span style="color: #660066;">setStyle</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'display'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'block'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'show'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//added to differentiate from default textShow event</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span><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>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Doing all this should simplify things and decrease the number of function calls. If you did a &#8216;console.profile&#8217; in Firebug, I&#8217;m sure you&#8217;ll notice the difference between OverText and TextOverlay. Give it a try and let me know what you think! I&#8217;ve set it up in <a href="http://github.com/GCheung55/MoreSimple/" target="_blank">Github</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.garrickcheung.com/mootools/textoverlay-class/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>MooTools FileManager by Christoph Pojer</title>
		<link>http://www.garrickcheung.com/uncategorized/mootools-filemanager-by-christoph-pojer/</link>
		<comments>http://www.garrickcheung.com/uncategorized/mootools-filemanager-by-christoph-pojer/#comments</comments>
		<pubDate>Wed, 29 Apr 2009 21:23:29 +0000</pubDate>
		<dc:creator>Garrick</dc:creator>
				<category><![CDATA[MooTools]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[file manager]]></category>

		<guid isPermaLink="false">http://www.garrickcheung.com/?p=322</guid>
		<description><![CDATA[Christoph, one of MooTools&#8217; developers and creator of Styx, a PHP framework, created a MooTools based File Manager. I&#8217;ve tried out his demos, and everything seems VERY slick. It has loads of features too. Features (straight from the horses mouth) Browse through Files and Folders on your Server Rename, Delete, Move (Drag&#38;Drop), Copy (Drag + [...]]]></description>
			<content:encoded><![CDATA[<p>Christoph, one of MooTools&#8217; developers and creator of <a href="http://styx.og5.net/" target="_blank">Styx, a PHP framework</a>, <a href="http://og5.net/christoph/article/MooTools_based_FileManager" target="_blank">created a MooTools based File Manager</a>. I&#8217;ve tried out his demos, and everything seems VERY slick. It has loads of features too.<span id="more-322"></span></p>
<p><strong>Features</strong> (straight from the horses mouth)</p>
<ul>
<li>Browse through Files and Folders on your Server</li>
<li>Rename, Delete, Move (Drag&amp;Drop), Copy (Drag + hold CTRL) and Download Files</li>
<li>View detailed Previews of Images, Text-Files, Compressed-Files or Audio Content</li>
<li>Nice User Interface <img src='http://www.garrickcheung.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </li>
<li>Upload Files via FancyUpload (integrated Feature)</li>
<li>Option to automatically resize big Images when uploading</li>
<li>Use it to select a File anywhere you need to specify one inside your Application&#8217;s Backend</li>
<li>Use as a FileManager in TinyMCE</li>
<li>Provides your Client with the most possible convenience ( ;D )</li>
</ul>
<p>The back-end is in PHP but you can port it to whatever language you&#8217;re working with. The file manager is also released under the MIT-License. This is currently his RC1 (1st release candidate, for those not in the know). <a href="http://og5.net/christoph/article/MooTools_based_FileManager" target="_blank">Head over to check out his demos</a>!</p>
<p>Great job, Christoph!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.garrickcheung.com/uncategorized/mootools-filemanager-by-christoph-pojer/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>MooTools 1.2.2 and More Released!</title>
		<link>http://www.garrickcheung.com/mootools/mootools-122-and-more-released/</link>
		<comments>http://www.garrickcheung.com/mootools/mootools-122-and-more-released/#comments</comments>
		<pubDate>Fri, 24 Apr 2009 01:31:19 +0000</pubDate>
		<dc:creator>Garrick</dc:creator>
				<category><![CDATA[MooTools]]></category>

		<guid isPermaLink="false">http://www.garrickcheung.com/?p=318</guid>
		<description><![CDATA[Valerio Proietti just posted the release of MooTools 1.2.2 and MooTools More (1.2.2.1). Looks like there are some goodies from the Core: MooTools 1.2.2 is a mainly a bug fix release but it also includes an almost entirely new Class.js. The reasoning behind this is that the old Class.js didn’t play nicely with some advanced [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://mootools.net/blog/2009/04/23/mootools-122-and-the-new-mootools-more/" target="_blank"> Valerio Proietti just posted the release of MooTools 1.2.2 and MooTools More (1.2.2.1)</a>.</p>
<p>Looks like there are some goodies from the Core:</p>
<blockquote><p>
MooTools 1.2.2 is a mainly a bug fix release but it also includes an almost entirely new Class.js. The reasoning behind this is that the old Class.js didn’t play nicely with some advanced usages of this.parent() present in the new MooTools-More. We already had the script ready and tested in the MooTools 2.0 branch so we simply “backported” it to 1.2.2. Other than providing the parent fixes, the new Class also features a much more robust inheritance model, especially when dealing with objects.
</p></blockquote>
<p>And something for the More:</p>
<blockquote><p>One of the new features of MooTools-More, since the last RC, is that it is now possible access the previous state of overwritten methods of classes through Class.refractor.</p></blockquote>
<p>And last bit of exciting news: quick/regular new feature bi-weekly releases.</p>
<p>Way to go team! Thank you for the awesome work!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.garrickcheung.com/mootools/mootools-122-and-more-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Smarty Debug with Firebug</title>
		<link>http://www.garrickcheung.com/javascript/smarty-debug-with-firebug/</link>
		<comments>http://www.garrickcheung.com/javascript/smarty-debug-with-firebug/#comments</comments>
		<pubDate>Thu, 16 Apr 2009 23:44:44 +0000</pubDate>
		<dc:creator>Garrick</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Smarty]]></category>

		<guid isPermaLink="false">http://www.garrickcheung.com/?p=314</guid>
		<description><![CDATA[I use Smarty, a template engine, at work. One of the most awesome things about it is the debug window, where it can list all the templates being used and variables that are available. Mike Horn shared with me how a user, named Hipska, created a Smarty debug template file that works with Firebug. I [...]]]></description>
			<content:encoded><![CDATA[<p>I use <a href="http://www.smarty.net" target="_blank">Smarty</a>, a template engine, at work. One of the most awesome things about it is the debug window, where it can list all the templates being used and variables that are available.</p>
<p><a href="http://www.thegpbkids.com/" target="_blank">Mike Horn</a> shared with me how a <a href="http://www.phphulp.nl/php/print/5/1540/0/scripts/" target="_blank">user, named Hipska, created a Smarty debug template</a> file that works with Firebug. I thought it was so awesome and decided to share it with you too, but with a slight tweak of my own.<span id="more-314"></span></p>
<h3>The Code</h3>
<p>Here&#8217;s the code. I&#8217;ll explain how it works right after.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
</pre></td><td class="code"><pre class="smarty" style="font-family:monospace;"><span style="color: #008080; font-style: italic;">{* Smarty *}</span>
<span style="color: #008080; font-style: italic;">{* debug.tpl, firebug version by Hipska, tweaked by GarrickCheung *}</span>
<span style="color: #D36900;">&#123;</span>assign_debug_info<span style="color: #D36900;">&#125;</span>
<span style="color: #D36900;">&#123;</span><span style="color: #0600FF;">if</span> <span style="color: #0600FF;">isset</span><span style="color: #D36900;">&#40;</span>$_smarty_debug_output<span style="color: #D36900;">&#41;</span> and $_smarty_debug_output <span style="color: #D36900;">eq</span> <span style="color: #ff0000;">&quot;html&quot;</span><span style="color: #D36900;">&#125;</span>
<span style="color: #009000;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.1//EN&quot; &quot;http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd&quot;&gt;</span>
<span style="color: #009000;">&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xml:lang=&quot;en&quot;&gt;</span>
<span style="color: #009000;">&lt;head&gt;</span>
    <span style="color: #009000;">&lt;title&gt;</span>Smarty Debug Console<span style="color: #009000;">&lt;/title&gt;</span>
<span style="color: #D36900;">&#123;</span>literal<span style="color: #D36900;">&#125;</span>
<span style="color: #009000;">&lt;style type=&quot;text/css&quot;&gt;</span>
/* <span style="color: #009000;">&lt;![CDATA[ */</span>
<span style="color: #009000;">body, h1, h2, td, th, p {</span>
<span style="color: #009000;">    font-family: sans-serif;</span>
<span style="color: #009000;">    font-weight: normal;</span>
<span style="color: #009000;">    font-size: 0.9em;</span>
<span style="color: #009000;">    margin: 1px;</span>
<span style="color: #009000;">    padding: 0;</span>
<span style="color: #009000;">}</span>
&nbsp;
<span style="color: #009000;">h1 {</span>
<span style="color: #009000;">    margin: 0;</span>
<span style="color: #009000;">    text-align: left;</span>
<span style="color: #009000;">    padding: 2px;</span>
<span style="color: #009000;">    background-color: #f0c040;</span>
<span style="color: #009000;">    color:  black;</span>
<span style="color: #009000;">    font-weight: bold;</span>
<span style="color: #009000;">    font-size: 1.2em;</span>
<span style="color: #009000;"> }</span>
&nbsp;
<span style="color: #009000;">h2 {</span>
<span style="color: #009000;">    background-color: #9B410E;</span>
<span style="color: #009000;">    color: white;</span>
<span style="color: #009000;">    text-align: left;</span>
<span style="color: #009000;">    font-weight: bold;</span>
<span style="color: #009000;">    padding: 2px;</span>
<span style="color: #009000;">    border-top: 1px solid black;</span>
<span style="color: #009000;">}</span>
&nbsp;
<span style="color: #009000;">body {</span>
<span style="color: #009000;">    background: black; </span>
<span style="color: #009000;">}</span>
&nbsp;
<span style="color: #009000;">p, table, div {</span>
<span style="color: #009000;">    background: #f0ead8;</span>
<span style="color: #009000;">} </span>
&nbsp;
<span style="color: #009000;">p {</span>
<span style="color: #009000;">    margin: 0;</span>
<span style="color: #009000;">    font-style: italic;</span>
<span style="color: #009000;">    text-align: center;</span>
<span style="color: #009000;">}</span>
&nbsp;
<span style="color: #009000;">table {</span>
<span style="color: #009000;">    width: 100%;</span>
<span style="color: #009000;">}</span>
&nbsp;
<span style="color: #009000;">th, td {</span>
<span style="color: #009000;">    font-family: monospace;</span>
<span style="color: #009000;">    vertical-align: top;</span>
<span style="color: #009000;">    text-align: left;</span>
<span style="color: #009000;">    width: 50%;</span>
<span style="color: #009000;">}</span>
&nbsp;
<span style="color: #009000;">td {</span>
<span style="color: #009000;">    color: green;</span>
<span style="color: #009000;">}</span>
&nbsp;
<span style="color: #009000;">.odd {</span>
<span style="color: #009000;">    background-color: #eeeeee;</span>
<span style="color: #009000;">}</span>
&nbsp;
<span style="color: #009000;">.even {</span>
<span style="color: #009000;">    background-color: #fafafa;</span>
<span style="color: #009000;">}</span>
&nbsp;
<span style="color: #009000;">.exectime {</span>
<span style="color: #009000;">    font-size: 0.8em;</span>
<span style="color: #009000;">    font-style: italic;</span>
<span style="color: #009000;">}</span>
&nbsp;
<span style="color: #009000;">#table_assigned_vars th {</span>
<span style="color: #009000;">    color: blue;</span>
<span style="color: #009000;">}</span>
&nbsp;
<span style="color: #009000;">#table_config_vars th {</span>
<span style="color: #009000;">    color: maroon;</span>
<span style="color: #009000;">}</span>
<span style="color: #009000;">/* ]]&gt;</span> */
<span style="color: #009000;">&lt;/style&gt;</span>
<span style="color: #D36900;">&#123;</span><span style="color: #D36900;">/</span>literal<span style="color: #D36900;">&#125;</span>
<span style="color: #009000;">&lt;/head&gt;</span>
<span style="color: #009000;">&lt;body&gt;</span>
&nbsp;
<span style="color: #009000;">&lt;h1&gt;</span>Smarty Debug Console<span style="color: #009000;">&lt;/h1&gt;</span>
&nbsp;
<span style="color: #009000;">&lt;h2&gt;</span>included templates &amp;amp; config files (load time in seconds)<span style="color: #009000;">&lt;/h2&gt;</span>
&nbsp;
<span style="color: #009000;">&lt;div&gt;</span>
<span style="color: #D36900;">&#123;</span><span style="color: #0600FF;">section</span> <span style="color: #6A0A0A;">name</span><span style="color: #D36900;">=</span>templates <span style="color: #6A0A0A;">loop</span><span style="color: #D36900;">=</span>$_debug_tpls<span style="color: #D36900;">&#125;</span>
    <span style="color: #D36900;">&#123;</span><span style="color: #0600FF;">section</span> <span style="color: #6A0A0A;">name</span><span style="color: #D36900;">=</span><span style="color: #008000;">indent</span> <span style="color: #6A0A0A;">loop</span><span style="color: #D36900;">=</span>$_debug_tpls<span style="color: #D36900;">&#91;</span>templates<span style="color: #D36900;">&#93;</span>.<span style="color: #006600;">depth</span><span style="color: #D36900;">&#125;</span>&amp;nbsp;&amp;nbsp;&amp;nbsp;<span style="color: #D36900;">&#123;</span><span style="color: #D36900;">/</span><span style="color: #0600FF;">section</span><span style="color: #D36900;">&#125;</span>
    <span style="color: #009000;">&lt;font color={if $_debug_tpls[templates].type eq &quot;template&quot;}brown{elseif $_debug_tpls[templates].type eq &quot;insert&quot;}black{else}green{/if}&gt;</span>
        <span style="color: #D36900;">&#123;</span>$_debug_tpls<span style="color: #D36900;">&#91;</span>templates<span style="color: #D36900;">&#93;</span>.<span style="color: #006600;">filename</span>|escape:html<span style="color: #D36900;">&#125;</span><span style="color: #009000;">&lt;/font&gt;</span>
    <span style="color: #D36900;">&#123;</span><span style="color: #0600FF;">if</span> <span style="color: #0600FF;">isset</span><span style="color: #D36900;">&#40;</span>$_debug_tpls<span style="color: #D36900;">&#91;</span>templates<span style="color: #D36900;">&#93;</span>.<span style="color: #006600;">exec_time</span><span style="color: #D36900;">&#41;</span><span style="color: #D36900;">&#125;</span>
        <span style="color: #009000;">&lt;span class=&quot;exectime&quot;&gt;</span>
        (<span style="color: #D36900;">&#123;</span>$_debug_tpls<span style="color: #D36900;">&#91;</span>templates<span style="color: #D36900;">&#93;</span>.<span style="color: #006600;">exec_time</span>|string_format:<span style="color: #ff0000;">&quot;%.5f&quot;</span><span style="color: #D36900;">&#125;</span>)
        <span style="color: #D36900;">&#123;</span><span style="color: #0600FF;">if</span> <span style="color: #D36900;">%</span>templates.<span style="color: #006600;">index</span><span style="color: #D36900;">%</span> <span style="color: #D36900;">eq</span> <span style="color: #cc66cc;">0</span><span style="color: #D36900;">&#125;</span>(total)<span style="color: #D36900;">&#123;</span><span style="color: #D36900;">/</span><span style="color: #0600FF;">if</span><span style="color: #D36900;">&#125;</span>
        <span style="color: #009000;">&lt;/span&gt;</span>
    <span style="color: #D36900;">&#123;</span><span style="color: #D36900;">/</span><span style="color: #0600FF;">if</span><span style="color: #D36900;">&#125;</span>
    <span style="color: #009000;">&lt;br /&gt;</span>
<span style="color: #D36900;">&#123;</span><span style="color: #0600FF;">sectionelse</span><span style="color: #D36900;">&#125;</span>
    <span style="color: #009000;">&lt;p&gt;</span>no templates included<span style="color: #009000;">&lt;/p&gt;</span>
<span style="color: #D36900;">&#123;</span><span style="color: #D36900;">/</span><span style="color: #0600FF;">section</span><span style="color: #D36900;">&#125;</span>
<span style="color: #009000;">&lt;/div&gt;</span>
&nbsp;
<span style="color: #009000;">&lt;h2&gt;</span>assigned template variables<span style="color: #009000;">&lt;/h2&gt;</span>
&nbsp;
<span style="color: #009000;">&lt;table id=&quot;table_assigned_vars&quot;&gt;</span>
    <span style="color: #D36900;">&#123;</span><span style="color: #0600FF;">section</span> <span style="color: #6A0A0A;">name</span><span style="color: #D36900;">=</span>vars <span style="color: #6A0A0A;">loop</span><span style="color: #D36900;">=</span>$_debug_keys<span style="color: #D36900;">&#125;</span>
        <span style="color: #009000;">&lt;tr class=&quot;{cycle values=&quot;odd,even&quot;}&quot;&gt;</span>
            <span style="color: #009000;">&lt;th&gt;</span><span style="color: #D36900;">&#123;</span><span style="color: #0600FF;">ldelim</span><span style="color: #D36900;">&#125;</span>$<span style="color: #D36900;">&#123;</span>$_debug_keys<span style="color: #D36900;">&#91;</span>vars<span style="color: #D36900;">&#93;</span>|escape:<span style="color: #ff0000;">'html'</span><span style="color: #D36900;">&#125;</span><span style="color: #D36900;">&#123;</span><span style="color: #0600FF;">rdelim</span><span style="color: #D36900;">&#125;</span><span style="color: #009000;">&lt;/th&gt;</span>
            <span style="color: #009000;">&lt;td&gt;</span><span style="color: #D36900;">&#123;</span>$_debug_vals<span style="color: #D36900;">&#91;</span>vars<span style="color: #D36900;">&#93;</span>|@debug_print_var<span style="color: #D36900;">&#125;</span><span style="color: #009000;">&lt;/td&gt;&lt;/tr&gt;</span>
    <span style="color: #D36900;">&#123;</span><span style="color: #0600FF;">sectionelse</span><span style="color: #D36900;">&#125;</span>
        <span style="color: #009000;">&lt;tr&gt;&lt;td&gt;&lt;p&gt;</span>no template variables assigned<span style="color: #009000;">&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;</span>
    <span style="color: #D36900;">&#123;</span><span style="color: #D36900;">/</span><span style="color: #0600FF;">section</span><span style="color: #D36900;">&#125;</span>
<span style="color: #009000;">&lt;/table&gt;</span>
&nbsp;
<span style="color: #009000;">&lt;h2&gt;</span>assigned config file variables (outer template scope)<span style="color: #009000;">&lt;/h2&gt;</span>
&nbsp;
<span style="color: #009000;">&lt;table id=&quot;table_config_vars&quot;&gt;</span>
    <span style="color: #D36900;">&#123;</span><span style="color: #0600FF;">section</span> <span style="color: #6A0A0A;">name</span><span style="color: #D36900;">=</span>config_vars <span style="color: #6A0A0A;">loop</span><span style="color: #D36900;">=</span>$_debug_config_keys<span style="color: #D36900;">&#125;</span>
        <span style="color: #009000;">&lt;tr class=&quot;{cycle values=&quot;odd,even&quot;}&quot;&gt;</span>
            <span style="color: #009000;">&lt;th&gt;</span><span style="color: #D36900;">&#123;</span><span style="color: #0600FF;">ldelim</span><span style="color: #D36900;">&#125;</span>#<span style="color: #D36900;">&#123;</span>$_debug_config_keys<span style="color: #D36900;">&#91;</span>config_vars<span style="color: #D36900;">&#93;</span>|escape:<span style="color: #ff0000;">'html'</span><span style="color: #D36900;">&#125;</span>#<span style="color: #D36900;">&#123;</span><span style="color: #0600FF;">rdelim</span><span style="color: #D36900;">&#125;</span><span style="color: #009000;">&lt;/th&gt;</span>
            <span style="color: #009000;">&lt;td&gt;</span><span style="color: #D36900;">&#123;</span>$_debug_config_vals<span style="color: #D36900;">&#91;</span>config_vars<span style="color: #D36900;">&#93;</span>|@debug_print_var<span style="color: #D36900;">&#125;</span><span style="color: #009000;">&lt;/td&gt;&lt;/tr&gt;</span>
    <span style="color: #D36900;">&#123;</span><span style="color: #0600FF;">sectionelse</span><span style="color: #D36900;">&#125;</span>
        <span style="color: #009000;">&lt;tr&gt;&lt;td&gt;&lt;p&gt;</span>no config vars assigned<span style="color: #009000;">&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;</span>
    <span style="color: #D36900;">&#123;</span><span style="color: #D36900;">/</span><span style="color: #0600FF;">section</span><span style="color: #D36900;">&#125;</span>
<span style="color: #009000;">&lt;/table&gt;</span>
<span style="color: #009000;">&lt;/body&gt;</span>
<span style="color: #009000;">&lt;/html&gt;</span>
<span style="color: #D36900;">&#123;</span><span style="color: #0600FF;">else</span><span style="color: #D36900;">&#125;</span>
<span style="color: #009000;">&lt;script type=&quot;text/javascript&quot;&gt;</span>
// <span style="color: #009000;">&lt;![CDATA[</span>
<span style="color: #009000;">var Smarty_debug = function Smarty_debug(collapsed){ldelim}</span>
&nbsp;
<span style="color: #009000;">	var group = (collapsed) ? console.groupCollapsed : console.group;</span>
&nbsp;
<span style="color: #009000;">	group(&quot;Smarty Debug&quot;);</span>
&nbsp;
<span style="color: #009000;">	group(&quot;Included templates &amp; config files&quot;);</span>
<span style="color: #009000;">	{section name=templates loop=$_debug_tpls}</span>
<span style="color: #009000;">		 console.log(&quot;{$_debug_tpls[templates].filename|escape:javascript}{if isset($_debug_tpls[templates].exec_time)} - {$_debug_tpls[templates].exec_time|string_format:&quot;%.5f&quot;}{if %templates.index% eq 0} (total){/if}{/if}&quot;);</span>
<span style="color: #009000;">	{sectionelse}</span>
<span style="color: #009000;">		 console.info(&quot;no templates included&quot;);</span>
<span style="color: #009000;">	{/section}</span>
<span style="color: #009000;">	console.groupEnd();</span>
&nbsp;
<span style="color: #009000;">	group(&quot;Assigned template variables&quot;);</span>
<span style="color: #009000;">	{section name=vars loop=$_debug_keys}</span>
<span style="color: #009000;">		 console.log(&quot;{ldelim}${$_debug_keys[vars]|escape:'javascript'}{rdelim}:&quot;, {$_debug_vals[vars]|@json_encode});</span>
<span style="color: #009000;">	{sectionelse}</span>
<span style="color: #009000;">		 console.info(&quot;no template variables assigned&quot;);</span>
<span style="color: #009000;">	{/section}</span>
<span style="color: #009000;">	console.groupEnd();</span>
&nbsp;
<span style="color: #009000;">	group(&quot;Assigned config file variables&quot;);</span>
<span style="color: #009000;">	{section name=config_vars loop=$_debug_config_keys}</span>
<span style="color: #009000;">		 console.log(&quot;{ldelim}#{$_debug_config_keys[config_vars]|escape:'javascript'}#{rdelim}:&quot;, {$_debug_config_vals[config_vars]|@json_encode});</span>
<span style="color: #009000;">	{sectionelse}</span>
<span style="color: #009000;">		 console.info(&quot;no config file variables assigned&quot;);</span>
<span style="color: #009000;">	{/section}</span>
<span style="color: #009000;">	console.groupEnd();</span>
&nbsp;
<span style="color: #009000;">	console.groupEnd();</span>
<span style="color: #009000;">	return &quot;Smarty version {$smarty.version}&quot;;</span>
&nbsp;
<span style="color: #009000;">{rdelim};</span>
<span style="color: #009000;">// ]]&gt;</span>
<span style="color: #009000;">&lt;/script&gt;</span>
<span style="color: #D36900;">&#123;</span><span style="color: #D36900;">/</span><span style="color: #0600FF;">if</span><span style="color: #D36900;">&#125;</span></pre></td></tr></table></div>

<h3>How it Works</h3>
<p>This debug template gives you two options on how to view it: the original method display&#8217;s everything in a new pop-up window, the new and awesome method shows the same thing but in the Firebug Console. The template has an if statement/flag that checks whether it should be rendered in HTML or use Firebug. You&#8217;ll have to do some digging on how to setup this flag in your configuration, but the flag is in line 4 defined as $_smarty_debug_output.</p>
<p>The default is to use Firebug. A function named Smarty_debug is defined at the bottom at line 143. When you run it in the Firebug console, it will print out the Smarty debug information in the console as collapsible groups. If the browser doesn&#8217;t support console, then you probably shouldn&#8217;t be using this method, that&#8217;s why the HTML version is available.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">Smarty_debug<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//type this in your Firebug Console</span></pre></td></tr></table></div>

<p>It bothered me a little that Hipska&#8217;s method printed out every line in the group once Smarty_debug function is called. Now here&#8217;s my tweak: I&#8217;ve made it optional to print out as a collapsed group but you WILL need Firebug 1.3+ (if it works on other versions, please let me know).  All you need to do is supply a boolean argument.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">Smarty_debug<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//prints out a collapsed group</span></pre></td></tr></table></div>

<h3>Conclusion</h3>
<p>I really love being able to print out the Smarty debug data to the Firebug Console because I won&#8217;t have to deal with an additional pop-up every time. I get&#8217;s a little annoying and I think it suck&#8217;s up more memory. Thank you Hipska and Mike!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.garrickcheung.com/javascript/smarty-debug-with-firebug/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Sly, New Selector Engine &amp; How to Use in MooTools</title>
		<link>http://www.garrickcheung.com/javascript/sly-selector-engine/</link>
		<comments>http://www.garrickcheung.com/javascript/sly-selector-engine/#comments</comments>
		<pubDate>Thu, 26 Mar 2009 16:00:44 +0000</pubDate>
		<dc:creator>Garrick</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[MooTools]]></category>
		<category><![CDATA[selector]]></category>
		<category><![CDATA[selector engine]]></category>
		<category><![CDATA[Sly]]></category>

		<guid isPermaLink="false">http://www.garrickcheung.com/?p=302</guid>
		<description><![CDATA[You&#8217;ve heard of selector engines right? The engine that parses the HTML to match a string argument to return matching HTML elements? How about Sizzle and Peppy (two fast selector engines) that was released? Or how a couple JS frameworks were implementing Sizzle and the MooTools dev team decided not to follow suit? Now, have [...]]]></description>
			<content:encoded><![CDATA[<p>You&#8217;ve heard of selector engines right? The engine that parses the HTML to match a string argument to return matching HTML elements? How about Sizzle and Peppy (two fast selector engines) that was released? Or how a couple JS frameworks were implementing Sizzle and the <a href="http://mootools.net/blog/2008/12/04/sizzle/" target="_blank">MooTools dev team decided not to follow suit</a>?</p>
<p>Now, have you heard of Sly, the new selector engine on the block? No? That&#8217;s because <a href="http://digitarald.de" target="_blank">Harald Kirschner</a> just released it yesterday, 03/25/09, and I can&#8217;t tell you how awesome it is.. or can I?</p>
<p>I&#8217;ll start you off with a brief description&#8230; and graphs!<span id="more-302"></span></p>
<blockquote><p>Sly is a turbocharged, cross-browser, library-agnostic JavaScript class for querying DOM documents using CSS3 selectors.</p></blockquote>
<p>And turbocharged it sure is, just check out the stats!<br />
<img src="http://www.garrickcheung.com/wp-content/uploads/sly_selector_performance.png" alt="Sly Selector Performance" style="width:455px;" /></p>
<p>The benefits:</p>
<ul>
<li>Pure and powerful <em>JavaScript</em> matching algorithm for <em>fast</em> and <em>accurate</em> queries</li>
<li>Extra optimizations for <em>frequently used selectors</em> and <em>latest browser features</em></li>
<li>Works uniformly in <code>DOM</code> documents, fragments or <code>XML</code> documents</li>
<li>Utility methods for matching and filtering of elements</li>
<li><em>Standalone selector parser</em> to produce <em>JavaScript</em> <code>Object</code> representations</li>
<li><em>Customizable</em> pseudo-classes, attribute operators and combinators</li>
<li>Just <strong>3 kB</strong>! (<a href="http://developer.yahoo.com/yui/compressor/" target="_blank">minified</a> and <a href="http://www.gzip.org/" target="_blank">gzipped</a>, <strong>8 kB</strong> without <em>gzip</em>)</li>
<li>No dependencies on third-party JS libraries, but developers can override internal methods (like <code>getAttribute</code>) for seamless integration.</li>
<li>Code follows the <a href="http://mootools.net" target="_blank">MooTools</a> philosophy, respecting strict standards, throwing no warnings and using meaningful variable names</li>
</ul>
<h3>Use it in MooTools?</h3>
<p>Yes, that&#8217;s right. You can use it in MooTools right now, though I don&#8217;t think it&#8217;s necessary since the MooTools selector engine is very good. But just like how <a href="http://davidwalsh.name/mootools-peppy-sizzle" target="_blank">David Walsh showed us how to use Sizzle and Peppy in MooTools</a>, you can do the following to use Sly:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">Window.<span style="color: #660066;">implement</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
    $Sly<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>selector<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">new</span> Sly<span style="color: #009900;">&#40;</span>selector<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;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// returns an array of all the anchors in the page</span>
$Sly<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">search</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #006600; font-style: italic;">// returns the first anchor on the page</span>
$Sly<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Now, you may be wondering whether doing this will allow you to use MooTools methods on the elements. Well, the good news is that you can because the MooTools Elements class applies the methods to all elements. Observe:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">// returns the href of the first anchor</span>
$Sly<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'a'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">find</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">get</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'href'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>And lastly, <a href="http://blog.olicio.us/2009/03/19/sly–-the-super-snazzy-selector-engine/" target="_blank">Oskar Krawczyk posted how to replace the $$ function itself (thanks Oskar!)</a>:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">Window.<span style="color: #660066;">implement</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
    $$<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>selector<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">return</span> Sly.<span style="color: #660066;">search</span><span style="color: #009900;">&#40;</span>selector<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;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Great job, Harald, great job indeed. Way to represent!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.garrickcheung.com/javascript/sly-selector-engine/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
